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

  1.  
  2. #include "msgg.h"
  3. #include "twindow.h"
  4. #include "keys.h"
  5.  
  6. extern char msk78[];
  7. #define msk35 msk78+43
  8. #define mskst msk35+33
  9. #define mskzip msk35+30
  10. #define mskcit msk35+11
  11. #define msk1 msk78+77
  12. #define msk3 msk35+32
  13. #define msk4 msk35+31
  14. #define msk5 msk35+30
  15. #define msk6 msk35+29
  16. #define msk47 msk78+31
  17. #define msk46 msk78+32
  18. #define msk51 msk78+28
  19. #define msk40 msk46+6
  20. #define msk39 msk46+7
  21. #define msk12 msk78+66
  22. #define msk65 msk78+13
  23. #define msk19 msk78+59
  24. #define msk26 msk78+52
  25. #define msk24 msk78+54
  26. #define msk58 msk78+20
  27. #define msk10 msk78+68
  28.  
  29. #define MAXNUMDIRS         1024
  30. #define MAXNUMAREA         1024
  31. #define MAXPROTOCOLS    130
  32. #define MAXARCHIVERS    256
  33. #define MAXDOORS        4096
  34.  
  35. extern char fileattrprompts[8][13];
  36. extern char attrprompts[16][13];
  37.  
  38. extern WINDOW *wnd4;
  39.  
  40. struct _mmboard {
  41.   char       name[48];
  42.   char       forceto[36];
  43.   word       attr;
  44.   word       max;
  45.   word       number;
  46.   word       substat1;
  47.   word       substat2;
  48.   char       descr[79];
  49.   signed char age;
  50.   word         flags;
  51.   word          zone;
  52.   word         net;
  53.   word          node;
  54.   word          point;
  55.   char       yourname[36];
  56.   word       minwrite;
  57. };
  58.  
  59. struct _ffboard {
  60.   char       name[47];
  61.   char       flags;
  62.   word         security;
  63.   char       dpath[79];
  64.   char       upath[79];
  65.   char       descr[79];
  66.   signed char age;
  67.   word          userflags;
  68.   char       leechpercent;
  69. };
  70.  
  71. extern word numprotos;
  72. extern char path[99];
  73. extern char msgareasfile[133];
  74. extern char fileareasfile[133];
  75. extern char msgareasfilebackup[133];
  76. extern char fileareasfilebackup[133];
  77.  
  78. extern struct _mmboard huge *marea;
  79. extern struct _mmboard huge *currarea;
  80. extern word higharea;
  81. extern word maxareas;
  82. extern char msgareasfile[133];
  83. extern struct _ffboard huge *curdir;
  84. extern struct _ffboard huge *dir;
  85. extern word numdirs;
  86. extern char fileareasfile[133];
  87.  
  88. extern word numdoors;
  89.  
  90. struct   _protocol {
  91.     char   name[25];
  92.     char   key;
  93.     int    adj;
  94.     char   spawndn[119];
  95.     char   spawnup[119];
  96.     char   abort[48];
  97.     unsigned wild:         1;
  98.     unsigned multi:        1;
  99.     unsigned simul:        1;
  100.     unsigned list:        1;
  101.     unsigned opus:        1;
  102.     unsigned noname:    1;
  103.     unsigned dszlog:    1;
  104.     unsigned reserved:    1;
  105.     char   pad1;
  106.     char   pad2;
  107. };
  108.  
  109. extern struct _protocol huge *proto;
  110.  
  111. struct   _door {
  112.     char name[25];
  113.     char type[4];
  114.     char spawn[79];
  115.     char descr[79];
  116. };
  117. extern struct _door huge *door;
  118.  
  119. extern word numdoors;
  120.  
  121. struct _archiver {
  122.     char ext[5];
  123.     char move[41];
  124.     char extract[41];
  125.     char list[41];
  126.     char error[41];
  127.     char aname[13];
  128.     char ename[13];
  129.     char id[25];
  130.     char pick[2];
  131.     int  skip;
  132.     int  errline;
  133. };
  134. extern struct _archiver huge *archiver;
  135. extern word numarchivers;
  136.  
  137. extern char filename[133];
  138. extern char textname[133];
  139.  
  140. extern void   pascal swap_msgareas(word,word);
  141. extern int      pascal sort_msgareas(void);
  142. extern void   pascal swap_fileareas(word,word);
  143. extern int      pascal sort_fileareas(void);
  144. extern word   pascal select_area(word);
  145. extern char * pascal msgarea_attr(void);
  146. extern char * pascal filearea_attr (char flags);
  147. extern char * pascal rstrip(char *);
  148. extern char * pascal lstrip(char *);
  149. extern char * pascal stripcr(char *);
  150. extern void   pascal load_fileareas(char *);
  151. extern void   pascal load_msgareas(char *);
  152. extern word   pascal find_msgarea(word);
  153. extern word   pascal find_filearea(char *);
  154. extern word   pascal list_msgareas(char *);
  155. extern word   pascal list_fileareas(char *);
  156. extern word   pascal check_area(word);
  157. extern word   pascal edit_msgarea(word);
  158. extern word   pascal edit_filearea(word);
  159. extern int      pascal setup_msg(void);
  160. extern int      pascal setup_file(void);
  161. extern int           addbackslash (char *,int);
  162. extern int           nomorethan4095 (char *,int);
  163.  
  164.        void   pascal make_msgmenu(void);
  165.        void   pascal make_filemenu(void);
  166.        void   pascal load_archivers(char *);
  167.        word   pascal list_archivers(char *);
  168.        word   pascal edit_archiver(word);
  169.  
  170. void   pascal swap_protocols(word,word);
  171. int       pascal sort_protocols(void);
  172.  
  173.  
  174.  
  175.  
  176. word pascal edit_protocol (word areano) {
  177.  
  178.     WINDOW *wnd6;
  179.     FIELD *fld3;
  180.     char s[133];
  181.     char redid=0;
  182.     char name[27];
  183.     char key[3];
  184.     char adj[7];
  185.     char spawndn[80];
  186.     char spawnup[80];
  187.     char sd1[80];
  188.     char su1[80];
  189.     char abort[50];
  190.     char wild[3];
  191.     char multi[3];
  192.     char simul[3];
  193.     char list[3];
  194.     char opus[3];
  195.     char noname[3];
  196.     char dszlog[3];
  197.     char reserved[3];
  198.     register word x;
  199.     int returncode;
  200.  
  201.     wnd6=establish_window(1,7,20,80);
  202.     set_border(wnd6,3);
  203.     set_title(wnd6," Edit Protocol Entry ");
  204.     set_colors(wnd6,BORDER,7,0,0);
  205.     display_window(wnd6);
  206.     wcursor(wnd6,0,0);
  207.     wprintf(wnd6," F10=chng/exit  F9=chng  F8=Del  F7=Add  F6=Sort  PGUP  PGDN  ESC=exit\n");
  208. Again:
  209.     wprompt(wnd6,2,2,"Name:");
  210.     wprompt(wnd6,2,3,"Key:");
  211.     wprompt(wnd6,2,4,"Adjustment:");
  212.     wprompt(wnd6,2,5,"Download spawn string:");
  213.     wprompt(wnd6,2,8,"Upload spawn string:");
  214.     wprompt(wnd6,2,11,"Abort string:");
  215.     wprompt(wnd6,2,13,"Wildcards:");
  216.     wprompt(wnd6,40,13,"Multiple filenames:");
  217.     wprompt(wnd6,2,14,"Simultaneous U/D:");
  218.     wprompt(wnd6,40,14,"Uses @List file:");
  219.     wprompt(wnd6,2,15,"Opus-style:");
  220.     wprompt(wnd6,40,15,"Names sent by remote:");
  221.     wprompt(wnd6,2,16,"Uses DSZLOG:");
  222.     wprompt(wnd6,40,16,"Reserved:");
  223. ReDo:
  224.     if(!numprotos) goto StartingOut;
  225.     init_template(wnd6);
  226.     proto[areano].pad1=0;
  227.     proto[areano].pad2=0;
  228.     strcpy(name,proto[areano].name);
  229.     sprintf(key,"%c",proto[areano].key);
  230.     sprintf(adj,"%01d",proto[areano].adj);
  231.     strncpy(spawndn,proto[areano].spawndn,79);
  232.     spawndn[78]=0;
  233.     strncpy(spawnup,proto[areano].spawnup,79);
  234.     spawnup[78]=0;
  235.     if(strlen(proto[areano].spawndn)>78) {
  236.         strcpy(sd1,&proto[areano].spawndn[78]);
  237.     }
  238.     else *sd1=0;
  239.     if(strlen(proto[areano].spawnup)>78) {
  240.         strcpy(su1,&proto[areano].spawnup[78]);
  241.     }
  242.     else *su1=0;
  243.     strcpy(abort,proto[areano].abort);
  244.     if(proto[areano].wild) strcpy(wild,"X");
  245.     else strcpy(wild,"-");
  246.     if(proto[areano].multi) strcpy(multi,"X");
  247.     else strcpy(multi,"-");
  248.     if(proto[areano].simul) strcpy(simul,"X");
  249.     else strcpy(simul,"-");
  250.     if(proto[areano].list) strcpy(list,"X");
  251.     else strcpy(list,"-");
  252.     if(proto[areano].opus) strcpy(opus,"X");
  253.     else strcpy(opus,"-");
  254.     if(proto[areano].noname) strcpy(noname,"X");
  255.     else strcpy(noname,"-");
  256.     if(proto[areano].dszlog) strcpy(dszlog,"X");
  257.     else strcpy(dszlog,"-");
  258.     if(proto[areano].reserved) strcpy(reserved,"X");
  259.     else strcpy(reserved,"-");
  260.  
  261.     fld3=establish_field(wnd6,15,2,msk24,name,'a');
  262.     field_window(fld3,"protoname ",40,2);
  263.     fld3=establish_field(wnd6,15,3,msk1,key,'A');
  264.     field_window(fld3,"protokey  ",40,2);
  265.     fld3=establish_field(wnd6,15,4,msk5,adj,'N');
  266.     field_window(fld3,"protoadj  ",40,2);
  267.     fld3=establish_field(wnd6,0,6,msk78,spawndn,'a');
  268.     field_window(fld3,"protodn   ",40,2);
  269.     fld3=establish_field(wnd6,0,7,msk39,sd1,'a');
  270.     field_window(fld3,"protodn2  ",40,2);
  271.     fld3=establish_field(wnd6,0,9,msk78,spawnup,'a');
  272.     field_window(fld3,"protoup   ",40,3);
  273.     fld3=establish_field(wnd6,0,10,msk39,su1,'a');
  274.     field_window(fld3,"protoup2  ",40,4);
  275.     fld3=establish_field(wnd6,0,12,msk47,abort,'a');
  276.     field_window(fld3,"protoabort",40,5);
  277.     fld3=establish_field(wnd6,24,13,msk1,wild,'O');
  278.     field_window(fld3,"protowild ",40,6);
  279.     fld3=establish_field(wnd6,64,13,msk1,multi,'O');
  280.     field_window(fld3,"protomulti",40,6);
  281.     fld3=establish_field(wnd6,24,14,msk1,simul,'O');
  282.     field_window(fld3,"protosimul",40,6);
  283.     fld3=establish_field(wnd6,64,14,msk1,list,'O');
  284.     field_window(fld3,"protolist ",40,6);
  285.     fld3=establish_field(wnd6,24,15,msk1,opus,'O');
  286.     field_window(fld3,"protoopus ",40,6);
  287.     fld3=establish_field(wnd6,64,15,msk1,noname,'O');
  288.     field_window(fld3,"protononam",40,6);
  289.     fld3=establish_field(wnd6,24,16,msk1,dszlog,'O');
  290.     field_window(fld3,"protodsz  ",40,6);
  291.     fld3=establish_field(wnd6,64,16,msk1,reserved,'O');
  292.     field_window(fld3,"protoreser",40,6);
  293.     prep_template(wnd6);
  294. AskOver:
  295.     returncode=data_entry(wnd6);
  296.     if (returncode==PGUP) {
  297.         if(!areano) areano=numprotos-1;
  298.         else areano--;
  299.         goto ReDo;
  300.     }
  301.     if (returncode==PGDN) {
  302.         if(areano>=(numprotos-1)) areano=0;
  303.         else areano++;
  304.         goto ReDo;
  305.     }
  306.     if (returncode==F6) {
  307.         sort_protocols();
  308.         goto ReDo;
  309.     }
  310.     if (returncode==F8) {
  311.         if (areano<numprotos) {
  312.             for(x=areano+1;x<numprotos;x++) {
  313.                 memcpy((void *)&proto[x-1],(void *)&proto[x],(word)sizeof(struct _protocol));
  314.             }
  315.         }
  316.         redid=1;
  317.         numprotos--;
  318.         if(!numprotos) {
  319.             delete_window(wnd6);
  320.             return (word)redid;
  321.         }
  322.         if(areano>(numprotos-1)) areano=numprotos-1;
  323.         goto ReDo;
  324.     }
  325.     if (returncode==F7) {
  326.         if(numprotos==MAXPROTOCOLS) {
  327.             error_message(" Sorry, I'm already maxed out... ");
  328.             pause_msg();
  329.             goto ReDo;
  330.         }
  331. StartingOut:
  332.         redid=1;
  333.         numprotos++;
  334.         memset((void *)&proto[numprotos-1],0,(unsigned)sizeof(struct _protocol));
  335.         strcpy(proto[numprotos-1].name,"New Protocol");
  336.         areano=numprotos-1;
  337.         goto ReDo;
  338.     }
  339.     if (returncode==ESC) goto Quit;
  340.     if (returncode!=F10 && returncode!=F9) goto AskOver;
  341.     rstrip(name);
  342.     lstrip(name);
  343.     lstrip(spawndn);
  344.     lstrip(spawnup);
  345.     rstrip(abort);
  346.     rstrip(sd1);
  347.     if(!*sd1)rstrip(spawndn);
  348.     rstrip(su1);
  349.     if(!*su1)rstrip(spawnup);
  350.     if (!*name || (!*spawndn && !*spawnup)) {
  351.         error_message(" Blank name and/or spawn field(s) ");
  352.         pause_msg();
  353.         if(returncode==F9) goto ReDo;
  354.     }
  355.     strcpy(proto[areano].name,name);
  356.     strcpy(proto[areano].spawndn,spawndn);
  357.     if(*sd1) strcat(proto[areano].spawndn,sd1);
  358.     strcpy(proto[areano].spawnup,spawnup);
  359.     if(*su1)strcat(proto[areano].spawnup,su1);
  360.     strcpy(proto[areano].abort,abort);
  361.     proto[areano].adj=atoi(adj);
  362.     proto[areano].key=*key;
  363.     if(*wild=='X') proto[areano].wild=1;
  364.     else proto[areano].wild=0;
  365.     if(*multi=='X') proto[areano].multi=1;
  366.     else proto[areano].multi=0;
  367.     if(*simul=='X') proto[areano].simul=1;
  368.     else proto[areano].simul=0;
  369.     if(*list=='X') proto[areano].list=1;
  370.     else proto[areano].list=0;
  371.     if(*opus=='X') proto[areano].opus=1;
  372.     else proto[areano].opus=0;
  373.     if(*dszlog=='X') proto[areano].dszlog=1;
  374.     else proto[areano].dszlog=0;
  375.     if(*noname=='X') proto[areano].noname=1;
  376.     else proto[areano].noname=0;
  377.     if(*reserved=='X') proto[areano].reserved=1;
  378.     else proto[areano].reserved=0;
  379.     redid=1;
  380.     if(returncode==F9) goto ReDo;
  381.     delete_window(wnd6);
  382.     return 1;
  383. Quit:
  384.     delete_window(wnd6);
  385.     if (redid) {
  386.         return 1;
  387.     }
  388.     return 0;
  389. }
  390.  
  391.  
  392.  
  393. int pascal sort_protocols (void) {    /* Simple bubble-sort */
  394.  
  395.     register word x;
  396.     char swapped=1;
  397.  
  398.     if(numprotos==1) return 0;
  399.     any_message(" Sorting ");
  400.     while(swapped) {
  401.         swapped=0;
  402.         for(x=1;x<numprotos;x++) {
  403.             if(strcmp(proto[x].name,proto[x-1].name)<0) {
  404.                 swap_protocols(x-1,x);
  405.                 swapped=1;
  406.             }
  407.         }
  408.     }
  409.     clear_message();
  410.     return 0;
  411. }
  412.  
  413.  
  414.  
  415. void pascal swap_protocols (word x, word y) {
  416.  
  417.     static struct _protocol temp;
  418.  
  419.     memcpy((void *)&temp,(void *)&proto[x],(word)sizeof(struct _protocol));
  420.     memcpy((void *)&proto[x],(void *)&proto[y],(word)sizeof(struct _protocol));
  421.     memcpy((void *)&proto[y],(void *)&temp,(word)sizeof(struct _protocol));
  422. }
  423.  
  424.  
  425.  
  426. void pascal load_protocols (char *file) {
  427.  
  428.     FILE *fp;
  429.     struct ffblk f;
  430.     char string[80];
  431.     word register x;
  432.  
  433.     if(findfirst(file,&f,0)) {
  434.         numprotos=0;
  435.         return;
  436.     }
  437.     numprotos=(word)(f.ff_fsize/(long)sizeof(struct _protocol));
  438.     if(!(fp=fopen(file,"rb"))) {
  439.         sprintf(string," Can't open %s ",file);
  440.         error_message(string);
  441.         pause_msg();
  442.         return;
  443.     }
  444.     fread((void *)proto,sizeof(struct _protocol),numprotos,fp);
  445.     fclose(fp);
  446.     for(x=0;x<numprotos;x++) {
  447.         proto[x].name[24]=0;
  448.         proto[x].spawndn[118]=0;
  449.         proto[x].spawnup[118]=0;
  450.         proto[x].abort[47]=0;
  451.     }
  452. }
  453.