- }
-
- return NULL;
-}
-
-static int id_insert(struct pci_access *a, int cat, int id1, int id2, int id3, int id4, char *text)
-{
- u32 id12 = id_pair(id1, id2);
- u32 id34 = id_pair(id3, id4);
- unsigned int h = id_hash(cat, id12, id34);
- struct id_entry *n = a->id_hash ? a->id_hash[h] : NULL;
- int len = strlen(text);
-
- while (n && (n->id12 != id12 || n->id34 != id34 || n->cat != cat))
- n = n->next;
- if (n)
- return 1;
- n = id_alloc(a, sizeof(struct id_entry) + len);
- n->id12 = id12;
- n->id34 = id34;
- n->cat = cat;
- memcpy(n->name, text, len+1);
- n->next = a->id_hash[h];
- a->id_hash[h] = n;
- return 0;
-}
-
-static char *id_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4)
-{
- struct id_entry *n;
- u32 id12 = id_pair(id1, id2);
- u32 id34 = id_pair(id3, id4);
- char *name;
-
- if (a->id_hash)
- {
- n = a->id_hash[id_hash(cat, id12, id34)];
- while (n && (n->id12 != id12 || n->id34 != id34 || n->cat != cat))
- n = n->next;
- if (n)
- return n->name;
- }
- if (name = id_net_lookup(a, cat, id1, id2, id3, id4))
- {
- id_insert(a, cat, id1, id2, id3, id4, name);
- return name;
- }
- return NULL;
-}
-
-static int id_hex(char *p, int cnt)
-{
- int x = 0;
- while (cnt--)
- {
- x <<= 4;
- if (*p >= '0' && *p <= '9')
- x += (*p - '0');
- else if (*p >= 'a' && *p <= 'f')
- x += (*p - 'a' + 10);
- else if (*p >= 'A' && *p <= 'F')
- x += (*p - 'A' + 10);
- else
- return -1;
- p++;
- }
- return x;
-}
-
-static inline int id_white_p(int c)
-{
- return (c == ' ') || (c == '\t');
-}
-
-static const char *id_parse_list(struct pci_access *a, pci_file f, int *lino)
-{
- char line[MAX_LINE];
- char *p;
- int id1=0, id2=0, id3=0, id4=0;
- int cat = -1;
- int nest;
- static const char parse_error[] = "Parse error";
-
- *lino = 0;
- while (pci_gets(f, line, sizeof(line)))
- {
- (*lino)++;
- p = line;
- while (*p && *p != '\n' && *p != '\r')
- p++;
- if (!*p && !pci_eof(f))
- return "Line too long";
- *p = 0;
- if (p > line && (p[-1] == ' ' || p[-1] == '\t'))
- *--p = 0;
-
- p = line;
- while (id_white_p(*p))
- p++;
- if (!*p || *p == '#')
- continue;
-
- p = line;
- while (*p == '\t')
- p++;
- nest = p - line;
-
- if (!nest) /* Top-level entries */