]> mj.ucw.cz Git - pciutils.git/blob - pciutils.h
Merge remote-tracking branch 'twilfredo/wilfred/fixup-doe-bits'
[pciutils.git] / pciutils.h
1 /*
2  *      The PCI Utilities -- Declarations
3  *
4  *      Copyright (c) 1997--2018 Martin Mares <mj@ucw.cz>
5  *
6  *      Can be freely distributed and used under the terms of the GNU GPL v2+
7  *
8  *      SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "lib/pci.h"
12 #include "lib/sysdep.h"
13
14 /*
15  * gcc predefines macro __MINGW32__ for all MinGW targets.
16  * Including some MinGW header (e.g. windef.h) defines additional
17  * macro __MINGW32_MAJOR_VERSION (available for all MinGW targets).
18  */
19 #if defined(PCI_OS_WINDOWS) && defined(__MINGW32__)
20 #include <windef.h>
21 #endif
22
23 /*
24  * On Windows only MinGW 3.0 and higher versions provides <getopt.h>
25  * header file. Older MinGW versions and MSVC do not have it.
26  */
27 #if defined(PCI_OS_WINDOWS) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 3)
28 #include "compat/getopt.h"
29 #else
30 #include <unistd.h>
31 #endif
32
33 #define PCIUTILS_VERSION PCILIB_VERSION
34
35 extern const char program_name[];
36
37 void die(char *msg, ...) NONRET PCI_PRINTF(1,2);
38 void *xmalloc(size_t howmuch);
39 void *xrealloc(void *ptr, size_t howmuch);
40 char *xstrdup(const char *str);
41 int parse_generic_option(int i, struct pci_access *pacc, char *arg);
42
43 #ifdef PCI_HAVE_PM_INTEL_CONF
44 #define GENOPT_INTEL "H:"
45 #define GENHELP_INTEL "-H <mode>\tUse direct hardware access (<mode> = 1 or 2)\n"
46 #else
47 #define GENOPT_INTEL
48 #define GENHELP_INTEL
49 #endif
50 #if defined(PCI_HAVE_PM_DUMP) && !defined(PCIUTILS_SETPCI)
51 #define GENOPT_DUMP "F:"
52 #define GENHELP_DUMP "-F <file>\tRead PCI configuration dump from a given file\n"
53 #else
54 #define GENOPT_DUMP
55 #define GENHELP_DUMP
56 #endif
57
58 #define GENERIC_OPTIONS "A:GO:" GENOPT_INTEL GENOPT_DUMP
59 #define GENERIC_HELP \
60         "-A <method>\tUse the specified PCI access method (see `-A help' for a list)\n" \
61         "-O <par>=<val>\tSet PCI access parameter (see `-O help' for a list)\n" \
62         "-G\t\tEnable PCI access debugging\n" \
63         GENHELP_INTEL GENHELP_DUMP