home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / LO241SRV.ZIP / LSETUP5.C < prev    next >
Text File  |  1998-05-17  |  73KB  |  2,036 lines

  1.  
  2. // LoraBBS Version 2.41 Free Edition
  3. // Copyright (C) 1987-98 Marco Maccaferri
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <ctype.h>
  22. #include <string.h>
  23. #include <io.h>
  24. #include <fcntl.h>
  25. #include <alloc.h>
  26. #include <sys\stat.h>
  27.  
  28. #include "lsetup.h"
  29. #include "lprot.h"
  30. #include "sched.h"
  31.  
  32. #include <cxl\cxlvid.h>
  33. #include <cxl\cxlwin.h>
  34. #include <cxl\cxlstr.h>
  35. #include <cxl\cxlkey.h>
  36.  
  37. extern struct _configuration config;
  38.  
  39. void start_update (void);
  40. void stop_update (void);
  41. char *get_priv_text (int);
  42. void create_path (char *);
  43. int sh_open (char *file, int shmode, int omode, int fmode);
  44. void clear_window (void);
  45.  
  46. static void edit_single_event (EVENT *);
  47. static void select_event_list (int, EVENT *);
  48.  
  49. void terminal_misc ()
  50. {
  51.    int wh, i = 1;
  52.    char string[128];
  53.  
  54.    wh = wopen (7, 9, 17, 69, 1, LCYAN|_BLACK, CYAN|_BLACK);
  55.    wactiv (wh);
  56.    wshadow (DGREY|_BLACK);
  57.    wtitle (" Miscellaneous ", TRIGHT, YELLOW|_BLUE);
  58.  
  59.    do {
  60.       stop_update ();
  61.       wclear ();
  62.  
  63.       wmenubegc ();
  64.       wmenuitem ( 1,  1, " Init            ", 0,  1, 0, NULL, 0, 0);
  65.       wmenuitem ( 2,  1, " Download        ", 0,  2, 0, NULL, 0, 0);
  66.       wmenuitem ( 3,  1, " Upload          ", 0,  3, 0, NULL, 0, 0);
  67.       wmenuitem ( 4,  1, " Avatar          ", 0,  4, 0, NULL, 0, 0);
  68.       wmenuitem ( 5,  1, " Auto Zmodem     ", 0,  5, 0, NULL, 0, 0);
  69.       wmenuitem ( 6,  1, " Dialing timeout ", 0,  6, 0, NULL, 0, 0);
  70.       wmenuitem ( 7,  1, "    Pause        ", 0,  7, 0, NULL, 0, 0);
  71.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  72.  
  73.       wprints (1, 19, CYAN|_BLACK, config.term_init);
  74.       wprints (2, 19, CYAN|_BLACK, config.dl_path);
  75.       wprints (3, 19, CYAN|_BLACK, config.ul_path);
  76.       wprints (4, 19, CYAN|_BLACK, config.avatar ? "Yes" : "No");
  77.       wprints (5, 19, CYAN|_BLACK, config.autozmodem ? "Yes" : "No");
  78.       sprintf (string, "%d", config.dial_timeout);
  79.       wprints (6, 19, CYAN|_BLACK, string);
  80.       sprintf (string, "%d", config.dial_pause);
  81.       wprints (7, 19, CYAN|_BLACK, string);
  82.  
  83.       start_update ();
  84.       i = wmenuget ();
  85.  
  86.       switch (i) {
  87.          case 1:
  88.             strcpy (string, config.term_init);
  89.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  90.             winpdef (1, 19, string, "??????????????????????????????????????", 0, 2, NULL, 0);
  91.             if (winpread () != W_ESCPRESS)
  92.                strcpy (config.term_init, strbtrim (string));
  93.             break;
  94.  
  95.          case 2:
  96.             strcpy (string, config.dl_path);
  97.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  98.             winpdef (2, 19, string, "??????????????????????????????????????", 0, 2, NULL, 0);
  99.             if (winpread () != W_ESCPRESS) {
  100.                strcpy (config.dl_path, strbtrim (string));
  101.                if (config.dl_path[0] && config.dl_path[strlen (config.dl_path) - 1] != '\\')
  102.                   strcat (config.dl_path, "\\");
  103.                create_path (config.dl_path);
  104.             }
  105.             break;
  106.  
  107.          case 3:
  108.             strcpy (string, config.ul_path);
  109.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  110.             winpdef (3, 19, string, "??????????????????????????????????????", 0, 2, NULL, 0);
  111.             if (winpread () != W_ESCPRESS) {
  112.                strcpy (config.ul_path, strbtrim (string));
  113.                if (config.ul_path[0] && config.ul_path[strlen (config.ul_path) - 1] != '\\')
  114.                   strcat (config.ul_path, "\\");
  115.                create_path (config.ul_path);
  116.             }
  117.             break;
  118.  
  119.          case 4:
  120.             config.avatar ^= 1;
  121.             break;
  122.  
  123.          case 5:
  124.             config.autozmodem ^= 1;
  125.             break;
  126.  
  127.          case 6:
  128.             sprintf (string, "%d", config.dial_timeout);
  129.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  130.             winpdef (6, 19, string, "???", 0, 2, NULL, 0);
  131.             if (winpread () != W_ESCPRESS)
  132.                config.dial_timeout = atoi (string);
  133.             break;
  134.  
  135.          case 7:
  136.             sprintf (string, "%d", config.dial_pause);
  137.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  138.             winpdef (7, 19, string, "???", 0, 2, NULL, 0);
  139.             if (winpread () != W_ESCPRESS)
  140.                config.dial_pause = atoi (string);
  141.             break;
  142.       }
  143.  
  144.       hidecur ();
  145.  
  146.    } while (i != -1);
  147.  
  148.    wclose ();
  149. }
  150.  
  151. void iemsi_linehelp_window ()
  152. {
  153.    char *str = "";
  154.    struct _menu_t *mt;
  155.  
  156.    mt = wmenumcurr ();
  157.    if (mt == NULL)
  158.       return;
  159.  
  160.    switch (mt->citem->tagid) {
  161.       case 1:
  162.          str = "Yes = IEMSI active";
  163.          break;
  164.       case 2:
  165.          str = "Seconds that remote system infos stay on screen";
  166.          break;
  167.       case 3:
  168.          str = "Password to use";
  169.          break;
  170.       case 4:
  171.          str = "Alternate user's name";
  172.          break;
  173.       case 5:
  174.          str = "Yes = Request hotkeyed menus";
  175.          break;
  176.       case 6:
  177.          str = "Yes = Enable online messages";
  178.          break;
  179.       case 7:
  180.          str = "Yes = Pause at the end of each screen page";
  181.          break;
  182.       case 8:
  183.          str = "Yes = Full screen editor";
  184.          break;
  185.       case 9:
  186.          str = "Yes = Shows news bulletins";
  187.          break;
  188.       case 10:
  189.          str = "Yes = Check for new mail at login";
  190.          break;
  191.       case 11:
  192.          str = "Yes = Check for new files at login";
  193.          break;
  194.       case 12:
  195.          str = "Yes = Send screen clearing codes";
  196.          break;
  197.    }
  198.  
  199.    clear_window ();
  200.    prints (24, 1, LGREY|_BLACK, str);
  201. }
  202.  
  203. void terminal_iemsi ()
  204. {
  205.    int wh, i = 1;
  206.    char string[128];
  207.  
  208.    wh = wopen (4, 13, 19, 69, 1, LCYAN|_BLACK, CYAN|_BLACK);
  209.    wactiv (wh);
  210.    wshadow (DGREY|_BLACK);
  211.    wtitle (" IEMSI Profile ", TRIGHT, YELLOW|_BLUE);
  212.  
  213.    do {
  214.       stop_update ();
  215.       wclear ();
  216.  
  217.       wmenubegc ();
  218.       wmenuitem ( 1,  1, " IEMSI On       ", 0,  1, 0, NULL, 0, 0);
  219.       wmenuiba (iemsi_linehelp_window, clear_window);
  220.       wmenuitem ( 2,  1, " ├ Info time    ", 0,  2, 0, NULL, 0, 0);
  221.       wmenuiba (iemsi_linehelp_window, clear_window);
  222.       wmenuitem ( 3,  1, " ├ Password     ", 0,  3, 0, NULL, 0, 0);
  223.       wmenuiba (iemsi_linehelp_window, clear_window);
  224.       wmenuitem ( 4,  1, " ├ Handle       ", 0,  4, 0, NULL, 0, 0);
  225.       wmenuiba (iemsi_linehelp_window, clear_window);
  226.       wmenuitem ( 5,  1, " ├ Hot keys     ", 0,  5, 0, NULL, 0, 0);
  227.       wmenuiba (iemsi_linehelp_window, clear_window);
  228.       wmenuitem ( 6,  1, " ├ Quiet        ", 0,  6, 0, NULL, 0, 0);
  229.       wmenuiba (iemsi_linehelp_window, clear_window);
  230.       wmenuitem ( 7,  1, " ├ Pausing      ", 0,  7, 0, NULL, 0, 0);
  231.       wmenuiba (iemsi_linehelp_window, clear_window);
  232.       wmenuitem ( 8,  1, " ├ Editor       ", 0,  8, 0, NULL, 0, 0);
  233.       wmenuiba (iemsi_linehelp_window, clear_window);
  234.       wmenuitem ( 9,  1, " ├ News         ", 0,  9, 0, NULL, 0, 0);
  235.       wmenuiba (iemsi_linehelp_window, clear_window);
  236.       wmenuitem (10,  1, " ├ New mail     ", 0, 10, 0, NULL, 0, 0);
  237.       wmenuiba (iemsi_linehelp_window, clear_window);
  238.       wmenuitem (11,  1, " ├ New files    ", 0, 11, 0, NULL, 0, 0);
  239.       wmenuiba (iemsi_linehelp_window, clear_window);
  240.       wmenuitem (12,  1, " └ Screen clear ", 0, 12, 0, NULL, 0, 0);
  241.       wmenuiba (iemsi_linehelp_window, clear_window);
  242.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  243.  
  244.       wprints (1, 18, CYAN|_BLACK, config.iemsi_on ? "Yes" : "No");
  245.       sprintf (string, "%d", config.iemsi_infotime);
  246.       wprints (2, 18, CYAN|_BLACK, string);
  247.       wprints (3, 18, CYAN|_BLACK, config.iemsi_pwd);
  248.       wprints (4, 18, CYAN|_BLACK, config.iemsi_handle);
  249.       wprints (5, 18, CYAN|_BLACK, config.iemsi_hotkeys ? "Yes" : "No");
  250.       wprints (6, 18, CYAN|_BLACK, config.iemsi_quiet ? "Yes" : "No");
  251.       wprints (7, 18, CYAN|_BLACK, config.iemsi_pausing ? "Yes" : "No");
  252.       wprints (8, 18, CYAN|_BLACK, config.iemsi_editor ? "Yes" : "No");
  253.       wprints (9, 18, CYAN|_BLACK, config.iemsi_news ? "Yes" : "No");
  254.       wprints (10, 18, CYAN|_BLACK, config.iemsi_newmail ? "Yes" : "No");
  255.       wprints (11, 18, CYAN|_BLACK, config.iemsi_newfiles ? "Yes" : "No");
  256.       wprints (12, 18, CYAN|_BLACK, config.iemsi_screenclr ? "Yes" : "No");
  257.  
  258.       start_update ();
  259.       i = wmenuget ();
  260.  
  261.       switch (i) {
  262.          case 1:
  263.             config.iemsi_on ^= 1;
  264.             break;
  265.  
  266.          case 2:
  267.             sprintf (string, "%d", config.iemsi_infotime);
  268.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  269.             winpdef (2, 18, string, "???", 0, 2, NULL, 0);
  270.             if (winpread () != W_ESCPRESS)
  271.                config.iemsi_infotime = atoi (string);
  272.             break;
  273.  
  274.          case 3:
  275.             strcpy (string, config.iemsi_pwd);
  276.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  277.             winpdef (3, 18, string, "???????????????????", 0, 2, NULL, 0);
  278.             if (winpread () != W_ESCPRESS)
  279.                strcpy (config.iemsi_pwd, strbtrim (string));
  280.             break;
  281.  
  282.          case 4:
  283.             strcpy (string, config.iemsi_handle);
  284.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  285.             winpdef (4, 18, string, "???????????????????????????????????", 0, 2, NULL, 0);
  286.             if (winpread () != W_ESCPRESS)
  287.                strcpy (config.iemsi_handle, strbtrim (string));
  288.             break;
  289.  
  290.          case 5:
  291.             config.iemsi_hotkeys ^= 1;
  292.             break;
  293.  
  294.          case 6:
  295.             config.iemsi_quiet ^= 1;
  296.             break;
  297.  
  298.          case 7:
  299.             config.iemsi_pausing ^= 1;
  300.             break;
  301.  
  302.          case 8:
  303.             config.iemsi_editor ^= 1;
  304.             break;
  305.  
  306.          case 9:
  307.             config.iemsi_news ^= 1;
  308.             break;
  309.  
  310.          case 10:
  311.             config.iemsi_newmail ^= 1;
  312.             break;
  313.  
  314.          case 11:
  315.             config.iemsi_newfiles ^= 1;
  316.             break;
  317.  
  318.          case 12:
  319.             config.iemsi_screenclr ^= 1;
  320.             break;
  321.       }
  322.  
  323.       hidecur ();
  324.  
  325.    } while (i != -1);
  326.  
  327.    wclose ();
  328. }
  329.  
  330. void manager_scheduler ()
  331. {
  332.    int fd, fdi, wh2, wh, wh1, i = 1, saved, minute, m, length, days;
  333.    int t1, t2;
  334.    char string[128], readed;
  335.    long pos;
  336.    EVENT nevt, bnevt;
  337.  
  338.    fd = open (config.sched_name, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  339.    if (fd == -1)
  340.       return;
  341.  
  342.    if (!read (fd, (char *)&nevt, sizeof (EVENT))) {
  343.       memset ((char *)&nevt, 0, sizeof (EVENT));
  344.       readed = 0;
  345.    }
  346.    else
  347.       readed = 1;
  348.  
  349.    gotoxy_ (24, 1);
  350.    clreol_ ();
  351.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Event  L-List  D-Delete  C-Copy");
  352.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  353.    prints (24, 26, YELLOW|_BLACK, "E");
  354.    prints (24, 34, YELLOW|_BLACK, "A");
  355.    prints (24, 51, YELLOW|_BLACK, "L");
  356.    prints (24, 59, YELLOW|_BLACK, "D");
  357.    prints (24, 69, YELLOW|_BLACK, "C");
  358.  
  359.    wh = wopen (3, 11, 21, 65, 1, LCYAN|_BLACK, CYAN|_BLACK);
  360.    wactiv (wh);
  361.    wshadow (DGREY|_BLACK);
  362.    wtitle (" Events ", TRIGHT, YELLOW|_BLUE);
  363.  
  364.    do {
  365.       stop_update ();
  366.       wclear ();
  367.  
  368.       wprints ( 1, 1, LGREY|_BLACK, " Title            ");
  369.       wprints ( 2, 1, LGREY|_BLACK, " Days             ");
  370.       wprints ( 3, 1, LGREY|_BLACK, " Start time       ");
  371.       wprints ( 4, 1, LGREY|_BLACK, " Stop time        ");
  372.       wprints ( 5, 1, LGREY|_BLACK, " Forced           ");
  373.       wprints ( 6, 1, LGREY|_BLACK, " Allow humans     ");
  374.       wprints ( 7, 1, LGREY|_BLACK, " Errorlevel       ");
  375.       wprints ( 8, 1, LGREY|_BLACK, " Clock adjustment ");
  376.       wprints ( 9, 1, LGREY|_BLACK, " Receive only     ");
  377.       wprints (10, 1, LGREY|_BLACK, " ├ Max try        ");
  378.       wprints (11, 1, LGREY|_BLACK, " ├ Max failed     ");
  379.       wprints (12, 1, LGREY|_BLACK, " └ Retry delay    ");
  380.       wprints (13, 1, LGREY|_BLACK, " Forced poll      ");
  381.       wprints (14, 1, LGREY|_BLACK, " └ Reserved node  ");
  382.       wprints (15, 1, LGREY|_BLACK, " Mail behavior    ");
  383.  
  384.       if (readed) {
  385.          wprints (1, 20, CYAN|_BLACK, nevt.cmd);
  386.          strcpy (string, "-------");
  387.          if (nevt.days & DAY_SUNDAY)
  388.             string[0] = 'S';
  389.          if (nevt.days & DAY_MONDAY)
  390.             string[1] = 'M';
  391.          if (nevt.days & DAY_TUESDAY)
  392.             string[2] = 'T';
  393.          if (nevt.days & DAY_WEDNESDAY)
  394.             string[3] = 'W';
  395.          if (nevt.days & DAY_THURSDAY)
  396.             string[4] = 'T';
  397.          if (nevt.days & DAY_FRIDAY)
  398.             string[5] = 'F';
  399.          if (nevt.days & DAY_SATURDAY)
  400.             string[6] = 'S';
  401.          wprints (2, 20, CYAN|_BLACK, string);
  402.          sprintf (string, "%02d:%02d", nevt.minute / 60, nevt.minute % 60);
  403.          wprints (3, 20, CYAN|_BLACK, string);
  404.          m = nevt.minute + nevt.length;
  405.          sprintf (string, "%02d:%02d", m / 60, m % 60);
  406.          wprints (4, 20, CYAN|_BLACK, string);
  407.          if (nevt.behavior & MAT_FORCED)
  408.             wprints (5, 20, CYAN|_BLACK, "Yes");
  409.          else
  410.             wprints (5, 20, CYAN|_BLACK, "No");
  411.          if (nevt.behavior & MAT_BBS)
  412.             wprints (6, 20, CYAN|_BLACK, "Yes");
  413.          else
  414.             wprints (6, 20, CYAN|_BLACK, "No");
  415.          sprintf (string, "%d", nevt.errlevel[0]);
  416.          wprints (7, 20, CYAN|_BLACK, string);
  417.          if (nevt.behavior & MAT_RESYNC)
  418.             wprints (8, 20, CYAN|_BLACK, "Yes");
  419.          else
  420.             wprints (8, 20, CYAN|_BLACK, "No");
  421.          if (nevt.behavior & MAT_NOOUT)
  422.             wprints (9, 20, CYAN|_BLACK, "Yes");
  423.          else
  424.             wprints (9, 20, CYAN|_BLACK, "No");
  425.          sprintf (string, "%d", nevt.no_connect);
  426.          wprints (10, 20, CYAN|_BLACK, string);
  427.          sprintf (string, "%d", nevt.with_connect);
  428.          wprints (11, 20, CYAN|_BLACK, string);
  429.          sprintf (string, "%d", nevt.wait_time);
  430.          wprints (12, 20, CYAN|_BLACK, string);
  431.          wprints (13, 20, CYAN|_BLACK, (nevt.echomail & ECHO_FORCECALL) ? "Yes" : "No");
  432.          if (nevt.behavior & MAT_RESERV) {
  433.             sprintf (string, "%d:%d/%d", nevt.res_zone, nevt.res_net, nevt.res_node);
  434.             wprints (14, 20, CYAN|_BLACK, string);
  435.          }
  436.       }
  437.  
  438.       start_update ();
  439.       i = getxch ();
  440.       if ( (i & 0xFF) != 0 )
  441.          i &= 0xFF;
  442.  
  443.       switch (i) {
  444.          // PgDn
  445.          case 0x5100:
  446.             if (readed)
  447.                read (fd, (char *)&nevt, sizeof (EVENT));
  448.             break;
  449.  
  450.          // PgUp
  451.          case 0x4900:
  452.             if (readed) {
  453.                if (tell (fd) > sizeof (EVENT)) {
  454.                   lseek (fd, -2L * sizeof (EVENT), SEEK_CUR);
  455.                   read (fd, (char *)&nevt, sizeof (EVENT));
  456.                }
  457.             }
  458.             break;
  459.  
  460.          // C Copy
  461.          case 'C':
  462.          case 'c':
  463.             wh2 = wh;
  464.  
  465.             nevt.cmd[0] = '\0';
  466.             minute = nevt.minute = 0;
  467.             length = nevt.length = 0;
  468.             days = nevt.days = 0;
  469.             i = 1;
  470.  
  471.             wh = wopen (11, 28, 18, 76, 1, LCYAN|_BLACK, CYAN|_BLACK);
  472.             wactiv (wh);
  473.             wshadow (DGREY|_BLACK);
  474.             wtitle (" Copy event ", TRIGHT, YELLOW|_BLUE);
  475.  
  476.             do {
  477.                stop_update ();
  478.                wclear ();
  479.  
  480.                wmenubegc ();
  481.                wmenuitem ( 1,  1, " Title       ", 0,  1, 0, NULL, 0, 0);
  482.                wmenuitem ( 2,  1, " Days        ", 0,  2, 0, NULL, 0, 0);
  483.                wmenuitem ( 3,  1, " Start time  ", 0,  3, 0, NULL, 0, 0);
  484.                wmenuitem ( 4,  1, " Stop time   ", 0,  4, 0, NULL, 0, 0);
  485.                wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  486.  
  487.                wprints (1, 15, CYAN|_BLACK, nevt.cmd);
  488.                strcpy (string, "-------");
  489.                if (nevt.days & DAY_SUNDAY)
  490.                   string[0] = 'S';
  491.                if (nevt.days & DAY_MONDAY)
  492.                   string[1] = 'M';
  493.                if (nevt.days & DAY_TUESDAY)
  494.                   string[2] = 'T';
  495.                if (nevt.days & DAY_WEDNESDAY)
  496.                   string[3] = 'W';
  497.                if (nevt.days & DAY_THURSDAY)
  498.                   string[4] = 'T';
  499.                if (nevt.days & DAY_FRIDAY)
  500.                   string[5] = 'F';
  501.                if (nevt.days & DAY_SATURDAY)
  502.                   string[6] = 'S';
  503.                wprints (2, 15, CYAN|_BLACK, string);
  504.                sprintf (string, "%02d:%02d", nevt.minute / 60, nevt.minute % 60);
  505.                wprints (3, 15, CYAN|_BLACK, string);
  506.                m = nevt.minute + nevt.length;
  507.                sprintf (string, "%02d:%02d", m / 60, m % 60);
  508.                wprints (4, 15, CYAN|_BLACK, string);
  509.  
  510.                start_update ();
  511.                i = wmenuget ();
  512.  
  513.                switch (i) {
  514.                   case 1:
  515.                      strcpy (string, nevt.cmd);
  516.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  517.                      winpdef (1, 15, string, "??????????????????????????????", 0, 2, NULL, 0);
  518.                      if (winpread () != W_ESCPRESS)
  519.                         strcpy (nevt.cmd, strbtrim (string));
  520.                      break;
  521.  
  522.                   case 2:
  523.                      wh1 = wopen (4, 30, 14, 50, 1, LCYAN|_BLACK, CYAN|_BLACK);
  524.                      wactiv (wh1);
  525.                      wshadow (DGREY|_BLACK);
  526.                      wtitle (" Days ", TRIGHT, YELLOW|_BLUE);
  527.                      i = 1;
  528.  
  529.                      do {
  530.                         stop_update ();
  531.                         wclear ();
  532.  
  533.                         wmenubegc ();
  534.                         wmenuitem ( 1,  1, " Sunday    ", 0, 1, 0, NULL, 0, 0);
  535.                         wmenuitem ( 2,  1, " Monday    ", 0, 2, 0, NULL, 0, 0);
  536.                         wmenuitem ( 3,  1, " Tuesday   ", 0, 3, 0, NULL, 0, 0);
  537.                         wmenuitem ( 4,  1, " Wednesday ", 0, 4, 0, NULL, 0, 0);
  538.                         wmenuitem ( 5,  1, " Thursday  ", 0, 5, 0, NULL, 0, 0);
  539.                         wmenuitem ( 6,  1, " Friday    ", 0, 6, 0, NULL, 0, 0);
  540.                         wmenuitem ( 7,  1, " Saturday  ", 0, 7, 0, NULL, 0, 0);
  541.                         wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  542.  
  543.                         if (nevt.days & DAY_SUNDAY)
  544.                            wprints (1, 13, CYAN|_BLACK, "Yes");
  545.                         else
  546.                            wprints (1, 13, CYAN|_BLACK, "No");
  547.                         if (nevt.days & DAY_MONDAY)
  548.                            wprints (2, 13, CYAN|_BLACK, "Yes");
  549.                         else
  550.                            wprints (2, 13, CYAN|_BLACK, "No");
  551.                         if (nevt.days & DAY_TUESDAY)
  552.                            wprints (3, 13, CYAN|_BLACK, "Yes");
  553.                         else
  554.                            wprints (3, 13, CYAN|_BLACK, "No");
  555.                         if (nevt.days & DAY_WEDNESDAY)
  556.                            wprints (4, 13, CYAN|_BLACK, "Yes");
  557.                         else
  558.                            wprints (4, 13, CYAN|_BLACK, "No");
  559.                         if (nevt.days & DAY_THURSDAY)
  560.                            wprints (5, 13, CYAN|_BLACK, "Yes");
  561.                         else
  562.                            wprints (5, 13, CYAN|_BLACK, "No");
  563.                         if (nevt.days & DAY_FRIDAY)
  564.                            wprints (6, 13, CYAN|_BLACK, "Yes");
  565.                         else
  566.                            wprints (6, 13, CYAN|_BLACK, "No");
  567.                         if (nevt.days & DAY_SATURDAY)
  568.                            wprints (7, 13, CYAN|_BLACK, "Yes");
  569.                         else
  570.                            wprints (7, 13, CYAN|_BLACK, "No");
  571.  
  572.                         start_update ();
  573.                         i = wmenuget ();
  574.  
  575.                         switch (i) {
  576.                            case 1:
  577.                               nevt.days ^= DAY_SUNDAY;
  578.                               break;
  579.  
  580.                            case 2:
  581.                               nevt.days ^= DAY_MONDAY;
  582.                               break;
  583.  
  584.                            case 3:
  585.                               nevt.days ^= DAY_TUESDAY;
  586.                               break;
  587.  
  588.                            case 4:
  589.                               nevt.days ^= DAY_WEDNESDAY;
  590.                               break;
  591.  
  592.                            case 5:
  593.                               nevt.days ^= DAY_THURSDAY;
  594.                               break;
  595.  
  596.                            case 6:
  597.                               nevt.days ^= DAY_FRIDAY;
  598.                               break;
  599.  
  600.                            case 7:
  601.                               nevt.days ^= DAY_SATURDAY;
  602.                               break;
  603.                         }
  604.  
  605.                      } while (i != -1);
  606.  
  607.                      wclose ();
  608.  
  609.                      i = 2;
  610.                      break;
  611.  
  612.                   case 3:
  613.                      sprintf (string, "%02d:%02d", nevt.minute / 60, nevt.minute % 60);
  614.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  615.                      winpdef (3, 15, string, "??????", 0, 2, NULL, 0);
  616.                      if (winpread () != W_ESCPRESS) {
  617.                         sscanf (string, "%d:%d", &t1, &t2);
  618.                         nevt.minute = t1 * 60 + t2;
  619.                      }
  620.                      break;
  621.  
  622.                   case 4:
  623.                      m = nevt.minute + nevt.length;
  624.                      sprintf (string, "%02d:%02d", m / 60, m % 60);
  625.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  626.                      winpdef (4, 15, string, "??????", 0, 2, NULL, 0);
  627.                      if (winpread () != W_ESCPRESS) {
  628.                         sscanf (string, "%d:%d", &t1, &t2);
  629.                         m = t1 * 60 + t2;
  630.                         nevt.length = m - nevt.minute;
  631.                      }
  632.                      break;
  633.                }
  634.  
  635.                hidecur ();
  636.             } while (i != -1);
  637.  
  638.             wclose ();
  639.             wh = wh2;
  640.             wactiv (wh);
  641.  
  642.             if (nevt.minute != minute || nevt.length != length || nevt.days != days) {
  643.                wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  644.                wactiv (wh1);
  645.                wshadow (DGREY|_BLACK);
  646.  
  647.                wcenters (1, BLACK|_LGREY, "Save changes (Y/n) ?  ");
  648.  
  649.                strcpy (string, "Y");
  650.                winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  651.                winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  652.  
  653.                i = winpread ();
  654.                wclose ();
  655.                hidecur ();
  656.  
  657.                if (i == W_ESCPRESS || toupper (string[0]) == 'N') {
  658.                   i = 'C';
  659.                   break;
  660.                }
  661.  
  662.                nevt.last_ran = 0;
  663.  
  664.                pos = tell (fd) - (long)sizeof (EVENT);
  665.                close (fd);
  666.  
  667.                unlink ("SCHED.BAK");
  668.                rename (config.sched_name, "SCHED.BAK");
  669.  
  670.                fd = open ("SCHED.BAK", O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  671.                fdi = open (config.sched_name, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  672.                saved = 0;
  673.  
  674.                while (read (fd, (char *)&bnevt, sizeof (EVENT)) == sizeof (EVENT)) {
  675.                   if (!saved && (nevt.minute + nevt.length) <= (bnevt.minute + bnevt.length)) {
  676.                      pos = tell (fdi);
  677.                      write (fdi, (char *)&nevt, sizeof (EVENT));
  678.                      saved = 1;
  679.                   }
  680.                   if (bnevt.minute != minute || bnevt.length != length || bnevt.days != days)
  681.                      write (fdi, (char *)&bnevt, sizeof (EVENT));
  682.                }
  683.  
  684.                if (!saved) {
  685.                   pos = tell (fdi);
  686.                   write (fdi, (char *)&nevt, sizeof (EVENT));
  687.                }
  688.  
  689.                close (fd);
  690.                close (fdi);
  691.  
  692.                unlink ("SCHED.BAK");
  693.  
  694.                fd = open (config.sched_name, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  695.                lseek (fd, pos, SEEK_SET);
  696.                read (fd, (char *)&nevt, sizeof (EVENT));
  697.             }
  698.             else {
  699.                lseek (fd, -1L * sizeof (EVENT), SEEK_CUR);
  700.                read (fd, (char *)&nevt, sizeof (EVENT));
  701.             }
  702.  
  703.             i = 'C';
  704.             break;
  705.  
  706.          // E Edit
  707.          case 'E':
  708.          case 'e':
  709.             if (readed) {
  710.                minute = nevt.minute;
  711.                length = nevt.length;
  712.                days = nevt.days;
  713.  
  714.                edit_single_event (&nevt);
  715.  
  716.                if (nevt.minute != minute || nevt.length != length) {
  717.                   pos = tell (fd) - (long)sizeof (EVENT);
  718.                   close (fd);
  719.  
  720.                   unlink ("SCHED.BAK");
  721.                   rename (config.sched_name, "SCHED.BAK");
  722.  
  723.                   fd = open ("SCHED.BAK", O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  724.                   fdi = open (config.sched_name, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  725.                   saved = 0;
  726.  
  727.                   while (read (fd, (char *)&bnevt, sizeof (EVENT)) == sizeof (EVENT)) {
  728.                      if (!saved && (nevt.minute + nevt.length) <= (bnevt.minute + bnevt.length)) {
  729.                         pos = tell (fdi);
  730.                         write (fdi, (char *)&nevt, sizeof (EVENT));
  731.                         saved = 1;
  732.                      }
  733.                      if (bnevt.minute != minute || bnevt.length != length || bnevt.days != days)
  734.                         write (fdi, (char *)&bnevt, sizeof (EVENT));
  735.                   }
  736.  
  737.                   if (!saved) {
  738.                      pos = tell (fdi);
  739.                      write (fdi, (char *)&nevt, sizeof (EVENT));
  740.                   }
  741.  
  742.                   close (fd);
  743.                   close (fdi);
  744.  
  745.                   unlink ("SCHED.BAK");
  746.  
  747.                   fd = open (config.sched_name, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  748.                   lseek (fd, pos, SEEK_SET);
  749.                   read (fd, (char *)&nevt, sizeof (EVENT));
  750.                }
  751.                else {
  752.                   lseek (fd, -1L * sizeof (EVENT), SEEK_CUR);
  753.                   write (fd, (char *)&nevt, sizeof (EVENT));
  754.                }
  755.             }
  756.             break;
  757.  
  758.          // L List
  759.          case 'L':
  760.          case 'l':
  761.             if (readed)
  762.                select_event_list (fd, &nevt);
  763.             break;
  764.  
  765.          // A Add
  766.          case 'A':
  767.          case 'a':
  768.             memset ((char *)&nevt, 0, sizeof (EVENT));
  769.             minute = nevt.minute;
  770.             length = nevt.length;
  771.             days = nevt.days = 0x7F;
  772.  
  773.             edit_single_event (&nevt);
  774.  
  775.             if (nevt.minute != minute || nevt.length != length || nevt.days != days) {
  776.                pos = tell (fd) - (long)sizeof (EVENT);
  777.                close (fd);
  778.  
  779.                unlink ("SCHED.BAK");
  780.                rename (config.sched_name, "SCHED.BAK");
  781.  
  782.                fd = open ("SCHED.BAK", O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  783.                fdi = open (config.sched_name, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  784.                saved = 0;
  785.  
  786.                while (read (fd, (char *)&bnevt, sizeof (EVENT)) == sizeof (EVENT)) {
  787.                   if (!saved && (nevt.minute + nevt.length) <= (bnevt.minute + bnevt.length)) {
  788.                      pos = tell (fdi);
  789.                      write (fdi, (char *)&nevt, sizeof (EVENT));
  790.                      saved = 1;
  791.                   }
  792.                   if (bnevt.minute != minute || bnevt.length != length || bnevt.days != days)
  793.                      write (fdi, (char *)&bnevt, sizeof (EVENT));
  794.                }
  795.  
  796.                if (!saved) {
  797.                   pos = tell (fdi);
  798.                   write (fdi, (char *)&nevt, sizeof (EVENT));
  799.                }
  800.  
  801.                close (fd);
  802.                close (fdi);
  803.  
  804.                unlink ("SCHED.BAK");
  805.  
  806.                fd = open (config.sched_name, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  807.                lseek (fd, pos, SEEK_SET);
  808.                read (fd, (char *)&nevt, sizeof (EVENT));
  809.             }
  810.             else {
  811.                lseek (fd, -1L * sizeof (EVENT), SEEK_CUR);
  812.                read (fd, (char *)&nevt, sizeof (EVENT));
  813.             }
  814.             break;
  815.  
  816.          // D Delete
  817.          case 'D':
  818.          case 'd':
  819.             wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  820.             wactiv (wh1);
  821.             wshadow (DGREY|_BLACK);
  822.  
  823.             wcenters (1, BLACK|_LGREY, "Are you sure (Y/n) ?  ");
  824.  
  825.             strcpy (string, "Y");
  826.             winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  827.             winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  828.  
  829.             i = winpread ();
  830.             wclose ();
  831.             hidecur ();
  832.  
  833.             if (i == W_ESCPRESS)
  834.                break;
  835.  
  836.             if (toupper (string[0]) == 'Y') {
  837.                minute = nevt.minute;
  838.                length = nevt.length;
  839.                days = nevt.days;
  840.  
  841.                pos = tell (fd) - (long)sizeof (EVENT);
  842.                close (fd);
  843.  
  844.                unlink ("SCHED.BAK");
  845.                rename (config.sched_name, "SCHED.BAK");
  846.  
  847.                fd = open ("SCHED.BAK", O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  848.                fdi = open (config.sched_name, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  849.                saved = 0;
  850.  
  851.                while (read (fd, (char *)&bnevt, sizeof (EVENT)) == sizeof (EVENT)) {
  852.                   if (bnevt.minute != minute || bnevt.length != length || bnevt.days != days)
  853.                      write (fdi, (char *)&bnevt, sizeof (EVENT));
  854.                }
  855.  
  856.                close (fd);
  857.                close (fdi);
  858.  
  859.                unlink ("SCHED.BAK");
  860.  
  861.                fd = open (config.sched_name, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  862.                if (lseek (fd, pos, SEEK_SET) == -1 || pos == filelength (fd)) {
  863.                   lseek (fd, -1l * sizeof (EVENT), SEEK_END);
  864.                   pos = tell (fd);
  865.                }
  866.                read (fd, (char *)&nevt, sizeof (EVENT));
  867.             }
  868.             break;
  869.  
  870.          // ESC Exit
  871.          case 0x1B:
  872.             i = -1;
  873.             break;
  874.       }
  875.  
  876.    } while (i != -1);
  877.  
  878.    close (fd);
  879.  
  880.    wclose ();
  881.    gotoxy_ (24, 1);
  882.    clreol_ ();
  883. }
  884.  
  885. void select_event_list (fd, nevt)
  886. int fd;
  887. EVENT *nevt;
  888. {
  889.    int wh, i, start, stop, beg = 0;
  890.    char string[128], *array[50], days[10];
  891.    EVENT evt;
  892.  
  893.    wh = wopen (4, 0, 21, 77, 1, LCYAN|_BLACK, CYAN|_BLACK);
  894.    wactiv (wh);
  895.    wshadow (DGREY|_BLACK);
  896.    wtitle (" Events ", TRIGHT, YELLOW|_BLUE);
  897.  
  898.    wprints (0, 0, LGREY|_BLACK, "  #  Title                    Days     Start   Stop    Lev   Try   Fail ");
  899.    whline (1, 0, 76, 0, BLUE|_BLACK);
  900.  
  901.    gotoxy_ (24, 1);
  902.    clreol_ ();
  903.    prints (24, 1, LGREY|_BLACK, "-Move bar  ENTER-Select");
  904.    prints (24, 1, YELLOW|_BLACK, "");
  905.    prints (24, 14, YELLOW|_BLACK, "ENTER");
  906.  
  907.    i = 0;
  908.    start = 0;
  909.    lseek (fd, 0L, SEEK_SET);
  910.  
  911.    while (read (fd, (char *)&evt, sizeof (EVENT)) == sizeof (EVENT)) {
  912.       if (memcmp ((char *)&evt, (char *)nevt, sizeof (EVENT)) == 0)
  913.          beg = i;
  914.       strcpy (days, "-------");
  915.       if (evt.days & DAY_SUNDAY)
  916.          days[0] = 'S';
  917.       if (evt.days & DAY_MONDAY)
  918.          days[1] = 'M';
  919.       if (evt.days & DAY_TUESDAY)
  920.          days[2] = 'T';
  921.       if (evt.days & DAY_WEDNESDAY)
  922.          days[3] = 'W';
  923.       if (evt.days & DAY_THURSDAY)
  924.          days[4] = 'T';
  925.       if (evt.days & DAY_FRIDAY)
  926.          days[5] = 'F';
  927.       if (evt.days & DAY_SATURDAY)
  928.          days[6] = 'S';
  929.       start = evt.minute;
  930.       stop = evt.minute + evt.length;
  931.       sprintf (string, "  %-2d  %-22.22s  %s  %2d:%02d   %2d:%02d   %3d   %3d    %3d    ", i + 1, evt.cmd, days, start / 60, start % 60, stop / 60, stop % 60, evt.errlevel[0], evt.no_connect, evt.with_connect);
  932.       array[i] = (char *)malloc (strlen (string) + 1);
  933.       if (array[i] == NULL)
  934.          break;
  935.       strcpy (array[i++], string);
  936.    }
  937.  
  938.    array[i] = NULL;
  939.  
  940.    i = wpickstr (7, 1, 20, 76, 5, LGREY|_BLACK, CYAN|_BLACK, BLUE|_LGREY, array, beg, NULL);
  941.  
  942.    if (i != -1) {
  943.       lseek (fd, (long)sizeof (EVENT) * (long)i, SEEK_SET);
  944.       read (fd, (char *)nevt, sizeof (EVENT));
  945.    }
  946.  
  947.    wclose ();
  948.  
  949.    gotoxy_ (24, 1);
  950.    clreol_ ();
  951.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Event  L-List  D-Delete  C-Copy");
  952.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  953.    prints (24, 26, YELLOW|_BLACK, "E");
  954.    prints (24, 34, YELLOW|_BLACK, "A");
  955.    prints (24, 51, YELLOW|_BLACK, "L");
  956.    prints (24, 59, YELLOW|_BLACK, "D");
  957.    prints (24, 69, YELLOW|_BLACK, "C");
  958. }
  959.  
  960. static void edit_single_event (evt)
  961. EVENT *evt;
  962. {
  963.    int i = 1, wh1, m, wh, t1, t2;
  964.    char string[128], *p;
  965.    EVENT nevt;
  966.  
  967.    memcpy ((char *)&nevt, (char *)evt, sizeof (EVENT));
  968.  
  969.    gotoxy_ (24, 1);
  970.    clreol_ ();
  971.    prints (24, 1, LGREY|_BLACK, "ESC-Exit/Save  ENTER-Edit");
  972.    prints (24, 1, YELLOW|_BLACK, "ESC");
  973.    prints (24, 16, YELLOW|_BLACK, "ENTER");
  974.  
  975.    wh = wopen (3, 11, 21, 65, 1, LCYAN|_BLACK, CYAN|_BLACK);
  976.    wactiv (wh);
  977.    wshadow (DGREY|_BLACK);
  978.    wtitle (" Edit event ", TRIGHT, YELLOW|_BLUE);
  979.  
  980. continue_editing:
  981.    do {
  982.       stop_update ();
  983.       wclear ();
  984.  
  985.       wmenubegc ();
  986.       wmenuitem ( 1,  1, " Title            ", 0,  1, 0, NULL, 0, 0);
  987.       wmenuitem ( 2,  1, " Days             ", 0,  2, 0, NULL, 0, 0);
  988.       wmenuitem ( 3,  1, " Start time       ", 0,  3, 0, NULL, 0, 0);
  989.       wmenuitem ( 4,  1, " Stop time        ", 0,  4, 0, NULL, 0, 0);
  990.       wmenuitem ( 5,  1, " Forced           ", 0,  5, 0, NULL, 0, 0);
  991.       wmenuitem ( 6,  1, " Allow humans     ", 0,  6, 0, NULL, 0, 0);
  992.       wmenuitem ( 7,  1, " Errorlevel       ", 0,  7, 0, NULL, 0, 0);
  993.       wmenuitem ( 8,  1, " Clock adjustment ", 0,  8, 0, NULL, 0, 0);
  994.       wmenuitem ( 9,  1, " Receive only     ", 0,  9, 0, NULL, 0, 0);
  995.       wmenuitem (10,  1, " ├ Max try        ", 0, 10, 0, NULL, 0, 0);
  996.       wmenuitem (11,  1, " ├ Max failed     ", 0, 11, 0, NULL, 0, 0);
  997.       wmenuitem (12,  1, " └ Retry delay    ", 0, 12, 0, NULL, 0, 0);
  998.       wmenuitem (13,  1, " Forced poll      ", 0, 14, 0, NULL, 0, 0);
  999.       wmenuitem (14,  1, " └ Reserved node  ", 0, 15, 0, NULL, 0, 0);
  1000.       wmenuitem (15,  1, " Mail behavior    ", 0, 13, 0, NULL, 0, 0);
  1001.  
  1002.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1003.  
  1004.       wprints (1, 20, CYAN|_BLACK, nevt.cmd);
  1005.       strcpy (string, "-------");
  1006.       if (nevt.days & DAY_SUNDAY)
  1007.          string[0] = 'S';
  1008.       if (nevt.days & DAY_MONDAY)
  1009.          string[1] = 'M';
  1010.       if (nevt.days & DAY_TUESDAY)
  1011.          string[2] = 'T';
  1012.       if (nevt.days & DAY_WEDNESDAY)
  1013.          string[3] = 'W';
  1014.       if (nevt.days & DAY_THURSDAY)
  1015.          string[4] = 'T';
  1016.       if (nevt.days & DAY_FRIDAY)
  1017.          string[5] = 'F';
  1018.       if (nevt.days & DAY_SATURDAY)
  1019.          string[6] = 'S';
  1020.       wprints (2, 20, CYAN|_BLACK, string);
  1021.       sprintf (string, "%02d:%02d", nevt.minute / 60, nevt.minute % 60);
  1022.       wprints (3, 20, CYAN|_BLACK, string);
  1023.       m = nevt.minute + nevt.length;
  1024.       sprintf (string, "%02d:%02d", m / 60, m % 60);
  1025.       wprints (4, 20, CYAN|_BLACK, string);
  1026.       if (nevt.behavior & MAT_FORCED)
  1027.          wprints (5, 20, CYAN|_BLACK, "Yes");
  1028.       else
  1029.          wprints (5, 20, CYAN|_BLACK, "No");
  1030.       if (nevt.behavior & MAT_BBS)
  1031.          wprints (6, 20, CYAN|_BLACK, "Yes");
  1032.       else
  1033.          wprints (6, 20, CYAN|_BLACK, "No");
  1034.       sprintf (string, "%d", nevt.errlevel[0]);
  1035.       wprints (7, 20, CYAN|_BLACK, string);
  1036.       if (nevt.behavior & MAT_RESYNC)
  1037.          wprints (8, 20, CYAN|_BLACK, "Yes");
  1038.       else
  1039.          wprints (8, 20, CYAN|_BLACK, "No");
  1040.       if (nevt.behavior & MAT_NOOUT)
  1041.          wprints (9, 20, CYAN|_BLACK, "Yes");
  1042.       else
  1043.          wprints (9, 20, CYAN|_BLACK, "No");
  1044.       sprintf (string, "%d", nevt.no_connect);
  1045.       wprints (10, 20, CYAN|_BLACK, string);
  1046.       sprintf (string, "%d", nevt.with_connect);
  1047.       wprints (11, 20, CYAN|_BLACK, string);
  1048.       sprintf (string, "%d", nevt.wait_time);
  1049.       wprints (12, 20, CYAN|_BLACK, string);
  1050.       wprints (13, 20, CYAN|_BLACK, (nevt.echomail & ECHO_FORCECALL) ? "Yes" : "No");
  1051.       if (nevt.behavior & MAT_RESERV) {
  1052.          sprintf (string, "%d:%d/%d", nevt.res_zone, nevt.res_net, nevt.res_node);
  1053.          wprints (14, 20, CYAN|_BLACK, string);
  1054.       }
  1055.  
  1056.       start_update ();
  1057.       i = wmenuget ();
  1058.  
  1059.       switch (i) {
  1060.          case 1:
  1061.             strcpy (string, nevt.cmd);
  1062.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1063.             winpdef (1, 20, string, "??????????????????????????????", 0, 2, NULL, 0);
  1064.             if (winpread () != W_ESCPRESS)
  1065.                strcpy (nevt.cmd, strbtrim (string));
  1066.             break;
  1067.  
  1068.          case 2:
  1069.             wh1 = wopen (4, 30, 14, 50, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1070.             wactiv (wh1);
  1071.             wshadow (DGREY|_BLACK);
  1072.             wtitle (" Days ", TRIGHT, YELLOW|_BLUE);
  1073.             i = 1;
  1074.  
  1075.             do {
  1076.                stop_update ();
  1077.                wclear ();
  1078.  
  1079.                wmenubegc ();
  1080.                wmenuitem ( 1,  1, " Sunday    ", 0, 1, 0, NULL, 0, 0);
  1081.                wmenuitem ( 2,  1, " Monday    ", 0, 2, 0, NULL, 0, 0);
  1082.                wmenuitem ( 3,  1, " Tuesday   ", 0, 3, 0, NULL, 0, 0);
  1083.                wmenuitem ( 4,  1, " Wednesday ", 0, 4, 0, NULL, 0, 0);
  1084.                wmenuitem ( 5,  1, " Thursday  ", 0, 5, 0, NULL, 0, 0);
  1085.                wmenuitem ( 6,  1, " Friday    ", 0, 6, 0, NULL, 0, 0);
  1086.                wmenuitem ( 7,  1, " Saturday  ", 0, 7, 0, NULL, 0, 0);
  1087.                wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1088.  
  1089.                if (nevt.days & DAY_SUNDAY)
  1090.                   wprints (1, 13, CYAN|_BLACK, "Yes");
  1091.                else
  1092.                   wprints (1, 13, CYAN|_BLACK, "No");
  1093.                if (nevt.days & DAY_MONDAY)
  1094.                   wprints (2, 13, CYAN|_BLACK, "Yes");
  1095.                else
  1096.                   wprints (2, 13, CYAN|_BLACK, "No");
  1097.                if (nevt.days & DAY_TUESDAY)
  1098.                   wprints (3, 13, CYAN|_BLACK, "Yes");
  1099.                else
  1100.                   wprints (3, 13, CYAN|_BLACK, "No");
  1101.                if (nevt.days & DAY_WEDNESDAY)
  1102.                   wprints (4, 13, CYAN|_BLACK, "Yes");
  1103.                else
  1104.                   wprints (4, 13, CYAN|_BLACK, "No");
  1105.                if (nevt.days & DAY_THURSDAY)
  1106.                   wprints (5, 13, CYAN|_BLACK, "Yes");
  1107.                else
  1108.                   wprints (5, 13, CYAN|_BLACK, "No");
  1109.                if (nevt.days & DAY_FRIDAY)
  1110.                   wprints (6, 13, CYAN|_BLACK, "Yes");
  1111.                else
  1112.                   wprints (6, 13, CYAN|_BLACK, "No");
  1113.                if (nevt.days & DAY_SATURDAY)
  1114.                   wprints (7, 13, CYAN|_BLACK, "Yes");
  1115.                else
  1116.                   wprints (7, 13, CYAN|_BLACK, "No");
  1117.  
  1118.                start_update ();
  1119.                i = wmenuget ();
  1120.  
  1121.                switch (i) {
  1122.                   case 1:
  1123.                      nevt.days ^= DAY_SUNDAY;
  1124.                      break;
  1125.  
  1126.                   case 2:
  1127.                      nevt.days ^= DAY_MONDAY;
  1128.                      break;
  1129.  
  1130.                   case 3:
  1131.                      nevt.days ^= DAY_TUESDAY;
  1132.                      break;
  1133.  
  1134.                   case 4:
  1135.                      nevt.days ^= DAY_WEDNESDAY;
  1136.                      break;
  1137.  
  1138.                   case 5:
  1139.                      nevt.days ^= DAY_THURSDAY;
  1140.                      break;
  1141.  
  1142.                   case 6:
  1143.                      nevt.days ^= DAY_FRIDAY;
  1144.                      break;
  1145.  
  1146.                   case 7:
  1147.                      nevt.days ^= DAY_SATURDAY;
  1148.                      break;
  1149.                }
  1150.  
  1151.             } while (i != -1);
  1152.  
  1153.             wclose ();
  1154.  
  1155.             i = 2;
  1156.             break;
  1157.  
  1158.          case 3:
  1159.             sprintf (string, "%02d:%02d", nevt.minute / 60, nevt.minute % 60);
  1160.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1161.             winpdef (3, 20, string, "??????", 0, 2, NULL, 0);
  1162.             if (winpread () != W_ESCPRESS) {
  1163.                sscanf (string, "%d:%d", &t1, &t2);
  1164.                nevt.minute = t1 * 60 + t2;
  1165.             }
  1166.             break;
  1167.  
  1168.          case 4:
  1169.             m = nevt.minute + nevt.length;
  1170.             sprintf (string, "%02d:%02d", m / 60, m % 60);
  1171.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1172.             winpdef (4, 20, string, "??????", 0, 2, NULL, 0);
  1173.             if (winpread () != W_ESCPRESS) {
  1174.                sscanf (string, "%d:%d", &t1, &t2);
  1175.                m = t1 * 60 + t2;
  1176.                nevt.length = m - nevt.minute;
  1177.             }
  1178.             break;
  1179.  
  1180.          case 5:
  1181.             nevt.behavior ^= MAT_FORCED;
  1182.             break;
  1183.  
  1184.          case 6:
  1185.             nevt.behavior ^= MAT_BBS;
  1186.             break;
  1187.  
  1188.          case 7:
  1189.             sprintf (string, "%d", nevt.errlevel[0]);
  1190.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1191.             winpdef (7, 20, string, "??????", 0, 2, NULL, 0);
  1192.             if (winpread () != W_ESCPRESS)
  1193.                nevt.errlevel[0] = atoi (string) % 256;
  1194.             break;
  1195.  
  1196.          case 8:
  1197.             nevt.behavior ^= MAT_RESYNC;
  1198.             break;
  1199.  
  1200.          case 9:
  1201.             nevt.behavior ^= MAT_NOOUT;
  1202.             break;
  1203.  
  1204.          case 10:
  1205.             sprintf (string, "%d", nevt.no_connect);
  1206.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1207.             winpdef (10, 20, string, "??????", 0, 2, NULL, 0);
  1208.             if (winpread () != W_ESCPRESS)
  1209.                nevt.no_connect = atoi (string);
  1210.             break;
  1211.  
  1212.          case 11:
  1213.             sprintf (string, "%d", nevt.with_connect);
  1214.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1215.             winpdef (11, 20, string, "??????", 0, 2, NULL, 0);
  1216.             if (winpread () != W_ESCPRESS)
  1217.                nevt.with_connect = atoi (string);
  1218.             break;
  1219.  
  1220.          case 12:
  1221.             sprintf (string, "%d", nevt.wait_time);
  1222.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1223.             winpdef (12, 20, string, "??????", 0, 2, NULL, 0);
  1224.             if (winpread () != W_ESCPRESS)
  1225.                nevt.wait_time = atoi (string);
  1226.             break;
  1227.  
  1228.          case 13:
  1229.             wh1 = wopen (4, 26, 21, 74, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1230.             wactiv (wh1);
  1231.             wshadow (DGREY|_BLACK);
  1232.             wtitle (" Mail behavior ", TRIGHT, YELLOW|_BLUE);
  1233.             i = 1;
  1234.  
  1235.             do {
  1236.                stop_update ();
  1237.                wclear ();
  1238.  
  1239.                wmenubegc ();
  1240.                wmenuitem ( 1,  1, " Allow file requests         ", 0,  1, 0, NULL, 0, 0);
  1241.                wmenuitem ( 2,  1, " Make file requests          ", 0,  2, 0, NULL, 0, 0);
  1242.                wmenuitem ( 3,  1, " Send to CM systems only     ", 0,  3, 0, NULL, 0, 0);
  1243.                wmenuitem ( 4,  1, " Send to non-CM systems only ", 0,  4, 0, NULL, 0, 0);
  1244.                wmenuitem ( 5,  1, " Import normal mail          ", 0,  9, 0, NULL, 0, 0);
  1245.                wmenuitem ( 6,  1, " Import know mail            ", 0, 10, 0, NULL, 0, 0);
  1246.                wmenuitem ( 7,  1, " Import prot mail            ", 0, 11, 0, NULL, 0, 0);
  1247.                wmenuitem ( 8,  1, " Export mail                 ", 0,  6, 0, NULL, 0, 0);
  1248.                wmenuitem ( 9,  1, " Import at start of event    ", 0,  7, 0, NULL, 0, 0);
  1249.                wmenuitem (10,  1, " Export at start of event    ", 0,  8, 0, NULL, 0, 0);
  1250.                wmenuitem (11,  1, " Dynamic                     ", 0, 13, 0, NULL, 0, 0);
  1251.                wmenuitem (12,  1, " Route TAG                   ", 0, 14, 0, NULL, 0, 0);
  1252.                wmenuitem (13,  1, " AfterMail exit errorlevel   ", 0, 15, 0, NULL, 0, 0);
  1253.                wmenuitem (14,  1, " Process TIC files           ", 0, 16, 0, NULL, 0, 0);
  1254.                wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1255.  
  1256.                if (nevt.behavior & MAT_NOREQ)
  1257.                   wprints (1, 31, CYAN|_BLACK, "No");
  1258.                else
  1259.                   wprints (1, 31, CYAN|_BLACK, "Yes");
  1260.                if (nevt.behavior & MAT_NOOUTREQ)
  1261.                   wprints (2, 31, CYAN|_BLACK, "No");
  1262.                else
  1263.                   wprints (2, 31, CYAN|_BLACK, "Yes");
  1264.                if (nevt.behavior & MAT_CM)
  1265.                   wprints (3, 31, CYAN|_BLACK, "Yes");
  1266.                else
  1267.                   wprints (3, 31, CYAN|_BLACK, "No");
  1268.                if (nevt.behavior & MAT_NOCM)
  1269.                   wprints (4, 31, CYAN|_BLACK, "Yes");
  1270.                else
  1271.                   wprints (4, 31, CYAN|_BLACK, "No");
  1272.                if (nevt.echomail & ECHO_NORMAL)
  1273.                   wprints (5, 31, CYAN|_BLACK, "Yes");
  1274.                else
  1275.                   wprints (5, 31, CYAN|_BLACK, "No");
  1276.                if (nevt.echomail & ECHO_KNOW)
  1277.                   wprints (6, 31, CYAN|_BLACK, "Yes");
  1278.                else
  1279.                   wprints (6, 31, CYAN|_BLACK, "No");
  1280.                if (nevt.echomail & ECHO_PROT)
  1281.                   wprints (7, 31, CYAN|_BLACK, "Yes");
  1282.                else
  1283.                   wprints (7, 31, CYAN|_BLACK, "No");
  1284.                if (nevt.echomail & ECHO_EXPORT)
  1285.                   wprints (8, 31, CYAN|_BLACK, "Yes");
  1286.                else
  1287.                   wprints (8, 31, CYAN|_BLACK, "No");
  1288.                if (nevt.echomail & ECHO_STARTIMPORT)
  1289.                   wprints (9, 31, CYAN|_BLACK, "Yes");
  1290.                else
  1291.                   wprints (9, 31, CYAN|_BLACK, "No");
  1292.                if (nevt.echomail & ECHO_STARTEXPORT)
  1293.                   wprints (10, 31, CYAN|_BLACK, "Yes");
  1294.                else
  1295.                   wprints (10, 31, CYAN|_BLACK, "No");
  1296.                if (nevt.behavior & MAT_DYNAM)
  1297.                   wprints (11, 31, CYAN|_BLACK, "Yes");
  1298.                else
  1299.                   wprints (11, 31, CYAN|_BLACK, "No");
  1300.                wprints (12, 31, CYAN|_BLACK, nevt.route_tag);
  1301.                sprintf (string, "%d", nevt.errlevel[2]);
  1302.                wprints (13, 31, CYAN|_BLACK, string);
  1303.                wprints (14, 31, CYAN|_BLACK, (nevt.echomail & ECHO_RESERVED4) ? "Yes" : "No");
  1304.  
  1305.                start_update ();
  1306.                i = wmenuget ();
  1307.  
  1308.                switch (i) {
  1309.                   case 1:
  1310.                      nevt.behavior ^= MAT_NOREQ;
  1311.                      break;
  1312.  
  1313.                   case 2:
  1314.                      nevt.behavior ^= MAT_NOOUTREQ;
  1315.                      break;
  1316.  
  1317.                   case 3:
  1318.                      nevt.behavior ^= MAT_CM;
  1319.                      break;
  1320.  
  1321.                   case 4:
  1322.                      nevt.behavior ^= MAT_NOCM;
  1323.                      break;
  1324.  
  1325.                   case 6:
  1326.                      nevt.echomail ^= ECHO_EXPORT;
  1327.                      break;
  1328.  
  1329.                   case 7:
  1330.                      nevt.echomail ^= ECHO_STARTIMPORT;
  1331.                      break;
  1332.  
  1333.                   case 8:
  1334.                      nevt.echomail ^= ECHO_STARTEXPORT;
  1335.                      break;
  1336.  
  1337.                   case 9:
  1338.                      nevt.echomail ^= ECHO_NORMAL;
  1339.                      break;
  1340.  
  1341.                   case 10:
  1342.                      nevt.echomail ^= ECHO_KNOW;
  1343.                      break;
  1344.  
  1345.                   case 11:
  1346.                      nevt.echomail ^= ECHO_PROT;
  1347.                      break;
  1348.  
  1349.                   case 13:
  1350.                      nevt.behavior ^= MAT_DYNAM;
  1351.                      break;
  1352.  
  1353.                   case 14:
  1354.                      strcpy (string, nevt.route_tag);
  1355.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1356.                      winpdef (12, 31, string, "???????????????", 0, 2, NULL, 0);
  1357.                      if (winpread () != W_ESCPRESS)
  1358.                         strcpy (nevt.route_tag, strupr (strbtrim (string)));
  1359.                      break;
  1360.  
  1361.                   case 15:
  1362.                      sprintf (string, "%d", nevt.errlevel[2]);
  1363.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1364.                      winpdef (13, 31, string, "???", 0, 2, NULL, 0);
  1365.                      if (winpread () != W_ESCPRESS)
  1366.                         nevt.errlevel[2] = atoi (string) % 256;
  1367.                      break;
  1368.  
  1369.                   case 16:
  1370.                      nevt.echomail ^= ECHO_RESERVED4;
  1371.                      break;
  1372.                }
  1373.  
  1374.                hidecur ();
  1375.             } while (i != -1);
  1376.  
  1377.             wclose ();
  1378.  
  1379.             i = 13;
  1380.             break;
  1381.  
  1382.          case 14:
  1383.             nevt.echomail ^= ECHO_FORCECALL;
  1384.             break;
  1385.  
  1386.          case 15:
  1387.             if (nevt.behavior & MAT_RESERV)
  1388.                sprintf (string, "%d:%d/%d", nevt.res_zone, nevt.res_net, nevt.res_node);
  1389.             else
  1390.                strcpy (string, "");
  1391.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1392.             winpdef (14, 20, string, "?????????????????", 0, 2, NULL, 0);
  1393.             if (winpread () != W_ESCPRESS) {
  1394.                p = strtok (strbtrim (string), " ");
  1395.                if (p == NULL || !strlen (p))
  1396.                         nevt.behavior &= ~MAT_RESERV;
  1397.                     else {
  1398.                         int dummy;
  1399.                         nevt.behavior |= MAT_RESERV;
  1400.                         parse_netnode(p,(int *)&nevt.res_zone, (int *)&nevt.res_net, (int *)&nevt.res_node,(int *)&dummy);
  1401. //                sscanf (p, "%d:%d/%d", &nevt.res_zone, &nevt.res_net, &nevt.res_node);
  1402.                     }
  1403.  
  1404.             }
  1405.             break;
  1406.       }
  1407.  
  1408.       hidecur ();
  1409.    } while (i != -1);
  1410.  
  1411.    if (memcmp ((char *)&nevt, (char *)evt, sizeof (EVENT))) {
  1412.       wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  1413.       wactiv (wh1);
  1414.       wshadow (DGREY|_BLACK);
  1415.  
  1416.       wcenters (1, BLACK|_LGREY, "Save changes (Y/n) ?  ");
  1417.  
  1418.       strcpy (string, "Y");
  1419.       winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  1420.       winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  1421.  
  1422.       i = winpread ();
  1423.       wclose ();
  1424.       hidecur ();
  1425.  
  1426.       if (i == W_ESCPRESS)
  1427.          goto continue_editing;
  1428.  
  1429.       if (toupper (string[0]) == 'Y') {
  1430.          nevt.last_ran = 0;
  1431.          memcpy ((char *)evt, (char *)&nevt, sizeof (EVENT));
  1432.       }
  1433.    }
  1434.  
  1435.    wclose ();
  1436.  
  1437.    gotoxy_ (24, 1);
  1438.    clreol_ ();
  1439.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Event  L-List  D-Delete  C-Copy");
  1440.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1441.    prints (24, 26, YELLOW|_BLACK, "E");
  1442.    prints (24, 34, YELLOW|_BLACK, "A");
  1443.    prints (24, 51, YELLOW|_BLACK, "L");
  1444.    prints (24, 59, YELLOW|_BLACK, "D");
  1445.    prints (24, 69, YELLOW|_BLACK, "C");
  1446. }
  1447.  
  1448. static void mailproc_linehelp (void)
  1449. {
  1450.    char *str = "";
  1451.    struct _menu_t *mt;
  1452.  
  1453.    mt = wmenumcurr ();
  1454.    if (mt == NULL)
  1455.       return;
  1456.  
  1457.    switch (mt->citem->tagid) {
  1458.       case 1:
  1459.          str = "Method of packing netmail and echomail";
  1460.          break;
  1461.       case 2:
  1462.          str = "Enable / disable the import of the mail for the Sysop to a separate area";
  1463.          break;
  1464.       case 3:
  1465.          str = "Directory to export to the mail addressed to the Sysop";
  1466.          break;
  1467.       case 4:
  1468.          str = "Enable / disable the replace or link of the tear line on local message";
  1469.          break;
  1470.       case 5:
  1471.          str = "Enable / disable the flashing MAIL flag on the bottom right corner";
  1472.          break;
  1473.       case 6:
  1474.          str = "Always import netmail messages without text";
  1475.          break;
  1476.       case 7:
  1477.          str = "Text to put as tearline when replaced";
  1478.          break;
  1479.       case 8:
  1480.          str = "Forces the insertion of the ^aINTL kludge in netmail messages";
  1481.          break;
  1482.       case 9:
  1483.          str = "Exports Internet-type message areas";
  1484.          break;
  1485.    }
  1486.  
  1487.    clear_window ();
  1488.    prints (24, 1, LGREY|_BLACK, str);
  1489. }
  1490.  
  1491. void mail_processing ()
  1492. {
  1493.    int wh, i = 1;
  1494.    char string[128];
  1495.  
  1496.    wh = wopen (7, 10, 19, 74, 3, LCYAN|_BLACK, CYAN|_BLACK);
  1497.    wactiv (wh);
  1498.    wshadow (DGREY|_BLACK);
  1499.    wtitle (" Mail Processing ", TRIGHT, YELLOW|_BLUE);
  1500.  
  1501.    do {
  1502.       stop_update ();
  1503.       wclear ();
  1504.  
  1505.       wmenubegc ();
  1506.       wmenuitem ( 1,  1, " Method             ", 0,  1, 0, NULL, 0, 0);
  1507.       wmenuiba (mailproc_linehelp, clear_window);
  1508.       wmenuitem ( 2,  1, " Save Sysop mail    ", 0,  2, 0, NULL, 0, 0);
  1509.       wmenuiba (mailproc_linehelp, clear_window);
  1510.       wmenuitem ( 3,  1, " ├─ Sysop Mail Path ", 0,  3, 0, NULL, 0, 0);
  1511.       wmenuiba (mailproc_linehelp, clear_window);
  1512.       wmenuitem ( 4,  1, " └─ Flashing flag   ", 0,  5, 0, NULL, 0, 0);
  1513.       wmenuiba (mailproc_linehelp, clear_window);
  1514.       wmenuitem ( 5,  1, " Replace tear line  ", 0,  4, 0, NULL, 0, 0);
  1515.       wmenuiba (mailproc_linehelp, clear_window);
  1516.       wmenuitem ( 6,  1, " └─ Tear line       ", 0,  7, 0, NULL, 0, 0);
  1517.       wmenuiba (mailproc_linehelp, clear_window);
  1518.       wmenuitem ( 7,  1, " Import empty msgs. ", 0,  6, 0, NULL, 0, 0);
  1519.       wmenuiba (mailproc_linehelp, clear_window);
  1520.       wmenuitem ( 8,  1, " Force INTL line    ", 0,  8, 0, NULL, 0, 0);
  1521.       wmenuiba (mailproc_linehelp, clear_window);
  1522.       wmenuitem ( 9,  1, " Export Internet    ", 0,  9, 0, NULL, 0, 0);
  1523.       wmenuiba (mailproc_linehelp, clear_window);
  1524.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1525.  
  1526.       wprints (1, 22, CYAN|_BLACK, config.mail_method ? "Separate netmail" : "Netmail and echomail together");
  1527.       wprints (2, 22, CYAN|_BLACK, config.save_my_mail ? "Yes" : "No");
  1528.       wprints (3, 22, CYAN|_BLACK, config.my_mail);
  1529.       wprints (4, 22, CYAN|_BLACK, config.mymail_flash ? "Yes" : "No");
  1530.       if (config.replace_tear == 0)
  1531.          wprints (5, 22, CYAN|_BLACK, "No");
  1532.       else if (config.replace_tear == 1)
  1533.          wprints (5, 22, CYAN|_BLACK, "Link (unlimited)");
  1534.       else if (config.replace_tear == 2)
  1535.          wprints (5, 22, CYAN|_BLACK, "Link (limit to 35 char.)");
  1536.       else if (config.replace_tear == 3)
  1537.          wprints (5, 22, CYAN|_BLACK, "Yes");
  1538.       wprints (6, 22, CYAN|_BLACK, config.tearline);
  1539.       wprints (7, 22, CYAN|_BLACK, config.keep_empty ? "Yes" : "No");
  1540.       wprints (8, 22, CYAN|_BLACK, config.force_intl ? "Yes" : "No");
  1541.       wprints (9, 22, CYAN|_BLACK, config.export_internet ? "Yes" : "No");
  1542.  
  1543.       start_update ();
  1544.       i = wmenuget ();
  1545.  
  1546.       switch (i) {
  1547.          case 1:
  1548.             config.mail_method ^= 1;
  1549.             break;
  1550.  
  1551.          case 2:
  1552.             config.save_my_mail ^= 1;
  1553.             break;
  1554.  
  1555.          case 3:
  1556.             strcpy (string, config.my_mail);
  1557.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1558.             winpdef (3, 22, string, "???????????????????????????????????????", 0, 2, NULL, 0);
  1559.             if (winpread () != W_ESCPRESS) {
  1560.                strcpy (config.my_mail, strbtrim (string));
  1561.                if (config.my_mail[0] && config.my_mail[strlen (config.my_mail) - 1] != '\\')
  1562.                   strcat (config.my_mail, "\\");
  1563.                create_path (config.my_mail);
  1564.             }
  1565.             break;
  1566.  
  1567.          case 4:
  1568.             if (config.replace_tear == 0)
  1569.                config.replace_tear = 1;
  1570.             else if (config.replace_tear == 1)
  1571.                config.replace_tear = 2;
  1572.             else if (config.replace_tear == 2)
  1573.                config.replace_tear = 3;
  1574.             else if (config.replace_tear == 3)
  1575.                config.replace_tear = 0;
  1576.             break;
  1577.  
  1578.          case 5:
  1579.             config.mymail_flash ^= 1;
  1580.             break;
  1581.  
  1582.          case 6:
  1583.             config.keep_empty ^= 1;
  1584.             break;
  1585.  
  1586.          case 7:
  1587.             strcpy (string, config.tearline);
  1588.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1589.             winpdef (6, 22, string, "???????????????????????????????????", 0, 2, NULL, 0);
  1590.             if (winpread () != W_ESCPRESS)
  1591.                strcpy (config.tearline, strbtrim (string));
  1592.             break;
  1593.  
  1594.          case 8:
  1595.             config.force_intl ^= 1;
  1596.             break;
  1597.  
  1598.          case 9:
  1599.             config.export_internet ^= 1;
  1600.             break;
  1601.       }
  1602.  
  1603.       hidecur ();
  1604.  
  1605.    } while (i != -1);
  1606.  
  1607.    wclose ();
  1608. }
  1609.  
  1610. static void edit_single_protocol (PROTOCOL *prot)
  1611. {
  1612.    int i = 1, wh1;
  1613.    char string[128];
  1614.    PROTOCOL nprot;
  1615.  
  1616.    memcpy ((char *)&nprot, (char *)prot, sizeof (PROTOCOL));
  1617.  
  1618.    gotoxy_ (24, 1);
  1619.    clreol_ ();
  1620.    prints (24, 1, LGREY|_BLACK, "ESC-Exit/Save  ENTER-Edit");
  1621.    prints (24, 1, YELLOW|_BLACK, "ESC");
  1622.    prints (24, 16, YELLOW|_BLACK, "ENTER");
  1623.  
  1624. continue_editing:
  1625.    do {
  1626.       stop_update ();
  1627.       wclear ();
  1628.  
  1629.       wmenubegc ();
  1630.       wmenuitem ( 1,  1, " Active           ", 0,  1, 0, NULL, 0, 0);
  1631.       wmenuitem ( 2,  1, " Name             ", 0,  2, 0, NULL, 0, 0);
  1632.       wmenuitem ( 3,  1, " Hotkey           ", 0,  3, 0, NULL, 0, 0);
  1633.       wmenuitem ( 4,  1, " Download command ", 0,  4, 0, NULL, 0, 0);
  1634.       wmenuitem ( 5,  1, " Upload command   ", 0,  5, 0, NULL, 0, 0);
  1635.       wmenuitem ( 6,  1, " Log file name    ", 0,  6, 0, NULL, 0, 0);
  1636.       wmenuitem ( 7,  1, " Control file     ", 0,  7, 0, NULL, 0, 0);
  1637.       wmenuitem ( 8,  1, " Download string  ", 0,  8, 0, NULL, 0, 0);
  1638.       wmenuitem ( 9,  1, " Upload string    ", 0,  9, 0, NULL, 0, 0);
  1639.       wmenuitem (10,  1, " Download keyword ", 0, 10, 0, NULL, 0, 0);
  1640.       wmenuitem (11,  1, " Upload keyword   ", 0, 11, 0, NULL, 0, 0);
  1641.       wmenuitem (12,  1, " Filename word    ", 0, 12, 0, NULL, 0, 0);
  1642.       wmenuitem (13,  1, " Size word        ", 0, 13, 0, NULL, 0, 0);
  1643.       wmenuitem (14,  1, " CPS word         ", 0, 14, 0, NULL, 0, 0);
  1644.       wmenuitem (12, 31, " Batch protocol   ", 0, 15, 0, NULL, 0, 0);
  1645.       wmenuitem (13, 31, " Disable FOSSIL   ", 0, 16, 0, NULL, 0, 0);
  1646.       wmenuitem (14, 31, " Change to UL dir ", 0, 17, 0, NULL, 0, 0);
  1647.  
  1648.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1649.  
  1650.       wprints (1, 20, CYAN|_BLACK, nprot.active ? "Yes" : "No");
  1651.       wprints (2, 20, CYAN|_BLACK, nprot.name);
  1652.       sprintf (string, "%c", nprot.hotkey);
  1653.       wprints (3, 20, CYAN|_BLACK, string);
  1654.       wprints (4, 20, CYAN|_BLACK, nprot.dl_command);
  1655.       wprints (5, 20, CYAN|_BLACK, nprot.ul_command);
  1656.       wprints (6, 20, CYAN|_BLACK, nprot.log_name);
  1657.       wprints (7, 20, CYAN|_BLACK, nprot.ctl_name);
  1658.       wprints (8, 20, CYAN|_BLACK, nprot.dl_ctl_string);
  1659.       wprints (9, 20, CYAN|_BLACK, nprot.ul_ctl_string);
  1660.       wprints (10, 20, CYAN|_BLACK, nprot.dl_keyword);
  1661.       wprints (11, 20, CYAN|_BLACK, nprot.ul_keyword);
  1662.       sprintf (string, "%d", nprot.filename);
  1663.       wprints (12, 20, CYAN|_BLACK, string);
  1664.       sprintf (string, "%d", nprot.size);
  1665.       wprints (13, 20, CYAN|_BLACK, string);
  1666.       sprintf (string, "%d", nprot.cps);
  1667.       wprints (14, 20, CYAN|_BLACK, string);
  1668.       wprints (12, 50, CYAN|_BLACK, nprot.batch ? "Yes" : "No");
  1669.       wprints (13, 50, CYAN|_BLACK, nprot.disable_fossil ? "Yes" : "No");
  1670.       wprints (14, 50, CYAN|_BLACK, nprot.change_to_dl ? "Yes" : "No");
  1671.       start_update ();
  1672.  
  1673.       i = wmenuget ();
  1674.  
  1675.       switch (i) {
  1676.          case 1:
  1677.             nprot.active ^= 1;
  1678.             break;
  1679.  
  1680.          case 2:
  1681.             strcpy (string, nprot.name);
  1682.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1683.             winpdef (2, 20, string, "?????????????????????????????", 0, 2, NULL, 0);
  1684.             if (winpread () != W_ESCPRESS)
  1685.                strcpy (nprot.name, strbtrim (string));
  1686.             break;
  1687.  
  1688.          case 3:
  1689.             sprintf (string, "%c", nprot.hotkey);
  1690.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1691.             winpdef (3, 20, string, "?", 0, 2, NULL, 0);
  1692.             if (winpread () != W_ESCPRESS)
  1693.                nprot.hotkey = toupper (string[0]);
  1694.             break;
  1695.  
  1696.          case 4:
  1697.             strcpy (string, nprot.dl_command);
  1698.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1699.             winpdef (4, 20, string, "???????????????????????????????????????????????", 0, 2, NULL, 0);
  1700.             if (winpread () != W_ESCPRESS)
  1701.                strcpy (nprot.dl_command, strbtrim (string));
  1702.             break;
  1703.  
  1704.          case 5:
  1705.             strcpy (string, nprot.ul_command);
  1706.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1707.             winpdef (5, 20, string, "???????????????????????????????????????????????", 0, 2, NULL, 0);
  1708.             if (winpread () != W_ESCPRESS)
  1709.                strcpy (nprot.ul_command, strbtrim (string));
  1710.             break;
  1711.  
  1712.          case 6:
  1713.             strcpy (string, nprot.log_name);
  1714.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1715.             winpdef (6, 20, string, "???????????????????????????????????????", 0, 2, NULL, 0);
  1716.             if (winpread () != W_ESCPRESS)
  1717.                strcpy (nprot.log_name, strbtrim (string));
  1718.             break;
  1719.  
  1720.          case 7:
  1721.             strcpy (string, nprot.ctl_name);
  1722.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1723.             winpdef (7, 20, string, "???????????????????????????????????????", 0, 2, NULL, 0);
  1724.             if (winpread () != W_ESCPRESS)
  1725.                strcpy (nprot.ctl_name, strbtrim (string));
  1726.             break;
  1727.  
  1728.          case 8:
  1729.             strcpy (string, nprot.dl_ctl_string);
  1730.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1731.             winpdef (8, 20, string, "???????????????????????????????????????", 0, 2, NULL, 0);
  1732.             if (winpread () != W_ESCPRESS)
  1733.                strcpy (nprot.dl_ctl_string, strbtrim (string));
  1734.             break;
  1735.  
  1736.          case 9:
  1737.             strcpy (string, nprot.ul_ctl_string);
  1738.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1739.             winpdef (9, 20, string, "???????????????????????????????????????", 0, 2, NULL, 0);
  1740.             if (winpread () != W_ESCPRESS)
  1741.                strcpy (nprot.ul_ctl_string, strbtrim (string));
  1742.             break;
  1743.  
  1744.          case 10:
  1745.             strcpy (string, nprot.dl_keyword);
  1746.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1747.             winpdef (10, 20, string, "???????????????????", 0, 2, NULL, 0);
  1748.             if (winpread () != W_ESCPRESS)
  1749.                strcpy (nprot.dl_keyword, strbtrim (string));
  1750.             break;
  1751.  
  1752.          case 11:
  1753.             strcpy (string, nprot.ul_keyword);
  1754.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1755.             winpdef (11, 20, string, "???????????????????", 0, 2, NULL, 0);
  1756.             if (winpread () != W_ESCPRESS)
  1757.                strcpy (nprot.ul_keyword, strbtrim (string));
  1758.             break;
  1759.  
  1760.          case 12:
  1761.             sprintf (string, "%d", nprot.filename);
  1762.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1763.             winpdef (12, 20, string, "???", 0, 2, NULL, 0);
  1764.             if (winpread () != W_ESCPRESS)
  1765.                nprot.filename = atoi (string);
  1766.             break;
  1767.  
  1768.          case 13:
  1769.             sprintf (string, "%d", nprot.size);
  1770.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1771.             winpdef (13, 20, string, "???", 0, 2, NULL, 0);
  1772.             if (winpread () != W_ESCPRESS)
  1773.                nprot.size = atoi (string);
  1774.             break;
  1775.  
  1776.          case 14:
  1777.             sprintf (string, "%d", nprot.cps);
  1778.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1779.             winpdef (14, 20, string, "???", 0, 2, NULL, 0);
  1780.             if (winpread () != W_ESCPRESS)
  1781.                nprot.cps = atoi (string);
  1782.             break;
  1783.  
  1784.          case 15:
  1785.             nprot.batch ^= 1;
  1786.             break;
  1787.  
  1788.          case 16:
  1789.             nprot.disable_fossil ^= 1;
  1790.             break;
  1791.  
  1792.          case 17:
  1793.             nprot.change_to_dl ^= 1;
  1794.             break;
  1795.       }
  1796.  
  1797.       hidecur ();
  1798.    } while (i != -1);
  1799.  
  1800.    if (memcmp ((char *)&nprot, (char *)prot, sizeof (PROTOCOL))) {
  1801.       wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  1802.       wactiv (wh1);
  1803.       wshadow (DGREY|_BLACK);
  1804.  
  1805.       wcenters (1, BLACK|_LGREY, "Save changes (Y/n) ?  ");
  1806.  
  1807.       strcpy (string, "Y");
  1808.       winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  1809.       winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  1810.  
  1811.       i = winpread ();
  1812.       wclose ();
  1813.       hidecur ();
  1814.  
  1815.       if (i == W_ESCPRESS)
  1816.          goto continue_editing;
  1817.  
  1818.       if (toupper (string[0]) == 'Y')
  1819.          memcpy ((char *)prot, (char *)&nprot, sizeof (PROTOCOL));
  1820.    }
  1821.  
  1822.    gotoxy_ (24, 1);
  1823.    clreol_ ();
  1824.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Protocol D-Delete");
  1825.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1826.    prints (24, 26, YELLOW|_BLACK, "E");
  1827.    prints (24, 34, YELLOW|_BLACK, "A");
  1828.    prints (24, 53, YELLOW|_BLACK, "D");
  1829. }
  1830.  
  1831. void bbs_protocol (void)
  1832. {
  1833.    int fdi, fd, wh, wh1, i = 1;
  1834.    char filename[80], string[128], readed;
  1835.    long pos;
  1836.    PROTOCOL nprot, bprot;
  1837.  
  1838.    sprintf (string, "%sPROTOCOL.DAT", config.sys_path);
  1839.    fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1840.    if (fd == -1)
  1841.       return;
  1842.  
  1843.    if (!read (fd, (char *)&nprot, sizeof (PROTOCOL))) {
  1844.       memset ((char *)&nprot, 0, sizeof (PROTOCOL));
  1845.       readed = 0;
  1846.    }
  1847.    else
  1848.       readed = 1;
  1849.  
  1850.    gotoxy_ (24, 1);
  1851.    clreol_ ();
  1852.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Protocol D-Delete");
  1853.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1854.    prints (24, 26, YELLOW|_BLACK, "E");
  1855.    prints (24, 34, YELLOW|_BLACK, "A");
  1856.    prints (24, 53, YELLOW|_BLACK, "D");
  1857.  
  1858.    wh = wopen (3, 5, 20, 74, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1859.    wactiv (wh);
  1860.    wshadow (DGREY|_BLACK);
  1861.    wtitle (" Ext. Protocols ", TRIGHT, YELLOW|_BLUE);
  1862.  
  1863.    do {
  1864.       stop_update ();
  1865.       wclear ();
  1866.  
  1867.       wprints ( 1, 1, LGREY|_BLACK, " Active           ");
  1868.       wprints ( 2, 1, LGREY|_BLACK, " Name             ");
  1869.       wprints ( 3, 1, LGREY|_BLACK, " Hotkey           ");
  1870.       wprints ( 4, 1, LGREY|_BLACK, " Download command ");
  1871.       wprints ( 5, 1, LGREY|_BLACK, " Upload command   ");
  1872.       wprints ( 6, 1, LGREY|_BLACK, " Log file name    ");
  1873.       wprints ( 7, 1, LGREY|_BLACK, " Control file     ");
  1874.       wprints ( 8, 1, LGREY|_BLACK, " Download string  ");
  1875.       wprints ( 9, 1, LGREY|_BLACK, " Upload string    ");
  1876.       wprints (10, 1, LGREY|_BLACK, " Download keyword ");
  1877.       wprints (11, 1, LGREY|_BLACK, " Upload keyword   ");
  1878.       wprints (12, 1, LGREY|_BLACK, " Filename word    ");
  1879.       wprints (13, 1, LGREY|_BLACK, " Size word        ");
  1880.       wprints (14, 1, LGREY|_BLACK, " CPS word         ");
  1881.       wprints (12, 31, LGREY|_BLACK, " Batch protocol   ");
  1882.       wprints (13, 31, LGREY|_BLACK, " Disable FOSSIL   ");
  1883.       wprints (14, 31, LGREY|_BLACK, " Change to UL dir ");
  1884.  
  1885.       if (readed) {
  1886.          wprints (1, 20, CYAN|_BLACK, nprot.active ? "Yes" : "No");
  1887.          wprints (2, 20, CYAN|_BLACK, nprot.name);
  1888.          sprintf (string, "%c", nprot.hotkey);
  1889.          wprints (3, 20, CYAN|_BLACK, string);
  1890.          wprints (4, 20, CYAN|_BLACK, nprot.dl_command);
  1891.          wprints (5, 20, CYAN|_BLACK, nprot.ul_command);
  1892.          wprints (6, 20, CYAN|_BLACK, nprot.log_name);
  1893.          wprints (7, 20, CYAN|_BLACK, nprot.ctl_name);
  1894.          wprints (8, 20, CYAN|_BLACK, nprot.dl_ctl_string);
  1895.          wprints (9, 20, CYAN|_BLACK, nprot.ul_ctl_string);
  1896.          wprints (10, 20, CYAN|_BLACK, nprot.dl_keyword);
  1897.          wprints (11, 20, CYAN|_BLACK, nprot.ul_keyword);
  1898.          sprintf (string, "%d", nprot.filename);
  1899.          wprints (12, 20, CYAN|_BLACK, string);
  1900.          sprintf (string, "%d", nprot.size);
  1901.          wprints (13, 20, CYAN|_BLACK, string);
  1902.          sprintf (string, "%d", nprot.cps);
  1903.          wprints (14, 20, CYAN|_BLACK, string);
  1904.          wprints (12, 50, CYAN|_BLACK, nprot.batch ? "Yes" : "No");
  1905.          wprints (13, 50, CYAN|_BLACK, nprot.disable_fossil ? "Yes" : "No");
  1906.          wprints (14, 50, CYAN|_BLACK, nprot.change_to_dl ? "Yes" : "No");
  1907.       }
  1908.       start_update ();
  1909.  
  1910.       i = getxch ();
  1911.       if ( (i & 0xFF) != 0 )
  1912.          i &= 0xFF;
  1913.  
  1914.       switch (i) {
  1915.          // PgDn
  1916.          case 0x5100:
  1917.             if (readed)
  1918.                read (fd, (char *)&nprot, sizeof (PROTOCOL));
  1919.             break;
  1920.  
  1921.          // PgUp
  1922.          case 0x4900:
  1923.             if (readed) {
  1924.                if (tell (fd) > sizeof (PROTOCOL)) {
  1925.                   lseek (fd, -2L * sizeof (PROTOCOL), SEEK_CUR);
  1926.                   read (fd, (char *)&nprot, sizeof (PROTOCOL));
  1927.                }
  1928.             }
  1929.             break;
  1930.  
  1931.          // E Edit
  1932.          case 'E':
  1933.          case 'e':
  1934.             if (readed) {
  1935.                edit_single_protocol (&nprot);
  1936.                lseek (fd, -1L * sizeof (PROTOCOL), SEEK_CUR);
  1937.                write (fd, (char *)&nprot, sizeof (PROTOCOL));
  1938.             }
  1939.             break;
  1940.  
  1941.          // A Add
  1942.          case 'A':
  1943.          case 'a':
  1944.             memset ((char *)&nprot, 0, sizeof (PROTOCOL));
  1945.             edit_single_protocol (&nprot);
  1946.  
  1947.             if (nprot.name[0]) {
  1948.                lseek (fd, 0L, SEEK_END);
  1949.                write (fd, (char *)&nprot, sizeof (PROTOCOL));
  1950.             }
  1951.  
  1952.             lseek (fd, -1L * sizeof (PROTOCOL), SEEK_CUR);
  1953.             readed = 0;
  1954.             if (read (fd, (char *)&nprot, sizeof (PROTOCOL)) == sizeof (PROTOCOL))
  1955.                readed = 1;
  1956.             break;
  1957.  
  1958.          // D Delete
  1959.          case 'D':
  1960.          case 'd':
  1961.             wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  1962.             wactiv (wh1);
  1963.             wshadow (DGREY|_BLACK);
  1964.  
  1965.             wcenters (1, BLACK|_LGREY, "Are you sure (Y/n) ?  ");
  1966.  
  1967.             strcpy (string, "Y");
  1968.             winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  1969.             winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  1970.  
  1971.             i = winpread ();
  1972.             wclose ();
  1973.             hidecur ();
  1974.  
  1975.             if (i == W_ESCPRESS)
  1976.                break;
  1977.  
  1978.             if (toupper (string[0]) == 'Y') {
  1979.                pos = tell (fd) - (long)sizeof (PROTOCOL);
  1980.                close (fd);
  1981.  
  1982.                update_message ();
  1983.  
  1984.                sprintf (filename, "%sPROTOCOL.BAK", config.sys_path);
  1985.                while ((fdi = sh_open (filename, SH_DENYRW, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE)) == -1)
  1986.                   ;
  1987.                sprintf (string, "%sPROTOCOL.DAT", config.sys_path);
  1988.                while ((fd = sh_open (string, SH_DENYRD, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE)) == -1)
  1989.                   ;
  1990.  
  1991.                while (read (fd, (char *)&bprot, sizeof (PROTOCOL)) == sizeof (PROTOCOL)) {
  1992.                   if (memcmp (&bprot, &nprot, sizeof (PROTOCOL)))
  1993.                      write (fdi, (char *)&bprot, sizeof (PROTOCOL));
  1994.                }
  1995.  
  1996.                lseek (fd, 0L, SEEK_SET);
  1997.                chsize (fd, 0L);
  1998.                lseek (fdi, 0L, SEEK_SET);
  1999.  
  2000.                while (read (fdi, (char *)&bprot, sizeof (PROTOCOL)) == sizeof (PROTOCOL))
  2001.                   write (fd, (char *)&bprot, sizeof (PROTOCOL));
  2002.  
  2003.                close (fd);
  2004.                close (fdi);
  2005.  
  2006.                unlink (filename);
  2007.  
  2008.                sprintf (string, "%sPROTOCOL.DAT", config.sys_path);
  2009.                while ((fd = sh_open (string, SH_DENYNONE, O_RDWR|O_BINARY, S_IREAD|S_IWRITE)) == -1)
  2010.                   ;
  2011.                if (lseek (fd, pos, SEEK_SET) == -1 || pos == filelength (fd)) {
  2012.                   lseek (fd, -1L * sizeof (PROTOCOL), SEEK_END);
  2013.                   pos = tell (fd);
  2014.                }
  2015.                read (fd, (char *)&nprot, sizeof (PROTOCOL));
  2016.  
  2017.                wclose ();
  2018.             }
  2019.             break;
  2020.  
  2021.          // ESC Exit
  2022.          case 0x1B:
  2023.             i = -1;
  2024.             break;
  2025.       }
  2026.  
  2027.    } while (i != -1);
  2028.  
  2029.    close (fd);
  2030.  
  2031.    wclose ();
  2032.    gotoxy_ (24, 1);
  2033.    clreol_ ();
  2034. }
  2035.  
  2036.