home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / misc / src / install / pci-probing / test-pciprobe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-06  |  1.2 KB  |  52 lines

  1. #include <stdio.h>
  2.  
  3. #include "pciprobe.h"
  4.  
  5.  
  6.  
  7. void printpciDevices( int n, struct pciDevice **devs, char *type ) {
  8.     int i, j;
  9.  
  10.     if (n<0) {
  11.     fprintf(stderr,
  12.         "System error - probably means you dont have a PCI mboard!\n");
  13.     exit(1);
  14.     } else if (n==0) {
  15.     printf("No PCI devices of type %s found.\n", type);
  16.     } else {
  17.     for (i=0; i<n; i++) {
  18.         printf("Card %d:    %d matches found in db\n", i, devs[i]->nhits);
  19.         for (j=0; j<devs[i]->nhits; j++) {
  20.         printf("       Match %d:  |%s| -> |%s|\n",
  21.                j, devs[i]->name[j], devs[i]->module[j]);
  22.         }
  23.     }
  24.     }
  25. }
  26.  
  27. int main () {
  28.  
  29.     int i, n;
  30.     struct pciDevice **devs;
  31.     
  32.     printf("Probing for ETHERNET devices....\n");
  33.     n = pciProbeDevice(PCI_ETHERNET, &devs);
  34.     printpciDevices(n, devs, "Ethernet");
  35.     for (i=0; i<n; i++)
  36.     pciFreeDevice(devs[i]);
  37.     
  38.     printf("\nProbing for SCSI devices....\n");
  39.     n = pciProbeDevice(PCI_SCSI, &devs);
  40.     printpciDevices(n, devs, "SCSI");
  41.     for (i=0; i<n; i++)
  42.     pciFreeDevice(devs[i]);
  43.  
  44.     printf("\nProbing for VIDEO devices....\n");
  45.     n = pciProbeDevice(PCI_VIDEO, &devs);
  46.     printpciDevices(n, devs, "Video");
  47.     for (i=0; i<n; i++)
  48.     pciFreeDevice(devs[i]);
  49.  
  50.     return 0;
  51. }
  52.