]> mj.ucw.cz Git - pciutils.git/commitdiff
Added options for setting of library parameters.
authorMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 08:37:25 +0000 (09:37 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 12 Feb 2008 08:37:25 +0000 (09:37 +0100)
common.c
pciutils.h

index 7d52530e59873db82626d18ea5793b5d950529c0..7e53157773dcfebacfc47428f647e0a9c3a0db67 100644 (file)
--- a/common.c
+++ b/common.c
@@ -44,6 +44,28 @@ xrealloc(void *ptr, unsigned int howmuch)
   return p;
 }
 
+static void
+set_pci_option(struct pci_access *pacc, char *arg)
+{
+  if (!strcmp(arg, "help"))
+    {
+      struct pci_param *p;
+      printf("Known PCI access parameters:\n\n");
+      for (p=NULL; p=pci_walk_params(pacc, p);)
+       printf("%-20s %s (%s)\n", p->param, p->help, p->value);
+      exit(0);
+    }
+  else
+    {
+      char *sep = strchr(arg, '=');
+      if (!sep)
+       die("Invalid PCI access parameter syntax: %s", arg);
+      *sep++ = 0;
+      if (pci_set_param(pacc, arg, sep) < 0)
+       die("Unrecognized PCI access parameter: %s", arg);
+    }
+}
+
 int
 parse_generic_option(int i, struct pci_access *pacc, char *optarg)
 {
@@ -74,6 +96,9 @@ parse_generic_option(int i, struct pci_access *pacc, char *optarg)
     case 'G':
       pacc->debugging++;
       break;
+    case 'O':
+      set_pci_option(pacc, optarg);
+      break;
     default:
       return 0;
     }
index d6669af6ba131d35e1b2ce25be69739bbe310097..02071ac2a39dced465e1abfa6c3f1b83bcff2613 100644 (file)
@@ -44,6 +44,7 @@ int parse_generic_option(int i, struct pci_access *pacc, char *optarg);
 #define GENHELP_DUMP
 #endif
 
-#define GENERIC_OPTIONS "G" GENOPT_PROC GENOPT_INTEL GENOPT_DUMP
+#define GENERIC_OPTIONS "GO:" GENOPT_PROC GENOPT_INTEL GENOPT_DUMP
 #define GENERIC_HELP GENHELP_PROC GENHELP_INTEL GENHELP_DUMP \
-       "-G\t\tEnable PCI access debugging\n"
+       "-G\t\tEnable PCI access debugging\n" \
+       "-O <par>=<val>\tSet PCI access parameter (see `-O help' for the list)\n"