home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XDEV_117.ZIP / INDEXUSR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-28  |  1.2 KB  |  73 lines

  1. /* FidoUser.Lst Indexer for XBBS */
  2.  
  3. #include "stdio.h"
  4. #include "stdlib.h"
  5. #include "dir.h"
  6.  
  7. static void getline (char *);
  8.  
  9. char alpha='B';
  10. #define MAXPROMPTS 1500
  11.  
  12. FILE *fp;
  13.  
  14. void main (void) {
  15.  
  16.     FILE *idxfp;
  17.     struct ffblk f;
  18.     char lineh[256]=" ";
  19.     char s[18];
  20.     long pos;
  21.  
  22.     if (findfirst ("FIDOUSER.LST",&f,0)) {
  23.         fputs("\nCan't find FIDOUSER.LST\n",stdout);
  24.         exit(1);
  25.     }
  26.  
  27.     if (f.ff_fsize<1) {
  28.         fputs("\nFIDOUSER.LST is null length\n",stdout);
  29.         exit(1);
  30.     }
  31.  
  32.     if ((fp = fopen("FIDOUSER.LST","r")) == NULL) {
  33.         fputs("\nCan't open FIDOUSER.LST\n",stdout);
  34.         exit(1);
  35.     }
  36.  
  37.     remove("FIDOUSER.IDX");
  38.  
  39.     if ((idxfp = fopen("FIDOUSER.IDX","wb")) == NULL) {
  40.         fputs("\nCan't open FIDOUSER.IDX\n",stdout);
  41.         exit(1);
  42.     }
  43.  
  44.     fputs("\nIndexing FIDOUSER.LST...\n",stdout);
  45.  
  46.     pos=0;
  47.     fwrite(&pos,sizeof(long),1,idxfp);
  48.     fputs("A \r",stdout);
  49.  
  50.     while (*lineh) {
  51.         pos=ftell(fp);
  52.         getline(lineh);
  53.         if (toupper(*lineh)!=alpha) continue;
  54.         fwrite(&pos,sizeof(long),1,idxfp);
  55.         *s=alpha;
  56.         s[1]=0;
  57.         fputs(s,stdout);
  58.         fputs(" \r",stdout);
  59.         alpha++;
  60.     }
  61.     fclose(fp);
  62.     fclose(idxfp);
  63. }
  64.  
  65.  
  66. static void getline (char *lineh) {
  67.  
  68.     if (fgets(lineh,256,fp)==NULL) *lineh=0;
  69.  
  70. }
  71.  
  72.  
  73.