home *** CD-ROM | disk | FTP | other *** search
- Programming guide with detect library
-
- I - How-to link with libdetect?
-
- If you use autoconf, you need to modify configure.in and check if
- detect is installed properly on system:
-
- Example:
-
- +----8<---------------------------------------------------------------
- |AC_CHECK_LIB(detect, report_detect, ,
- | AC_MSG_ERROR(Can't find detect library!))
- +----8<---------------------------------------------------------------
-
- Maybe you'll want to add a '--with-detect-prefix' parameters to
- allow compilation on system with a libdetect location different
- than /usr:
-
- +----8<---------------------------------------------------------------
- |AC_ARG_WITH(detect_prefix,
- | [ --with-detect-prefix=PFX Prefix where detect is installed],
- | DETECT_PATH="$withval", DETECT_PATH="/usr/local")
- +----8<---------------------------------------------------------------
-
- You also need to modify Makefile.am. Consult automake and autoconf
- info pages.
-
- However you use static Makefile, Add -ldetect to LDFLAGS.
-
-
- II - Include detect header file
-
- Include detect.h header file into your source code.
-
- +----8<---------------------------------------------------------------
- |#include <detect.h>
- +----8<---------------------------------------------------------------
-
-
- III - Use detect API
-
- You can use detect API documentation file that contains all detect
- functions and their uses.
-
- I recommend to make a sync before all detection operation. Because
- some criticals parts as isa, modem and mouse detection cand freeze
- your system.
-
- If you want to use isa/pci/pcmcia/scsi/usb detection you need to initialize lst
- files shipped with detect library. Use the
-
-
- +----8<---------------------------------------------------------------
- |#define ISA_LST "/usr/share/detect/isa.lst"
- |#define PCI_LST "/usr/share/detect/pci.lst"
- |#define PCMCIA_LST "/usr/share/detect/pcmcia.lst"
- |#define USB_LST "/usr/share/detect/usb.lst"
- |
- | struct cards_lst *lst;
- | struct isa_info *isa;
- | struct pci_info *pci;
- | struct usb_info *usb:
- | struct pcmcia_info *pcmcia;
- |
- | lst = init_lst(ISA_LST, PCI_LST, PCMCIA_LST, USB_LST);
- +----8<---------------------------------------------------------------
-
- Here we've hardcoded pci.lst and isa.lst path. But you can easily
- pass this value trough a configure passed argument as
- '--with-detect-prefix'.
-
- The next function you should call is init_bus by passing the lst
- initialized structure(see below) as argument. This function will detect all
- evices presents on the following busses:
-
- -ISA
- -PCI
- -PCMCIA
- -USB
- -IDE
- -SCSI
- -PARALLEL
- -SERIAL
-
- +----8<---------------------------------------------------------------
- |bus = init_bus(lst);
- +---------------------------------------------------------------------
-
- Now you can use device detection functions. Some functions needs args. some
- none.
-
- +----8<---------------------------------------------------------------
- |cpu = cpu_detect(); /* This functions don't use args */
- |
- |scsiintf = scsinterface_detect(bus); /* Use bus structure*/
- +----8<---------------------------------------------------------------
-
- All devices detected are in a linked list. You can parse it:
-
- +----8<----------------------------------------------------------------
- | for(;cpu;cpu->next)
- | printf("I've found a %s %s\n", cpu->vendor, cpu->model);
- +-----------------------------------------------------------------------
-
- As you can see detect library is very easy to use. With only few lines you can
- add hardware detection feature to your program.
-