home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 2 / Chip_Hitware_Vol_02.iso / chiphit2 / tools / system / pcinvent / extupd.c < prev    next >
C/C++ Source or Header  |  1995-03-31  |  6KB  |  180 lines

  1. /********************************* EXTUPD.C *************************
  2.  
  3. External update program for manipulating MBS PC INVENTORY hardware database:
  4. HIFILE.MBX and software database SIFILE.MBX.
  5.  
  6. It is intended for use by manufacturers of pc hardware to markup the database
  7. upon installation, deinstallation, or upgrade process.
  8.  
  9. The hardware database record structure is:
  10.  
  11. typedef struct { char szResource[40];
  12.                  char szTitle[40];
  13.                  char szName_Ad[120];
  14.                  char szMsc[100];
  15.                  char szComs[120];
  16.                  char szDriver[800];
  17.                  char szIrq[20];
  18.                  char szIo_Ad[20];
  19.                  char szBase_Ad[20];
  20.                  char szDma[20];
  21.                  BOOL bStatus;
  22.                 } Hard_Inv_Rec;  //1.3kb record
  23.  
  24.  
  25. where:
  26.  szResource[40]; resorce name e.g. com1
  27.  szTitle[40]; the official TITLE of the hardware card e.g. XX super ide controller
  28.  szName_Ad[120]; manufacturer name and address
  29.  szMsc1[100]; communcation channels, e.g. phone/fax/bbs/internat address etc.
  30.  szMsc2[120]; msc comments, e.g. com1 is used for serial mouse
  31.  szDriver[800]; driver information, SEE NOTE 1
  32.  szIrq[20]; irq number, 
  33.  szIo_Ad[20]; io address
  34.  szBase_Ad[20]; base address
  35.  szDma[20]; dma number
  36.  bStatus; status, set = 1 = activate(installation), 
  37.                         0 = mark delete(uninstall), to be purged by user
  38.  
  39.  
  40. The software database record structure is:                        
  41.  
  42. typedef struct { char szSTitle[40];
  43.                  char szSNameAd[120];
  44.                  char szSCom[120];
  45.                  char szSDirs[1020];
  46.                  BOOL  bSStatus;
  47.                } SOFT_INV_REC;
  48.                
  49. SOFT_INV_REC soft_inv_rec;   
  50.  
  51. where:
  52.  
  53. szSTitle[40]; is the software title
  54. szSNAMEAD[120]; is the manufacturer name and address
  55. szSCom[120]; phone,fax, bbs, internet address etc of manufacturer
  56. szSDirs[1020]; software settings:config.sys,ini settings,main directories,etc
  57. bSStatus= 1 for active, 0 for mark for deletion
  58.  
  59. Two function in EXTUPDO.OBJ are provided for appending, altering or (mark)
  60. deleting a record in the data bases: Rec_To_HIFILE() and Rec_To_SIFILE();
  61.           
  62. Per this example, the manufacturer's program fills the record structures
  63. and makes the function call:
  64.  
  65. ret1=Rec_To_HIFILE(spath);  //record->to->hardware_inventory_file
  66. and
  67. ret2=Rec_To_SIFILE(spath);  //record->to->software_inventory_file
  68.  
  69. Thess functions attempt to open the right inventory file, look for the
  70. the resource (szResouce in hardware database) or title (szSTitle in software 
  71. database) as the database keys, replace the record if found(See NOTE3), 
  72. append to inventory otherwise.
  73.  
  74. Function Params: 
  75.  
  76. char * spath; is the full path name of the inventory database :HIFILE.MBX.
  77.  
  78. int ret1; returns are:
  79.           -3  PC Inventory full (max#=48 resources currently)
  80.           -2  MBS PC Inventory nor registered (SEE NOTE 2)
  81.           -1  inventory file didn't exist
  82.           11  replaced an existing record
  83.           10  replace failed
  84.           21  added a new record
  85.           20  add failed
  86.  
  87. --------------------------------------------------------------------------          
  88. NOTE 1- settings information(szDriver in hardware and szSDirs in software
  89.                              databses respective):use convention:
  90.                              
  91.    {SYSTEM.INI}
  92.    
  93.    [xxSection]
  94.  
  95.    driver infor
  96.     
  97.    [otherSection]
  98.    other onfo
  99.        .
  100.        .
  101.        .   
  102.    {WIN.INI}
  103.    
  104.    [xxSection]
  105.    
  106.    setupinfo
  107.        .
  108.        .
  109.        
  110.    {CONFIG.SYS}
  111.    dos sys info
  112.        .
  113.        .
  114.        .          
  115.    {GENERAL}
  116.    (in szDriver) feature x uses irq? and dma!
  117.    (in szSDirs) the main directories set up are C:\\xxx and C:\yyy and
  118.                 also win.ini and system ini are written to
  119.                 
  120.        .
  121.        .
  122.        .
  123.        
  124.                     
  125. i.e. the effected file is in {}, the section in the effected file, if
  126. applicable, would be in [], and under it the actual textual info. 
  127. (along the lines of windows .ini standards)       
  128. We added the {GENERAL} section as a catch all msc field.
  129.  
  130.  
  131. NOTE 2- MBS PC INVENTORY in it's initial shareware version can only
  132. be manually maintained. Registerd versions can be maintained by 
  133. Rec_To_HIFILE calls.
  134.  
  135. NOTE 3- STRING COMPARISONS in 2 functions above are done lexically 
  136. and are not "white space smart", i.e. "RESOURCE" and "RESOURCE   " are
  137. not equal, so a new hardware database entry is created instead of 
  138. altering the old RESOURCE.
  139.  
  140.  ****************************************************************/
  141.  
  142. #include "extupd.h"
  143.  
  144. /***********************************************************************/
  145.  
  146. void main(void)
  147. {
  148.  char spath[70]; 
  149.  int ret1,ret2;
  150.  
  151.  strcpy( hard_inv_rec.szResource,"a new res");
  152.  strcpy( hard_inv_rec.szTitle,"Test Title");
  153.  strcpy( hard_inv_rec.szName_Ad,"Test Name_Ad");
  154.  strcpy( hard_inv_rec.szMsc1,"Test Coms");
  155.  strcpy( hard_inv_rec.szMsc2,"Test Msc");
  156.  strcpy( hard_inv_rec.szDriver," Test Driver set");
  157.  strcpy( hard_inv_rec.szIrq,"ad Irq");
  158.  strcpy( hard_inv_rec.szIo_Ad,"ad IO"); 
  159.  strcpy( hard_inv_rec.szBase_Ad,"ad Basead alt");
  160.  strcpy( hard_inv_rec.szDma,"ad Dma alt");
  161.  hard_inv_rec.bStatus=1;  /*set to 0 to mark the record for deletion*/
  162.  strcpy(spath,"d:\\test\\t3");
  163.  ret1=Rec_To_HIFILE(spath);
  164.  printf("Add Hardware Record result=%d\n",ret1);            
  165.  
  166.  /*-----------------------------------------------------*/
  167.  
  168.  strcpy( soft_inv_rec.szSTitle,"Test Software Title   ");
  169.  strcpy( soft_inv_rec.szSNameAd,"Test Name_Ad");
  170.  strcpy( soft_inv_rec.szSCom,"Test comunications1");
  171.  strcpy( soft_inv_rec.szSDirs,"Test Software Settings alt"); 
  172.  soft_inv_rec.bSStatus=1;  /*set to 0 to mark the record for deletion*/
  173.  strcpy(spath,"d:\\test\\t3");
  174.  ret2=Rec_To_SIFILE(spath);
  175.  printf("Add Software Record result=%d\n",ret2);  
  176.  
  177.  
  178.  
  179.