+char *
+xstrdup(const char *str)
+{
+ int len = strlen(str) + 1;
+ char *copy = xmalloc(len);
+ memcpy(copy, str, len);
+ return copy;
+}
+
+static void
+set_pci_method(struct pci_access *pacc, char *arg)
+{
+ char *name;
+ int i;
+
+ if (!strcmp(arg, "help"))
+ {
+ printf("Known PCI access methods:\n\n");
+ for (i=0; name = pci_get_method_name(i); i++)
+ if (name[0])
+ printf("%s\n", name);
+ exit(0);
+ }
+ else
+ {
+ i = pci_lookup_method(arg);
+ if (i < 0)
+ die("No such PCI access method: %s (see `-A help' for a list)", arg);
+ pacc->method = i;
+ }
+}
+
+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 (see `-O help' for a list)", arg);
+ }
+}
+