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

  1. /* XEDIT v1.16 copyright (c) 1990 by M. Kimes */
  2.  
  3. #include "msgg.h"
  4. #include "twindow.h"
  5. #include "keys.h"
  6.  
  7. char msk78[]="______________________________________________________________________________";
  8. #define msk35 msk78+43
  9. #define mskst msk35+33
  10. #define mskzip msk35+30
  11. #define mskcit msk35+11
  12. #define msk1 msk78+77
  13. #define msk3 msk35+32
  14. #define msk4 msk35+31
  15. #define msk5 msk35+30
  16. #define msk6 msk35+29
  17. #define msk47 msk78+31
  18. #define msk46 msk78+32
  19. #define msk51 msk78+28
  20. #define msk40 msk46+6
  21. #define msk39 msk46+7
  22. #define msk12 msk78+66
  23. #define msk65 msk78+13
  24. #define msk19 msk78+59
  25. #define msk26 msk78+52
  26. #define msk24 msk78+54
  27. #define msk58 msk78+20
  28. #define msk10 msk78+68
  29.  
  30. #define MAXNUMDIRS         1024
  31. #define MAXNUMAREA         1024
  32. #define MAXPROTOCOLS    130
  33. #define MAXARCHIVERS    256
  34. #define MAXDOORS        4096
  35.  
  36. WINDOW *wnd4=NULL;
  37.  
  38. struct _mmboard {
  39.   char       name[48];
  40.   char       forceto[36];
  41.   word       attr;
  42.   word       max;
  43.   word       number;
  44.   word       substat1;
  45.   word       substat2;
  46.   char       descr[79];
  47.   signed char age;
  48.   word       flags;
  49.   word          zone;
  50.   word         net;
  51.   word          node;
  52.   word         point;
  53.   char       yourname[36];
  54.   word       minwrite;
  55. };
  56.  
  57. struct _ffboard {
  58.   char       name[47];
  59.   char       flags;
  60.   word         security;
  61.   char       dpath[79];
  62.   char       upath[79];
  63.   char       descr[79];
  64.   signed char age;
  65.   word          userflags;
  66.   char       leechpercent;
  67. };
  68.  
  69. char path[99]="C:\\XBBS\\MESS\\";
  70. char msgareasfile[133]="C:\\XBBS\\MESS\\MSGAREAS.XBS";
  71. char fileareasfile[133]="C:\\XBBS\\FLSEARCH.CTL";
  72. char msgareasfilebackup[133]="C:\\XBBS\\MESS\\MSGAREAS.BAK";
  73. char fileareasfilebackup[133]="C:\\XBBS\\FLSEARCH.BAK";
  74. struct _mmboard huge *marea=NULL;
  75. struct _mmboard huge *currarea=NULL;
  76. word higharea;
  77. word maxareas=0;
  78. struct _ffboard huge *curdir=NULL;
  79. struct _ffboard huge *dir=NULL;
  80. word numdirs=0;
  81.  
  82. struct   _door {
  83.     char name[25];
  84.     char type[4];
  85.     char spawn[79];
  86.     char descr[79];
  87. } huge *door=NULL;
  88.  
  89. word numdoors=0;
  90.  
  91. struct   _protocol {
  92.     char   name[25];
  93.     char   key;
  94.     int    adj;
  95.     char   spawndn[119];
  96.     char   spawnup[119];
  97.     char   abort[48];
  98.     unsigned wild:         1;
  99.     unsigned multi:        1;
  100.     unsigned simul:        1;
  101.     unsigned list:        1;
  102.     unsigned opus:        1;
  103.     unsigned noname:    1;
  104.     unsigned dszlog:    1;
  105.     unsigned reserved:    1;
  106.     char   pad1;
  107.     char   pad2;
  108. } huge *proto=NULL;
  109.  
  110. word numprotos=0;
  111.  
  112. struct _archiver {
  113.     char ext[5];
  114.     char move[41];
  115.     char extract[41];
  116.     char list[41];
  117.     char error[41];
  118.     char aname[13];
  119.     char ename[13];
  120.     char id[25];
  121.     char pick[2];
  122.     int  skip;
  123.     int  errline;
  124. } huge *archiver=NULL;
  125. word numarchivers;
  126. char filename[133];
  127. char textname[133];
  128.  
  129. void   cdecl  deinit(void);
  130. int       cdecl  break_handler(void);
  131. void   pascal swap_msgareas(word,word);
  132. int       pascal sort_msgareas(void);
  133. void   pascal swap_fileareas(word,word);
  134. int       pascal sort_fileareas(void);
  135. void   pascal swap_protocols(word,word);
  136. int       pascal sort_protocols(void);
  137. word   pascal select_area(word);
  138. char * pascal msgarea_attr(void);
  139. char * pascal filearea_attr (char flags);
  140. char * pascal rstrip(char *);
  141. char * pascal lstrip(char *);
  142. char * pascal stripcr(char *);
  143. void   pascal load_fileareas(char *);
  144. void   pascal load_msgareas(char *);
  145. void   pascal load_protocols(char *);
  146. word   pascal find_msgarea(word);
  147. word   pascal find_filearea(char *);
  148. word   pascal list_msgareas(char *);
  149. word   pascal list_fileareas(char *);
  150. word   pascal list_protocols(char *);
  151. word   pascal check_area(word);
  152. word   pascal edit_msgarea(word);
  153. word   pascal edit_filearea(word);
  154. word   pascal edit_protocol(word);
  155. int       pascal setup_msg(void);
  156. int       pascal setup_file(void);
  157. int           addbackslash (char *,int);
  158. int           nomorethan4095 (char *,int);
  159.  
  160. extern void pascal make_msgmenu(void);
  161. extern void pascal make_filemenu(void);
  162. extern void   pascal load_archivers(char *);
  163. extern word   pascal list_archivers(char *);
  164. extern word   pascal edit_archiver(word);
  165. extern word maxx;
  166. extern word maxy;
  167. extern unsigned char usemouse;
  168. extern WINDOW *ewnd;
  169.  
  170. extern unsigned _Cdecl _stklen = 8192;    /* Stack length */
  171.  
  172.  
  173. void cdecl main () {
  174.  
  175.     WINDOW *wnd;
  176.     word areano;
  177.     int choice;
  178.     FILE *fp;
  179.     char *p;
  180.     register word x;
  181.  
  182.     maxx=80;
  183.     maxy=25;
  184.     fputs("\n Copyright (c) 1990 by M. Kimes ",stdout);
  185.     ctrlbrk(break_handler);
  186.     atexit(deinit);
  187.     areano=0;
  188.     load_help(searchpath("xedit.hlp"));
  189.  
  190.     {
  191.  
  192.         long x;
  193.  
  194.         x=(long)getvect(0x33);  /* Check for mouse driver */
  195.         if(x!=0L) {
  196.             _AX=0;  /* Initialize mouse */
  197.             geninterrupt(0x33);
  198.         }
  199.         usemouse=(unsigned char)_AX;
  200.         if(usemouse) {    /* Make sure mouse cursor stays hidden */
  201.             _AX=2;
  202.             geninterrupt(0x33);
  203.         }
  204.     }
  205.  
  206.     printf("\x1b[2J");
  207.     wnd=establish_window(2,2,7,40);
  208.     set_title(wnd," XEdit (XBBS Control File Editor) ");
  209.     display_window(wnd);
  210.     wprintf(wnd," [M]essage area file\n [F]ile area file\n [P]rotocol.CTL\n P[E]eker.CTL\n [Q]uit");
  211.  
  212.   while (1) {
  213.     if(wnd4) {
  214.         delete_window(wnd4);
  215.         wnd4=NULL;
  216.     }
  217.     set_help("startup   ",10,10);
  218.     choice=get_selection(wnd,1,"MFPEQ");
  219.     switch(choice) {
  220.     set_help("",1,1);
  221.         case 5:
  222.         case 0:     printf("\x1b[2J");
  223.                     exit(0);
  224.         case 2:     if(!setup_file()) break;
  225.                     load_fileareas(fileareasfile);
  226.                     do {
  227.                         if(numdirs)areano=list_fileareas(fileareasfile);
  228.                         if(areano || !numdirs) {
  229.                             edit_filearea(areano-1);
  230.                         }
  231.                     } while (areano || !numdirs);
  232. ReInput2:
  233.                     areano=0;
  234.                     any_message(" Save? (Y-n) ");
  235.                     choice=toupper(generic_mouse_input(ewnd));
  236.                     clear_message();
  237.                     if(choice=='N' || choice==ESC) {
  238.  
  239.                     }
  240.                     else {
  241.                         if(*fileareasfilebackup) {
  242.                             unlink(fileareasfilebackup);
  243.                             rename(fileareasfile,fileareasfilebackup);
  244.                         }
  245.                         if(!((fp=fopen(fileareasfile,"wt")))) {
  246.                             if(*fileareasfilebackup) {
  247.                                 rename(fileareasfilebackup,fileareasfile);
  248.                             }
  249.                             error_message(" Unable to create new file ");
  250.                             pause_msg();
  251.                         }
  252.                         else {
  253.                             for(x=0;x<numdirs;x++) {
  254.                                 while((p=strchr(dir[x].name,' '))!=NULL) *p='_';
  255.                                 fprintf(fp,"%s %u %s %u %s %s,%hd,%u,%hu\n",dir[x].dpath,dir[x].security,dir[x].name,dir[x].flags,dir[x].upath,dir[x].descr,dir[x].age,dir[x].userflags,dir[x].leechpercent);
  256.                             }
  257.                             fprintf(fp,"\n");
  258.                             fclose(fp);
  259.                         }
  260.                         break;
  261.                     }
  262.                     if(dir) {
  263.                         free((struct _ffboard far *)dir);
  264.                         dir=NULL;
  265.                         numdirs=0;
  266.                     }
  267.                     break;
  268.         case 1:     if(!setup_msg()) break;
  269.                     load_msgareas(msgareasfile);
  270.                     do {
  271.                         if(maxareas)areano=list_msgareas(msgareasfile);
  272.                         if(areano || !maxareas) {
  273.                             edit_msgarea(areano);
  274.                         }
  275.                     } while (areano || !maxareas);
  276. ReInput:
  277.                     areano=0;
  278.                     any_message(" Save? (Y-n) ");
  279.                     choice=toupper(generic_mouse_input(ewnd));
  280.                     clear_message();
  281.                     if(choice=='N' || choice==ESC) {
  282.                     }
  283.                     else {
  284.                         if(*msgareasfilebackup) {
  285.                             unlink(msgareasfilebackup);
  286.                             rename(msgareasfile,msgareasfilebackup);
  287.                         }
  288.                         if(!((fp=fopen(msgareasfile,"wt")))) {
  289.                             if(*msgareasfilebackup) {
  290.                                 rename(msgareasfilebackup,msgareasfile);
  291.                             }
  292.                             error_message(" Unable to create new file ");
  293.                             pause_msg();
  294.                         }
  295.                         else {
  296.                             for(x=0;x<maxareas;x++) {
  297.                                 fprintf(fp,"%s,%u,%u,%u,%u,%u",marea[x].name,marea[x].attr,marea[x].max,marea[x].number,marea[x].substat1,marea[x].substat2);
  298.                                 fprintf(fp,",%s",marea[x].forceto);
  299.                                 fprintf(fp,",%s",marea[x].descr);
  300.                                 fprintf(fp,",%hd",marea[x].age);
  301.                                 fprintf(fp,",%u",marea[x].flags);
  302.                                 if(marea[x].zone && marea[x].net) {
  303.                                     fprintf(fp,",%u:%u/%01u.%01u",marea[x].zone,marea[x].net,marea[x].node,marea[x].point);
  304.                                 }
  305.                                 else fprintf(fp,",");
  306.                                 fprintf(fp,",%s",marea[x].yourname);
  307.                                 fprintf(fp,",%u",marea[x].minwrite);
  308.                                 fprintf(fp,"\n");
  309.                             }
  310.                             fprintf(fp,"\n");
  311.                             fclose(fp);
  312.                         }
  313.                         break;
  314.                     }
  315.                     if(marea) {
  316.                         free((struct _mmboard far *)marea);
  317.                         marea=NULL;
  318.                         maxareas=0;
  319.                         higharea=0;
  320.                     }
  321.                     break;
  322.         case 3:     proto=(struct _protocol huge*)malloc((MAXPROTOCOLS*sizeof(struct _protocol))+sizeof(struct _protocol));
  323.                     if (proto==NULL) {
  324.                         error_message(" No memory for protocols ");
  325.                         numprotos=0;
  326.                         exit(1);
  327.                     }
  328.                     load_protocols("Protocol.CTL");
  329.                     do {
  330.                         if(numprotos)areano=list_protocols("PROTOCOL.CTL");
  331.                         if(areano || !numprotos) {
  332.                             edit_protocol(areano-1);
  333.                         }
  334.                     } while (areano || !numprotos);
  335. ReInput3:
  336.                     areano=0;
  337.                     any_message(" Save? (Y-n) ");
  338.                     choice=toupper(generic_mouse_input(ewnd));
  339.                     clear_message();
  340.                     if(choice=='N' || choice==ESC) {
  341.                     }
  342.                     else {
  343.                         if(!((fp=fopen("Protocol.CTL","wb")))) {
  344.                             error_message(" Unable to create new file ");
  345.                             pause_msg();
  346.                         }
  347.                         else {
  348.                             fwrite((void far *)proto,sizeof(struct _protocol),numprotos,fp);
  349.                             fclose(fp);
  350.                         }
  351.                         break;
  352.                     }
  353.                     if(proto) {
  354.                         free((struct _protocol far *)proto);
  355.                         proto=NULL;
  356.                         numprotos=0;
  357.                     }
  358.                     break;
  359.         case 4:     archiver=(struct _archiver huge*)malloc((MAXARCHIVERS*sizeof(struct _archiver))+sizeof(struct _archiver));
  360.                     if (archiver==NULL) {
  361.                         error_message(" No memory for archivers ");
  362.                         numarchivers=0;
  363.                         exit(1);
  364.                     }
  365.                     load_archivers("Peeker.CTL");
  366.                     do {
  367.                         if(numarchivers)areano=list_archivers("PEEKER.CTL");
  368.                         if(areano || !numarchivers) {
  369.                             edit_archiver(areano-1);
  370.                         }
  371.                     } while (areano || !numarchivers);
  372. ReInput4:
  373.                     areano=0;
  374.                     any_message(" Save? (Y-n) ");
  375.                     choice=toupper(generic_mouse_input(ewnd));
  376.                     clear_message();
  377.                     if(choice=='N' || choice==ESC) {
  378.                     }
  379.                     else {
  380.                         if(!((fp=fopen("Peeker.CTL","wb")))) {
  381.                             error_message(" Unable to create new file ");
  382.                             pause_msg();
  383.                         }
  384.                         else {
  385.                             fwrite((void far *)archiver,sizeof(struct _archiver),numarchivers,fp);
  386.                             fclose(fp);
  387.                         }
  388.                         break;
  389.                     }
  390.                     if(archiver) {
  391.                         free((struct _archiver far *)archiver);
  392.                         archiver=NULL;
  393.                         numarchivers=0;
  394.                     }
  395.                     break;
  396.         default:    break;
  397.     }
  398.   }
  399. }
  400.  
  401.  
  402.  
  403. int cdecl break_handler (void) {
  404.  
  405.     return 0;        /* Shut down in event of CTRL-BREAK */
  406.  
  407. }
  408.  
  409.  
  410.  
  411. void cdecl deinit (void) {
  412.  
  413.     if(marea)free((void far *)marea);
  414.     if(dir)free((void far *)dir);
  415.     if(proto)free((void far *)proto);
  416.     if(archiver)free((void far *)archiver);
  417.     if(door)free((void far *)door);
  418.     fcloseall();
  419. }
  420.  
  421.  
  422.  
  423. void pascal load_msgareas (char *file) {
  424.  
  425.     FILE *fp;
  426.     char *p;
  427.     char *pp;
  428.     struct ffblk f;
  429.     static char string[256];
  430.     word tempareas=0;
  431.  
  432.     if(findfirst(file,&f,0)) return;
  433.     if(!(fp=fopen(file,"rt"))) {
  434.         sprintf(string," Can't open %s ",file);
  435.         error_message(string);
  436.         pause_msg();
  437.         return;
  438.     }
  439.     while (!feof(fp)) {
  440.         if (!fgets(string,255,fp)) break;
  441.         if (*string=='\n' || *string==';') continue;
  442.         stripcr(string);
  443.         strncpy(marea[tempareas].name,strtok(string,","),48);
  444.         marea[tempareas].name[47]=0;
  445.         marea[tempareas].attr=(word)atoi(strtok(0," ,"));
  446.         marea[tempareas].max=(word)atoi(strtok(0," ,"));
  447.         marea[tempareas].number=(word)atoi(strtok(0," ,"));
  448.         marea[tempareas].substat1=(word)atoi(strtok(0," ,"));
  449.         marea[tempareas].substat2=(word)atoi(strtok(0," ,"));
  450.         pp=strtok(0,"\n");
  451.         p=NULL;
  452.         if(pp) {
  453.             if(*pp!=',') {
  454.                 p=strtok(pp,",");
  455.                 pp=strtok(0,"\n");
  456.             }
  457.             else pp++;
  458.         }
  459.         if(p!=NULL)strncpy(marea[tempareas].forceto,p,36);
  460.         else *marea[tempareas].forceto=0;
  461.         marea[tempareas].forceto[35]=0;
  462.         p=NULL;
  463.         if(pp && *pp) {
  464.             if(*pp!=',') {
  465.                 p=strtok(pp,",");
  466.                 pp=strtok(0,"\n");
  467.             }
  468.             else pp++;
  469.         }
  470.         if(!p) strcpy(marea[tempareas].descr,"No Description");
  471.         else strncpy(marea[tempareas].descr,p,79);
  472.         marea[tempareas].descr[78]=0;
  473.         p=NULL;
  474.         if(pp && *pp) {
  475.             if(*pp!=',') {
  476.                 p=strtok(pp,",");
  477.                 pp=strtok(0,"\n");
  478.             }
  479.             else pp++;
  480.         }
  481.         if(!p) marea[tempareas].age=0;
  482.         else marea[tempareas].age=(signed char)atoi(p);
  483.         p=NULL;
  484.         if(pp && *pp) {
  485.             if(*pp!=',') {
  486.                 p=strtok(pp,",");
  487.                 pp=strtok(0,"\n");
  488.             }
  489.             else pp++;
  490.         }
  491.         if(!p)marea[tempareas].flags=0;
  492.         else marea[tempareas].flags=(word)atol(p);
  493.         p=NULL;
  494.         if(pp && *pp) {
  495.             if(*pp!=',') {
  496.                 p=strtok(pp,",");
  497.                 pp=strtok(0,"\n");
  498.             }
  499.             else pp++;
  500.         }
  501.         if(!p) marea[tempareas].zone=marea[tempareas].net=marea[tempareas].node=marea[tempareas].point=0;
  502.         else {
  503.             p=strtok(p,":");
  504.             marea[tempareas].zone=(word)atol(p);
  505.             p=strtok(0,"/");
  506.             marea[tempareas].net=(word)atol(p);
  507.             p=strtok(0,".");
  508.             marea[tempareas].node=(word)atol(p);
  509.             p=strtok(0,"@");
  510.             marea[tempareas].point=(word)atol(p);
  511.         }
  512.         p=NULL;
  513.         if(*pp && pp) {
  514.             if(*pp!=',' && *pp!=0) {
  515.                 p=strtok(pp,",");
  516.                 pp=strtok(0,"\n");
  517.             }
  518.             else pp++;
  519.         }
  520.         if(!p) *marea[tempareas].yourname=0;
  521.         else {
  522.             strncpy(marea[tempareas].yourname,p,36);
  523.             marea[tempareas].yourname[35]=0;
  524.         }
  525.         p=NULL;
  526.         if(*pp && pp) {
  527.             if(*pp!=',' && *pp!=0) p=strtok(pp,"\n");
  528.             else if(*pp)p=++pp;
  529.         }
  530.         if(!p) marea[tempareas].minwrite=0;
  531.         else {
  532.             marea[tempareas].minwrite=(word)atol(p);
  533.         }
  534.         if (marea[tempareas].number>higharea) higharea=marea[tempareas].number;
  535.         tempareas++;
  536.     }
  537.     maxareas=tempareas;
  538.     fclose(fp);
  539. }
  540.  
  541.  
  542.  
  543.  
  544. void pascal load_fileareas (char *file) {
  545.  
  546.     FILE *fp;
  547.     char *p;
  548.     struct ffblk f;
  549.     static char string[256];
  550.     word tempareas=0;
  551.  
  552.     if(findfirst(file,&f,0)) return;
  553.     if(!(fp=fopen(file,"rt"))) {
  554.         sprintf(string," Can't open %s ",file);
  555.         error_message(string);
  556.         pause_msg();
  557.         return;
  558.     }
  559.     while (!feof(fp)) {
  560.         if (!fgets(string,255,fp)) break;
  561.         if (*string=='\n' || *string==';') continue;
  562.         stripcr(string);
  563.         strncpy(dir[tempareas].dpath,strtok(string," "),78);
  564.         dir[tempareas].dpath[78]=0;
  565.         if (dir[tempareas].dpath[strlen(dir[tempareas].dpath)-1]!='\\') strcat(dir[tempareas].dpath,"\\");
  566.         dir[tempareas].security=(word)atol(strtok(0," "));
  567.         strncpy(dir[tempareas].name,strtok(0," "),46);
  568.         dir[tempareas].name[46]=0;
  569.         strupr(dir[tempareas].name);
  570.         while((p=strchr(dir[tempareas].name,'_'))!=NULL) *p=' ';
  571.         dir[tempareas].flags=(char)atoi(strtok(0," "));
  572.         p=strtok(0," ");
  573.         if (p) {
  574.             strncpy(dir[tempareas].upath,p,79);
  575.             dir[tempareas].upath[78]=0;
  576.             if (dir[tempareas].upath[strlen(dir[tempareas].upath)-1]!='\\') strcat(dir[tempareas].upath,"\\");
  577.         }
  578.         else strcpy(dir[tempareas].upath,"NUL");
  579.         p=strtok(0,",");
  580.         if(p) {
  581.             if(*p==',') strcpy(dir[tempareas].descr,"No Description");
  582.             else strncpy(dir[tempareas].descr,p,79);
  583.             dir[tempareas].descr[78]=0;
  584.         }
  585.         else {
  586.             strcpy(dir[tempareas].descr,"No Description");
  587.         }
  588.         p=strtok(0,",\n");
  589.         if(p) {
  590.             dir[tempareas].age=(signed char)atoi(p);
  591.         }
  592.         else dir[tempareas].age=0;
  593.         p=strtok(0,",");
  594.         if(p) {
  595.             dir[tempareas].userflags=(word)atol(p);
  596.         }
  597.         else dir[tempareas].userflags=0;
  598.         p=strtok(0,",\n");
  599.         if(p) {
  600.             dir[tempareas].leechpercent=(char)atoi(p);
  601.         }
  602.         else dir[tempareas].leechpercent=0;
  603.         tempareas++;
  604.     }
  605.     numdirs=tempareas;
  606.     fclose(fp);
  607. }
  608.  
  609.  
  610.  
  611.  
  612. word pascal find_msgarea (word areano) {
  613.  
  614.     word register x;
  615.  
  616.     if (!areano || !maxareas) return 0;
  617.     for (x=0;x<maxareas;x++) {
  618.         if (marea[x].number==areano) {
  619.             currarea=&marea[x];
  620.             return x+1;
  621.         }
  622.     }
  623.     return 0;
  624. }
  625.  
  626.  
  627.  
  628. word pascal find_filearea (char *name) {
  629.  
  630.     word register x;
  631.  
  632.     if (!*name || !name || !numdirs) return 0;
  633.     for (x=0;x<numdirs;x++) {
  634.         if (!strcmp(dir[x].name,name)) {
  635.             curdir=&dir[x];
  636.             return x+1;
  637.         }
  638.     }
  639.     return 0;
  640. }
  641.  
  642.  
  643.  
  644. word pascal list_msgareas (char *msgareasname) {
  645.  
  646.     word areano;
  647.     char s[181];
  648.     word lineareas[25];
  649.     char dirstring[133];
  650.     word counter;
  651.     register word x;
  652.     word temp;
  653.     int  temporary;
  654.     int  selection;
  655.     struct ffblk f;
  656.  
  657.         set_help("msgarealis",18,0);
  658.         if(wnd4)delete_window(wnd4);
  659.         wnd4=establish_window(0,0,25,80);
  660.         if(!wnd4) {
  661.             printf("\nUnable to establish window...\n");
  662.             return 0;
  663.         }
  664.         set_border(wnd4,1);
  665.         sprintf(s," Listing areas in file %s ",msgareasname);
  666.         s[76]=0;
  667.         set_title(wnd4,s);
  668.         display_window(wnd4);
  669.         wcursor(wnd4,0,0);
  670.         x=0;
  671. OverAgain:
  672.         counter=0;
  673.         for(temporary=0;temporary<25;temporary++)lineareas[temporary]=0;
  674.         if(x>=maxareas)x=0;
  675.         while(1) {
  676.                 areano=marea[x].number;
  677.                 temporary=find_msgarea(areano);
  678.                 sprintf(dirstring,"%sXDATA.%03x",path,areano);
  679.                 if (findfirst(dirstring,&f,0)) temp=0;
  680.                 else temp=(word)(f.ff_fsize/(long)sizeof(struct _xmsg));
  681.                 lineareas[counter]=areano;
  682.                 wprintf(wnd4,"Area#%-4u %-12.12s %-5u message(s) ",areano,currarea->name,temp);
  683.                 wprintf(wnd4,"%s %05u %-12.12s\n",msgarea_attr(),currarea->max,currarea->forceto);
  684.                 x++;
  685.                 counter++;
  686.                 if (counter>=22 || x>=maxareas) {
  687.                     wcursor(wnd4,0,22);
  688.                     wprintf(wnd4,"  -=Jump direct to an area #");
  689.                     break;
  690.                 }
  691.         }
  692. Again:
  693.                 selection=get_selection(wnd4,1,NULL);
  694.                 if(selection>0 && selection<23) {
  695.                     if(lineareas[selection-1])areano=lineareas[selection-1];
  696.                     else {
  697.                         fputs("\x7",stdout);
  698.                         goto Again;
  699.                     }
  700.                     find_msgarea(areano);
  701.                     return areano;
  702.                 }
  703.                 switch (selection) {
  704.                     case 23:    areano=select_area(currarea->number);
  705.                                 if(areano) {
  706.                                     find_msgarea(areano);
  707.                                     return areano;
  708.                                 }
  709.                                 break;
  710.                     case HOME:  x=0;
  711.                                 break;
  712.                     case END:   if(maxareas>21) x=maxareas-22;
  713.                                 else x=0;
  714.                                 break;
  715.                     case PGUP:
  716.                     case BS:    if(x<23 && maxareas>21) {
  717.                                     x=maxareas-22;
  718.                                     if(x>maxareas)x=0;
  719.                                     break;
  720.                                 }
  721.                                 if (x<21) break;
  722.                                 else if (x<43) x=0;
  723.                                 else x-=44;
  724.                                 break;
  725.                     case PGDN:
  726.                     case FWD:   if (x>=maxareas) x=0;
  727.                                 else if ((maxareas-x)<22) {
  728.                                     if (maxareas>21) x=maxareas-22;
  729.                                     else x=0;
  730.                                 }
  731.                                 break;
  732.                     case 0:     goto BreakOut;
  733.                     default:    fputs("\x7",stdout);
  734.                                 break;
  735.                 }
  736.                 counter=0;
  737.                 clear_window(wnd4);
  738.                 wcursor(wnd4,0,0);
  739.                 goto OverAgain;
  740. BreakOut:
  741.                 return 0;
  742. }
  743.  
  744.  
  745.  
  746. word pascal check_area (word tempno) {
  747.  
  748.  struct ffblk f;
  749.  
  750.      sprintf(filename,"%sXDATA.%03x",path,tempno);
  751.      sprintf(textname,"%sXTEXT.%03x",path,tempno);
  752.  
  753.      if (findfirst(filename,&f,0)) {
  754.       return 0;
  755.      }
  756.  
  757.      tempno=(word)(f.ff_fsize/(long)sizeof(struct _xmsg));
  758.      if (f.ff_fsize<(long)sizeof(struct _xmsg) || findfirst(textname,&f,0)){
  759.         return 0;
  760.      }
  761.      return tempno;
  762. }
  763.  
  764.  
  765.  
  766. char * pascal rstrip (char *a)
  767.  
  768. {
  769.   while ((strlen(a)) && (a[strlen(a)-1]==' ')) a[strlen(a)-1]=0;
  770.   return a;
  771. }
  772.  
  773.  
  774.  
  775. char * pascal lstrip (char *a)
  776.  
  777. {
  778.   while ((strlen(a)) && (*a==' ')) memmove (a,(a+1),strlen(a));
  779.   return (a);
  780. }
  781.  
  782.  
  783.  
  784. char * pascal stripcr (char *a)
  785.  
  786. {
  787.  
  788.   while (a[strlen(a)-1]=='\n' || a[strlen(a)-1]=='\r') a[strlen(a)-1]=0;
  789.   return a;
  790.  
  791. }
  792.  
  793.  
  794.  
  795. word pascal select_area (word areano) {
  796.  
  797.     WINDOW *wnd6;
  798.     FIELD *fld3;
  799.     char s[9];
  800.     int  returncode;
  801.  
  802. Again:
  803.     wnd6=establish_window(3,18,7,42);
  804.     set_border(wnd6,3);
  805.     set_title(wnd6," Area Selection ");
  806.     set_colors(wnd6,BORDER,7,0,0);
  807.     display_window(wnd6);
  808.     wcursor(wnd6,0,0);
  809.     wprintf(wnd6," F10 to change or ESC to abort\n");
  810.     wprintf(wnd6,"\n  Current: %s",msgarea_attr());
  811.     sprintf(s,"%u",areano);
  812.     init_template(wnd6);
  813.     wprompt(wnd6,1,4,"Area #:");
  814.     fld3=establish_field(wnd6,15,4,msk5,s,'N');
  815.     field_window(fld3,"areas     ",40,6);
  816.     prep_template(wnd6);
  817. AskOver:
  818.     returncode=data_entry(wnd6);
  819.     if (returncode==ESC) {
  820.         delete_window(wnd6);
  821.         return areano;
  822.     }
  823.     if (returncode!=F10) goto AskOver;
  824.     delete_window(wnd6);
  825.     if ((word)atol(s)<1) {
  826.         find_msgarea(areano);
  827.         return areano;
  828.     }
  829.     if ((word)atol(s)>4095) goto Again;
  830.  
  831.     if(find_msgarea((word)atol(s))) areano=(word)atol(s);
  832.     return areano;
  833. }
  834.  
  835.  
  836.  
  837. char * pascal msgarea_attr (void) {
  838.  
  839.     word register x;
  840.     word temp;
  841.     static char attrstring[22];
  842.  
  843.     strcpy(attrstring,"[");
  844.     for (x=0;x<16;x++) {
  845.        temp=1;
  846.        temp=temp<<x;
  847.        (currarea->attr & temp) ? strcat(attrstring,"X") : strcat (attrstring,"-");
  848.     }
  849.     strcat(attrstring,"]");
  850.     return attrstring;
  851. }
  852.  
  853.  
  854.  
  855.  
  856.  
  857. char * pascal filearea_attr (char flags) {
  858.  
  859.     register char x;
  860.     char temp;
  861.     static char attrstring[22];
  862.  
  863.     strcpy(attrstring,"[");
  864.     for (x=0;x<8;x++) {
  865.        temp=1;
  866.        temp=temp<<x;
  867.        (flags & temp) ? strcat(attrstring,"X") : strcat (attrstring,"-");
  868.     }
  869.     strcat(attrstring,"]");
  870.     return attrstring;
  871. }
  872.  
  873.  
  874.  
  875. void pascal print_clock (void) {}
  876.