home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / BFE2000P.ZIP / BFE2000P.EXE / DEVKIT / MAX2BFE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-30  |  2.1 KB  |  81 lines

  1. /*╓────────────────────────────────────────────────────────────────────────┐
  2.   ║  MAX2BFE - Converts Maximus CBCS 2.x userbase into BFE format          │
  3.   ║  Copyright 1993, Cairo Research Labs, All Rights Reserved.             │
  4.   ╙────────────────────────────────────────────────────────────────────────┘*/
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <mem.h>
  10.  
  11. #include "msgapi.h"                             // From the Squish API
  12. #include "mstruct.h"                            // From the Squish API
  13. #include "..\structs.h"                         // From the BFE/DevKit
  14.  
  15. // One big main()! Sloppy, but does the job!
  16.  
  17. void main(int argc, char *argv[])
  18. {
  19.   long sec[13];
  20.   FILE *in, *out, *cfg;
  21.   struct _usr olduser;
  22.   _USER newuser;
  23.   char buf[100];
  24.   int x;
  25.   long usercount=0L;
  26.  
  27.   printf("\n\rMAX2BFE - Converts Maximus v2.0x USER.BBS structure to BFE format\n\r");
  28.   printf("(C)opyright 1993, Cairo Research Labs, all rights reserved\n\r\n\r");
  29.  
  30.   if(argc != 2) {
  31.     printf("USAGE: max2bfe <path/filename of USER.BBS file>\n\r\n\r");
  32.     exit(99);
  33.   }
  34.  
  35.   if((in = fopen(argv[1], "rb")) == NULL) {
  36.     printf("■ ERROR: Unable to open USER.BBS file!\n\r\n\r");
  37.     exit(99);
  38.   }
  39.  
  40.   if((out = fopen("USER.BFE", "wb")) == NULL) {
  41.     printf("■ ERROR: Unable to create USER.BFE file!\n\r\n\r");
  42.     exit(98);
  43.   }
  44.  
  45.   if((cfg = fopen("MAX2BFE.CTL", "rt")) == NULL) {
  46.     printf("■ ERROR: Unable to open MAX2BFE.CFG file!\n\r\n\r");
  47.     exit(97);
  48.   }
  49.  
  50.   for(x=0; x<12; x++) {
  51.     fgets(buf, 80, cfg);
  52.     sec[x] = atol(buf);
  53.   }
  54.   fclose(cfg);
  55.  
  56.   do {
  57.     fread(&olduser, 1, sizeof(struct _usr), in);
  58.     if(feof(in)) break;
  59.  
  60.     memset(&newuser, '\0', sizeof(_USER));
  61.  
  62.     printf("Converting: %s            \r", olduser.name);
  63.  
  64.     strcpy(newuser.name, olduser.name);
  65.     strcpy(newuser.location, olduser.city);
  66.     strcpy(newuser.password, olduser.pwd);
  67.     newuser.security = sec[olduser.priv];
  68.     fwrite(&newuser, 1, sizeof(_USER), out);
  69.  
  70.     usercount++;
  71.  
  72.   } while(!feof(in));
  73.  
  74.   printf("\rConverted %ld users                 \n\r", usercount);
  75.  
  76.   fclose(in);
  77.   fclose(out);
  78.  
  79. }
  80.  
  81.