]> mj.ucw.cz Git - pciutils.git/commitdiff
libpci: djgpp: Allow to specify empty IDSDIR=
authorPali Rohár <pali@kernel.org>
Fri, 18 Nov 2022 20:57:50 +0000 (21:57 +0100)
committerPali Rohár <pali@kernel.org>
Fri, 18 Nov 2022 20:57:50 +0000 (21:57 +0100)
Like for windows builds this will cause to load pci.ids file from the same
directory where is stored application binary. Code is same as for Windows,
just djgpp uses global symbol __dos_argv0 instead of _pgmptr.

Tested with following compile command:
  make CROSS_COMPILE=i586-pc-msdosdjgpp- HOST=i586-djgpp ZLIB=no DNS=no IDSDIR=

lib/init.c

index 590dfb4227bc3140075f45630ac2ff0def46cad7..8c8f9732692acfd3bb5bc4ac6274d091396e2a23 100644 (file)
 
 #include "internal.h"
 
+#ifdef PCI_OS_DJGPP
+#include <crt0.h> /* for __dos_argv0 */
+#endif
+
 #ifdef PCI_OS_WINDOWS
 
 #include <windows.h>
@@ -262,7 +266,7 @@ pci_get_method_name(int index)
     return pci_methods[index]->name;
 }
 
-#ifdef PCI_OS_WINDOWS
+#if defined(PCI_OS_WINDOWS) || defined(PCI_OS_DJGPP)
 
 static void
 pci_init_name_list_path(struct pci_access *a)
@@ -274,7 +278,7 @@ pci_init_name_list_path(struct pci_access *a)
       char *path, *sep;
       size_t len;
 
-#if defined(_WIN32) || defined(_WINDLL) || defined(_WINDOWS)
+#if defined(PCI_OS_WINDOWS) && (defined(_WIN32) || defined(_WINDLL) || defined(_WINDOWS))
 
       HMODULE module;
       size_t size;
@@ -309,11 +313,15 @@ retry:
       else if (len == 0)
         path[0] = '\0';
 
-#else
+#elif defined(PCI_OS_DJGPP) || defined(PCI_OS_WINDOWS)
 
       const char *exe_path;
 
+#ifdef PCI_OS_DJGPP
+      exe_path = __dos_argv0;
+#else
       exe_path = _pgmptr;
+#endif
 
       len = strlen(exe_path);
       path = pci_malloc(a, len+sizeof(PCI_IDS));