home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / LO241SRV.ZIP / lsetup2.c < prev    next >
Text File  |  1998-08-01  |  72KB  |  2,049 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 <io.h>
  21. #include <share.h>
  22. #include <fcntl.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <ctype.h>
  26. #include <alloc.h>
  27. #include <conio.h>
  28. #include <dir.h>
  29. #include <process.h>
  30. #include <sys\stat.h>
  31.  
  32. #include "sched.h"
  33. #include "lsetup.h"
  34. #include "lprot.h"
  35.  
  36. extern char *LSETUP_VERSION;
  37.  
  38. void clear_window (void);
  39. void linehelp_window (void);
  40. int sh_open (char *file, int shmode, int omode, int fmode);
  41. long window_get_flags (int y, int x, int type, long f);
  42.  
  43. #include <cxl\cxlvid.h>
  44. #include <cxl\cxlwin.h>
  45. #include <cxl\cxlstr.h>
  46. #include <cxl\cxlkey.h>
  47.  
  48. extern struct _configuration config;
  49.  
  50. char *get_priv_text (int);
  51.  
  52. static void edit_single_node (NODEINFO *);
  53. static void edit_single_location (ACCOUNT *);
  54. static void select_nodes_list (int, NODEINFO *);
  55. static void select_cost_list (int, ACCOUNT *);
  56.  
  57. char *get_priv_text (priv)
  58. int priv;
  59. {
  60.    int i;
  61.    char *txt;
  62.  
  63.    txt = " ??? ";
  64.  
  65.    for (i=0;i<12;i++)
  66.       if (levels[i].p_length == priv)
  67.       {
  68.          txt = levels[i].p_string;
  69.          break;
  70.       }
  71.  
  72.    return (txt);
  73. }
  74.  
  75. void mailer_misc ()
  76. {
  77.    int wh, i = 1;
  78.    char string[128];
  79.  
  80.    wh = wopen (6, 5, 18, 74, 1, LCYAN|_BLACK, CYAN|_BLACK);
  81.    wactiv (wh);
  82.    wshadow (DGREY|_BLACK);
  83.    wtitle (" Miscellaneous ", TRIGHT, YELLOW|_BLUE);
  84.  
  85.    do {
  86.       stop_update ();
  87.       wclear ();
  88.  
  89.       wmenubegc ();
  90.       wmenuitem (1, 1," Banner        ", 'B', 1, 0, NULL, 0, 0);
  91.       wmenuiba (linehelp_window, clear_window);
  92.       wmenuitem (2, 1," Mail-only     ", 'M', 2, 0, NULL, 0, 0);
  93.       wmenuiba (linehelp_window, clear_window);
  94.       wmenuitem (3, 1," Enter-BBS     ", 'E', 3, 0, NULL, 0, 0);
  95.       wmenuiba (linehelp_window, clear_window);
  96.       wmenuitem (4, 1," Events file  ", 'J', 10, 0, NULL, 0, 0);
  97.       wmenuiba (linehelp_window, clear_window);
  98.       wmenuitem (6, 1," WaZOO              ", 'W', 4, 0, NULL, 0, 0);
  99.       wmenuiba (linehelp_window, clear_window);
  100.       wmenuitem (7, 1," EMSI               ", 'E', 5, 0, NULL, 0, 0);
  101.       wmenuiba (linehelp_window, clear_window);
  102.       wmenuitem (8, 1," Janus              ", 'J', 6, 0, NULL, 0, 0);
  103.       wmenuiba (linehelp_window, clear_window);
  104.       wmenuitem (9, 1," Random redial time ", 'J', 12, 0, NULL, 0, 0);
  105.       wmenuiba (linehelp_window, clear_window);
  106.       wmenuitem (6, 31," Secure             ", 'J', 7, 0, NULL, 0, 0);
  107.       wmenuiba (linehelp_window, clear_window);
  108.       wmenuitem (7, 31," Keep netmail       ", 'J', 8, 0, NULL, 0, 0);
  109.       wmenuiba (linehelp_window, clear_window);
  110.       wmenuitem (8, 31," Flashing mail      ", 'J', 11, 0, NULL, 0, 0);
  111.       wmenuiba (linehelp_window, clear_window);
  112.       wmenuitem (9, 31," Track Netmail      ", 'J', 13, 0, NULL, 0, 0);
  113.       wmenuiba (linehelp_window, clear_window);
  114.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  115.  
  116.       wprints (1, 17, CYAN|_BLACK, config.banner);
  117.       wprints (2, 17, CYAN|_BLACK, config.mail_only);
  118.       wprints (3, 17, CYAN|_BLACK, config.enterbbs);
  119.       wprints (4, 17, CYAN|_BLACK, config.sched_name);
  120.       wprints (6, 22, CYAN|_BLACK, config.wazoo ? "Yes" : "No");
  121.       wprints (7, 22, CYAN|_BLACK, config.emsi ? "Yes" : "No");
  122.       wprints (8, 22, CYAN|_BLACK, config.janus ? "Yes" : "No");
  123.       wprints (9, 22, CYAN|_BLACK, config.random_redial ? "Yes" : "No");
  124.       wprints (6, 52, CYAN|_BLACK, config.secure ? "Yes" : "No");
  125.       wprints (7, 52, CYAN|_BLACK, config.keeptransit ? "Yes" : "No");
  126.       wprints (8, 52, CYAN|_BLACK, config.newmail_flash ? "Yes" : "No");
  127.       wprints (9, 52, CYAN|_BLACK, config.msgtrack ? "Yes" : "No");
  128.  
  129.       start_update ();
  130.       i = wmenuget ();
  131.  
  132.       switch (i) {
  133.          case 1:
  134.             strcpy (string, config.banner);
  135.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  136.             winpdef (1, 17, string, "?????????????????????????????????????????????????", 0, 2, NULL, 0);
  137.             if (winpread () != W_ESCPRESS)
  138.                strcpy (config.banner, strbtrim (string));
  139.             hidecur ();
  140.             break;
  141.  
  142.          case 2:
  143.             strcpy (string, config.mail_only);
  144.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  145.             winpdef (2, 17, string, "?????????????????????????????????????????????????", 0, 2, NULL, 0);
  146.             if (winpread () != W_ESCPRESS)
  147.                strcpy (config.mail_only, strbtrim (string));
  148.             break;
  149.  
  150.          case 3:
  151.             strcpy (string, config.enterbbs);
  152.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  153.             winpdef (3, 17, string, "?????????????????????????????????????????????????", 0, 2, NULL, 0);
  154.             if (winpread () != W_ESCPRESS)
  155.                strcpy (config.enterbbs, strbtrim (string));
  156.             break;
  157.  
  158.          case 4:
  159.             config.wazoo ^= 1;
  160.             break;
  161.  
  162.          case 5:
  163.             config.emsi ^= 1;
  164.             break;
  165.  
  166.          case 6:
  167.             config.janus ^= 1;
  168.             break;
  169.  
  170.          case 7:
  171.             config.secure ^= 1;
  172.             break;
  173.  
  174.          case 8:
  175.             config.keeptransit ^= 1;
  176.             break;
  177.  
  178.          case 10:
  179.             strcpy (string, config.sched_name);
  180.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  181.             winpdef (4, 17, string, "???????????????????????????????????????", 0, 2, NULL, 0);
  182.             if (winpread () != W_ESCPRESS)
  183.                strcpy (config.sched_name, strbtrim (string));
  184.             hidecur ();
  185.             break;
  186.  
  187.          case 11:
  188.             config.newmail_flash ^= 1;
  189.             break;
  190.  
  191.          case 12:
  192.             config.random_redial ^= 1;
  193.             break;
  194.  
  195.          case 13:
  196.             config.msgtrack ^= 1;
  197.             break;
  198.       }
  199.  
  200.       hidecur ();
  201.  
  202.    } while (i != -1);
  203.  
  204.    wclose ();
  205. }
  206.  
  207. void write_areasbbs ()
  208. {
  209.    FILE *fp;
  210.    int wh, i = 1, fd;
  211.    char string[128];
  212.    struct _sys sys;
  213.  
  214.    wh = wopen (7, 4, 11, 73, 1, LCYAN|_BLACK, CYAN|_BLACK);
  215.    wactiv (wh);
  216.    wshadow (DGREY|_BLACK);
  217.    wtitle (" Write AREAS.BBS ", TRIGHT, YELLOW|_BLUE);
  218.  
  219.    wprints (1, 1, CYAN|_BLACK, " Filename:");
  220.    if (!config.areas_bbs[0])
  221.       sprintf (string, "%sAREAS.BBS", config.sys_path);
  222.    else
  223.       strcpy (string, config.areas_bbs);
  224.    winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  225.    winpdef (1, 12, string, "?????????????????????????????????????????????????????", 0, 2, NULL, 0);
  226.    i = winpread ();
  227.  
  228.    hidecur ();
  229.  
  230.    if (i == W_ESCPRESS) {
  231.       wclose ();
  232.       return;
  233.    }
  234.  
  235.    if ((fp = fopen (string, "wt")) == NULL) {
  236.       wclose ();
  237.       return;
  238.    }
  239.  
  240.    fprintf (fp, "%s ! %s\n;\n", config.system_name, config.sysop);
  241.  
  242.    sprintf (string, "%sSYSMSG.DAT", config.sys_path);
  243.    while ((fd = sopen (string, SH_DENYWR, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1)
  244.       ;
  245.  
  246.    while (read (fd, (char *)&sys, SIZEOF_MSGAREA) == SIZEOF_MSGAREA) {
  247.       if (!sys.echomail && !sys.passthrough)
  248.          continue;
  249.  
  250.       if (sys.passthrough) {
  251.          fprintf (fp, "##%s %s %s", "", sys.echotag, sys.forward1);
  252.          if (sys.forward2[0])
  253.             fprintf (fp, " %s", sys.forward2);
  254.          if (sys.forward3[0])
  255.             fprintf (fp, " %s", sys.forward3);
  256.       }
  257.       else if (sys.quick_board) {
  258.          fprintf (fp, "%d %s %s", sys.quick_board, sys.echotag, sys.forward1);
  259.          if (sys.forward2[0])
  260.             fprintf (fp, " %s", sys.forward2);
  261.          if (sys.forward3[0])
  262.             fprintf (fp, " %s", sys.forward3);
  263.       }
  264.       else if (sys.gold_board) {
  265.          fprintf (fp, "G%d %s %s", sys.gold_board, sys.echotag, sys.forward1);
  266.          if (sys.forward2[0])
  267.             fprintf (fp, " %s", sys.forward2);
  268.          if (sys.forward3[0])
  269.             fprintf (fp, " %s", sys.forward3);
  270.       }
  271.       else if (sys.pip_board) {
  272.          fprintf (fp, "!%d %s %s", sys.pip_board, sys.echotag, sys.forward1);
  273.          if (sys.forward2[0])
  274.             fprintf (fp, " %s", sys.forward2);
  275.          if (sys.forward3[0])
  276.             fprintf (fp, " %s", sys.forward3);
  277.       }
  278.       else if (sys.squish) {
  279.          fprintf (fp, "$%s %s %s", sys.msg_path, sys.echotag, sys.forward1);
  280.          if (sys.forward2[0])
  281.             fprintf (fp, " %s", sys.forward2);
  282.          if (sys.forward3[0])
  283.             fprintf (fp, " %s", sys.forward3);
  284.       }
  285.       else {
  286.          fprintf (fp, "%s %s %s", sys.msg_path, sys.echotag, sys.forward1);
  287.          if (sys.forward2[0])
  288.             fprintf (fp, " %s", sys.forward2);
  289.          if (sys.forward3[0])
  290.             fprintf (fp, " %s", sys.forward3);
  291.       }
  292.  
  293.       fprintf (fp, "\n");
  294.    }
  295.  
  296.    fprintf (fp, ";\n; Created by LSETUP v.%s\n;\n", LSETUP_VERSION);
  297.  
  298.    fclose (fp);
  299.    close (fd);
  300.  
  301.    wclose ();
  302. }
  303.  
  304. void manager_nodelist ()
  305. {
  306.    int wh, i;
  307.    char string[80];
  308.  
  309.    wh = wopen (0, 16, 23, 57, 1, LCYAN|_BLACK, CYAN|_BLACK);
  310.    wactiv (wh);
  311.    wshadow (DGREY|_BLACK);
  312.    wtitle (" Nodelist ", TRIGHT, YELLOW|_BLUE);
  313.    i = 80;
  314.  
  315.    do {
  316.       stop_update ();
  317.       wclear ();
  318.  
  319. //      wprints (1, 11, LGREY|BLACK, "┌──Nodelist──┐┌──Nodediff──┐┌───Packed───┐");
  320.       wprints (1, 11, LGREY|BLACK, "┌──Nodelist──┐┌──Nodediff──┐");
  321.  
  322.       wmenubegc ();
  323.       wmenuitem ( 2, 1," List 1  ", 'L', 80, 0, NULL, 0, 0);
  324.       wmenuitem ( 3, 1," List 2  ", 'L', 81, 0, NULL, 0, 0);
  325.       wmenuitem ( 4, 1," List 3  ", 'L', 82, 0, NULL, 0, 0);
  326.       wmenuitem ( 5, 1," List 4  ", 'L', 83, 0, NULL, 0, 0);
  327.       wmenuitem ( 6, 1," List 5  ", 'L', 84, 0, NULL, 0, 0);
  328.       wmenuitem ( 7, 1," List 6  ", 'L', 85, 0, NULL, 0, 0);
  329.       wmenuitem ( 8, 1," List 7  ", 'L', 86, 0, NULL, 0, 0);
  330.       wmenuitem ( 9, 1," List 8  ", 'L', 87, 0, NULL, 0, 0);
  331.       wmenuitem (10, 1," List 9  ", 'L', 88, 0, NULL, 0, 0);
  332.       wmenuitem (11, 1," List 10 ", 'L', 89, 0, NULL, 0, 0);
  333.       wmenuitem (12, 1," List 11 ", 'L', 90, 0, NULL, 0, 0);
  334.       wmenuitem (13, 1," List 12 ", 'L', 91, 0, NULL, 0, 0);
  335.       wmenuitem (14, 1," List 13 ", 'L', 92, 0, NULL, 0, 0);
  336.       wmenuitem (15, 1," List 14 ", 'L', 93, 0, NULL, 0, 0);
  337.       wmenuitem (16, 1," List 15 ", 'L', 94, 0, NULL, 0, 0);
  338.       wmenuitem (17, 1," List 16 ", 'L', 95, 0, NULL, 0, 0);
  339.       wmenuitem (18, 1," List 17 ", 'L', 96, 0, NULL, 0, 0);
  340.       wmenuitem (19, 1," List 18 ", 'L', 97, 0, NULL, 0, 0);
  341.       wmenuitem (20, 1," List 19 ", 'L', 98, 0, NULL, 0, 0);
  342.       wmenuitem (21, 1," List 20 ", 'L', 99, 0, NULL, 0, 0);      wmenuend (i, M_VERT, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  343.  
  344.       for (i = 0; i < MAXNL; i++) {
  345.          wprints (i + 2, 12, CYAN|_BLACK, config.nl[i].list_name);
  346.          wprints (i + 2, 26, CYAN|_BLACK, config.nl[i].diff_name);
  347. //         wprints (i + 2, 40, CYAN|_BLACK, config.nl[i].arc_name);
  348.       }
  349.  
  350.       start_update ();
  351.       i = wmenuget ();
  352.       if (i != -1) {
  353.          i -= 80;
  354.          strcpy (string, config.nl[i].list_name);
  355.          winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  356.          winpdef (i + 2, 12, string, "????????????", 0, 2, NULL, 0);
  357.          if (winpread () != W_ESCPRESS) {
  358.             strcpy (config.nl[i].list_name, strbtrim (string));
  359.             wprints (i + 2, 12, CYAN|_BLACK, "            ");
  360.             wprints (i + 2, 12, CYAN|_BLACK, config.nl[i].list_name);
  361.  
  362.             strcpy (string, config.nl[i].diff_name);
  363.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  364.             winpdef (i + 2, 26, string, "????????????", 0, 2, NULL, 0);
  365.             if (winpread () != W_ESCPRESS) {
  366.                strcpy (config.nl[i].diff_name, strbtrim (string));
  367.                wprints (i + 2, 26, CYAN|_BLACK, "            ");
  368.                wprints (i + 2, 26, CYAN|_BLACK, config.nl[i].diff_name);
  369.  
  370. //               strcpy (string, config.nl[i].arc_name);
  371. //               winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  372. //               winpdef (i + 2, 40, string, "????????????", 0, 2, NULL, 0);
  373. //               if (winpread () != W_ESCPRESS) {
  374. //                  strcpy (config.nl[i].arc_name, strbtrim (string));
  375. //                  wprints (i + 2, 40, CYAN|_BLACK, "            ");
  376. //                  wprints (i + 2, 40, CYAN|_BLACK, config.nl[i].arc_name);
  377. //               }
  378.             }
  379.          }
  380.  
  381.          i += 80;
  382.          hidecur ();
  383.       }
  384.  
  385.    } while (i != -1);
  386.  
  387.    wclose ();
  388. }
  389.  
  390. void manager_edit_packer (int o)
  391. {
  392.    int wh, i = 1;
  393.    char string[80];
  394.  
  395.    wh = wopen (4, 20, 13, 69, 1, LCYAN|_BLACK, CYAN|_BLACK);
  396.    wactiv (wh);
  397.    wshadow (DGREY|_BLACK);
  398.    wtitle (" Edit Packers ", TRIGHT, YELLOW|_BLUE);
  399.  
  400.    do {
  401.       stop_update ();
  402.       wclear ();
  403.  
  404.       wmenubegc ();
  405.       wmenuitem ( 1, 1," Log ID         ", 'I', 1, 0, NULL, 0, 0);
  406.       wmenuitem ( 2, 1," Users display  ", 'd', 2, 0, NULL, 0, 0);
  407.       wmenuitem ( 3, 1," Pack command   ", 'P', 3, 0, NULL, 0, 0);
  408.       wmenuitem ( 4, 1," Unpack command ", 'U', 4, 0, NULL, 0, 0);
  409.       wmenuitem ( 5, 1," Offset         ", 'O', 5, 0, NULL, 0, 0);
  410.       wmenuitem ( 6, 1," └─ ID bytes    ", 'b', 6, 0, NULL, 0, 0);
  411.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  412.  
  413.       wprints (1, 18, CYAN|_BLACK, config.packers[o].id);
  414.       wprints (2, 18, CYAN|_BLACK, config.packid[o].display);
  415.       wprints (3, 18, CYAN|_BLACK, config.packers[o].packcmd);
  416.       wprints (4, 18, CYAN|_BLACK, config.packers[o].unpackcmd);
  417.       sprintf (string, "%d", config.packid[o].offset);
  418.       wprints (5, 18, CYAN|_BLACK, string);
  419.       wprints (6, 18, CYAN|_BLACK, config.packid[o].ident);
  420.  
  421.       start_update ();
  422.       i = wmenuget ();
  423.  
  424.       switch (i) {
  425.          case 1:
  426.             strcpy (string, config.packers[o].id);
  427.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  428.             winpdef (1, 18, string, "????????", 0, 2, NULL, 0);
  429.             if (winpread () != W_ESCPRESS)
  430.                strcpy (config.packers[o].id, strbtrim (string));
  431.             break;
  432.  
  433.          case 2:
  434.             strcpy (string, config.packid[o].display);
  435.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  436.             winpdef (2, 18, string, "???????????????????", 0, 2, NULL, 0);
  437.             if (winpread () != W_ESCPRESS)
  438.                strcpy (config.packid[o].display, strbtrim (string));
  439.             break;
  440.  
  441.          case 3:
  442.             strcpy (string, config.packers[o].packcmd);
  443.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  444.             winpdef (3, 18, string, "?????????????????????????????", 0, 2, NULL, 0);
  445.             if (winpread () != W_ESCPRESS)
  446.                strcpy (config.packers[o].packcmd, strbtrim (string));
  447.             break;
  448.  
  449.          case 4:
  450.             strcpy (string, config.packers[o].unpackcmd);
  451.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  452.             winpdef (4, 18, string, "?????????????????????????????", 0, 2, NULL, 0);
  453.             if (winpread () != W_ESCPRESS)
  454.                strcpy (config.packers[o].unpackcmd, strbtrim (string));
  455.             break;
  456.  
  457.          case 5:
  458.             sprintf (string, "%d", config.packid[o].offset);
  459.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  460.             winpdef (5, 18, string, "?????", 0, 2, NULL, 0);
  461.             if (winpread () != W_ESCPRESS)
  462.                config.packid[o].offset = atoi (strbtrim (string));
  463.             break;
  464.  
  465.          case 6:
  466.             strcpy (string, config.packid[o].ident);
  467.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  468.             winpdef (6, 18, string, "??????????????????", 0, 2, NULL, 0);
  469.             if (winpread () != W_ESCPRESS)
  470.                strcpy (config.packid[o].ident, strupr (strbtrim (string)));
  471.             break;
  472.       }
  473.  
  474.       hidecur ();
  475.    } while (i != -1);
  476.  
  477.    wclose ();
  478. }
  479.  
  480. void manager_packers ()
  481. {
  482.    int i = 1, m;
  483.    char packs[10][20];
  484.  
  485.    wopen (6, 32, 19, 45, 1, LCYAN|_BLACK, CYAN|_BLACK);
  486.    wshadow (DGREY|_BLACK);
  487.    wtitle (" Packer ", TRIGHT, YELLOW|_BLUE);
  488.  
  489.    for (;;) {
  490.       stop_update ();
  491.       wmenubegc ();
  492.       for (m = 0; m < 10; m++) {
  493.          sprintf (packs[m], " %-8.8s ", config.packers[m].id);
  494.          wmenuitem (m + 1, 1, packs[m], 0, m + 1, 0, NULL, 0, 0);
  495.       }
  496.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  497.  
  498.       start_update ();
  499.       if ((i = wmenuget ()) == -1)
  500.          break;
  501.  
  502.       manager_edit_packer (i - 1);
  503.    }
  504.  
  505.    wclose ();
  506. }
  507.  
  508. static int node_sort_func (NODEINFO *a1, NODEINFO *b1)
  509. {
  510.    if (a1->zone != b1->zone)  return (a1->zone - b1->zone);
  511.    if (a1->net != b1->net)    return (a1->net - b1->net);
  512.    if (a1->node != b1->node)  return (a1->node - b1->node);
  513.    return (a1->point - b1->point);
  514. }
  515.  
  516. void manager_nodes ()
  517. {
  518.     int fd, fdi, wh, wh1, i = 1, saved, zz, ne, no, po;
  519.     char string[128], readed, filename[80];
  520.     long pos;
  521.     NODEINFO ni, bni;
  522.  
  523.     sprintf (string, "%sNODES.DAT", config.net_info);
  524.     fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  525.     if (fd == -1)
  526.         return;
  527.  
  528.     if (!read (fd, (char *)&ni, sizeof (NODEINFO))) {
  529.         memset ((char *)&ni, 0, sizeof (NODEINFO));
  530.         readed = 0;
  531.     }
  532.     else
  533.         readed = 1;
  534.  
  535.     gotoxy_ (24, 1);
  536.     clreol_ ();
  537.     prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Node  C-Copy  L-List  D-Delete");
  538.     prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  539.     prints (24, 26, YELLOW|_BLACK, "E");
  540.     prints (24, 34, YELLOW|_BLACK, "A");
  541.     prints (24, 50, YELLOW|_BLACK, "C");
  542.     prints (24, 58, YELLOW|_BLACK, "L");
  543.     prints (24, 66, YELLOW|_BLACK, "D");
  544.  
  545.     wh = wopen (2, 6, 22, 75, 1, LCYAN|_BLACK, CYAN|_BLACK);
  546.     wactiv (wh);
  547.     wshadow (DGREY|_BLACK);
  548.     wtitle (" Nodes ", TRIGHT, YELLOW|_BLUE);
  549.  
  550.     do {
  551.         stop_update ();
  552.         wclear ();
  553.  
  554.         wprints ( 1,  1, LGREY|_BLACK," Address         ");
  555.         wprints ( 2,  1, LGREY|_BLACK," System          ");
  556.         wprints ( 3,  1, LGREY|_BLACK," Sysop Name      ");
  557.         wprints ( 4,  1, LGREY|_BLACK," Packer          ");
  558.         wprints ( 4, 33, LGREY|_BLACK," Mailer aka      ");
  559.         wprints ( 5,  1, LGREY|_BLACK," Session Pw      ");
  560.         wprints ( 6,  1, LGREY|_BLACK," Packet Pw (OUT) ");
  561.         wprints ( 6, 33, LGREY|_BLACK," Packet Pw (IN)  ");
  562.         wprints ( 7,  1, LGREY|_BLACK," Areafix Pw      ");
  563.         wprints ( 8,  1, LGREY|_BLACK," TIC Pw          ");
  564.         wprints ( 9,  1, LGREY|_BLACK," Phone           ");
  565.         wprints (10,  1, LGREY|_BLACK," Dial Prefix     ");
  566.         wprints (11,  1, LGREY|_BLACK," Capabilities    ");
  567.         wprints (10, 33, LGREY|_BLACK," Min. baud rate  ");
  568.         wprints (12,  1, LGREY|_BLACK," Echomail aka    ");
  569.         wprints (13,  1, LGREY|_BLACK," Areafix Level   ");
  570.         wprints (14,  1, LGREY|_BLACK," ├─ A Flag       ");
  571.         wprints (15,  1, LGREY|_BLACK," ├─ B Flag       ");
  572.         wprints (16,  1, LGREY|_BLACK," ├─ C Flag       ");
  573.         wprints (17,  1, LGREY|_BLACK," └─ D Flag       ");
  574.         wprints (12, 33, LGREY|_BLACK," TIC aka         ");
  575.         wprints (13, 33, LGREY|_BLACK," TIC Level       ");
  576.         wprints (14, 33, LGREY|_BLACK," ├─ A Flag       ");
  577.         wprints (15, 33, LGREY|_BLACK," ├─ B Flag       ");
  578.         wprints (16, 33, LGREY|_BLACK," ├─ C Flag       ");
  579.         wprints (17, 33, LGREY|_BLACK," └─ D Flag       ");
  580.  
  581.         if (readed) {
  582.             sprintf (string, "%u:%u/%u.%u", ni.zone, ni.net, ni.node, ni.point);
  583.             wprints (1, 19, CYAN|_BLACK, string);
  584.             wprints (2, 19, CYAN|_BLACK, ni.system);
  585.             wprints (3, 19, CYAN|_BLACK, ni.sysop_name);
  586.             wprints (4, 19, CYAN|_BLACK, config.packers[ni.packer].id);
  587.             sprintf (string, "%u:%u/%u.%u", config.alias[ni.mailer_aka].zone, config.alias[ni.mailer_aka].net, config.alias[ni.mailer_aka].node, config.alias[ni.mailer_aka].point);
  588.             wprints (4, 51, CYAN|_BLACK, string);
  589.             wprints (5, 19, CYAN|_BLACK, ni.pw_session);
  590.             wprints (6, 19, CYAN|_BLACK, ni.pw_packet);
  591.             wprints (6, 51, CYAN|_BLACK, ni.pw_inbound_packet);
  592.             wprints (7, 19, CYAN|_BLACK, ni.pw_areafix);
  593.             wprints (8, 19, CYAN|_BLACK, ni.pw_tic);
  594.             wprints (9, 19, CYAN|_BLACK, ni.phone);
  595.             sprintf (string, "%d", ni.modem_type);
  596.             wprints (10, 19, CYAN|_BLACK, string);
  597.             strcpy (string, "----");
  598.             if (ni.remap4d)
  599.                 string[0] = 'M';
  600.             if (ni.wazoo)
  601.                 string[1] = 'W';
  602.             if (ni.emsi)
  603.                 string[2] = 'E';
  604.             if (ni.janus)
  605.                 string[3] = 'J';
  606.             wprints (11, 19, CYAN|_BLACK, string);
  607.             sprintf (string,"%ld",ni.min_baud_rate);
  608.             wprints (10, 51, CYAN|_BLACK, string);
  609.             if (ni.aka == 0)
  610.                 ni.aka++;
  611.             sprintf (string, "%u:%u/%u.%u", config.alias[ni.aka - 1].zone, config.alias[ni.aka - 1].net, config.alias[ni.aka - 1].node, config.alias[ni.aka - 1].point);
  612.             wprints (12, 19, CYAN|_BLACK, string);
  613.  
  614.             sprintf (string, "%d", ni.afx_level);
  615.             wprints (13, 19, CYAN|_BLACK, string);
  616.             wprints (14, 19, CYAN|_BLACK, get_flagA_text ((ni.afx_flags >> 24) & 0xFF));
  617.             wprints (15, 19, CYAN|_BLACK, get_flagB_text ((ni.afx_flags >> 16) & 0xFF));
  618.             wprints (16, 19, CYAN|_BLACK, get_flagC_text ((ni.afx_flags >> 8) & 0xFF));
  619.             wprints (17, 19, CYAN|_BLACK, get_flagD_text (ni.afx_flags & 0xFF));
  620.             if (ni.tic_aka == 0 )
  621.                 ni.tic_aka++;
  622.             sprintf (string, "%u:%u/%u.%u", config.alias[ni.tic_aka - 1].zone, config.alias[ni.tic_aka - 1].net, config.alias[ni.tic_aka - 1].node, config.alias[ni.tic_aka - 1].point);
  623.             wprints (12, 51, CYAN|_BLACK, string);
  624.  
  625.             sprintf (string, "%d", ni.tic_level);
  626.             wprints (13, 51, CYAN|_BLACK, string);
  627.             wprints (14, 51, CYAN|_BLACK, get_flagA_text ((ni.tic_flags >> 24) & 0xFF));
  628.             wprints (15, 51, CYAN|_BLACK, get_flagB_text ((ni.tic_flags >> 16) & 0xFF));
  629.             wprints (16, 51, CYAN|_BLACK, get_flagC_text ((ni.tic_flags >> 8) & 0xFF));
  630.             wprints (17, 51, CYAN|_BLACK, get_flagD_text (ni.tic_flags & 0xFF));
  631.         }
  632.  
  633.         start_update ();
  634.         i = getxch ();
  635.         if ( (i & 0xFF) != 0 )
  636.             i &= 0xFF;
  637.  
  638.         switch (i) {
  639.             // PgDn
  640.             case 0x5100:
  641.                 if (readed)
  642.                     read (fd, (char *)&ni, sizeof (NODEINFO));
  643.                 break;
  644.  
  645.             // PgUp
  646.             case 0x4900:
  647.                 if (readed) {
  648.                     if (tell (fd) > sizeof (NODEINFO)) {
  649.                         lseek (fd, -2L * sizeof (NODEINFO), SEEK_CUR);
  650.                         read (fd, (char *)&ni, sizeof (NODEINFO));
  651.                     }
  652.                 }
  653.                 break;
  654.  
  655.             // E Edit
  656.             case 'E':
  657.             case 'e':
  658.                 if (readed) {
  659.                     zz = ni.zone;
  660.                     ne = ni.net;
  661.                     no = ni.node;
  662.                     po = ni.point;
  663.  
  664.                     edit_single_node (&ni);
  665.  
  666.                     if (zz != ni.zone || ne != ni.net || no != ni.node || po != ni.point) {
  667.                         pos = tell (fd) - (long)sizeof (NODEINFO);
  668.                         close (fd);
  669.  
  670.                         sprintf (filename, "%sNODES.BAK", config.net_info);
  671.                         unlink (filename);
  672.                         sprintf (string, "%sNODES.DAT", config.net_info);
  673.                         rename (string, filename);
  674.  
  675.                         fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  676.                         fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  677.                         saved = 0;
  678.  
  679.                         while (read (fd, (char *)&bni, sizeof (NODEINFO)) == sizeof (NODEINFO)) {
  680.                             if (!saved && node_sort_func (&ni, &bni) < 0) {
  681.                                 pos = tell (fdi);
  682.                                 write (fdi, (char *)&ni, sizeof (NODEINFO));
  683.                                 saved = 1;
  684.                             }
  685.                             if ((bni.zone != ni.zone || bni.net != ni.net || bni.node != ni.node || bni.point != ni.point) &&
  686.                                  (bni.zone != zz || bni.net != ne || bni.node != no || bni.point != po))
  687.                                 write (fdi, (char *)&bni, sizeof (NODEINFO));
  688.                         }
  689.  
  690.                         if (!saved) {
  691.                             pos = tell (fdi);
  692.                             write (fdi, (char *)&ni, sizeof (NODEINFO));
  693.                         }
  694.  
  695.                         close (fd);
  696.                         close (fdi);
  697.  
  698.                         unlink (filename);
  699.  
  700.                         sprintf (string, "%sNODES.DAT", config.net_info);
  701.                         fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  702.                         lseek (fd, pos, SEEK_SET);
  703.                         read (fd, (char *)&ni, sizeof (NODEINFO));
  704.                     }
  705.                     else {
  706.                         lseek (fd, -1L * sizeof (NODEINFO), SEEK_CUR);
  707.                         write (fd, (char *)&ni, sizeof (NODEINFO));
  708.                     }
  709.                 }
  710.                 break;
  711.  
  712.             // L List
  713.             case 'L':
  714.             case 'l':
  715.                 if (readed)
  716.                     select_nodes_list (fd, &ni);
  717.                 break;
  718.  
  719.             // A Add & C Copy
  720.             case 'A':
  721.             case 'a':
  722.  
  723.                 memset ((char *)&ni, 0, sizeof (NODEINFO));
  724.                 ni.remap4d = ni.wazoo = ni.emsi = ni.janus = 1;
  725.  
  726.  
  727.             case 'C':
  728.             case 'c':
  729.  
  730.                 if ((i=='C'||i=='c')&&!readed) break;
  731.  
  732.                     edit_single_node (&ni);
  733.  
  734.                 if (ni.zone) {
  735.                     pos = tell (fd) - (long)sizeof (NODEINFO);
  736.                     close (fd);
  737.  
  738.                     sprintf (filename, "%sNODES.BAK", config.net_info);
  739.                     unlink (filename);
  740.                     sprintf (string, "%sNODES.DAT", config.net_info);
  741.                     rename (string, filename);
  742.  
  743.                     fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  744.                     fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  745.                     saved = 0;
  746.  
  747.                     while (read (fd, (char *)&bni, sizeof (NODEINFO)) == sizeof (NODEINFO)) {
  748.                         if (!saved && node_sort_func (&ni, &bni) < 0) {
  749.                             pos = tell (fdi);
  750.                             write (fdi, (char *)&ni, sizeof (NODEINFO));
  751.                             saved = 1;
  752.                         }
  753.                         if (bni.zone != ni.zone || bni.net != ni.net || bni.node != ni.node || bni.point != ni.point)
  754.                             write (fdi, (char *)&bni, sizeof (NODEINFO));
  755.                     }
  756.  
  757.                     if (!saved) {
  758.                         pos = tell (fdi);
  759.                         write (fdi, (char *)&ni, sizeof (NODEINFO));
  760.                     }
  761.  
  762.                     close (fd);
  763.                     close (fdi);
  764.  
  765.                     unlink (filename);
  766.  
  767.                     sprintf (string, "%sNODES.DAT", config.net_info);
  768.                     fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  769.                     lseek (fd, pos, SEEK_SET);
  770.                     read (fd, (char *)&ni, sizeof (NODEINFO));
  771.                 }
  772.                 break;
  773.  
  774.  
  775.             // D Delete
  776.             case 'D':
  777.             case 'd':
  778.                 wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  779.                 wactiv (wh1);
  780.                 wshadow (DGREY|_BLACK);
  781.  
  782.                 wcenters (1, BLACK|_LGREY, "Are you sure (Y/n) ?  ");
  783.  
  784.                 strcpy (string, "Y");
  785.                 winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  786.                 winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  787.  
  788.                 i = winpread ();
  789.                 wclose ();
  790.                 hidecur ();
  791.  
  792.                 if (i == W_ESCPRESS)
  793.                     break;
  794.  
  795.                 pos = tell (fd) - (long)sizeof (NODEINFO);
  796.                 close (fd);
  797.  
  798.                 if (toupper (string[0]) == 'Y') {
  799.                     sprintf (filename, "%sNODES.BAK", config.net_info);
  800.                     unlink (filename);
  801.                     sprintf (string, "%sNODES.DAT", config.net_info);
  802.                     rename (string, filename);
  803.  
  804.                     fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  805.                     fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  806.  
  807.                     while (read (fd, (char *)&bni, sizeof (NODEINFO)) == sizeof (NODEINFO)) {
  808.                         if (bni.zone != ni.zone || bni.net != ni.net || bni.node != ni.node || bni.point != ni.point)
  809.                             write (fdi, (char *)&bni, sizeof (NODEINFO));
  810.                     }
  811.  
  812.                     close (fd);
  813.                     close (fdi);
  814.  
  815.                     unlink (filename);
  816.                 }
  817.  
  818.                 sprintf (string, "%sNODES.DAT", config.net_info);
  819.                 fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  820.                 lseek (fd, pos, SEEK_SET);
  821.                 read (fd, (char *)&ni, sizeof (NODEINFO));
  822.                 break;
  823.  
  824.             // ESC Exit
  825.             case 0x1B:
  826.                 i = -1;
  827.                 break;
  828.         }
  829.  
  830.     } while (i != -1);
  831.  
  832.     close (fd);
  833.  
  834.     wclose ();
  835.     gotoxy_ (24, 1);
  836.     clreol_ ();
  837. }
  838.  
  839. static void edit_single_node (nip)
  840. NODEINFO *nip;
  841. {
  842.     int wh1, wh, i = 1, m, mx;
  843.     char string[128], packs[10][12], *akas[MAX_ALIAS + 2], temp[42];
  844.     NODEINFO ni;
  845.  
  846.     memcpy ((char *)&ni, (char *)nip, sizeof (NODEINFO));
  847.  
  848.     gotoxy_ (24, 1);
  849.     clreol_ ();
  850.     prints (24, 1, LGREY|_BLACK, "ESC-Exit/Save  ENTER-Edit");
  851.     prints (24, 1, YELLOW|_BLACK, "ESC");
  852.     prints (24, 16, YELLOW|_BLACK, "ENTER");
  853.  
  854. continue_editing:
  855.     do {
  856.         stop_update ();
  857.         wclear ();
  858.  
  859.         wmenubegc ();
  860.         wmenuitem ( 1,  1, " Address         ", 0,  1, 0, NULL, 0, 0);
  861.         wmenuitem ( 2,  1, " System          ", 0, 11, 0, NULL, 0, 0);
  862.         wmenuitem ( 3,  1, " Sysop Name      ", 0, 10, 0, NULL, 0, 0);
  863.         wmenuitem ( 4,  1, " Packer          ", 0,  3, 0, NULL, 0, 0);
  864.         wmenuitem ( 4, 33, " Mailer aka      ", 0, 26, 0, NULL, 0, 0);
  865.         wmenuitem ( 5,  1, " Session Pw      ", 0,  4, 0, NULL, 0, 0);
  866.         wmenuitem ( 6,  1, " Packet Pw (OUT) ", 0,  5, 0, NULL, 0, 0);
  867.         wmenuitem ( 6, 33, " Packet Pw (IN)  ", 0, 25, 0, NULL, 0, 0);
  868.         wmenuitem ( 7,  1, " Areafix Pw      ", 0,  6, 0, NULL, 0, 0);
  869.         wmenuitem ( 8,  1, " TIC Pw          ", 0, 14, 0, NULL, 0, 0);
  870.         wmenuitem ( 9,  1, " Phone           ", 0,  8, 0, NULL, 0, 0);
  871.         wmenuitem (10,  1, " Dial Prefix     ", 0,  9, 0, NULL, 0, 0);
  872.         wmenuitem (11,  1, " Capabilities    ", 0, 12, 0, NULL, 0, 0);
  873.         wmenuitem (10, 33, " Min. baud rate  ", 0, 27, 0, NULL, 0, 0);
  874.         wmenuitem (12,  1, " Echomail aka    ", 0, 13, 0, NULL, 0, 0);
  875.         wmenuitem (13,  1, " Areafix Level   ", 0,  2, 0, NULL, 0, 0);
  876.         wmenuitem (14,  1, " ├─ A Flag       ", 0, 15, 0, NULL, 0, 0);
  877.         wmenuitem (15,  1, " ├─ B Flag       ", 0, 16, 0, NULL, 0, 0);
  878.         wmenuitem (16,  1, " ├─ C Flag       ", 0, 17, 0, NULL, 0, 0);
  879.         wmenuitem (17,  1, " └─ D Flag       ", 0, 18, 0, NULL, 0, 0);
  880.         wmenuitem (12, 33, " TIC aka         ", 0, 19, 0, NULL, 0, 0);
  881.         wmenuitem (13, 33, " TIC Level       ", 0, 20, 0, NULL, 0, 0);
  882.         wmenuitem (14, 33, " ├─ A Flag       ", 0, 21, 0, NULL, 0, 0);
  883.         wmenuitem (15, 33, " ├─ B Flag       ", 0, 22, 0, NULL, 0, 0);
  884.         wmenuitem (16, 33, " ├─ C Flag       ", 0, 23, 0, NULL, 0, 0);
  885.         wmenuitem (17, 33, " └─ D Flag       ", 0, 24, 0, NULL, 0, 0);
  886.         wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  887.  
  888.         sprintf (string, "%u:%u/%u.%u", ni.zone, ni.net, ni.node, ni.point);
  889.         wprints (1, 19, CYAN|_BLACK, string);
  890.         wprints (2, 19, CYAN|_BLACK, ni.system);
  891.         wprints (3, 19, CYAN|_BLACK, ni.sysop_name);
  892.         wprints (4, 19, CYAN|_BLACK, config.packers[ni.packer].id);
  893.         sprintf (string, "%u:%u/%u.%u", config.alias[ni.mailer_aka].zone, config.alias[ni.mailer_aka].net, config.alias[ni.mailer_aka].node, config.alias[ni.mailer_aka].point);
  894.         wprints (4, 51, CYAN|_BLACK, string);
  895.         wprints (5, 19, CYAN|_BLACK, ni.pw_session);
  896.         wprints (6, 19, CYAN|_BLACK, ni.pw_packet);
  897.         wprints (6, 51, CYAN|_BLACK, ni.pw_inbound_packet);
  898.         wprints (7, 19, CYAN|_BLACK, ni.pw_areafix);
  899.         wprints (8, 19, CYAN|_BLACK, ni.pw_tic);
  900.         wprints (9, 19, CYAN|_BLACK, ni.phone);
  901.         sprintf (string, "%d", ni.modem_type);
  902.         wprints (10, 19, CYAN|_BLACK, string);
  903.         strcpy (string, "----");
  904.         if (ni.remap4d)
  905.             string[0] = 'M';
  906.         if (ni.wazoo)
  907.             string[1] = 'W';
  908.         if (ni.emsi)
  909.             string[2] = 'E';
  910.         if (ni.janus)
  911.             string[3] = 'J';
  912.         wprints (11, 19, CYAN|_BLACK, string);
  913.         sprintf (string,"%ld",ni.min_baud_rate);
  914.         wprints (10, 51, CYAN|_BLACK, string);
  915.  
  916.         if (ni.aka == 0)
  917.             ni.aka++;
  918.         sprintf (string, "%u:%u/%u.%u", config.alias[ni.aka - 1].zone, config.alias[ni.aka - 1].net, config.alias[ni.aka - 1].node, config.alias[ni.aka - 1].point);
  919.         wprints (12, 19, CYAN|_BLACK, string);
  920.  
  921.         sprintf (string, "%d", ni.afx_level);
  922.         wprints (13, 19, CYAN|_BLACK, string);
  923.         wprints (14, 19, CYAN|_BLACK, get_flagA_text ((ni.afx_flags >> 24) & 0xFF));
  924.         wprints (15, 19, CYAN|_BLACK, get_flagB_text ((ni.afx_flags >> 16) & 0xFF));
  925.         wprints (16, 19, CYAN|_BLACK, get_flagC_text ((ni.afx_flags >> 8) & 0xFF));
  926.         wprints (17, 19, CYAN|_BLACK, get_flagD_text (ni.afx_flags & 0xFF));
  927.  
  928.         if (ni.tic_aka == 0)
  929.             ni.tic_aka++;
  930.         sprintf (string, "%u:%u/%u.%u", config.alias[ni.tic_aka - 1].zone, config.alias[ni.tic_aka - 1].net, config.alias[ni.tic_aka - 1].node, config.alias[ni.tic_aka - 1].point);
  931.         wprints (12, 51, CYAN|_BLACK, string);
  932.  
  933.         sprintf (string, "%d", ni.tic_level);
  934.         wprints (13, 51, CYAN|_BLACK, string);
  935.         wprints (14, 51, CYAN|_BLACK, get_flagA_text ((ni.tic_flags >> 24) & 0xFF));
  936.         wprints (15, 51, CYAN|_BLACK, get_flagB_text ((ni.tic_flags >> 16) & 0xFF));
  937.         wprints (16, 51, CYAN|_BLACK, get_flagC_text ((ni.tic_flags >> 8) & 0xFF));
  938.         wprints (17, 51, CYAN|_BLACK, get_flagD_text (ni.tic_flags & 0xFF));
  939.  
  940.         start_update ();
  941.         i = wmenuget ();
  942.  
  943.         switch (i) {
  944.             case 1:
  945.                 sprintf (string, "%u:%u/%u.%u", ni.zone, ni.net, ni.node, ni.point);
  946.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  947.                 winpdef (1, 19, string, "???????????????????", 0, 2, NULL, 0);
  948.                 if (winpread () != W_ESCPRESS)
  949.                     parse_netnode (strbtrim (string), (int *)&ni.zone, (int *)&ni.net, (int *)&ni.node, (int *)&ni.point);
  950.                 break;
  951.  
  952.             case 2:
  953.                 sprintf (string, "%d", ni.afx_level);
  954.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  955.                 winpdef (13, 19, string, "???", 0, 2, NULL, 0);
  956.                 if (winpread () != W_ESCPRESS)
  957.                     ni.afx_level = atoi (strbtrim (string));
  958.                 break;
  959.  
  960.             case 3:
  961.                 wh = wopen (6, 32, 19, 45, 1, LCYAN|_BLACK, CYAN|_BLACK);
  962.                 wactiv (wh);
  963.                 wshadow (DGREY|_BLACK);
  964.                 wtitle (" Packer ", TRIGHT, YELLOW|_BLUE);
  965.                 stop_update ();
  966.                 wmenubegc ();
  967.                 for (m = 0; m < 10; m++) {
  968.                     sprintf (packs[m], " %-8.8s ", config.packers[m].id);
  969.                     wmenuitem (m + 1, 1, packs[m], 0, m + 20, 0, NULL, 0, 0);
  970.                 }
  971.                 wmenuend (ni.packer + 20, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  972.                 start_update ();
  973.                 i = wmenuget ();
  974.                 wclose ();
  975.                 if (i != -1)
  976.                     ni.packer = i - 20;
  977.                 i = 3;
  978.                 break;
  979.  
  980.             case 4:
  981.                 strcpy (string, ni.pw_session);
  982.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  983.                 winpdef (5, 19, string, "???????????????????", 0, 2, NULL, 0);
  984.                 if (winpread () != W_ESCPRESS)
  985.                     strcpy (ni.pw_session, strbtrim (string));
  986.                 break;
  987.  
  988.             case 5:
  989.                 strcpy (string, ni.pw_packet);
  990.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  991.                 winpdef (6, 19, string, "????????", 0, 2, NULL, 0);
  992.                 if (winpread () != W_ESCPRESS)
  993.                     strcpy (ni.pw_packet, strbtrim (string));
  994.                 break;
  995.  
  996.             case 6:
  997.                 strcpy (string, ni.pw_areafix);
  998.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  999.                 winpdef (7, 19, string, "???????????????????", 0, 2, NULL, 0);
  1000.                 if (winpread () != W_ESCPRESS)
  1001.                     strcpy (ni.pw_areafix, strbtrim (string));
  1002.                 break;
  1003.  
  1004.             case 8:
  1005.                 strcpy (string, ni.phone);
  1006.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1007.                 winpdef (9, 19, string, "?????????????????????????????", 0, 2, NULL, 0);
  1008.                 if (winpread () != W_ESCPRESS)
  1009.                     strcpy (ni.phone, strbtrim (string));
  1010.                 break;
  1011.  
  1012.             case 9:
  1013.                 sprintf (string, "%d", ni.modem_type);
  1014.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1015.                 winpdef (10, 19, string, "?????", 0, 2, NULL, 0);
  1016.                 if (winpread () != W_ESCPRESS)
  1017.                     ni.modem_type = atoi (strbtrim (string));
  1018.                 break;
  1019.  
  1020.             case 10:
  1021.                 strcpy (string, ni.sysop_name);
  1022.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1023.                 winpdef (3, 19, string, "???????????????????????????????????", 0, 2, NULL, 0);
  1024.                 if (winpread () != W_ESCPRESS)
  1025.                     strcpy (ni.sysop_name, strbtrim (string));
  1026.                 break;
  1027.  
  1028.             case 11:
  1029.                 strcpy (string, ni.system);
  1030.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1031.                 winpdef (2, 19, string, "???????????????????????????????????", 0, 2, NULL, 0);
  1032.                 if (winpread () != W_ESCPRESS)
  1033.                     strcpy (ni.system, strbtrim (string));
  1034.                 break;
  1035.  
  1036.             case 12:
  1037.                 i = 51;
  1038.                 wh = wopen (9, 32, 16, 56, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1039.                 wactiv (wh);
  1040.                 wshadow (DGREY|_BLACK);
  1041.                 wtitle (" Capabilities ", TRIGHT, YELLOW|_BLUE);
  1042.                 do {
  1043.                     stop_update ();
  1044.                     wclear ();
  1045.  
  1046.                     wmenubegc ();
  1047.                     wmenuitem ( 1, 1, " Remap to point ", 0, 51, 0, NULL, 0, 0);
  1048.                     wmenuitem ( 2, 1, " WaZOO          ", 0, 53, 0, NULL, 0, 0);
  1049.                     wmenuitem ( 3, 1, " EMSI           ", 0, 54, 0, NULL, 0, 0);
  1050.                     wmenuitem ( 4, 1, " Janus          ", 0, 55, 0, NULL, 0, 0);
  1051.                     wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1052.  
  1053.                     wprints (1, 18, CYAN|_BLACK, ni.remap4d ? "Yes" : "No");
  1054.                     wprints (2, 18, CYAN|_BLACK, ni.wazoo ? "Yes" : "No");
  1055.                     wprints (3, 18, CYAN|_BLACK, ni.emsi ? "Yes" : "No");
  1056.                     wprints (4, 18, CYAN|_BLACK, ni.janus ? "Yes" : "No");
  1057.  
  1058.                     start_update ();
  1059.                     i = wmenuget ();
  1060.                     switch (i) {
  1061.                         case 51:
  1062.                             ni.remap4d ^= 1;
  1063.                             break;
  1064.  
  1065.                         case 53:
  1066.                             ni.wazoo ^= 1;
  1067.                             break;
  1068.  
  1069.                         case 54:
  1070.                             ni.emsi ^= 1;
  1071.                             break;
  1072.  
  1073.                         case 55:
  1074.                             ni.janus ^= 1;
  1075.                             break;
  1076.                     }
  1077.                 } while (i != -1);
  1078.  
  1079.                 wclose ();
  1080.                 i = 12;
  1081.                 break;
  1082.  
  1083.  
  1084.             case 13:
  1085.                 mx = 0;
  1086.                 for (m = 0; m <= MAX_ALIAS && config.alias[m].net; m++) {
  1087.                /* MM */
  1088.                sprintf (temp, "%d:%d/%d.%d", config.alias[m].zone, config.alias[m].net, config.alias[m].node, config.alias[m].point);
  1089.                sprintf (string, " %-18.18s ", temp);
  1090.                /* MM*/                    akas[m] = (char *)malloc (strlen (string) + 1);
  1091.                     strcpy (akas[m], string);
  1092.                     if (strlen (string) > mx)
  1093.                         mx = strlen (string);
  1094.                 }
  1095.                 akas[m] = NULL;
  1096.                 /* MM */ // Modificata la gestione del wpickstr, la finestra e'
  1097.                      // a dimensione fissa e non viene piu' calcolata come prima.
  1098.                      // Se necessario aumentare le dimensioni di wopen w wpickstr
  1099.             wh1 = wopen (10, 25, 20, 48, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1100.             wactiv (wh1);
  1101.             wshadow (DGREY|_BLACK);
  1102.             wtitle (" AKAs ", TRIGHT, YELLOW|_BLUE);
  1103.             m = wpickstr (12, 27, 18, 46, 5, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY, akas, ni.aka - 1, NULL);
  1104.             /* MM */
  1105.             if (m != -1)
  1106.                     ni.aka = m+1;
  1107.                 wclose ();
  1108.                 for (m = 0; m <= MAX_ALIAS && config.alias[m].net; m++)
  1109.                     free (akas[m]);
  1110.                 break;
  1111.  
  1112.             case 14:
  1113.                 strcpy (string, ni.pw_tic);
  1114.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1115.                 winpdef (8, 19, string, "???????????????????", 0, 2, NULL, 0);
  1116.                 if (winpread () != W_ESCPRESS)
  1117.                     strcpy (ni.pw_tic, strbtrim (string));
  1118.                 break;
  1119.  
  1120.             case 15:
  1121.                 ni.afx_flags = window_get_flags (8, 34, 1, ni.afx_flags);
  1122.                 break;
  1123.  
  1124.             case 16:
  1125.                 ni.afx_flags = window_get_flags (8, 34, 2, ni.afx_flags);
  1126.                 break;
  1127.  
  1128.             case 17:
  1129.                 ni.afx_flags = window_get_flags (8, 34, 3, ni.afx_flags);
  1130.                 break;
  1131.  
  1132.             case 18:
  1133.                 ni.afx_flags = window_get_flags (8, 34, 4, ni.afx_flags);
  1134.                 break;
  1135.  
  1136.  
  1137.             case 19:
  1138.                 mx = 0;
  1139.                 for (m = 0; m <= MAX_ALIAS && config.alias[m].net; m++) {
  1140.                /* MM */
  1141.                sprintf (temp, "%d:%d/%d.%d", config.alias[m].zone, config.alias[m].net, config.alias[m].node, config.alias[m].point);
  1142.                sprintf (string, " %-18.18s ", temp);
  1143.                /* MM */                    akas[m] = (char *)malloc (strlen (string) + 1);
  1144.                     strcpy (akas[m], string);
  1145.                     if (strlen (string) > mx)
  1146.                         mx = strlen (string);
  1147.                 }
  1148.                 akas[m] = NULL;
  1149.             /* MM */ // Modificata la gestione del wpickstr, la finestra e'
  1150.                      // a dimensione fissa e non viene piu' calcolata come prima.
  1151.                      // Se necessario aumentare le dimensioni di wopen w wpickstr
  1152.             wh1 = wopen (10, 25, 20, 48, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1153.             wactiv (wh1);
  1154.             wshadow (DGREY|_BLACK);
  1155.             wtitle (" AKAs ", TRIGHT, YELLOW|_BLUE);
  1156.             m = wpickstr (12, 27, 18, 46, 5, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY, akas, ni.tic_aka - 1, NULL);
  1157.             /* MM */                if (m != -1)
  1158.                     ni.tic_aka = m+1;
  1159.                 wclose ();
  1160.                 for (m = 0; m <= MAX_ALIAS && config.alias[m].net; m++)
  1161.                     free (akas[m]);
  1162.                 break;
  1163.  
  1164.             case 20:
  1165.                 sprintf (string, "%d", ni.tic_level);
  1166.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1167.                 winpdef (13, 51, string, "???", 0, 2, NULL, 0);
  1168.                 if (winpread () != W_ESCPRESS)
  1169.                     ni.tic_level = atoi (strbtrim (string));
  1170.                 break;
  1171.  
  1172.             case 21:
  1173.                 ni.tic_flags = window_get_flags (8, 46, 1, ni.tic_flags);
  1174.                 break;
  1175.  
  1176.             case 22:
  1177.                 ni.tic_flags = window_get_flags (8, 46, 2, ni.tic_flags);
  1178.                 break;
  1179.  
  1180.             case 23:
  1181.                 ni.tic_flags = window_get_flags (8, 46, 3, ni.tic_flags);
  1182.                 break;
  1183.  
  1184.             case 24:
  1185.                 ni.tic_flags = window_get_flags (8, 46, 4, ni.tic_flags);
  1186.                 break;
  1187.  
  1188.             case 25:
  1189.                 strcpy (string, ni.pw_inbound_packet);
  1190.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1191.                 winpdef (6, 51, string, "????????", 0, 2, NULL, 0);
  1192.                 if (winpread () != W_ESCPRESS)
  1193.                     strcpy (ni.pw_inbound_packet, strbtrim (string));
  1194.                 break;
  1195.  
  1196.             case 26:
  1197.                 mx = 0;
  1198.                 for (m = 0; m < MAX_ALIAS && config.alias[m].net; m++) {
  1199.                /* MM */
  1200.                sprintf (temp, "%d:%d/%d.%d", config.alias[m].zone, config.alias[m].net, config.alias[m].node, config.alias[m].point);
  1201.                sprintf (string, " %-18.18s ", temp);
  1202.                /* MM */                    akas[m] = (char *)malloc (strlen (string) + 1);
  1203.                     strcpy (akas[m], string);
  1204.                     if (strlen (string) > mx)
  1205.                         mx = strlen (string);
  1206.                 }
  1207.                 akas[m] = NULL;
  1208.             /* MM */ // Modificata la gestione del wpickstr, la finestra e'
  1209.                      // a dimensione fissa e non viene piu' calcolata come prima.
  1210.                      // Se necessario aumentare le dimensioni di wopen w wpickstr
  1211.             wh1 = wopen (10, 25, 20, 48, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1212.             wactiv (wh1);
  1213.             wshadow (DGREY|_BLACK);
  1214.             wtitle (" AKAs ", TRIGHT, YELLOW|_BLUE);
  1215.             m = wpickstr (12, 27, 18, 46, 5, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY, akas, ni.mailer_aka - 1, NULL);
  1216.             /* MM */                if (m != -1)
  1217.                     ni.mailer_aka = m;
  1218.                 wclose ();
  1219.                 for (m = 0; m < MAX_ALIAS && config.alias[m].net; m++)
  1220.                     free (akas[m]);
  1221.                 break;
  1222.  
  1223.             case 27:
  1224.                 sprintf (string, "%ld", ni.min_baud_rate);
  1225.                 winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1226.                 wprints (10, 51, CYAN|_BLACK, string);
  1227.                 winpdef (10, 51, string, "??????", 0, 2, NULL, 0);
  1228.                 if (winpread () != W_ESCPRESS)
  1229.                     ni.min_baud_rate = atoi (strbtrim (string));
  1230.                 break;
  1231.         }
  1232.  
  1233.         hidecur ();
  1234.     } while (i != -1);
  1235.  
  1236.     if (memcmp ((char *)&ni, (char *)nip, sizeof (NODEINFO))) {
  1237.         wh = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  1238.         wactiv (wh);
  1239.         wshadow (DGREY|_BLACK);
  1240.  
  1241.         wcenters (1, BLACK|_LGREY, "Save changes (Y/n) ?  ");
  1242.  
  1243.         strcpy (string, "Y");
  1244.         winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  1245.         winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  1246.  
  1247.         i = winpread ();
  1248.         wclose ();
  1249.         hidecur ();
  1250.  
  1251.         if (i == W_ESCPRESS)
  1252.             goto continue_editing;
  1253.  
  1254.       if (toupper (string[0]) == 'Y')
  1255.          memcpy ((char *)nip, (char *)&ni, sizeof (NODEINFO));
  1256.    }
  1257.  
  1258.     gotoxy_ (24, 1);
  1259.     clreol_ ();
  1260.     prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Node  C-Copy  L-List  D-Delete");
  1261.     prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1262.     prints (24, 26, YELLOW|_BLACK, "E");
  1263.     prints (24, 34, YELLOW|_BLACK, "A");
  1264.     prints (24, 50, YELLOW|_BLACK, "C");
  1265.     prints (24, 58, YELLOW|_BLACK, "L");
  1266.     prints (24, 66, YELLOW|_BLACK, "D");
  1267. }
  1268.  
  1269. static void select_nodes_list (fd, oni)
  1270. int fd;
  1271. NODEINFO *oni;
  1272. {
  1273.    int wh, i, x = 0;
  1274.    char string[80], **array, addr[50];
  1275.     NODEINFO ni;
  1276.    long pos;
  1277.  
  1278.    i = (int)(filelength (fd) / sizeof (NODEINFO));
  1279.    i += 2;
  1280.    if ((array = (char **)malloc (i * sizeof (char *))) == NULL)
  1281.       return;
  1282.  
  1283.    pos = tell (fd) - sizeof (NODEINFO);
  1284.    lseek (fd, 0L, SEEK_SET);
  1285.    i = 0;
  1286.  
  1287.    while (read (fd, (char *)&ni, sizeof (NODEINFO)) == sizeof (NODEINFO)) {
  1288.       if (memcmp ((char *)&ni, (char *)oni, sizeof (NODEINFO)) == 0)
  1289.          x = i;
  1290.       sprintf (addr, "%d:%d/%d.%d", ni.zone, ni.net, ni.node, ni.point);
  1291.       sprintf (string, " %-20.20s %-6.6s %-20.20s %5d ", addr, config.packers[ni.packer].id, ni.pw_session, ni.afx_level);
  1292.       array[i] = (char *)malloc (strlen (string) + 1);
  1293.       if (array[i] == NULL)
  1294.          break;
  1295.       strcpy (array[i++], string);
  1296.    }
  1297.    array[i] = NULL;
  1298.  
  1299.    wh = wopen (7, 5, 20, 64, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1300.    wactiv (wh);
  1301.    wshadow (DGREY|_BLACK);
  1302.    wtitle (" Select node ", TRIGHT, YELLOW|_BLUE);
  1303.  
  1304.    wprints (0, 2, LGREY|_BLACK, "Node #               Packer Password             Level");
  1305.    whline (1, 0, 58, 0, BLUE|_BLACK);
  1306.  
  1307.    gotoxy_ (24, 1);
  1308.    clreol_ ();
  1309.    prints (24, 1, LGREY|_BLACK, "-Move bar  ENTER-Select");
  1310.    prints (24, 1, YELLOW|_BLACK, "");
  1311.    prints (24, 14, YELLOW|_BLACK, "ENTER");
  1312.  
  1313.    x = wpickstr (10, 7, 19, 62, 5, LGREY|_BLACK, CYAN|_BLACK, BLUE|_LGREY, array, x, NULL);
  1314.  
  1315.    if (x == -1)
  1316.       lseek (fd, pos, SEEK_SET);
  1317.    else
  1318.       lseek (fd, (long)x * sizeof (NODEINFO), SEEK_SET);
  1319.    read (fd, (char *)oni, sizeof (NODEINFO));
  1320.  
  1321.    wclose ();
  1322.  
  1323.    i = 0;
  1324.    while (array[i] != NULL)
  1325.       free (array[i++]);
  1326.    free (array);
  1327.  
  1328.    gotoxy_ (24, 1);
  1329.     clreol_ ();
  1330.     prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add New Node  C-Copy  L-List  D-Delete");
  1331.     prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1332.     prints (24, 26, YELLOW|_BLACK, "E");
  1333.     prints (24, 34, YELLOW|_BLACK, "A");
  1334.     prints (24, 50, YELLOW|_BLACK, "C");
  1335.     prints (24, 58, YELLOW|_BLACK, "L");
  1336.     prints (24, 66, YELLOW|_BLACK, "D");
  1337. }
  1338.  
  1339. void manager_translation ()
  1340. {
  1341.     int fd, wh, i = 1, saved, fdi, wh1, wh2, m;
  1342.     char string[128], readed, filename[80];
  1343.    long pos;
  1344.    ACCOUNT ai, bai;
  1345.  
  1346.    sprintf (string, "%sCOST.DAT", config.net_info);
  1347.    fd = sh_open (string, SH_DENYNONE, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1348.    if (fd == -1)
  1349.       return;
  1350.  
  1351.    if (!read (fd, (char *)&ai, sizeof (ACCOUNT))) {
  1352.       memset ((char *)&ai, 0, sizeof (ACCOUNT));
  1353.       readed = 0;
  1354.    }
  1355.    else
  1356.       readed = 1;
  1357.  
  1358.    gotoxy_ (24, 1);
  1359.    clreol_ ();
  1360.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add  L-List  D-Delete  C-Copy");
  1361.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1362.    prints (24, 26, YELLOW|_BLACK, "E");
  1363.    prints (24, 34, YELLOW|_BLACK, "A");
  1364.    prints (24, 41, YELLOW|_BLACK, "L");
  1365.    prints (24, 49, YELLOW|_BLACK, "D");
  1366.    prints (24, 59, YELLOW|_BLACK, "C");
  1367.  
  1368.    wh = wopen (2, 6, 21, 74, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1369.    wshadow (DGREY|_BLACK);
  1370.    wtitle (" Translation/Cost ", TRIGHT, YELLOW|_BLUE);
  1371.  
  1372.    do {
  1373.       stop_update ();
  1374.       wclear ();
  1375.  
  1376.       wprints ( 1, 10, LGREY|_BLACK," Location     ");
  1377.       wprints ( 2, 10, LGREY|_BLACK," Prefix       ");
  1378.       wprints ( 3, 10, LGREY|_BLACK," Translate to ");
  1379.  
  1380.       wprints ( 6, 2, LGREY|_BLACK,"│ S M T W T F S │Start│ End │ Cost / Seconds │ Cost / Seconds │");
  1381.  
  1382.       if (readed) {
  1383.          wprints (1, 25, CYAN|_BLACK, ai.location);
  1384.          wprints (2, 25, CYAN|_BLACK, ai.search);
  1385.          wprints (3, 25, CYAN|_BLACK, ai.traslate);
  1386.          for (i = 0; i < 9; i++) {
  1387.             if (!ai.cost[i].start && !ai.cost[i].stop)
  1388.                continue;
  1389.  
  1390.             sprintf (string, "│               │%2d:%02d│%2d:%02d│ %4d / %3d.%d   │ %4d / %3d.%d   │",
  1391.                      ai.cost[i].start / 60, ai.cost[i].start % 60,
  1392.                      ai.cost[i].stop / 60, ai.cost[i].stop % 60,
  1393.                      ai.cost[i].cost_first, ai.cost[i].time_first / 10, ai.cost[i].time_first % 10,
  1394.                      ai.cost[i].cost, ai.cost[i].time / 10, ai.cost[i].time % 10);
  1395.             if (ai.cost[i].days & DAY_SUNDAY)
  1396.                string[2] = 'S';
  1397.             if (ai.cost[i].days & DAY_MONDAY)
  1398.                string[4] = 'M';
  1399.             if (ai.cost[i].days & DAY_TUESDAY)
  1400.                string[6] = 'T';
  1401.             if (ai.cost[i].days & DAY_WEDNESDAY)
  1402.                string[8] = 'W';
  1403.             if (ai.cost[i].days & DAY_THURSDAY)
  1404.                string[10] = 'T';
  1405.             if (ai.cost[i].days & DAY_FRIDAY)
  1406.                string[12] = 'F';
  1407.             if (ai.cost[i].days & DAY_SATURDAY)
  1408.                string[14] = 'S';
  1409.             wprints ( i + 8, 2, LGREY|_BLACK, string);
  1410.          }
  1411.       }
  1412.  
  1413.       start_update ();
  1414.  
  1415.       wbox (5, 2, 17, 64, 0, LGREY|_BLACK);
  1416.       whline (7, 2, 63, 0, LGREY|_BLACK);
  1417.       wvline (5, 18, 13, 0, LGREY|_BLACK);
  1418.       wvline (5, 24, 13, 0, LGREY|_BLACK);
  1419.       wvline (5, 30, 13, 0, LGREY|_BLACK);
  1420.       wvline (5, 47, 13, 0, LGREY|_BLACK);
  1421.       VioUpdate ();
  1422.  
  1423.       i = getxch ();
  1424.       if ( (i & 0xFF) != 0 )
  1425.          i &= 0xFF;
  1426.  
  1427.       switch (i) {
  1428.          // PgDn
  1429.          case 0x5100:
  1430.             if (readed)
  1431.                read (fd, (char *)&ai, sizeof (ACCOUNT));
  1432.             break;
  1433.  
  1434.          // PgUp
  1435.          case 0x4900:
  1436.             if (readed) {
  1437.                if (tell (fd) > sizeof (ACCOUNT)) {
  1438.                   lseek (fd, -2L * sizeof (ACCOUNT), SEEK_CUR);
  1439.                   read (fd, (char *)&ai, sizeof (ACCOUNT));
  1440.                }
  1441.             }
  1442.             break;
  1443.  
  1444.          // C Copy
  1445.          case 'C':
  1446.          case 'c':
  1447.             ai.search[0] = ai.traslate[0] = ai.location[0] = '\0';
  1448.  
  1449.             wh2 = wh;
  1450.             i = 1;
  1451.  
  1452.             wh = wopen (6, 10, 12, 58, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1453.             wactiv (wh);
  1454.             wshadow (DGREY|_BLACK);
  1455.             wtitle (" Copy translation ", TRIGHT, YELLOW|_BLUE);
  1456.  
  1457.             do {
  1458.                stop_update ();
  1459.                wclear ();
  1460.  
  1461.                wmenubegc ();
  1462.                wmenuitem ( 1, 1, " Location     ", 0, 1, 0, NULL, 0, 0);
  1463.                wmenuitem ( 2, 1, " Prefix       ", 0, 2, 0, NULL, 0, 0);
  1464.                wmenuitem ( 3, 1, " Translate to ", 0, 3, 0, NULL, 0, 0);
  1465.  
  1466.                wprints (1, 16, CYAN|_BLACK, ai.location);
  1467.                wprints (2, 16, CYAN|_BLACK, ai.search);
  1468.                wprints (3, 16, CYAN|_BLACK, ai.traslate);
  1469.  
  1470.                wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1471.  
  1472.                start_update ();
  1473.                i = wmenuget ();
  1474.  
  1475.                switch (i) {
  1476.                   case 1:
  1477.                      strcpy (string, ai.location);
  1478.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1479.                      winpdef (1, 16, string, "?????????????????????????????", 0, 2, NULL, 0);
  1480.                      if (winpread () != W_ESCPRESS)
  1481.                         strcpy (ai.location, strbtrim (string));
  1482.                      break;
  1483.  
  1484.                   case 2:
  1485.                      strcpy (string, ai.search);
  1486.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1487.                      winpdef (2, 16, string, "???????????????????", 0, 2, NULL, 0);
  1488.                      if (winpread () != W_ESCPRESS)
  1489.                         strcpy (ai.search, strbtrim (string));
  1490.                      break;
  1491.  
  1492.                   case 3:
  1493.                      strcpy (string, ai.traslate);
  1494.                      winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1495.                      winpdef (3, 16, string, "????????????????????????????????????????????", 0, 2, NULL, 0);
  1496.                      if (winpread () != W_ESCPRESS)
  1497.                         strcpy (ai.traslate, strbtrim (string));
  1498.                      break;
  1499.                }
  1500.  
  1501.                hidecur ();
  1502.             } while (i != -1);
  1503.  
  1504.             wclose ();
  1505.             wh = wh2;
  1506.             wactiv (wh);
  1507.  
  1508.             if (ai.search[0]) {
  1509.                pos = tell (fd) - (long)sizeof (ACCOUNT);
  1510.                close (fd);
  1511.  
  1512.                sprintf (filename, "%sCOST.BAK", config.net_info);
  1513.                unlink (filename);
  1514.                sprintf (string, "%sCOST.DAT", config.net_info);
  1515.                rename (string, filename);
  1516.  
  1517.                fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1518.                fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  1519.                saved = 0;
  1520.  
  1521.                while (read (fd, (char *)&bai, sizeof (ACCOUNT)) == sizeof (ACCOUNT)) {
  1522.                   m = min (strlen (bai.location), strlen (ai.location));
  1523.                   if (!saved && strncmp (bai.location, ai.location, m) > 0 || (strncmp (bai.location, ai.location, m) == 0 && strlen (bai.location) < strlen (ai.location))) {
  1524.                      pos = tell (fdi);
  1525.                      write (fdi, (char *)&ai, sizeof (ACCOUNT));
  1526.                      saved = 1;
  1527.                   }
  1528.                   if (strcmp (bai.location, ai.location))
  1529.                      write (fdi, (char *)&bai, sizeof (ACCOUNT));
  1530.                }
  1531.  
  1532.                if (!saved) {
  1533.                   pos = tell (fdi);
  1534.                   write (fdi, (char *)&ai, sizeof (ACCOUNT));
  1535.                }
  1536.  
  1537.                close (fd);
  1538.                close (fdi);
  1539.  
  1540.                unlink (filename);
  1541.  
  1542.                sprintf (string, "%sCOST.DAT", config.net_info);
  1543.                fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1544.                lseek (fd, pos, SEEK_SET);
  1545.                read (fd, (char *)&ai, sizeof (ACCOUNT));
  1546.             }
  1547.  
  1548.             i = 'C';
  1549.             break;
  1550.  
  1551.          // E Edit
  1552.          case 'E':
  1553.          case 'e':
  1554.             strcpy (string, ai.location);
  1555.             edit_single_location (&ai);
  1556.             lseek (fd, -1L * sizeof (ACCOUNT), SEEK_CUR);
  1557.             write (fd, (char *)&ai, sizeof (ACCOUNT));
  1558.  
  1559.             if (stricmp (string, ai.location)) {
  1560.                pos = tell (fd) - (long)sizeof (ACCOUNT);
  1561.                close (fd);
  1562.  
  1563.                sprintf (filename, "%sCOST.BAK", config.net_info);
  1564.                unlink (filename);
  1565.                sprintf (string, "%sCOST.DAT", config.net_info);
  1566.                rename (string, filename);
  1567.  
  1568.                fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1569.                fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  1570.                saved = 0;
  1571.  
  1572.                while (read (fd, (char *)&bai, sizeof (ACCOUNT)) == sizeof (ACCOUNT)) {
  1573.                   m = min (strlen (bai.location), strlen (ai.location));
  1574.                   if (!saved && strncmp (bai.location, ai.location, m) > 0 || (strncmp (bai.location, ai.location, m) == 0 && strlen (bai.location) < strlen (ai.location))) {
  1575.                      pos = tell (fdi);
  1576.                      write (fdi, (char *)&ai, sizeof (ACCOUNT));
  1577.                      saved = 1;
  1578.                   }
  1579.                   if (strcmp (bai.location, ai.location))
  1580.                      write (fdi, (char *)&bai, sizeof (ACCOUNT));
  1581.                }
  1582.  
  1583.                if (!saved) {
  1584.                   pos = tell (fdi);
  1585.                   write (fdi, (char *)&ai, sizeof (ACCOUNT));
  1586.                }
  1587.  
  1588.                close (fd);
  1589.                close (fdi);
  1590.  
  1591.                unlink (filename);
  1592.  
  1593.                sprintf (string, "%sCOST.DAT", config.net_info);
  1594.                fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1595.                lseek (fd, pos, SEEK_SET);
  1596.                read (fd, (char *)&ai, sizeof (ACCOUNT));
  1597.             }
  1598.             break;
  1599.  
  1600.          // D Delete
  1601.          case 'D':
  1602.          case 'd':
  1603.             wh1 = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  1604.             wactiv (wh1);
  1605.             wshadow (DGREY|_BLACK);
  1606.  
  1607.             wcenters (1, BLACK|_LGREY, "Are you sure (Y/n) ?  ");
  1608.  
  1609.             strcpy (string, "Y");
  1610.             winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  1611.             winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  1612.  
  1613.             i = winpread ();
  1614.             wclose ();
  1615.             hidecur ();
  1616.  
  1617.             if (i == W_ESCPRESS)
  1618.                break;
  1619.  
  1620.             if (toupper (string[0]) == 'Y') {
  1621.                pos = tell (fd) - (long)sizeof (ACCOUNT);
  1622.                close (fd);
  1623.  
  1624.                sprintf (filename, "%sCOST.BAK", config.net_info);
  1625.                unlink (filename);
  1626.                sprintf (string, "%sCOST.DAT", config.net_info);
  1627.                rename (string, filename);
  1628.  
  1629.                fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1630.                fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  1631.                saved = 0;
  1632.  
  1633.                while (read (fd, (char *)&bai, sizeof (ACCOUNT)) == sizeof (ACCOUNT)) {
  1634.                   if (strcmp (bai.location, ai.location))
  1635.                      write (fdi, (char *)&bai, sizeof (ACCOUNT));
  1636.                }
  1637.  
  1638.                close (fd);
  1639.                close (fdi);
  1640.  
  1641.                unlink (filename);
  1642.  
  1643.                sprintf (string, "%sCOST.DAT", config.net_info);
  1644.                fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1645.                if (read (fd, (char *)&ai, sizeof (ACCOUNT)) < sizeof (ACCOUNT)) {
  1646.                   lseek (fd, 0L, SEEK_SET);
  1647.                   read (fd, (char *)&ai, sizeof (ACCOUNT));
  1648.                }
  1649.             }
  1650.             break;
  1651.  
  1652.          // L List
  1653.          case 'L':
  1654.          case 'l':
  1655.             select_cost_list (fd, &ai);
  1656.             break;
  1657.  
  1658.          // A Add
  1659.          case 'A':
  1660.          case 'a':
  1661.             memset ((char *)&ai, 0, sizeof (ACCOUNT));
  1662.             edit_single_location (&ai);
  1663.             lseek (fd, 0L, SEEK_END);
  1664.             write (fd, (char *)&ai, sizeof (ACCOUNT));
  1665.  
  1666.             if (strlen (ai.search)) {
  1667.                pos = tell (fd) - (long)sizeof (ACCOUNT);
  1668.                close (fd);
  1669.  
  1670.                sprintf (filename, "%sCOST.BAK", config.net_info);
  1671.                unlink (filename);
  1672.                sprintf (string, "%sCOST.DAT", config.net_info);
  1673.                rename (string, filename);
  1674.  
  1675.                fd = open (filename, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1676.                fdi = open (string, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
  1677.                saved = 0;
  1678.  
  1679.                while (read (fd, (char *)&bai, sizeof (ACCOUNT)) == sizeof (ACCOUNT)) {
  1680.                   m = min (strlen (bai.location), strlen (ai.location));
  1681.                   if (!saved && strncmp (bai.location, ai.location, m) > 0 || (strncmp (bai.location, ai.location, m) == 0 && strlen (bai.location) < strlen (ai.location))) {
  1682.                      pos = tell (fdi);
  1683.                      write (fdi, (char *)&ai, sizeof (ACCOUNT));
  1684.                      saved = 1;
  1685.                   }
  1686.                   if (strcmp (bai.location, ai.location))
  1687.                      write (fdi, (char *)&bai, sizeof (ACCOUNT));
  1688.                }
  1689.  
  1690.                if (!saved) {
  1691.                   pos = tell (fdi);
  1692.                   write (fdi, (char *)&ai, sizeof (ACCOUNT));
  1693.                }
  1694.  
  1695.                close (fd);
  1696.                close (fdi);
  1697.  
  1698.                unlink (filename);
  1699.  
  1700.                sprintf (string, "%sCOST.DAT", config.net_info);
  1701.                fd = open (string, O_RDWR|O_CREAT|O_BINARY, S_IREAD|S_IWRITE);
  1702.                lseek (fd, pos, SEEK_SET);
  1703.                read (fd, (char *)&ai, sizeof (ACCOUNT));
  1704.             }
  1705.             readed = 1;
  1706.             break;
  1707.  
  1708.          // ESC Exit
  1709.          case 0x1B:
  1710.             i = -1;
  1711.             break;
  1712.       }
  1713.  
  1714.    } while (i != -1);
  1715.  
  1716.    close (fd);
  1717.  
  1718.    wclose ();
  1719.    gotoxy_ (24, 1);
  1720.    clreol_ ();
  1721. }
  1722.  
  1723. static void edit_single_location (aip)
  1724. ACCOUNT *aip;
  1725. {
  1726.    int wh, i = 1, x, t1, t2;
  1727.    char string[128], packs[10][70], start[10], stop[10];
  1728.    char cost1[10], seconds1[10], cost2[10], seconds2[10];
  1729.    char sun[2], mon[2], tue[2], wed[2], thu[2], fri[2], sat[2];
  1730.    ACCOUNT ai;
  1731.  
  1732.    memcpy ((char *)&ai, (char *)aip, sizeof (ACCOUNT));
  1733.    sun[1] = mon[1] = tue[1] = wed[1] = thu[1] = fri[1] = sat[1] = '\0';
  1734.  
  1735.    gotoxy_ (24, 1);
  1736.    clreol_ ();
  1737.    prints (24, 1, LGREY|_BLACK, "ESC-Exit/Save  ENTER-Edit");
  1738.    prints (24, 1, YELLOW|_BLACK, "ESC");
  1739.    prints (24, 16, YELLOW|_BLACK, "ENTER");
  1740.  
  1741. continue_editing:
  1742.    do {
  1743.       stop_update ();
  1744.       wclear ();
  1745.  
  1746.       wprints ( 1, 10, LGREY|_BLACK," Location     ");
  1747.       wprints ( 2, 10, LGREY|_BLACK," Prefix       ");
  1748.       wprints ( 3, 10, LGREY|_BLACK," Translate to ");
  1749.       wprints ( 6, 2, LGREY|_BLACK,"│ S M T W T F S │Start│ End │ Cost / Seconds │ Cost / Seconds │");
  1750.  
  1751.       wmenubegc ();
  1752.       wmenuitem ( 1, 10, " Location     ", 0, 1, 0, NULL, 0, 0);
  1753.       wmenuitem ( 2, 10, " Prefix       ", 0, 2, 0, NULL, 0, 0);
  1754.       wmenuitem ( 3, 10, " Translate to ", 0, 3, 0, NULL, 0, 0);
  1755.  
  1756.       wprints (1, 25, CYAN|_BLACK, ai.location);
  1757.       wprints (2, 25, CYAN|_BLACK, ai.search);
  1758.       wprints (3, 25, CYAN|_BLACK, ai.traslate);
  1759.  
  1760.       for (x = 0; x < 9; x++) {
  1761.          if (!ai.cost[x].days)
  1762.             strcpy (packs[x],  "               │     │     │                │                ");
  1763.          else {
  1764.             sprintf (packs[x], "               │%2d:%02d│%2d:%02d│ %4d / %3d.%d   │ %4d / %3d.%d   ",
  1765.                      ai.cost[x].start / 60, ai.cost[x].start % 60,
  1766.                      ai.cost[x].stop / 60, ai.cost[x].stop % 60,
  1767.                      ai.cost[x].cost_first, ai.cost[x].time_first / 10, ai.cost[x].time_first % 10,
  1768.                      ai.cost[x].cost, ai.cost[x].time / 10, ai.cost[x].time % 10);
  1769.             if (ai.cost[x].days & DAY_SUNDAY)
  1770.                packs[x][1] = 'S';
  1771.             if (ai.cost[x].days & DAY_MONDAY)
  1772.                packs[x][3] = 'M';
  1773.             if (ai.cost[x].days & DAY_TUESDAY)
  1774.                packs[x][5] = 'T';
  1775.             if (ai.cost[x].days & DAY_WEDNESDAY)
  1776.                packs[x][7] = 'W';
  1777.             if (ai.cost[x].days & DAY_THURSDAY)
  1778.                packs[x][9] = 'T';
  1779.             if (ai.cost[x].days & DAY_FRIDAY)
  1780.                packs[x][11] = 'F';
  1781.             if (ai.cost[x].days & DAY_SATURDAY)
  1782.                packs[x][13] = 'S';
  1783.          }
  1784.  
  1785.          wmenuitem ( x + 8, 3, packs[x], 0, 4 + x, 0, NULL, 0, 0);
  1786.       }
  1787.  
  1788.       wmenuend (i, M_OMNI|M_SAVE, 0, 0, LGREY|_BLACK, LGREY|_BLACK, LGREY|_BLACK, BLUE|_LGREY);
  1789.  
  1790.       start_update ();
  1791.  
  1792.       wbox (5, 2, 17, 64, 0, LGREY|_BLACK);
  1793.       whline (7, 2, 63, 0, LGREY|_BLACK);
  1794.       wvline (5, 18, 13, 0, LGREY|_BLACK);
  1795.       wvline (5, 24, 13, 0, LGREY|_BLACK);
  1796.       wvline (5, 30, 13, 0, LGREY|_BLACK);
  1797.       wvline (5, 47, 13, 0, LGREY|_BLACK);
  1798.       VioUpdate ();
  1799.  
  1800.       i = wmenuget ();
  1801.  
  1802.       switch (i) {
  1803.          case 1:
  1804.             strcpy (string, ai.location);
  1805.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1806.             winpdef (1, 25, string, "?????????????????????????????", 0, 2, NULL, 0);
  1807.             if (winpread () != W_ESCPRESS)
  1808.                strcpy (ai.location, strbtrim (string));
  1809.             break;
  1810.  
  1811.          case 2:
  1812.             strcpy (string, ai.search);
  1813.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1814.             winpdef (2, 25, string, "???????????????????", 0, 2, NULL, 0);
  1815.             if (winpread () != W_ESCPRESS)
  1816.                strcpy (ai.search, strbtrim (string));
  1817.             break;
  1818.  
  1819.          case 3:
  1820.             strcpy (string, ai.traslate);
  1821.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1822.             winpdef (3, 25, string, "????????????????????????????????????????????", 0, 2, NULL, 0);
  1823.             if (winpread () != W_ESCPRESS)
  1824.                strcpy (ai.traslate, strbtrim (string));
  1825.             break;
  1826.  
  1827.          case 4:
  1828.          case 5:
  1829.          case 6:
  1830.          case 7:
  1831.          case 8:
  1832.          case 9:
  1833.          case 10:
  1834.          case 11:
  1835.          case 12:
  1836.             if (!ai.cost[i-4].days)
  1837.                strcpy (packs[i-4],  "               │     │     │                │                ");
  1838.              else {
  1839.                sprintf (packs[i-4], "               │%2d:%02d│%2d:%02d│ %4d / %3d.%d   │ %4d / %3d.%d   ",
  1840.                         ai.cost[i-4].start / 60, ai.cost[i-4].start % 60,
  1841.                         ai.cost[i-4].stop / 60, ai.cost[i-4].stop % 60,
  1842.                         ai.cost[i-4].cost_first, ai.cost[i-4].time_first / 10, ai.cost[i-4].time_first % 10,
  1843.                         ai.cost[i-4].cost, ai.cost[i-4].time / 10, ai.cost[i-4].time % 10);
  1844.                if (ai.cost[i-4].days & DAY_SUNDAY)
  1845.                   packs[i-4][1] = 'S';
  1846.                if (ai.cost[i-4].days & DAY_MONDAY)
  1847.                   packs[i-4][3] = 'M';
  1848.                if (ai.cost[i-4].days & DAY_TUESDAY)
  1849.                   packs[i-4][5] = 'T';
  1850.                if (ai.cost[i-4].days & DAY_WEDNESDAY)
  1851.                   packs[i-4][7] = 'W';
  1852.                if (ai.cost[i-4].days & DAY_THURSDAY)
  1853.                   packs[i-4][9] = 'T';
  1854.                if (ai.cost[i-4].days & DAY_FRIDAY)
  1855.                   packs[i-4][11] = 'F';
  1856.                if (ai.cost[i-4].days & DAY_SATURDAY)
  1857.                   packs[i-4][13] = 'S';
  1858.             }
  1859.             wprints ( i + 4, 3, LGREY|_BLACK, packs[i-4]);
  1860.  
  1861.             sun[0] = mon[0] = tue[0] = wed[0] = thu[0] = fri[0] = sat[0] = ' ';
  1862.  
  1863.             if (ai.cost[i - 4].days & DAY_SUNDAY)
  1864.                sun[0] = 'S';
  1865.             if (ai.cost[i - 4].days & DAY_MONDAY)
  1866.                mon[0] = 'M';
  1867.             if (ai.cost[i - 4].days & DAY_TUESDAY)
  1868.                tue[0] = 'T';
  1869.             if (ai.cost[i - 4].days & DAY_WEDNESDAY)
  1870.                wed[0] = 'W';
  1871.             if (ai.cost[i - 4].days & DAY_THURSDAY)
  1872.                thu[0] = 'T';
  1873.             if (ai.cost[i - 4].days & DAY_FRIDAY)
  1874.                fri[0] = 'F';
  1875.             if (ai.cost[i - 4].days & DAY_SATURDAY)
  1876.                sat[0] = 'S';
  1877.             sprintf (start, "%2d:%02d", ai.cost[i - 4].start / 60, ai.cost[i - 4].start % 60);
  1878.             sprintf (stop, "%2d:%02d", ai.cost[i - 4].stop / 60, ai.cost[i - 4].stop % 60);
  1879.             sprintf (cost1, "%4d", ai.cost[i - 4].cost_first);
  1880.             sprintf (seconds1, "%3d.%d", ai.cost[i - 4].time_first / 10, ai.cost[i - 4].time_first % 10);
  1881.             sprintf (cost2, "%4d", ai.cost[i - 4].cost);
  1882.             sprintf (seconds2, "%3d.%d", ai.cost[i - 4].time / 10, ai.cost[i - 4].time % 10);
  1883.  
  1884.             winpbeg (BLUE|_GREEN, BLUE|_GREEN);
  1885.             winpdef (i + 4,  4, sun, "?", 0, 2, NULL, 0);
  1886.             winpdef (i + 4,  6, mon, "?", 0, 2, NULL, 0);
  1887.             winpdef (i + 4,  8, tue, "?", 0, 2, NULL, 0);
  1888.             winpdef (i + 4, 10, wed, "?", 0, 2, NULL, 0);
  1889.             winpdef (i + 4, 12, thu, "?", 0, 2, NULL, 0);
  1890.             winpdef (i + 4, 14, fri, "?", 0, 2, NULL, 0);
  1891.             winpdef (i + 4, 16, sat, "?", 0, 2, NULL, 0);
  1892.             winpdef (i + 4, 19, start, "?????", 0, 2, NULL, 0);
  1893.             winpdef (i + 4, 25, stop, "?????", 0, 2, NULL, 0);
  1894.             winpdef (i + 4, 32, cost1, "????", 0, 2, NULL, 0);
  1895.             winpdef (i + 4, 39, seconds1, "??????", 0, 2, NULL, 0);
  1896.             winpdef (i + 4, 49, cost2, "????", 0, 2, NULL, 0);
  1897.             winpdef (i + 4, 56, seconds2, "??????", 0, 2, NULL, 0);
  1898.             winpread ();
  1899.  
  1900.             sscanf (start, "%d:%d", &t1, &t2);
  1901.             ai.cost[i - 4].start = t1 * 60 + t2;
  1902.             sscanf (stop, "%d:%d", &t1, &t2);
  1903.             ai.cost[i - 4].stop = t1 * 60 + t2;
  1904.             ai.cost[i - 4].cost_first = atoi (cost1);
  1905.             if (sscanf (seconds1, "%d.%d", &t1, &t2) == 1)
  1906.                ai.cost[i - 4].time_first = t1 * 10;
  1907.             else
  1908.                ai.cost[i - 4].time_first = t1 * 10 + t2;
  1909.             ai.cost[i - 4].cost = atoi (cost2);
  1910.             if (sscanf (seconds2, "%d.%d", &t1, &t2) == 1)
  1911.                ai.cost[i - 4].time = t1 * 10;
  1912.             else
  1913.                ai.cost[i - 4].time = t1 * 10 + t2;
  1914.             if (sun[0] != ' ')
  1915.                ai.cost[i - 4].days |= DAY_SUNDAY;
  1916.             else
  1917.                ai.cost[i - 4].days &= ~DAY_SUNDAY;
  1918.             if (mon[0] != ' ')
  1919.                ai.cost[i - 4].days |= DAY_MONDAY;
  1920.             else
  1921.                ai.cost[i - 4].days &= ~DAY_MONDAY;
  1922.             if (tue[0] != ' ')
  1923.                ai.cost[i - 4].days |= DAY_TUESDAY;
  1924.             else
  1925.                ai.cost[i - 4].days &= ~DAY_TUESDAY;
  1926.             if (wed[0] != ' ')
  1927.                ai.cost[i - 4].days |= DAY_WEDNESDAY;
  1928.             else
  1929.                ai.cost[i - 4].days &= ~DAY_WEDNESDAY;
  1930.             if (thu[0] != ' ')
  1931.                ai.cost[i - 4].days |= DAY_THURSDAY;
  1932.             else
  1933.                ai.cost[i - 4].days &= ~DAY_THURSDAY;
  1934.             if (fri[0] != ' ')
  1935.                ai.cost[i - 4].days |= DAY_FRIDAY;
  1936.             else
  1937.                ai.cost[i - 4].days &= ~DAY_FRIDAY;
  1938.             if (sat[0] != ' ')
  1939.                ai.cost[i - 4].days |= DAY_SATURDAY;
  1940.             else
  1941.                ai.cost[i - 4].days &= ~DAY_SATURDAY;
  1942.       }
  1943.  
  1944.       hidecur ();
  1945.    } while (i != -1);
  1946.  
  1947.    if (memcmp ((char *)&ai, (char *)aip, sizeof (ACCOUNT))) {
  1948.       wh = wopen (10, 25, 14, 54, 0, BLACK|_LGREY, BLACK|_LGREY);
  1949.       wactiv (wh);
  1950.       wshadow (DGREY|_BLACK);
  1951.  
  1952.       wcenters (1, BLACK|_LGREY, "Save changes (Y/n) ?  ");
  1953.  
  1954.       strcpy (string, "Y");
  1955.       winpbeg (BLACK|_LGREY, BLACK|_LGREY);
  1956.       winpdef (1, 24, string, "?", 0, 2, NULL, 0);
  1957.  
  1958.       i = winpread ();
  1959.       wclose ();
  1960.       hidecur ();
  1961.  
  1962.       if (i == W_ESCPRESS)
  1963.          goto continue_editing;
  1964.  
  1965.       if (toupper (string[0]) == 'Y')
  1966.          memcpy ((char *)aip, (char *)&ai, sizeof (ACCOUNT));
  1967.    }
  1968.  
  1969.    gotoxy_ (24, 1);
  1970.    clreol_ ();
  1971.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add  L-List  D-Delete  C-Copy");
  1972.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  1973.    prints (24, 26, YELLOW|_BLACK, "E");
  1974.    prints (24, 34, YELLOW|_BLACK, "A");
  1975.    prints (24, 41, YELLOW|_BLACK, "L");
  1976.    prints (24, 49, YELLOW|_BLACK, "D");
  1977.    prints (24, 59, YELLOW|_BLACK, "C");
  1978. }
  1979.  
  1980. #define COSTARRAY 150
  1981.  
  1982. static void select_cost_list (fd, ai)
  1983. int fd;
  1984. ACCOUNT *ai;
  1985. {
  1986.    int wh, i, beg;
  1987.    char string[128], **array;
  1988.    ACCOUNT bai;
  1989.  
  1990.    wh = wopen (3, 2, 21, 76, 1, LCYAN|_BLACK, CYAN|_BLACK);
  1991.    wactiv (wh);
  1992.    wshadow (DGREY|_BLACK);
  1993.    wtitle (" Account/Traslation ", TRIGHT, YELLOW|_BLUE);
  1994.  
  1995.    wprints (0, 0, LGREY|_BLACK, " Location                      Prefix              Traslate to          ");
  1996.    whline (1, 0, 76, 0, BLUE|_BLACK);
  1997.  
  1998.    gotoxy_ (24, 1);
  1999.    clreol_ ();
  2000.    prints (24, 1, LGREY|_BLACK, "-Move bar  ENTER-Select");
  2001.    prints (24, 1, YELLOW|_BLACK, "");
  2002.    prints (24, 14, YELLOW|_BLACK, "ENTER");
  2003.  
  2004.    i = (int)(filelength (fd) / sizeof (ACCOUNT));
  2005.    i += 2;
  2006.    if ((array = (char **)malloc (i * sizeof (char *))) == NULL)
  2007.       return;
  2008.  
  2009.    beg = i = 0;
  2010.    lseek (fd, 0L, SEEK_SET);
  2011.  
  2012.    while (read (fd, (char *)&bai, sizeof (ACCOUNT)) == sizeof (ACCOUNT)) {
  2013.       if (memcmp ((char *)&bai, (char *)ai, sizeof (ACCOUNT)) == 0)
  2014.          beg = i;
  2015.       sprintf (string, " %-28.28s %-19.19s %-20.20s ", bai.location, bai.search, bai.traslate);
  2016.       array[i] = (char *)malloc (strlen (string) + 1);
  2017.       if (array[i] == NULL)
  2018.          break;
  2019.       strcpy (array[i++], string);
  2020.    }
  2021.  
  2022.    array[i] = NULL;
  2023.  
  2024.    i = wpickstr (6, 3, 20, 75, 5, LGREY|_BLACK, CYAN|_BLACK, BLUE|_LGREY, array, beg, NULL);
  2025.  
  2026.    if (i != -1) {
  2027.       lseek (fd, (long)sizeof (ACCOUNT) * (long)i, SEEK_SET);
  2028.       read (fd, (char *)ai, sizeof (ACCOUNT));
  2029.    }
  2030.  
  2031.    i = 0;
  2032.    while (array[i] != NULL)
  2033.       free (array[i++]);
  2034.    free (array);
  2035.  
  2036.    wclose ();
  2037.  
  2038.    gotoxy_ (24, 1);
  2039.    clreol_ ();
  2040.    prints (24, 1, LGREY|_BLACK, "PgUp/PgDn-Next/Previous  E-Edit  A-Add  L-List  D-Delete  C-Copy");
  2041.    prints (24, 1, YELLOW|_BLACK, "PgUp/PgDn");
  2042.    prints (24, 26, YELLOW|_BLACK, "E");
  2043.    prints (24, 34, YELLOW|_BLACK, "A");
  2044.    prints (24, 41, YELLOW|_BLACK, "L");
  2045.    prints (24, 49, YELLOW|_BLACK, "D");
  2046.    prints (24, 59, YELLOW|_BLACK, "C");
  2047. }
  2048.  
  2049.