]> mj.ucw.cz Git - pciutils.git/blobdiff - names.c
Intermediate version of pciutils.
[pciutils.git] / names.c
diff --git a/names.c b/names.c
index 485050f0bc13b1a2fa0e83e46baeca64ceece44f..9ea00ada7fb0adccb95c4e38fe8ed92dd2be3882 100644 (file)
--- a/names.c
+++ b/names.c
@@ -1,9 +1,9 @@
 /*
- *     $Id: names.c,v 1.1 1997/12/23 10:29:18 mj Exp $
+ *     $Id: names.c,v 1.3 1998/01/27 11:50:10 mj Exp $
  *
  *     Linux PCI Utilities -- Device ID to Name Translation
  *
- *     Copyright (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     Copyright (c) 1997, 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -20,6 +20,8 @@
 
 int show_numeric_ids;
 
+char *pci_ids = ETC_PCI_IDS;
+
 static byte *name_list;
 static int name_list_loaded;
 
@@ -78,7 +80,7 @@ static int nl_add(int id1, int id2, byte *text)
 static void
 err_name_list(char *msg)
 {
-  fprintf(stderr, ETC_PCI_IDS ": %s: %m\n", msg);
+  fprintf(stderr, "%s: %s: %m\n", pci_ids, msg);
   exit(1);
 }
 
@@ -159,14 +161,14 @@ parse_name_list(void)
        goto parserr;
       if (nl_add(i, j, q))
        {
-         fprintf(stderr, ETC_PCI_IDS ", line %d: duplicate entry\n", lino);
+         fprintf(stderr, "%s, line %d: duplicate entry\n", pci_ids, lino);
          exit(1);
        }
     }
   return;
 
 parserr:
-  fprintf(stderr, ETC_PCI_IDS ", line %d: parse error\n", lino);
+  fprintf(stderr, "%s, line %d: parse error\n", pci_ids, lino);
   exit(1);
 }
 
@@ -176,7 +178,7 @@ load_name_list(void)
   int fd;
   struct stat st;
 
-  fd = open(ETC_PCI_IDS, O_RDONLY);
+  fd = open(pci_ids, O_RDONLY);
   if (fd < 0)
     {
       show_numeric_ids = 1;
@@ -198,12 +200,12 @@ lookup_vendor(word i)
 {
   static char vendbuf[6];
 
+  if (!show_numeric_ids && !name_list_loaded)
+    load_name_list();
   if (!show_numeric_ids)
     {
       struct nl_entry *e;
 
-      if (!name_list_loaded)
-       load_name_list();
       e = nl_lookup(ID1_VENDOR, i);
       if (e)
        return e->name;
@@ -217,12 +219,12 @@ lookup_device(word v, word i)
 {
   static char devbuf[6];
 
+  if (!show_numeric_ids && !name_list_loaded)
+    load_name_list();
   if (!show_numeric_ids)
     {
       struct nl_entry *e;
 
-      if (!name_list_loaded)
-       load_name_list();
       e = nl_lookup(v, i);
       if (e)
        return e->name;
@@ -236,12 +238,12 @@ lookup_device_full(word v, word i)
 {
   static char fullbuf[256];
 
+  if (!show_numeric_ids && !name_list_loaded)
+    load_name_list();
   if (!show_numeric_ids)
     {
       struct nl_entry *e, *e2;
 
-      if (!name_list_loaded)
-       load_name_list();
       e = nl_lookup(ID1_VENDOR, v);
       e2 = nl_lookup(v, i);
       if (!e)
@@ -261,12 +263,12 @@ lookup_class(word c)
 {
   static char classbuf[80];
 
+  if (!show_numeric_ids && !name_list_loaded)
+    load_name_list();
   if (!show_numeric_ids)
     {
       struct nl_entry *e;
 
-      if (!name_list_loaded)
-       load_name_list();
       e = nl_lookup(ID1_SUBCLASS, c);
       if (e)
        return e->name;