home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MSGDP206.SZH / SETTINGS.C < prev    next >
Text File  |  1991-01-23  |  46KB  |  1,507 lines

  1. /*
  2.  
  3. Title:  MsgEd
  4.  
  5. File:   settings.c
  6.  
  7. Author: Jim Nutt
  8.  
  9. Copr:   released into the PUBLIC DOMAIN 30 jul 1990 by jim nutt
  10.  
  11. Description:
  12.  
  13.     handles configuration setup from within msged
  14.  
  15. Support Files:
  16.  
  17.     msged.h
  18.     menu.h
  19.  
  20. */
  21.  
  22. #define NOSPELL
  23. #include "msged.h"
  24. #include "menu.h"
  25.  
  26. void    _pascal e_assignkey(unsigned int key, char *label);
  27. char *  _pascal e_getlabels(int i);
  28. char *  _pascal e_getbind(unsigned int key);
  29. void    _pascal r_assignkey(unsigned int key, char *label);
  30. char *  _pascal r_getbind(unsigned int key);
  31. char *  _pascal r_getlabels(int i);
  32.  
  33. static void _pascal set_colors(void);
  34. static void _pascal set_switch(void);
  35. static void _pascal set_margins(void);
  36. static void _pascal set_files(void);
  37. static void _pascal set_areas(void);
  38. static void _pascal set_gates(void);
  39. static void _pascal set_quotes(void);
  40. static void _pascal set_macro(void);
  41. static void _pascal set_address(void);
  42. static void _pascal set_video(void);
  43. static void _pascal set_misc(void);
  44. static void _pascal save_set(void);
  45. static void _pascal set_attrib(int x1, int y1, int x2, int y2, AREA *a);
  46. static void _pascal edit_area(AREA *a);
  47. static void _pascal set_key(int i);
  48. static unsigned int * _pascal build_macro(void);
  49.  
  50. void _pascal settings()
  51.  
  52. {
  53.     static char *s_items[] = {
  54.         "Switches ",
  55.         "Margins  ",
  56.         "Files    ",
  57.         "Attribute",
  58.         "Areas    ",
  59.         "Gates    ",
  60.         "Quoting  ",
  61.         "Macros   ",
  62.         "Addresses",
  63.         "Video    ",
  64.         "Misc     ",
  65.         "Save     ",
  66.         NULL
  67.     };
  68.  
  69.     int i = 0;
  70.  
  71.     cls();
  72.  
  73.     set_color(co_info);
  74.     gotoxy(2,2); bputs("msged version " VERSION " setup.");
  75.  
  76.     for (;;) switch (i = menu(5,5,15,16,s_items,co_hilite,co_normal,i)) {
  77.         case -1:set_color(co_normal);
  78.             return;
  79.         case  0:
  80.             set_switch();
  81.             break;
  82.         case  1:
  83.             set_margins();
  84.             break;
  85.         case  2:
  86.             set_files();
  87.             break;
  88.         case  3:
  89.             gotoxy(20,7);
  90.             bprintf("Default message attributes for %s",arealist[area].description);
  91.             set_attrib(20,9,35,14,&arealist[area]);
  92.             break;
  93.         case  4:
  94.             set_areas();
  95.             break;
  96.         case  5:
  97.             set_gates();
  98.             break;
  99.         case  6:
  100.             set_quotes();
  101.             break;
  102.         case  7:
  103.             set_macro();
  104.             break;
  105.         case  8:
  106.             set_address();
  107.             break;
  108.         case  9:
  109.             set_video();
  110.             break;
  111.         case 10:
  112.             set_misc();
  113.             break;
  114.         case 11:
  115.             save_set();
  116.             break;
  117.         default:
  118.             break;
  119.     }
  120. }
  121.  
  122. static void _pascal set_switch()
  123.  
  124. {
  125.     static char *switches[] = {
  126.         "Soft Returns off",
  127.         "Seen-Bys off",
  128.         "Tearlines off",
  129.         "Kludge line display off",
  130.         "Confirm Deletes off",
  131.         "MSGIDs off",
  132.         "Strip Kludges off",
  133.         "Opus Dates off",
  134.         "Swapping off",
  135. #ifndef NOSPELL
  136.         "Spell Check off",
  137. #endif
  138.         NULL
  139.     };
  140.  
  141.     int i = 0;
  142.  
  143.     for (;;) {
  144.  
  145.         strcpy(switches[0]+13,softcr?"on ":"off");
  146.         strcpy(switches[1]+9,seenbys?"on ":"off");
  147.         strcpy(switches[2]+10,tearline?"on ":"off");
  148.         strcpy(switches[3]+20,shownotes?"on ":"off");
  149.         strcpy(switches[4]+16,confirmations?"on ":"off");
  150.         strcpy(switches[5]+7,msgids?"on ":"off");
  151.         strcpy(switches[6]+14,stripnotes?"on ":"off");
  152.         strcpy(switches[7]+11,opusdate?"on ":"off");
  153.         strcpy(switches[8]+9,swapping?"on ":"off");
  154. #ifndef NOSPELL
  155.         strcpy(switches[8]+12,spell?"on ":"off");
  156. #endif
  157.  
  158.         switch (i = menu(20,6,45,17,switches,co_hilite,co_normal,i)) {
  159.             case -1:set_color(co_normal);
  160.                 clrwnd(20,6,45,17);
  161.                 return;
  162.             case 0: softcr = !softcr;
  163.                 break;
  164.             case 1: seenbys = !seenbys;
  165.                 break;
  166.             case 2: tearline = !tearline;
  167.                 break;
  168.             case 3: shownotes = !shownotes;
  169.                 break;
  170.             case 4: confirmations = !confirmations;
  171.                 break;
  172.             case 5: msgids = !msgids;
  173.                 break;
  174.             case 6: stripnotes = !stripnotes;
  175.                 break;
  176.             case 7: opusdate = !opusdate;
  177.                 break;
  178.             case 8: swapping = !swapping;
  179.                 break;
  180. #ifndef NOSPELL
  181.             case 8: spell = !spell;
  182.                 break;
  183. #endif
  184.             default: break;
  185.         }
  186.     }
  187.  
  188. }
  189.  
  190. static void _pascal set_margins()
  191.  
  192. {
  193.     static char *items[] = {
  194.         "Right margin is xxx",
  195.         "Quote margin is xxx",
  196.         "Tab size is xx",
  197.         NULL
  198.     };
  199.  
  200.     int i = 0;
  201.  
  202.     for (;;) {
  203.         sprintf(items[0]+16,"%-3d",rm);
  204.         sprintf(items[1]+16,"%-3d",qm);
  205.         sprintf(items[2]+12,"%-2d",tabsize);
  206.  
  207.         switch(i = menu(20,7,40,10,items,co_hilite,co_normal,i)) {
  208.             case -1:
  209.                 set_color(co_normal);
  210.                 clrwnd(20,7,40,10);
  211.                 return;
  212.             case  0:
  213.                 set_color(co_hilite);
  214.                 gotoxy(36,wherey());
  215.                 rm = getnum(5,maxx,rm);
  216.                 break;
  217.             case  1:
  218.                 set_color(co_hilite);
  219.                 gotoxy(36,wherey());
  220.                 qm = getnum(5,rm,qm);
  221.                 break;
  222.             case  2:
  223.                 set_color(co_hilite);
  224.                 gotoxy(32,wherey());
  225.                 tabsize = getnum(1,rm,tabsize);
  226.                 break;
  227.         }
  228.     }
  229. }
  230.  
  231. static void _pascal set_files()
  232.  
  233. {
  234.     char *item[9];
  235.     int i,f=0, j = 0;
  236.  
  237.  
  238.     while (f != ABORT) {
  239.         memset(item,0,sizeof item);
  240.         for (i = 0; i < 8; i++)
  241.             item[i] = calloc(1,128);
  242.         item[8] = NULL;
  243.  
  244.         sprintf(item[0],"Outfile is %s",outfile);
  245.         sprintf(item[1],"Lastread file is %s",lastread);
  246.         sprintf(item[2],"Echomail toss log is %s",confmail);
  247.         sprintf(item[3],"Quickbbs directory is %s",quickbbs);
  248.         sprintf(item[4],"Primary userlist is %s",fidolist);
  249.         sprintf(item[5],"Secondary userlist is %s",userlist);
  250.         sprintf(item[6],
  251. #ifndef NOSPELL
  252.             "Spell Checker is %s",speller);
  253.         sprintf(item[7],
  254. #endif
  255.             "Config file is %s",cfgfile);
  256. #ifdef NOSPELL
  257.         free(item[7]); item[7] = NULL;
  258. #endif
  259.  
  260.         switch(j = menu(20,8,maxx,15,item,co_hilite,co_normal,j)) {
  261.             case -1:
  262.                 f = ABORT;
  263.                 break;
  264.             case  0:
  265.                 if (outfile) free(outfile);
  266.                 gotoxy(31,wherey()); set_color(co_hilite);
  267.                 f = bgets(item[0]+11,64,maxx-31);
  268.                 outfile = strdup(item[0]+11);
  269.                 break;
  270.             case 1:
  271.                 if (lastread) free(lastread);
  272.                 gotoxy(37,wherey()); set_color(co_hilite);
  273.                 f = bgets(item[1]+17,64,maxx-37);
  274.                 lastread = strdup(item[1]+17);
  275.                 break;
  276.             case 2:
  277.                 if (confmail) free(confmail);
  278.                 gotoxy(41,wherey()); set_color(co_hilite);
  279.                 f = bgets(item[2]+21,64,maxx-41);
  280.                 confmail = strdup(item[2]+21);
  281.                 break;
  282.             case 3:
  283.                 if (quickbbs) free(quickbbs);
  284.                 gotoxy(42,wherey()); set_color(co_hilite);
  285.                 f = bgets(item[3]+22,64,maxx-42);
  286.                 quickbbs = strdup(item[3]+22);
  287.                 break;
  288.             case 4:
  289.                 if (fidolist) free(fidolist);
  290.                 gotoxy(40,wherey()); set_color(co_hilite);
  291.                 f = bgets(item[4]+20,64,maxx-40);
  292.                 fidolist = strdup(item[4]+20);
  293.                 break;
  294.             case 5:
  295.                 if (userlist) free(userlist);
  296.                 gotoxy(42,wherey()); set_color(co_hilite);
  297.                 f = bgets(item[5]+22,64,maxx-42);
  298.                 userlist = strdup(item[5]+22);
  299.                 break;
  300.             case 6:
  301. #ifndef NOSPELL
  302.                 if (speller) free(speller);
  303.                 gotoxy(37,wherey()); set_color(co_hilite);
  304.                 f = bgets(item[6]+17,64,maxx-37);
  305.                 speller = strdup(item[6]+17);
  306.                 break;
  307.             case 7:
  308. #endif
  309.                 if (cfgfile) free(cfgfile);
  310.                 gotoxy(35,wherey()); set_color(co_hilite);
  311. #ifndef NOSPELL
  312.                 f = bgets(item[7]+15,64,maxx-35);
  313.                 cfgfile = strdup(item[7]+15);
  314. #else
  315.                 f = bgets(item[6]+15,64,maxx-35);
  316.                 cfgfile = strdup(item[6]+15);
  317. #endif
  318.                 break;
  319.         }
  320.     }
  321.  
  322.     for (i = 0;
  323. #ifndef NOSPELL
  324.         i < 8;
  325. #else
  326.         i < 7;
  327. #endif
  328.             i++) {
  329.         free(item[i]);
  330.     }
  331.  
  332.     set_color(co_normal);
  333.     clrwnd(20,8,maxx,15);
  334. }
  335.  
  336. static void _pascal set_attrib(int x1, int y1, int x2, int y2, AREA *a)
  337.  
  338. {
  339.     static char *items[] = {
  340.         "Privileged o",
  341.         "Hold       o",
  342.         "Direct     o",
  343.         "Crash      o",
  344.         "Kill/Sent  o",
  345.         NULL
  346.     };
  347.  
  348.     int i = 0;
  349.  
  350.     for (;;) {
  351.  
  352.         *(items[0]+11) = (char) ((a->priv)?0xfb:0x20);
  353.         *(items[1]+11) = (char) ((a->hold)?0xfb:0x20);
  354.         *(items[2]+11) = (char) ((a->direct)?0xfb:0x20);
  355.         *(items[3]+11) = (char) ((a->crash)?0xfb:0x20);
  356.         *(items[4]+11)  = (char) ((a->killsent)?0xfb:0x20);
  357.  
  358.         switch(i = menu(x1,y1,x2,y2,items,co_hilite,co_normal,i)) {
  359.             case -1:
  360.                 set_color(co_normal);
  361.                 clrwnd(x1,y1,x2,y2);
  362.                 return;
  363.             case  0:
  364.                 arealist[area].priv = !arealist[area].priv;
  365.                 break;
  366.             case  1:
  367.                 arealist[area].hold = !arealist[area].hold;
  368.                 break;
  369.             case  2:
  370.                 arealist[area].direct = !arealist[area].direct;
  371.                 break;
  372.             case  3:
  373.                 arealist[area].crash = !arealist[area].crash;
  374.                 break;
  375.             case  4:
  376.                 arealist[area].killsent = !arealist[area].killsent;
  377.                 break;
  378.         }
  379.     }
  380. }
  381.  
  382. static void _pascal set_areas()
  383.  
  384. {
  385.     AREA __handle *a;
  386.  
  387.     static char *flist[] = {
  388.         "Add an area",
  389.         "Edit an area",
  390.         "Delete an area",
  391.         NULL
  392.     };
  393.  
  394.     char **list = NULL;
  395.     int i1 = 0, i2 = 0, j = 0, i;
  396.  
  397.     for (;;) {
  398.         switch (j = menu(20,5,33,7,flist,co_hilite,co_normal,j)) {
  399.             case -1:
  400.                 set_color(co_normal);
  401.                 clrwnd(20,5,33,7);
  402.                 return;
  403.  
  404.             case  0:
  405.                 set_color(co_normal);
  406.                 clrwnd(20,5,33,7);
  407.                 areas++;
  408.                 a = arealist;
  409.                 arealist = handle_realloc(arealist,sizeof(AREA) * areas);
  410.                 if (arealist == NULL)
  411.                     arealist = a;
  412.                 a = arealist+areas-1;
  413.                 memset(a,0,sizeof(AREA));
  414.                 edit_area(a);
  415.                 break;
  416.  
  417.             case  1:
  418.                 set_color(co_normal);
  419.                 clrwnd(20,5,33,7);
  420.                 list = calloc(areas+1,sizeof(char *));
  421.                 for (i = 0; i < areas; i++)
  422.                     list[i] = arealist[i].description;
  423.                 i1 = i = menu(20,5,maxx,min(maxy,areas+5),list,co_hilite,co_normal,i1);
  424.                 set_color(co_normal); clrwnd(20,5,maxx,min(maxy,areas+5));
  425.                 if (i == -1)
  426.                     break;
  427.                 a = arealist+i;
  428.                 edit_area(a);
  429.                 free(list);
  430.                 break;
  431.             case  2:
  432.                 set_color(co_normal);
  433.                 clrwnd(20,5,33,7);
  434.                 list = calloc(areas+1,sizeof(char *));
  435.                 for (i = 0; i < areas; i++)
  436.                     list[i] = arealist[i].description;
  437.                 i2 = menu(20,5,maxx,min(maxy,areas+5),list,co_hilite,co_normal,i2);
  438.                 set_color(co_normal); clrwnd(20,5,maxx,min(maxy,areas+5));
  439.                 if (i == -1)
  440.                     break;
  441.                 free(list);
  442.                 if (arealist[i].msgtype == FIDO)
  443.                     free(arealist[i].path);
  444.                 free(arealist[i].description);
  445.                 if (arealist[i].echomail)
  446.                     free(arealist[i].tag);
  447.                 while ((i+1) < areas) {
  448.                     arealist[i] = arealist[i+1];
  449.                     i++;
  450.                 }
  451.                 areas--;
  452.                 a = handle_realloc(arealist,sizeof(AREA) * areas);
  453.                 if (a)
  454.                     arealist = a;
  455.                 break;
  456.         }
  457.     }
  458. }
  459.  
  460. static void _pascal set_gates()
  461.  
  462. {
  463.     static char *list[] = {
  464.         "UUCP gateway",
  465.         "Add a domain gate",
  466.         "Delete a domain gate",
  467.         "Change a domain gate",
  468.         "Set gating method",
  469.         NULL
  470.     };
  471.  
  472.     static char *glist[] = {
  473.         "Neither",
  474.         "Domains",
  475.         "Zones",
  476.         "Both",
  477.         NULL
  478.     };
  479.  
  480.     char buffer[128];
  481.     int i, j = 0, k = 0, l = 0, m = 0;
  482.     char **alist;
  483.     ADDRESS *a;
  484.     int f = 0;
  485.  
  486.     while (f != ABORT) {
  487.  
  488.         alist = calloc(domains+1,sizeof (char *));
  489.         for (i = 0; i < domains; i++)
  490.             alist[i] = strdup(show_address(domain_list[i]));
  491.         alist[i] = NULL;
  492.  
  493.         switch(j = menu(20,11,40,15,list,co_hilite,co_normal,j)) {
  494.             case -1:
  495.                 f = ABORT;
  496.                     break;
  497.             case 0:
  498.                 if (uucp_gate.notfound)
  499.                     memset(buffer,0,sizeof buffer);
  500.                 else
  501.                     strcpy(buffer,show_address(uucp_gate));
  502.  
  503.                 gotoxy(20,17);
  504.                 f = bgets(buffer,sizeof buffer - 1, maxx - 20);
  505.                 set_color(co_normal); clrwnd(20,17,maxx,17);
  506.                 if (uucp_gate.domain)
  507.                     free(uucp_gate.domain);
  508.                 uucp_gate = parsenode(buffer);
  509.                 break;
  510.             case 1:
  511.                 domains++;
  512.                 a = realloc(domain_list,sizeof(ADDRESS) * domains);
  513.                 if (a != NULL)
  514.                     domain_list = a;
  515.                 else
  516.                     break;
  517.                 gotoxy(20,19);
  518.                 bputs("Gate to be added:");
  519.                 gotoxy(20,20); memset(buffer,0,sizeof buffer);
  520.                 f = bgets(buffer,sizeof(buffer)-1,maxx-20);
  521.                 domain_list[domains-1] = parsenode(buffer);
  522.                 set_color(co_normal); clrwnd(20,19,maxx,20);
  523.                 break;
  524.             case 2:
  525.                 if ((domain_list == NULL) || (domains < 1))
  526.                     break;
  527.                 k = i = menu(40,15,70,20,alist,co_hilite,co_normal,k);
  528.                 set_color(co_normal); clrwnd(40,15,70,20);
  529.                 if (i < 0)
  530.                     break;
  531.                 if (domain_list[i].domain)
  532.                     free(domain_list[i].domain);
  533.                 while (i+1 < domains) {
  534.                     domain_list[i] = domain_list[i+1];
  535.                     i++;
  536.                 }
  537.                 domains--;
  538.                 free(alist[domains]);
  539.                 break;
  540.             case 3:
  541.                 if ((domain_list == NULL) || (domains < 1))
  542.                     break;
  543.                 l = i = menu(40,15,70,20,alist,co_hilite,co_normal,l);
  544.                 set_color(co_normal); clrwnd(40,15,70,20);
  545.                 if (i < 0)
  546.                     break;
  547.                 strcpy(buffer,show_address(domain_list[i]));
  548.                 if (domain_list[i].domain)
  549.                     free(domain_list[i].domain);
  550.                 gotoxy(20,19);
  551.                 bputs("Gate to change:");
  552.                 gotoxy(20,20);
  553.                 f = bgets(buffer,sizeof buffer - 1, maxx-20);
  554.                 domain_list[i] = parsenode(buffer);
  555.                 set_color(co_normal); clrwnd(20,19,maxx,20);
  556.                 break;
  557.             case 4:
  558.                 m = i = menu(45,16,60,19,glist,co_hilite,co_normal,m);
  559.                 set_color(co_normal); clrwnd(45,16,60,19);
  560.                 if (i > -1)
  561.                     gate = i;
  562.                 break;
  563.         }
  564.         for (i = 0; i < domains; i++)
  565.             free(alist[i]);
  566.         free(alist);
  567.     }
  568.  
  569.     set_color(co_normal);
  570.     clrwnd(20,11,40,15);
  571. }
  572.  
  573. static void _pascal set_quotes()
  574.  
  575. {
  576.     char *list[3];
  577.     int f = 0;
  578.     int i = 0;
  579.  
  580.     list[0] = (char *) malloc(128);
  581.     list[1] = (char *) malloc(256);
  582.     list[2] = NULL;
  583.  
  584.     while (f != ABORT) {
  585.         sprintf(list[0],"Quote string is %s",quotestr);
  586.         sprintf(list[1],"Attribution line is %s",attribline);
  587.  
  588.         switch (i = menu(20,12,maxx,13,list,co_hilite,co_normal,i)) {
  589.             case -1:
  590.                 f = ABORT;
  591.                 break;
  592.             case  0:
  593.                 if (quotestr) free(quotestr);
  594.                 gotoxy(36,wherey()); set_color(co_hilite);
  595.                 f = bgets(list[0]+16,30,maxx-36);
  596.                 quotestr = strdup(list[0]+16);
  597.                 break;
  598.  
  599.             case  1:
  600.                 if (attribline) free(attribline);
  601.                 gotoxy(40,wherey()); set_color(co_hilite);
  602.                 f = bgets(list[1]+20,128,maxx-40);
  603.                 attribline = strdup(list[1]+20);
  604.                 break;
  605.  
  606.         }
  607.     }
  608.     free(list[0]);
  609.     free(list[1]);
  610.  
  611.     set_color(co_normal);
  612.     clrwnd(20,12,maxx,13);
  613. }
  614.  
  615. static void _pascal set_macro()
  616.  
  617. {
  618.     static char *list[] = {
  619.         "Macro key definition",
  620.         "Command redefinition",
  621.         NULL
  622.     };
  623.  
  624.     static char *items[] = {
  625.         "Message reader",
  626.         "Editor",
  627.         NULL
  628.     };
  629.  
  630.     int i= 0,j = 0, i1 = 0;
  631.  
  632.     for (;;) {
  633.         switch(j = menu(20,13,40,14,list,co_hilite,co_normal,j)) {
  634.             case -1:
  635.                 set_color(co_normal);
  636.                 clrwnd(20,13,40,14);
  637.                 return;
  638.             case  0:
  639.                 gotoxy(45,14);
  640.                 bputs("Function to program: ");
  641.                 i = getnum(0,40,0);
  642.                 if (macros[i])
  643.                     free(macros[i]);
  644.                 macros[i] = build_macro();
  645.                 set_color(co_normal);
  646.                 clrwnd(45,14,maxx,14);
  647.                 clrwnd(5,18,maxx,20);
  648.                 break;
  649.  
  650.             case  1:
  651.                 while ((i1 = menu(45,14,60,15,items,co_hilite,co_normal,i1)) != -1)
  652.                     set_key(i1);
  653.                 set_color(co_normal);
  654.                 clrwnd(45,14,60,15);
  655.                 break;
  656.         }
  657.     }
  658. }
  659.  
  660. static unsigned int * _pascal build_macro()
  661.  
  662. {
  663.     unsigned int key = 0;
  664.     int stat = 0;
  665.     unsigned int mac[80];
  666.     unsigned int *t;
  667.     int c=0;
  668.  
  669.     gotoxy(5,18); bputs("Enter macro, press <ESC> twice to finish");
  670.     gotoxy(5,19);
  671.  
  672.     for (;;) {
  673.         video_update();
  674.         key = getkey();
  675.         if (key == ABORT) {
  676.             if (stat) {
  677.                 c--;
  678.                 t = calloc(c+1,sizeof (int));
  679.                 memcpy(t,mac,c * sizeof (int));
  680.                 return(t);
  681.             }
  682.             else
  683.                 stat = 1;
  684.         }
  685.         else
  686.             stat = 0;
  687.  
  688.         mac[c++] = key;
  689.  
  690.         if (key < 32) {
  691.             bputc('^');
  692.             bputc(key+96);
  693.         }
  694.         else if (key & 0xff00)
  695.             bprintf("\\0x%02x",key>>8);
  696.         else
  697.             bputc(key);
  698.  
  699.         if (c == 40)
  700.             gotoxy(5,20);
  701.  
  702.         if (c > 78) {
  703.             t = calloc(c+1,sizeof (int));
  704.             memcpy(t,mac,c * sizeof (int));
  705.             return(t);
  706.         }
  707.     }
  708. }
  709.  
  710. static void _pascal set_key(int t)
  711.  
  712. {
  713.     char **clist;
  714.     int i,j,k = 0;
  715.     unsigned int key;
  716.  
  717.     i = 0;
  718.     while ((t?e_getlabels(i):r_getlabels(i)) != NULL)
  719.         i++;
  720.  
  721.     clist = (char **) calloc(i+1,sizeof(char *));
  722.     for (j = 0; j <= i; j++)                                  /*WRA*/
  723.         clist[j] = t?e_getlabels(j):r_getlabels(j);
  724.  
  725.  
  726.     for (;;) {
  727.         k = menu(62,15,75,20,clist,co_hilite,co_normal,k);
  728.         set_color(co_normal); clrwnd(62,15,75,20);
  729.         if (k > -1) {
  730.             gotoxy(62,15); bputs("Assign "); bputs(clist[k]);
  731.                        bputs(" to: (press the key)");
  732.             gotoxy(62,16);
  733.             video_update();
  734.  
  735.             key = getkey();
  736.             bprintf("0x%4x",key);
  737.  
  738.             if (t)
  739.                 e_assignkey(key,clist[k]);
  740.             else
  741.                 r_assignkey(key,clist[k]);
  742.  
  743.             set_color(co_normal);
  744.             clrwnd(62,15,maxx,16);
  745.         }
  746.         else
  747.             break;
  748.     }
  749.  
  750.     free(clist);
  751. }
  752.  
  753. static void _pascal set_address()
  754.  
  755. {
  756.     static char *list[] = {
  757.         "Delete an alias",
  758.         "Add an alias",
  759.         "Change an alias",
  760.         "Set private net",
  761.         NULL
  762.     };
  763.  
  764.     char buffer[128];
  765.     char **alist;
  766.     int i, i1 = 0, j = 0;
  767.     ADDRESS *a;
  768.     int f = 0;
  769.  
  770.     while (f != ABORT) {
  771.  
  772.         alist = calloc(aliascount+1,sizeof (char *));
  773.         for (i = 0; i < aliascount; i++)
  774.             alist[i] = strdup(show_address(alias[i]));
  775.         alist[i] = NULL;
  776.  
  777.         switch(j = menu(20,14,40,17,list,co_hilite,co_normal,j)) {
  778.             case -1:
  779.                 f = ABORT;
  780.                 break;
  781.             case  0:
  782.                 if (aliascount == 1) {
  783.                     set_color(co_warn);
  784.                     gotoxy(40,10);
  785.                     bputs("Can't delete only alias!");
  786.                     gotoxy(40,11);
  787.                     bputs("press any key to continue");
  788.                     getkey();
  789.                     set_color(co_normal);
  790.                     clrwnd(40,10,80,11);
  791.                     break;
  792.                 }
  793.                 i1 = i = menu(40,15,70,20,alist,co_hilite,co_normal,i1);
  794.                 set_color(co_normal); clrwnd(40,15,70,20);
  795.                 if (i < 0)
  796.                     break;
  797.                 if (alias[i].domain)
  798.                     free(alias[i].domain);
  799.                 while (i+1 < aliascount) {
  800.                     alias[i] = alias[i+1];
  801.                     i++;
  802.                 }
  803.                 aliascount--;
  804.                 free(alist[aliascount]);
  805.                 break;
  806.             case  1:
  807.                 aliascount++;
  808.                 a = realloc(alias,sizeof(ADDRESS) * aliascount);
  809.                 if (a != NULL)
  810.                     alias = a;
  811.                 else
  812.                     break;
  813.                 gotoxy(20,19);
  814.                 bputs("Alias to be added:");
  815.                 gotoxy(20,20); memset(buffer,0,sizeof buffer);
  816.                 f = bgets(buffer,sizeof(buffer)-1,maxx-20);
  817.                 alias[aliascount-1] = parsenode(buffer);
  818.                 set_color(co_normal); clrwnd(20,19,maxx,20);
  819.                 break;
  820.             case  2:
  821.                 j = i = menu(40,15,70,20,alist,co_hilite,co_normal,j);
  822.                 set_color(co_normal); clrwnd(40,15,70,20);
  823.                 if (i < 0)
  824.                     break;
  825.                 strcpy(buffer,show_address(alias[i]));
  826.                 if (alias[i].domain)
  827.                     free(alias[i].domain);
  828.                 gotoxy(20,19);
  829.                 bputs("Alias to change:");
  830.                 gotoxy(20,20);
  831.                 f = bgets(buffer,sizeof buffer - 1, maxx-20);
  832.                 alias[i] = parsenode(buffer);
  833.                 set_color(co_normal); clrwnd(20,19,maxx,20);
  834.                 break;
  835.             case  3:
  836.                 gotoxy(40,15); bputs("Privatenet number: ");
  837.                 pointnet = getnum(0,32767,pointnet);
  838.                 set_color(co_normal); clrwnd(40,15,maxx,15);
  839.                 break;
  840.         }
  841.         for (i = 0; i < aliascount; i++)
  842.             free(alist[i]);
  843.         free(alist);
  844.     }
  845.     clrwnd(20,14,40,17);
  846. }
  847.  
  848. static void _pascal set_video()
  849.  
  850. {
  851.     char *list[5];
  852.     int i, j = 0, k = 0;
  853.  
  854.     static char *vlist[] = {
  855.         "Direct",
  856.         "BIOS",
  857.         "FOSSIL",
  858.         NULL
  859.     };
  860.  
  861.     for (i = 0; i < 4; i++)
  862.         list[i] = (char *) malloc(32);
  863.     list[4] = NULL;
  864.  
  865.     for (;;) {
  866.  
  867.         sprintf(list[0],"Screen width is %d",maxx);
  868.         sprintf(list[1],"Height is %d",maxy);
  869.         strcpy(list[2],"Colors");
  870.         sprintf(list[3],"Video %s",(videomethod==DIRECT)?"direct":(videomethod==BIOS)?"bios":(videomethod==ANSI)?"ERROR":"fossil");
  871.  
  872.         switch (j = menu(20,15,40,18,list,co_hilite,co_normal,j)) {
  873.             case -1:
  874.                 for (i = 0; i < 4; i++)
  875.                     free(list[i]);
  876.                 set_color(co_normal);
  877.                 clrwnd(20,15,40,18);
  878.                 return;
  879.             case 0:
  880.                 gotoxy(36,wherey()); set_color(co_hilite);
  881.                 maxx = getnum(0,1000,maxx);
  882.                 break;
  883.             case 1:
  884.                 gotoxy(30,wherey()); set_color(co_hilite);
  885.                 maxy = getnum(0,1000,maxy);
  886.                 break;
  887.             case 2:
  888.                 set_colors();
  889.                 break;
  890.             case 3:
  891.                 k = i = menu(45,15,55,19,vlist,co_hilite,co_normal,k);
  892.                 set_color(co_normal); clrwnd(45,15,55,18);
  893.                 if (i == -1)
  894.                     return;
  895.                 videomethod = i;
  896.                 video_init();
  897.                 break;
  898.         }
  899.     }
  900.  
  901. }
  902.  
  903. static void _pascal set_colors()
  904.  
  905. {
  906.     static char *clist[] = {
  907.         "Black", "Blue", "Green", "Cyan",
  908.         "Red", "Magenta", "Brown", "Grey",
  909.         "Dark Grey", "Lt Blue", "Lt Green", "Lt Cyan",
  910.         "Lt Red", "Lt Magenta", "Yellow", "White", NULL
  911.     };
  912.  
  913.     static char *fblist[] = {
  914.         "Foreground", "Background", NULL
  915.     };
  916.  
  917.     static char *tlist[] = {
  918.         "Normal", "Warnings", "Quotes",
  919.         "Block Anchor", "Information",
  920.         "Highlight", NULL
  921.     };
  922.  
  923.     int which = 0;
  924.     int fb = 0;
  925.     int co = 0;
  926.     int mask = 0;
  927.  
  928.  
  929.     for (;;) {
  930.         gotoxy(40,5); set_color(co_normal);
  931.         bputs("Normal text");
  932.         gotoxy(40,6); set_color(co_warn);
  933.         bputs("Warning messages");
  934.         gotoxy(40,7); set_color(co_quote);
  935.         bputs("Quoted text");
  936.         gotoxy(40,8); set_color(co_block);
  937.         bputs("Block anchor");
  938.         gotoxy(40,9); set_color(co_info);
  939.         bputs("Information");
  940.         gotoxy(40,10); set_color(co_hilite);
  941.         bputs("Highlighted text");
  942.         set_color(co_normal);
  943.  
  944.         which = menu(40,17,52,22,tlist,co_hilite,co_normal,which);
  945.         if (which == -1) {
  946.             set_color(co_normal);
  947.             clrwnd(40,5,60,10);
  948.             clrwnd(40,17,52,22);
  949.             return;
  950.         }
  951.  
  952.         do  {
  953.             fb = menu(55,18,65,19,fblist,co_hilite,co_normal,fb);
  954.             if (fb != -1) {
  955. /*    WRA       co = menu(67,19,77,24,clist,co_hilite,co_normal,co); */
  956.                 co = menu(67,9,77,24,clist,co_hilite,co_normal,co);
  957.                 if (co != -1) {
  958.                     if (fb) {
  959.                         co <<= 4;
  960.                         mask = 0x0f;
  961.                     }
  962.                     else
  963.                         mask = 0xf0;
  964.  
  965.                     switch (which) {
  966.                         case 0: co_normal &= mask;
  967.                             co_normal |= co;
  968.                             break;
  969.                         case 1: co_warn &= mask;
  970.                             co_warn |= co;
  971.                             break;
  972.                         case 2: co_quote &= mask;
  973.                             co_quote |= co;
  974.                             break;
  975.                         case 3: co_block &= mask;
  976.                             co_block |= co;
  977.                             break;
  978.                         case 4: co_info &= mask;
  979.                             co_info |= co;
  980.                             break;
  981.                         case 5: co_hilite &= mask;
  982.                             co_hilite |= co;
  983.                             break;
  984.                     }
  985.                 }
  986.                 co = 0;
  987.                 set_color(co_normal);
  988. /*   WRA        clrwnd(55,18,77,24); */
  989.                 clrwnd(55,18,65,19);
  990.                 clrwnd(67,9,77,24);
  991.             }
  992.             else {
  993.                 set_color(co_normal);
  994.                 clrwnd(55,18,65,19);
  995.             }
  996.  
  997.             gotoxy(40,5); set_color(co_normal);
  998.             bputs("Normal text");
  999.             gotoxy(40,6); set_color(co_warn);
  1000.             bputs("Warning messages");
  1001.             gotoxy(40,7); set_color(co_quote);
  1002.             bputs("Quoted text");
  1003.             gotoxy(40,8); set_color(co_block);
  1004.             bputs("Block anchor");
  1005.             gotoxy(40,9); set_color(co_info);
  1006.             bputs("Information");
  1007.             gotoxy(40,10); set_color(co_hilite);
  1008.             bputs("Highlighted text");
  1009.             set_color(co_normal);
  1010.  
  1011.         } while (fb != -1);
  1012.         fb = 0;
  1013.     }
  1014. }
  1015.  
  1016. static void _pascal set_misc()
  1017.  
  1018. {
  1019.     char *list[3];
  1020.     int i;
  1021.     int f = 0;
  1022.     int j = 0;
  1023.  
  1024.     for (i = 0; i < 2; i++)
  1025.         list[i] = (char *) malloc(128);
  1026.     list[2] = NULL;
  1027.  
  1028.     while (f != ABORT) {
  1029.         sprintf(list[0],"Your name is %s",username);
  1030.         sprintf(list[1],"Origin line is %s",origin);
  1031.  
  1032.         switch (j = menu(20,16,maxx,17,list,co_hilite,co_normal,j)) {
  1033.             case -1:
  1034.                 f = ABORT;
  1035.                 break;
  1036.             case  0:
  1037.                 if (username) free(username);
  1038.                 gotoxy(33,wherey()); set_color(co_hilite);
  1039.                 f = bgets(list[0]+13,80,maxx-33);
  1040.                 username = strdup(list[0]+13);
  1041.                 break;
  1042.             case  1:
  1043.                 if (origin) free(origin);
  1044.                 gotoxy(35,wherey()); set_color(co_hilite);
  1045.                 f = bgets(list[1]+15,65,maxx-35);
  1046.                 origin = strdup(list[1]+15);
  1047.                 break;
  1048.  
  1049.         }
  1050.     }
  1051.  
  1052.     for (i = 0; i < 3; i++)
  1053.         free(list[i]);
  1054.  
  1055.     set_color(co_normal);
  1056.     clrwnd(20,16,maxx,17);
  1057. }
  1058.  
  1059. static void _pascal save_set()
  1060.  
  1061. {
  1062.     FILE *fp;
  1063.     int i;
  1064.     char *s;
  1065.     time_t ntime;
  1066.     unsigned int key;
  1067.     unsigned int *keys;
  1068.  
  1069.     static char *colors[] = {
  1070.         "bla", "blu", "gre", "cya",
  1071.         "red", "mag", "yel", "whi"
  1072.     };
  1073.  
  1074.     if (*cfgfile == '+')
  1075.         fp = fopen(cfgfile+1,"a");
  1076.     else
  1077.         fp = fopen(cfgfile,"w");
  1078.  
  1079.     time(&ntime);
  1080.  
  1081.     fputs("\n; msged " VERSION " config file\n",fp);
  1082.     fputs("; generated ",fp);
  1083.     fputs(ctime(&ntime),fp);
  1084.  
  1085.     fputs("\n; who you are\n\n",fp);
  1086.  
  1087.     fprintf(fp,"name %s\n\n", username);
  1088.  
  1089.     fputs("; where you are\n\n",fp);
  1090.  
  1091.     for (i = 0; i < aliascount; i++)
  1092.         fprintf(fp,"address %s\n",show_address(alias[i]));
  1093.  
  1094.     if (pointnet)
  1095.         fprintf(fp,"privatenet %d\n",pointnet);
  1096.  
  1097.     fputs("\n; default file names\n\n",fp);
  1098.  
  1099.     if (quickbbs) {
  1100.         if (*(quickbbs+strlen(quickbbs)-1) == '\\')
  1101.             *(quickbbs+strlen(quickbbs)-1) = '\0';
  1102.         fprintf(fp,"quickbbs %s\n",quickbbs);
  1103.         strcat(quickbbs,"\\");
  1104.     }
  1105.  
  1106.     fprintf(fp,"outfile %s\n",outfile);
  1107.     fprintf(fp,"lastread %s\n",lastread);
  1108.     fprintf(fp,"tosslog %s\n",confmail);
  1109.     fprintf(fp,"userlist %s,%s\n\n",fidolist,userlist);
  1110.  
  1111.     fputs("; how you like your quotes\n\n",fp);
  1112.  
  1113.     fprintf(fp,"attribution %s\n",attribline?attribline:"");
  1114.     fputs("quote ",fp);
  1115.     s = quotestr;
  1116.     while (*s) {
  1117.         if (*s == ' ')
  1118.             fputc('_',fp);
  1119.         else
  1120.             fputc(*s,fp);
  1121.         s++;
  1122.     }
  1123.  
  1124.     fputs("\n\n; switch settings\n\n",fp);
  1125.  
  1126.     if (!softcr) fputs("no softcr\n",fp);
  1127.     if (!seenbys) fputs("no seen-bys\n",fp);
  1128.     if (!tearline) fputs("no tearline\n",fp);
  1129.     if (!shownotes) fputs("no shownotes\n",fp);
  1130.     if (!confirmations) fputs("no confirm\n",fp);
  1131.     if (!msgids) fputs("no msgids\n",fp);
  1132.     if (!stripnotes) fputs("no strip\n",fp);
  1133.     if (!opusdate) fputs("no opusdate\n",fp);
  1134.     if (!swapping) fputs("no swapping\n",fp);
  1135.  
  1136.     fputs("\n; video settings\n\n",fp);
  1137.  
  1138.     fprintf(fp,"video %s\n",(videomethod==DIRECT)?"direct":(videomethod==BIOS)?"bios":(videomethod==ANSI)?"ansi":"fossil");
  1139.  
  1140.     fprintf(fp,"color normal %s%c/%s%c\n",
  1141.         colors[co_normal & 0x07],
  1142.         (co_normal & 0x08)?'+':' ',
  1143.         colors[(co_normal >> 4) & 0x07],
  1144.         (co_normal & 0x80)?'+':' ');
  1145.  
  1146.     fprintf(fp,"color warn %s%c/%s%c\n",
  1147.         colors[co_warn & 0x07],
  1148.         (co_warn & 0x08)?'+':' ',
  1149.         colors[(co_warn >> 4) & 0x07],
  1150.         (co_warn & 0x80)?'+':' ');
  1151.  
  1152.     fprintf(fp,"color quote %s%c/%s%c\n",
  1153.         colors[co_quote & 0x07],
  1154.         (co_quote & 0x08)?'+':' ',
  1155.         colors[(co_quote >> 4) & 0x07],
  1156.         (co_quote & 0x80)?'+':' ');
  1157.  
  1158.     fprintf(fp,"color block %s%c/%s%c\n",
  1159.         colors[co_block & 0x07],
  1160.         (co_block & 0x08)?'+':' ',
  1161.         colors[(co_block >> 4) & 0x07],
  1162.         (co_block & 0x80)?'+':' ');
  1163.  
  1164.     fprintf(fp,"color info %s%c/%s%c\n",
  1165.         colors[co_info & 0x07],
  1166.         (co_info & 0x08)?'+':' ',
  1167.         colors[(co_info >> 4) & 0x07],
  1168.         (co_info & 0x80)?'+':' ');
  1169.  
  1170.     fprintf(fp,"color hilite %s%c/%s%c\n",
  1171.         colors[co_hilite & 0x07],
  1172.         (co_hilite & 0x08)?'+':' ',
  1173.         colors[(co_hilite >> 4) & 0x07],
  1174.         (co_hilite & 0x80)?'+':' ');
  1175.  
  1176.     fputs("\n; margins and tabs\n\n",fp);
  1177.  
  1178.     fprintf(fp,"right %d\nquoteright %d\ntabsize %d\n",
  1179.         rm,qm,tabsize);
  1180.  
  1181.     fputs("\n; all about your areas\n\n",fp);
  1182.  
  1183.     for (i = 0; i < areas; i++) {
  1184.         if (arealist[i].msgtype == FIDO) {
  1185.             if (arealist[i].local) {
  1186.                 fputs("fido local ",fp);
  1187.                 if (arealist[i].priv) fputc('p',fp);
  1188.                 if (arealist[i].hold) fputc('h',fp);
  1189.                  if (arealist[i].direct) fputc('d',fp);
  1190.                 if (arealist[i].crash) fputc('c',fp);
  1191.                 if (arealist[i].killsent) fputc('k',fp);
  1192.                 fprintf(fp," \"%s\" %s\n",arealist[i].description,arealist[i].path);
  1193.             }
  1194.  
  1195.             if (arealist[i].netmail) {
  1196.                 fputs("fido mail ",fp);
  1197.                 if (arealist[i].priv) fputc('p',fp);
  1198.                 if (arealist[i].hold) fputc('h',fp);
  1199.                 if (arealist[i].direct) fputc('d',fp);
  1200.                 if (arealist[i].crash) fputc('c',fp);
  1201.                 if (arealist[i].killsent) fputc('k',fp);
  1202.                 fprintf(fp," \"%s\" %s\n",arealist[i].description,arealist[i].path);
  1203.             }
  1204.  
  1205.             if (arealist[i].echomail) {
  1206.                 fputs("fido echo ",fp);
  1207.                 if (arealist[i].priv) fputc('p',fp);
  1208.                 if (arealist[i].hold) fputc('h',fp);
  1209.                 if (arealist[i].direct) fputc('d',fp);
  1210.                 if (arealist[i].crash) fputc('c',fp);
  1211.                 if (arealist[i].killsent) fputc('k',fp);
  1212.                 fprintf(fp," \"%s\" %s %s\n",arealist[i].description,arealist[i].path, arealist[i].tag);
  1213.             }
  1214.  
  1215.             if (arealist[i].news) {
  1216.                 fputs("fido news ",fp);
  1217.                 if (arealist[i].priv) fputc('p',fp);
  1218.                 if (arealist[i].hold) fputc('h',fp);
  1219.                 if (arealist[i].direct) fputc('d',fp);
  1220.                 if (arealist[i].crash) fputc('c',fp);
  1221.                 if (arealist[i].killsent) fputc('k',fp);
  1222.                 fprintf(fp," \"%s\" %s\n",arealist[i].description,arealist[i].path);
  1223.             }
  1224.  
  1225.             if (arealist[i].uucp) {
  1226.                 fputs("fido uucp ",fp);
  1227.                 if (arealist[i].priv) fputc('p',fp);
  1228.                 if (arealist[i].hold) fputc('h',fp);
  1229.                 if (arealist[i].direct) fputc('d',fp);
  1230.                 if (arealist[i].crash) fputc('c',fp);
  1231.                 if (arealist[i].killsent) fputc('k',fp);
  1232.                 fprintf(fp," \"%s\" %s\n",arealist[i].description,arealist[i].path);
  1233.             }
  1234.         }
  1235.         if (arealist[i].msgtype == QUICK) {
  1236.             if (arealist[i].local) {
  1237.                 fputs("quick local ",fp);
  1238.                 if (arealist[i].priv) fputc('p',fp);
  1239.                 if (arealist[i].hold) fputc('h',fp);
  1240.                 if (arealist[i].direct) fputc('d',fp);
  1241.                 if (arealist[i].crash) fputc('c',fp);
  1242.                 if (arealist[i].killsent) fputc('k',fp);
  1243.                 fprintf(fp," \"%s\" %d\n",arealist[i].description,arealist[i].board);
  1244.             }
  1245.  
  1246.             if (arealist[i].netmail) {
  1247.                 fputs("quick mail ",fp);
  1248.                 if (arealist[i].priv) fputc('p',fp);
  1249.                 if (arealist[i].hold) fputc('h',fp);
  1250.                 if (arealist[i].direct) fputc('d',fp);
  1251.                 if (arealist[i].crash) fputc('c',fp);
  1252.                 if (arealist[i].killsent) fputc('k',fp);
  1253.                 fprintf(fp," \"%s\" %d\n",arealist[i].description,arealist[i].board);
  1254.             }
  1255.  
  1256.             if (arealist[i].echomail) {
  1257.                 fputs("quick echo ",fp);
  1258.                 if (arealist[i].priv) fputc('p',fp);
  1259.                 if (arealist[i].hold) fputc('h',fp);
  1260.                 if (arealist[i].direct) fputc('d',fp);
  1261.                 if (arealist[i].crash) fputc('c',fp);
  1262.                 if (arealist[i].killsent) fputc('k',fp);
  1263.                 fprintf(fp," \"%s\" %d %s\n",arealist[i].description,arealist[i].board, arealist[i].tag);
  1264.             }
  1265.  
  1266.             if (arealist[i].news) {
  1267.                 fputs("quick news ",fp);
  1268.                 if (arealist[i].priv) fputc('p',fp);
  1269.                 if (arealist[i].hold) fputc('h',fp);
  1270.                 if (arealist[i].direct) fputc('d',fp);
  1271.                 if (arealist[i].crash) fputc('c',fp);
  1272.                 if (arealist[i].killsent) fputc('k',fp);
  1273.                 fprintf(fp," \"%s\" %d\n",arealist[i].description,arealist[i].board);
  1274.             }
  1275.  
  1276.             if (arealist[i].uucp) {
  1277.                 fputs("quick uucp ",fp);
  1278.                 if (arealist[i].priv) fputc('p',fp);
  1279.                 if (arealist[i].hold) fputc('h',fp);
  1280.                 if (arealist[i].direct) fputc('d',fp);
  1281.                 if (arealist[i].crash) fputc('c',fp);
  1282.                 if (arealist[i].killsent) fputc('k',fp);
  1283.                 fprintf(fp," \"%s\" %d\n",arealist[i].description,arealist[i].board);
  1284.             }
  1285.         }
  1286.     }
  1287.  
  1288.     fputs("\n; uucp and domain gates\n\n",fp);
  1289.  
  1290.     if (!uucp_gate.notfound)
  1291.         fprintf(fp,"uucp %s\n\n",show_address(uucp_gate));
  1292.  
  1293.     for (i = 0; i < domains; i++)
  1294.         fprintf(fp,"domain %s\n\n",show_address(domain_list[i]));
  1295.  
  1296.     switch (gate) {
  1297.         case GDOMAINS:  fputs("gate domains\n",fp);
  1298.                 break;
  1299.         case GZONES:    fputs("gate zones\n",fp);
  1300.                 break;
  1301.         case BOTH:      fputs("gate both\n",fp);
  1302.                 break;
  1303.         case 0:         fputs("gate none\n",fp);
  1304.                 break;
  1305.     }
  1306.  
  1307.     fputs("\n; your origin line\n\n",fp);
  1308.  
  1309.     fprintf(fp,"origin %s\n",origin);
  1310.  
  1311.     fputs("\n; message reader key definitions\n\n",fp);
  1312.  
  1313.     for (key = 0; key < 256; key++)
  1314.         if (r_getbind(key) != NULL)
  1315.             fprintf(fp,"readkey 0x%04x %s\n",key,r_getbind(key));
  1316.  
  1317.     for (key = 0; key < 256; key++)
  1318.         if (r_getbind(key<<8) != NULL)
  1319.             fprintf(fp,"readkey 0x%02x00 %s\n",key,r_getbind(key<<8));
  1320.  
  1321.     fputs("\n; editor key definitions\n\n",fp);
  1322.  
  1323.     for (key = 0; key < 256; key++)
  1324.         if (e_getbind(key) != NULL)
  1325.             fprintf(fp,"editkey 0x%04x %s\n",key,e_getbind(key));
  1326.  
  1327.     for (key = 0; key < 256; key++)
  1328.         if (e_getbind(key<<8) != NULL)
  1329.             fprintf(fp,"editkey 0x%02x00 %s\n",key,e_getbind(key<<8));
  1330.  
  1331.     fputs("\n; function key definitions\n\n",fp);
  1332.  
  1333.     for (i = 0; i < 40; i++) {
  1334.         if (macros[i] != NULL) {
  1335.             fprintf(fp,"function %d ",i);
  1336.             keys = macros[i];
  1337.             while (*keys) {
  1338.                 if (*keys < 32) {
  1339.                     fputc('^',fp);
  1340.                     fputc(*keys+96,fp);
  1341.                 }
  1342.                 else if (*keys & 0xff00)
  1343.                     fprintf(fp,"\\0x%02x",*keys>>8);
  1344.                 else
  1345.                     fputc(*keys,fp);
  1346.                 keys++;
  1347.             }
  1348.             fputc('\n',fp);
  1349.         }
  1350.     }
  1351.  
  1352.     fclose(fp);
  1353. }
  1354.  
  1355.  
  1356. static void _pascal edit_area(AREA *a)
  1357.  
  1358. {
  1359.     char *fields[7];
  1360.  
  1361.     static char *slist[] = {
  1362.         "Fido (.msg)", "QuickBBS   ", NULL
  1363.     };
  1364.  
  1365.     static char *tlist[] = {
  1366.         "local  ",
  1367.         "net    ",
  1368.         "echo   ",
  1369.         "news   ",
  1370.         "uucp   ",
  1371.         NULL
  1372.     };
  1373.  
  1374.     int i = 0,j;
  1375.     int f2 = 0;
  1376.  
  1377.     fields[6] = NULL;
  1378.  
  1379.     for (;;) {
  1380.         fields[0] = calloc(256,sizeof(char));
  1381.         sprintf(fields[0],"Description:     %s",a->description?a->description:"");
  1382.         fields[1] = calloc(128,sizeof(char));
  1383.  
  1384.         if (a->msgtype == FIDO) {
  1385.             sprintf(fields[1],"Path:            %s",a->path?a->path:"");
  1386.             fields[3] = strdup("Message Base:    Fido (.msg)");
  1387.         }
  1388.         else {
  1389.             sprintf(fields[1],"Board Number:    %d",a->board);
  1390.             fields[3] = strdup("Message Base:    QuickBBS");
  1391.         }
  1392.  
  1393.         fields[2] = strdup("Attributes:              ");
  1394.         *(fields[2] + 17) = '\0';
  1395.         if (a->priv) strcat(fields[2],"p");
  1396.         if (a->hold) strcat(fields[2],"h");
  1397.         if (a->direct) strcat(fields[2],"d");
  1398.         if (a->crash) strcat(fields[2],"c");
  1399.         if (a->killsent) strcat(fields[2],"k");
  1400.  
  1401.         fields[4] = calloc(128,sizeof(char));
  1402.         strcpy(fields[4],  "Type of Message: ");
  1403.         if (a->local) {
  1404.             strcat(fields[4],"local ");
  1405.             *(tlist[0] + 6) = 0xfb;
  1406.         }
  1407.         else
  1408.             *(tlist[0] + 6) = ' ';
  1409.  
  1410.         if (a->netmail) {
  1411.             strcat(fields[4],"net ");
  1412.             *(tlist[1] + 6) = 0xfb;
  1413.         }
  1414.         else
  1415.             *(tlist[1] + 6) = ' ';
  1416.  
  1417.  
  1418.         if (a->echomail) {
  1419.             *(tlist[2] + 6) = 0xfb;
  1420.             fields[5] = calloc(128,sizeof(char));
  1421.             sprintf(fields[5],"Echomail Tag:    %s",a->tag?a->tag:"");
  1422.             strcat(fields[4],"echo ");
  1423.         }
  1424.         else {
  1425.             *(tlist[2] + 6) = ' ';
  1426.             fields[5] = NULL;
  1427.         }
  1428.  
  1429.         if (a->news) {
  1430.             strcat(fields[4],"news ");
  1431.             *(tlist[3] + 6) = 0xfb;
  1432.         }
  1433.         else
  1434.             *(tlist[3] + 6) = ' ';
  1435.  
  1436.         if (a->uucp) {
  1437.             strcat(fields[4],"uucp");
  1438.             *(tlist[4] + 6) = 0xfb;
  1439.         }
  1440.         else
  1441.             *(tlist[4] + 6) = ' ';
  1442.  
  1443.         i = menu(5,18,maxx,maxy,fields,co_hilite,co_normal,i);
  1444.  
  1445.         switch (i) {
  1446.             case 0: if (a->description) free(a->description);
  1447.                 gotoxy(22,wherey()); set_color(co_hilite);
  1448.                 bgets(fields[0]+17,80,min(80,maxx-22));
  1449.                 a->description = strdup(fields[0]+17);
  1450.                 break;
  1451.  
  1452.             case 1: if (a->msgtype == FIDO) {
  1453.                     if (a->path) free(a->path);
  1454.                     gotoxy(22,wherey()); set_color(co_hilite);
  1455.                     bgets(fields[1]+17,80,min(80,maxx-22));
  1456.                     a->path = strdup(fields[1]+17);
  1457.                 }
  1458.                 else if (a->msgtype == QUICK) {
  1459.                     gotoxy(22,wherey()); set_color(co_hilite);
  1460.                     a->board = getnum(1,200,a->board);
  1461.                 }
  1462.                 break;
  1463.  
  1464.             case 2: box(14,14,27,20,1);
  1465.                 set_attrib(15,15,26,19,a);
  1466.                 clrwnd(14,14,27,20);
  1467.                 break;
  1468.  
  1469.             case 3: box(15,15,27,18,1);
  1470.                 a->msgtype = menu(16,16,26,17,slist,co_hilite,co_normal,a->msgtype);
  1471.                 clrwnd(15,15,27,18);
  1472.                 break;
  1473.  
  1474.             case 4: box(14,14,22,20,1);
  1475.                 while ((f2 = menu(15,15,21,19,tlist,co_hilite,co_normal,f2)) != -1) {
  1476.                     switch (f2) {
  1477.                         case 0: *(tlist[0]+6) = (char) (((a->local = !a->local) != 0)?0xfb:0x20); break;
  1478.                         case 1: *(tlist[1]+6) = (char) (((a->netmail = !a->netmail) != 0)?0xfb:0x20); break;
  1479.                         case 2: *(tlist[2]+6) = (char) (((a->echomail = !a->echomail) != 0)?0xfb:0x20); break;
  1480.                         case 4: *(tlist[4]+6) = (char) (((a->uucp = !a->uucp) != 0)?0xfb:0x20); break;
  1481.                         case 3: *(tlist[3]+6) = (char) (((a->news = !a->news) != 0)?0xfb:0x20); break;
  1482.                     }
  1483.                 }
  1484.                 clrwnd(14,14,22,20);
  1485.                 break;
  1486.  
  1487.             case 5: if (a->echomail) {
  1488.                     if (a->tag) free(a->tag);
  1489.                     gotoxy(22,wherey()); set_color(co_hilite);
  1490.                     bgets(fields[5]+17,64,min(64,maxx-22));
  1491.                     a->tag = strdup(fields[5]+17);
  1492.                 }
  1493.                 break;
  1494.         }
  1495.  
  1496.         for (j = 0; j < 6; j++)
  1497.             if (fields[j]) free(fields[j]);
  1498.  
  1499.         if (i == -1) {
  1500.             set_color(co_normal);
  1501.             clrwnd(5,18,maxx,maxy);
  1502.             return;
  1503.         }
  1504.     }
  1505. }
  1506.  
  1507.