]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/names-net.c
Bump the API version (the new API is not cast in stone yet, however).
[pciutils.git] / lib / names-net.c
index 167cd1fb10229b489974fd9f53d395bb9ec204a8..335bf682212495d1da20b35b1850ac6d5bb1a91f 100644 (file)
@@ -8,23 +8,30 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
 
 #include "internal.h"
 #include "names.h"
 
+#ifdef PCI_USE_DNS
+
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
 char
 *pci_id_net_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4)
 {
-  char name[256], dnsname[256], txt[256];
+  char name[256], dnsname[256], txt[256], *domain;
   byte answer[4096];
   const byte *data;
   int res, i, j, dlen;
   ns_msg m;
   ns_rr rr;
 
+  domain = pci_get_param(a, "net.domain");
+  if (!domain || !domain[0])
+    return NULL;
+
   switch (cat)
     {
     case ID_VENDOR:
@@ -51,7 +58,7 @@ char
     default:
       return NULL;
     }
-  sprintf(dnsname, "%s.%s", name, a->id_domain);
+  sprintf(dnsname, "%s.%s", name, domain);
 
   a->debug("Resolving %s\n", dnsname);
   res_init();
@@ -88,11 +95,11 @@ char
   return NULL;
 }
 
-void
-pci_set_net_domain(struct pci_access *a, char *name, int to_be_freed)
+#else
+
+char *pci_id_net_lookup(struct pci_access *a UNUSED, int cat UNUSED, int id1 UNUSED, int id2 UNUSED, int id3 UNUSED, int id4 UNUSED)
 {
-  if (a->free_id_domain)
-    free(a->id_domain);
-  a->id_domain = name;
-  a->free_id_domain = to_be_freed;
+  return NULL;
 }
+
+#endif