diff options
author | wpaul <wpaul@FreeBSD.org> | 2003-12-12 03:40:05 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 2003-12-12 03:40:05 +0000 |
commit | 361276aef1eab5c663385d9aca40dca8c45612b8 (patch) | |
tree | b5ce9bd57cc1e5b00184ab938df8a5ea7b915029 /usr.sbin/ndiscvt | |
parent | f9016d0ffd1f176464212f0743ea398890b6b18f (diff) | |
download | FreeBSD-src-361276aef1eab5c663385d9aca40dca8c45612b8.zip FreeBSD-src-361276aef1eab5c663385d9aca40dca8c45612b8.tar.gz |
Attempt to handle WinXP .INF files. Also, in dump_regvals(), handle
the case where there's an entry in the manufacturer's device list but
no corresponding installation section (and hence no AddReg assignments),
i.e. if dev = find_assign(sname, "AddReg"); returns NULL, then
don't try to dereference dev.
There is a fundamental problem with the handling of .INF files that
contain definitions for multiple devices: right now we dump all the
AddReg sections that we find, but don't distinguish what device they
belong to. This often results in duplicate keys.
Diffstat (limited to 'usr.sbin/ndiscvt')
-rw-r--r-- | usr.sbin/ndiscvt/inf.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c index 2f5e5b3..8262638 100644 --- a/usr.sbin/ndiscvt/inf.c +++ b/usr.sbin/ndiscvt/inf.c @@ -146,12 +146,20 @@ dump_deviceids() struct assign *manf, *dev; struct section *sec; struct assign *assign; + char xpsec[256]; /* Find manufacturer name */ manf = find_assign("Manufacturer", NULL); /* Find manufacturer section */ - sec = find_section(manf->vals[0]); + if (manf->vals[1] != NULL && + strcasecmp(manf->vals[1], "NT.5.1") == 0) { + /* Handle Windows XP INF files. */ + snprintf(xpsec, sizeof(xpsec), "%s.%s", + manf->vals[0], manf->vals[1]); + sec = find_section(xpsec); + } else + sec = find_section(manf->vals[0]); /* Emit start of device table */ fprintf (ofp, "#define NDIS_DEV_TABLE"); @@ -206,7 +214,7 @@ dump_addreg(const char *s) fprintf(ofp,"\n\t\"%s \",", reg->key); fprintf(ofp, "\n\t{ \"%s\" } },", reg->value == NULL ? "" : - reg->value); + stringcvt(reg->value)); } else if (strcasestr(reg->subkey, "Ndi\\params") != NULL && strcasecmp(reg->key, "ParamDesc") == 0) @@ -229,7 +237,8 @@ dump_enumreg(const struct section *s, const struct reg *r) continue; if (reg->subkey == NULL || strcasecmp(reg->subkey, enumkey)) continue; - fprintf(ofp, " [%s=%s]", reg->key, stringcvt(reg->value)); + fprintf(ofp, " [%s=%s]", reg->key, + stringcvt(reg->value)); } return; } @@ -352,7 +361,7 @@ dump_regvals(void) struct assign *assign; struct assign_head tmp_ah; char sname[256]; - int i; + int i, is_winxp = 0; TAILQ_INIT(&tmp_ah); @@ -360,7 +369,15 @@ dump_regvals(void) manf = find_assign("Manufacturer", NULL); /* Find manufacturer section */ - sec = find_section(manf->vals[0]); + if (manf->vals[1] != NULL && + strcasecmp(manf->vals[1], "NT.5.1") == 0) { + is_winxp++; + /* Handle Windows XP INF files. */ + snprintf(sname, sizeof(sname), "%s.%s", + manf->vals[0], manf->vals[1]); + sec = find_section(sname); + } else + sec = find_section(manf->vals[0]); /* Emit start of block */ fprintf (ofp, "ndis_cfg ndis_regvals[] = {"); @@ -380,10 +397,20 @@ dump_regvals(void) sizeof(struct assign)); TAILQ_INSERT_TAIL(&tmp_ah, dev_dup, link); if (assign->section == sec) { - /* Ignore Windows 95-era data. */ - sprintf(sname, "%s.NT", assign->vals[0]); - /* Find all the AddReg sections. */ - dev = find_assign(sname, "AddReg"); + /* + * Find all the AddReg sections. + * Look for section names with .NT, unless + * this is a WinXP .INF file. + */ + if (is_winxp) + dev = find_assign(assign->vals[0], "AddReg"); + else { + sprintf(sname, "%s.NT", assign->vals[0]); + dev = find_assign(sname, "AddReg"); + } + /* Section not found. */ + if (dev == NULL) + continue; for (i = 0; i < W_MAX; i++) { if (dev->vals[i] != NULL) dump_addreg(dev->vals[i]); |