home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / makeidx.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  893b  |  50 lines

  1. /* Creates graph.idx, to speed up reading of hlp file */
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #include <assert.h>
  7.  
  8. main()
  9. {
  10.     FILE *f,*fi;
  11.     long lvl;
  12.     long p;
  13.     int slen;
  14.     char buff[200];
  15.  
  16. #ifdef __TURBOC__
  17.     f = fopen("exe\\graph.hlp","r");
  18.     fi = fopen("exe\\graph.idx","wb");
  19. #else
  20.     f = fopen("graph.hlp","r");
  21.     fi = fopen("graph.idx","wb");
  22. #endif
  23.     if (f==NULL) die("Unable to open exe\graph.hlp for input \n");
  24.     if (fi==NULL) die("Unable to open exe\graph.idx  for output \n");
  25.     for (;!feof(f);) {
  26.       if (fgets(buff,190,f)!=NULL) {
  27.         p = ftell(f);
  28.         lvl = buff[0]-'0';
  29.         if (lvl>0 && lvl<9)  {
  30.             slen=strlen(buff);
  31.             fwrite(&slen,sizeof(slen),1,fi);
  32.             fwrite(buff,1,slen,fi);
  33.             fwrite(&p,sizeof(p),1,fi);
  34.         }
  35.       }
  36.     }
  37.     fclose(fi); fclose(f);
  38. #ifndef VMS
  39.     return 0;
  40. #else
  41.     return 1;
  42. #endif
  43. }
  44. die(char *s)
  45. {
  46.     printf("Dieing {%s} \n",s);
  47.     exit(1);
  48. }
  49.  
  50.