home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / Geneve / 9640news / CAT36 / EMULSRC.ZIP / CONFIG.C < prev    next >
C/C++ Source or Header  |  1994-02-18  |  1KB  |  45 lines

  1. /* This utility scans & displays a configuration file
  2.  * It is an unnescessary piece of software :-)
  3.  * Ton Brouwer '94
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8.  
  9. main(int argc,char *argv[])
  10. {
  11. FILE *infile;
  12. char configname[20],line[80],filename[15],memtype;
  13. int base,offset,length;
  14.  
  15. if (argc>1) strcpy(configname,argv[1]);
  16. else strcpy(configname,"ticonfig.dat");
  17. if ((infile=fopen(configname,"r"))==NULL)
  18. {
  19.     printf("Config file '%s' not found!\n",configname);
  20.     exit(0);
  21. }
  22. else
  23. {
  24.     while(!feof(infile))
  25.     {
  26.         fgets(line,80,infile);
  27.         if ((line[0]!='*')&&(line[0]!=' ')&&(strlen(line)>8))
  28.         {
  29.             if(sscanf(line,"%s %c %x %x %x",filename,
  30.             &memtype,&base,&offset,&length)!=5)
  31.             printf("SYNTAX ERROR in '%s'\n>>> %s <<<\n",
  32.             configname,line);
  33.             else
  34.             {
  35.                 printf("Filename: %s\n",filename);
  36.                 printf("Memtype : %c\n",memtype);
  37.                 printf("Address : %04x\n",base);
  38.                 printf("Skip    : %d\n",offset);
  39.                 printf("Length  : %04x\n",length);
  40.             }
  41.         }
  42.     }
  43. }
  44. }
  45.