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

  1. /* Module 2 of MSETUP.C */
  2.  
  3.  
  4. #include "msgg.h"
  5.  
  6. #define XBBS
  7.  
  8. #ifdef XBBS
  9. extern struct _config conf;
  10. extern     struct _user user;
  11. extern     word userno;
  12. extern     struct time timeon;
  13. extern     char timer_off;
  14. extern     word hold_time;
  15. extern     char age;
  16. extern     char pages;
  17. extern     struct _mboard mboard;
  18. extern     struct _fboard fboard;
  19. extern     struct _events event[10];
  20. extern     char variable[10][82];
  21. #endif
  22.  
  23. extern char   debug_mode;
  24. extern char   graphics;
  25. extern word   timelimit;
  26. extern word   baud;
  27. extern char   numlines;
  28. extern word   seclvl;
  29. extern ulong  startt;
  30. extern char   sysopin;
  31. extern char   fastANSI;
  32. extern char   commport;
  33. extern struct time starter;
  34. extern union  REGS rg;
  35. extern char   logfile[133];
  36. extern char   username[36];
  37. extern char   width;
  38. extern char   fast;
  39. extern char   chatting;
  40. extern char   chatted;
  41. extern char   nodenumber;
  42. extern char   system_name[64];
  43. extern char   sysop[36];
  44.  
  45. struct _msetup {
  46.     unsigned long userid;
  47.     char node;
  48.     unsigned char areas[512];
  49. };
  50. extern struct _msetup mset;
  51.  
  52. #define MAXNUMAREA 1024
  53.  
  54. struct _ffboard {
  55.   char       name[47];
  56.   char       flags;
  57.   word         security;
  58.   char       dpath[79];
  59.   char       upath[79];
  60.   char       descr[79];
  61.   signed char age;
  62.   word          userflags;
  63.   char          leechpercent;
  64. };
  65.  
  66. struct _mmboard {
  67.   char       name[48];
  68.   char       forceto[36];
  69.   word       attr;
  70.   word       max;
  71.   word       number;
  72.   word       substat1;
  73.   word       substat2;
  74.   char       descr[79];
  75.   signed char age;
  76.   word       flags;
  77.   word          zone;
  78.   word         net;
  79.   word          node;
  80.   word         point;
  81.   char       yourname[36];
  82.   word         minwrite;
  83. };
  84.  
  85. extern char pathfile[133];
  86. extern char msgareasfile[133];
  87. extern char filetocreate[133];
  88. extern char fileareasfile[133];
  89. extern char filefiletocreate[133];
  90. extern struct _mmboard huge *marea;
  91. extern struct _mmboard huge *currarea;
  92. extern word higharea;
  93. extern word maxareas;
  94. extern char create;
  95. extern char fseclvl;
  96. extern char dofiles;
  97.  
  98.  
  99. extern char * pascal stripcr(char *);
  100.  
  101.  
  102.  
  103. void pascal do_fboard (void) {
  104.  
  105.     FILE *fp;
  106.     char *p;
  107.     register word y;
  108.     struct ffblk f;
  109.     static char string[256];
  110.     word tempareas=0;
  111.     struct _ffboard huge * dir=NULL;
  112.  
  113.     baud=0;
  114.     dir=(struct _ffboard huge*)farmalloc((MAXNUMAREA * sizeof(struct _ffboard))+sizeof(struct _ffboard));
  115.     if (dir==NULL) {
  116.         return;
  117.     }
  118.  
  119.     if(!*fileareasfile) sprintf(fileareasfile,"FLSEARCH.CTL");
  120.     if(findfirst(fileareasfile,&f,0)) {
  121.         if(dir)farfree((struct _ffboard far *)dir);
  122.         return;
  123.     }
  124.     if(!(fp=fopen(fileareasfile,"rt"))) {
  125.         if(dir)farfree((struct _ffboard far *)dir);
  126.         return;
  127.     }
  128.     while (!feof(fp)) {
  129.         if (!fgets(string,255,fp)) break;
  130.         if (*string=='\n' || *string==';') continue;
  131.         stripcr(string);
  132.         strncpy(dir[tempareas].dpath,strtok(string," "),78);
  133.         dir[tempareas].dpath[78]=0;
  134.         if (dir[tempareas].dpath[strlen(dir[tempareas].dpath)-1]!='\\') strcat(dir[tempareas].dpath,"\\");
  135.         dir[tempareas].security=(word)atol(strtok(0," "));
  136.         if(dir[tempareas].security > user.stat[fseclvl]) continue;
  137.         strncpy(dir[tempareas].name,strtok(0," "),46);
  138.         dir[tempareas].name[46]=0;
  139.         strupr(dir[tempareas].name);
  140. /*      while((p=strchr(dir[tempareas].name,'_'))!=NULL) *p=' '; */
  141.         dir[tempareas].flags=(char)atoi(strtok(0," "));
  142.         p=strtok(0," ");
  143.         if (p) {
  144.             strncpy(dir[tempareas].upath,p,79);
  145.             dir[tempareas].upath[78]=0;
  146.             if (dir[tempareas].upath[strlen(dir[tempareas].upath)-1]!='\\') strcat(dir[tempareas].upath,"\\");
  147.         }
  148.         else strcpy(dir[tempareas].upath,"NUL");
  149.         p=strtok(0,",");
  150.         if(p) {
  151.             if(*p==',') strcpy(dir[tempareas].descr,"No Description");
  152.             else strncpy(dir[tempareas].descr,p,79);
  153.             dir[tempareas].descr[78]=0;
  154.         }
  155.         else {
  156.             strcpy(dir[tempareas].descr,"No Description");
  157.         }
  158.         p=strtok(0,",");
  159.         if(p) {
  160.             dir[tempareas].age=(signed char)atoi(p);
  161.         }
  162.         else dir[tempareas].age=0;
  163.         p=strtok(0,",");
  164.         if(p) {
  165.             dir[tempareas].userflags=(word)atol(p);
  166.         }
  167.         else dir[tempareas].userflags=0;
  168.         p=strtok(0,",");
  169.         if(p)dir[tempareas].leechpercent=(char)atoi(p);
  170.         else dir[tempareas].leechpercent=0;
  171.  
  172.         if(dir[tempareas].age) {
  173.             if(dir[tempareas].age>0) {
  174.                 if(age<(char)dir[tempareas].age) {
  175.                     continue;
  176.                 }
  177.             }
  178.             else {
  179.                 if(age>(char)abs(dir[tempareas].age)) {
  180.                     continue;
  181.                 }
  182.             }
  183.         }
  184.         if(dir[tempareas].userflags) {
  185.             for(y=0;y<16;y++) {
  186.                 if(dir[tempareas].userflags & (1<<y)) {
  187.                     if(!(user.attr2 & (1<<y))) {
  188.                         continue;
  189.                     }
  190.                 }
  191.             }
  192.         }
  193.         tempareas++;
  194.     }
  195.     fclose(fp);
  196.  
  197.     if(!*filefiletocreate) sprintf(filefiletocreate,"FLSEARCH.%03hu",nodenumber);
  198.     if(!*pathfile) sprintf(pathfile,"DLPATHS.%03hu",nodenumber);
  199.  
  200.     if(tempareas) {
  201.         fp=fopen(filefiletocreate,"wt");
  202.         for(y=0;y<tempareas;y++) {
  203. /*          while((p=strchr(dir[y].name,' '))!=NULL) *p='_';  */
  204.             fprintf(fp,"%s %u %s %u %s %s,%hd,%u,%hu\n",dir[y].dpath,dir[y].security,dir[y].name,dir[y].flags,dir[y].upath,dir[y].descr,dir[y].age,dir[y].userflags,dir[y].leechpercent);
  205.         }
  206.         fprintf(fp,"\n");
  207.         fclose(fp);
  208.         printfm("\n\04Created %s\n",filefiletocreate);
  209.         sprintf(string,"PLSEARCH.%03hu",nodenumber);
  210.         fp=fopen(string,"wt");
  211.         for(y=0;y<tempareas;y++) {
  212. /*          while((p=strchr(dir[y].name,' '))!=NULL) *p='_';  */
  213.             if(stricmp(dir[y].dpath,"NUL") && stricmp(dir[y].dpath,"NUL\\")) fprintf(fp,"%s %u %s\n",dir[y].dpath,dir[y].security,dir[y].name);
  214.         }
  215.         fprintf(fp,"\n");
  216.         fclose(fp);
  217.         printfm("\04Created %s\n",string);
  218.         fp=fopen(pathfile,"wt");
  219.         for(y=0;y<tempareas;y++) {
  220.             if(stricmp(dir[y].dpath,"NUL") && stricmp(dir[y].dpath,"NUL\\")) fprintf(fp,"%s\n",dir[y].dpath);
  221.         }
  222.         fprintf(fp,"\n");
  223.         fclose(fp);
  224.         printfm("\04Created %s\n",pathfile);
  225.     }
  226.  
  227.     if(dir)farfree((struct _ffboard far *)dir);
  228. }
  229.