home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / PPPBCKP / SRC15B42.ZIP / INSTALL.C < prev    next >
C/C++ Source or Header  |  1997-04-05  |  35KB  |  1,210 lines

  1. /* ══════════════════════  START OF PPPINST.CPP  ════════════════════════ */
  2.  
  3. #include <io.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <stdarg.h>
  7. #include <conio.h>
  8. #include <string.h>
  9. #include <ctype.h>
  10. #include <dos.h>
  11. #include <dir.h>
  12. #include <fcntl.h>
  13. #include <sys\stat.h>
  14. #include <direct.h>
  15. #include "vardec.h"
  16. #include "net.h"
  17.  
  18. #define VERSION "Beta-2"
  19.  
  20. #define LAST(s) s[strlen(s)-1]
  21. #define BACKSPC 0x08
  22. #define ESC     0x1B
  23. #define LEFT    0x4B
  24. #define RIGHT   0x4D
  25. #define HOME    0x47
  26. #define END     0x4F
  27. #define INSERT  0x52
  28. #define DELETE  0x53
  29. #define ENTER   0x0D
  30. #define CTLEND  0x75
  31. #define CTLHOME 0x77
  32. #define CTLRT   0x74
  33. #define CTLLFT  0x73
  34.  
  35. char *instfile[] = {
  36.   "NETWORK.EXE",
  37.   "PPP.EXE",
  38.   "PPPWAT.EXE",
  39.   "PPPSTATE.EXE",
  40.   "PPPINIT.OVL",
  41.   "UU.EXE",
  42.   "LSL.COM",
  43.   "IPSTUB.EXE",
  44.   "POP.EXE",
  45.   "LOAD.BAT",
  46.   "UNLOAD.BAT",
  47.   "NEWS.EXE",
  48.   "PPPMENU.EXE",
  49.   "NSLOOKUP.EXE",
  50.   "VKTIPPP.386",
  51.   "EXP.EXE",
  52.   "PING.EXE",
  53.   0L,
  54. };
  55.  
  56. char *texth[] = {"th", "st", "nd", "rd"};
  57.  
  58. char *ordinal_text(unsigned number)
  59. {
  60.   if (((number %= 100) > 9 && number < 20) || (number %= 10) > 3)
  61.     number = 0;
  62.   return texth[number];
  63. }
  64.  
  65.  
  66. configrec syscfg;
  67. net_networks_rec *net_networks;
  68.  
  69. char wwiv_net_no[20], maindir[181];
  70. char instdir[121];
  71. char *net_name, *net_data;
  72. unsigned short net_sysnum;
  73. int net_num, net_num_max;
  74.  
  75. char SMTPHOST[60], POPHOST[60], POPNAME[60], POPPASS[25];
  76. char NETMASK[21];
  77. char ISPPHONE[21], DNS[21], DOMAIN[60];
  78. char LOGINPROMPT[21], LOGINNAME[21], LOGINPASS[21], PASSPROMPT[21];
  79. unsigned int COMPORT, ALLMAIL;
  80.  
  81. typedef unsigned char uchar;                /* 8 bits, unsigned  */
  82. typedef unsigned int uint;                  /* 16 bits, unsigned  */
  83.  
  84. void *mallocx(unsigned long l)
  85. {
  86.   void *x;
  87.   char huge *xx;
  88.  
  89.   if (!l)
  90.     l = 1;
  91.   x = (void *) malloc((int) l);
  92.  
  93.   if (!x) {
  94.     fprintf(stderr, "\n ■ Unable to allocate %ld bytes of memory", l);
  95.     exit(EXIT_FAILURE);
  96.   }
  97.   xx = (char huge *) x;
  98.   while (l > 0L) {
  99.     if (l > 32768L) {
  100.       memset((void *) xx, 0L, (int) 32768L);
  101.       l -= 32768L;
  102.       xx += 32768L;
  103.     } else {
  104.       memset((void *) xx, 0L, (int) l);
  105.       break;
  106.     }
  107.   }
  108.   return (x);
  109. }
  110.  
  111.  
  112. int cd_to(char *path)
  113. {
  114.   int d, max_d;
  115.  
  116.   strupr(path);
  117.   if (path[1] == ':') {
  118.     max_d = getdisk();
  119.     max_d = setdisk(max_d);
  120.     d = path[0] - 'A';
  121.     if (d < max_d) {
  122.       setdisk(d);
  123.       if (chdir(path) == -1)
  124.         return -1;
  125.     } else {
  126.       return -1;
  127.     }
  128.   } else {
  129.     if (chdir(path) == -1)
  130.       return -1;
  131.   }
  132.   return 0;
  133. }
  134.  
  135. void get_dir(char *s, int be)
  136. {
  137.   strcpy(s, "X:\\");
  138.   s[0] = 'A' + getdisk();
  139.   getcurdir(0, &(s[3]));
  140.   if (be) {
  141.     if (s[strlen(s) - 1] == '\\')
  142.       s[strlen(s)] = 0;
  143.   }
  144. }
  145.  
  146.  
  147. void set_net_num(int n)
  148. {
  149.   if ((n >= 0) && (n < net_num_max)) {
  150.     net_num = n;
  151.     net_name = net_networks[net_num].name;
  152.     net_data = net_networks[net_num].dir;
  153.     net_sysnum = net_networks[net_num].sysnum;
  154.     sprintf(wwiv_net_no, "WWIV_NET=%d", net_num);
  155.   }
  156. }
  157.  
  158. void read_networks(void)
  159. {
  160.   int f;
  161.   char s[121];
  162.  
  163.   sprintf(s, "%sNETWORKS.DAT", syscfg.datadir);
  164.   f = open(s, O_RDONLY | O_BINARY);
  165.   net_num_max = 0;
  166.   if (f > 0) {
  167.     net_num_max = (int) (filelength(f) / sizeof(net_networks_rec));
  168.     close(f);
  169.   }
  170. }
  171.  
  172. void err_exit(char *fmt,...)
  173. {
  174.   va_list v;
  175.  
  176.   va_start(v, fmt);
  177.   vfprintf(stderr, fmt, v);
  178.   va_end(v);
  179.   cd_to(maindir);
  180.   exit(1);
  181. }
  182.  
  183.  
  184.  
  185.  
  186. int make_path(char *s)
  187. {
  188.   unsigned int i;
  189.   char drive, current_path[_MAX_PATH], current_drive, *p, *flp;
  190.   union REGS r;
  191.  
  192.  
  193.   p = flp = strdup(s);
  194.  
  195.   _getdcwd(0, current_path, _MAX_PATH);
  196.   current_drive = *current_path - '@';
  197.  
  198.   if (LAST(s) == '\\')
  199.     LAST(s) = 0;
  200.  
  201.   if (p[1] == ':') {
  202.     drive = toupper(p[0]) - 'A' + 1;
  203.  
  204.     if ((_osmajor == 3 && _osminor >= 1) ||
  205.         (_osmajor > 3)) {
  206.       r.x.ax = 0x4409;
  207.       r.h.bl = drive;
  208.       int86(0x21, &r, &r);
  209.  
  210.       if (r.x.cflag)
  211.         return -3;
  212.     }
  213.     if (_chdrive(drive)) {
  214.       chdir(current_path);
  215.       _dos_setdrive(current_drive, &i);
  216.       return -2;
  217.     }
  218.     p += 2;
  219.   }
  220.   if (*p == '\\') {
  221.     chdir("\\");
  222.     p++;
  223.   }
  224.   for (; (p = strtok(p, "\\")) != 0;
  225.        p = 0) {
  226.     if (chdir(p)) {
  227.       if (mkdir(p)) {
  228.         chdir(current_path);
  229.         _dos_setdrive(current_drive, &i);
  230.         return -1;
  231.       }
  232.       chdir(p);
  233.     }
  234.   }
  235.  
  236.   chdir(current_path);
  237.   if (flp)
  238.     free(flp);
  239.   return 0;
  240.  
  241. }
  242.  
  243.  
  244.  
  245. int jgets(char *s, int maxlen)
  246. {
  247.   char temp[500];
  248.   int insert = 1, done = 0, pos = 0, len = 0, i, c, zeroflag;
  249.  
  250.   textattr(116);
  251.   for (i = 0; i < maxlen; i++)
  252.     cprintf(" ");
  253.   for (i = 0; i < maxlen; i++)
  254.     cprintf("\b");
  255.   textattr(15);
  256.   while (!done) {
  257.     zeroflag = 0;
  258.     if ((c = getch()) == 0) {
  259.       zeroflag = 1;
  260.       c = getch();
  261.     }
  262.     switch (c) {
  263.       case ESC:
  264.         if (len == 0) {
  265.           err_exit("\n\nInstallation aborted.\n\n");
  266.         }
  267.         if (pos != len) {
  268.           pos = len = 0;
  269.           break;
  270.         }
  271.       case LEFT:
  272.         if (zeroflag) {
  273.           if (pos == 0)
  274.             break;
  275.           pos--;
  276.           putch(BACKSPC);
  277.           break;
  278.         }
  279.       case RIGHT:
  280.         if (zeroflag) {
  281.           if (pos == len)
  282.             break;
  283.           if (pos != maxlen) {
  284.             putch(temp[pos]);
  285.             pos++;
  286.           }
  287.           break;
  288.         }
  289.       case HOME:
  290.         if (zeroflag) {
  291.           while (pos-- > 0)
  292.             putch(BACKSPC);
  293.           pos = 0;
  294.           break;
  295.         }
  296.       case END:
  297.         if (zeroflag) {
  298.           while (pos < len)
  299.             putch(temp[pos++]);
  300.           break;
  301.         }
  302.       case INSERT:
  303.         if (zeroflag) {
  304.           insert = (!(insert));
  305.           break;
  306.         }
  307.       case DELETE:
  308.         if (zeroflag) {
  309.           if (pos == len)
  310.             break;
  311.           for (i = pos; i < len; i++)
  312.             temp[i] = temp[i + 1];
  313.           len--;
  314.           for (i = pos; i < len; i++)
  315.             putch(temp[i]);
  316.           for (i = len + 1; i > pos; i--)
  317.             putch(BACKSPC);
  318.           break;
  319.         }
  320.       case BACKSPC:
  321.         if (c == BACKSPC) {
  322.           if (pos == 0)
  323.             break;
  324.           if (pos != len) {
  325.             for (i = pos - 1; i < len; i++)
  326.               temp[i] = temp[i + 1];
  327.             pos--;
  328.             len--;
  329.             putch(BACKSPC);
  330.             for (i = pos; i < len; i++)
  331.               putch(temp[i]);
  332.             for (i = len; i >= pos; i--)
  333.               putch(BACKSPC);
  334.           } else {
  335.             putch(BACKSPC);
  336.             pos = --len;
  337.           }
  338.           break;
  339.         }
  340.       case ENTER:
  341.         if (c == ENTER) {
  342.           done = 1;
  343.           break;
  344.         }
  345.       case CTLEND:
  346.         if (zeroflag) {
  347.           len = pos;
  348.           break;
  349.         }
  350.       case CTLHOME:
  351.         if (zeroflag) {
  352.           if (pos == 0)
  353.             break;
  354.           if (pos != len) {
  355.             while (0 != pos) {
  356.               for (i = pos - 1; i < len; i++)
  357.                 temp[i] = temp[i + 1];
  358.               pos--;
  359.               len--;
  360.               putch(BACKSPC);
  361.               for (i = pos; i < len; i++)
  362.                 putch(temp[i]);
  363.               for (i = len; i >= pos; i--)
  364.                 putch(BACKSPC);
  365.             }
  366.           } else {
  367.             while (0 != pos)
  368.               pos = --len;
  369.           }
  370.           break;
  371.         }
  372.       case CTLRT:
  373.         if (zeroflag) {
  374.           do {
  375.             if (pos == len)
  376.               break;
  377.             if (pos != maxlen) {
  378.               putch(temp[pos]);
  379.               pos++;
  380.             }
  381.           } while (isspace(temp[pos]));
  382.           do {
  383.             if (pos == len)
  384.               break;
  385.             if (pos != maxlen) {
  386.               putch(temp[pos]);
  387.               pos++;
  388.             }
  389.           } while (!isspace(temp[pos]));
  390.           break;
  391.         }
  392.       case CTLLFT:
  393.         if (zeroflag) {
  394.           do {
  395.             if (pos == 0)
  396.               break;
  397.             pos--;
  398.             putch(BACKSPC);
  399.           } while (isspace(temp[pos]));
  400.           do {
  401.             if (pos == 0)
  402.               break;
  403.             pos--;
  404.             putch(BACKSPC);
  405.           } while (!isspace(temp[pos]));
  406.           break;
  407.         }
  408.       default:
  409.         if (zeroflag)
  410.           break;
  411.         if (c == 0 || pos == maxlen)
  412.           break;
  413.         if ((!(insert)) || pos == len) {
  414.           temp[pos++] = c;
  415.           if (pos > len)
  416.             len++;
  417.           putch(c);
  418.         } else {
  419.           for (i = len++; i >= pos; i--)
  420.             temp[i + 1] = temp[i];
  421.           temp[pos++] = c;
  422.           putch(c);
  423.           for (i = pos; i < len; i++)
  424.             putch(temp[i]);
  425.           for (i = len; i > pos; i--)
  426.             putch(BACKSPC);
  427.         }
  428.     }
  429.   }
  430.   temp[len] = '\0';
  431.   strcpy(s, temp);
  432.   return len;
  433. }
  434.  
  435.  
  436. int exist(char *s)
  437. {
  438.   int i;
  439.   struct ffblk ff;
  440.  
  441.   i = findfirst(s, &ff, FA_HIDDEN);
  442.   if (i)
  443.     return (0);
  444.   else
  445.     return (1);
  446. }
  447.  
  448.  
  449.  
  450. void add_network(void)
  451. {
  452.   int f, done;
  453.   char s[181];
  454.  
  455.   net_networks = (net_networks_rec *) realloc(net_networks,
  456.                               (net_num_max + 1) * sizeof(net_networks_rec));
  457.  
  458.   net_networks[net_num_max].type = 0;
  459.   strcpy(net_networks[net_num_max].name, "FILEnet");
  460.   done = 0;
  461.   while (!done) {
  462.     sprintf(net_data, "%s\\FILENET", instdir);
  463.     fprintf(stderr, "\n\nEnter the directory to store FILEnet network files (BBSLIST/CALLOUT/etc.)");
  464.     fprintf(stderr, "\n<Enter> to use %s\n", net_data);
  465.     s[0] = 0;
  466.     jgets(s, 79);
  467.     strupr(s);
  468.     if (s[0] == 0) {
  469.       if (make_path(net_data) < 0)
  470.         err_exit("\nUnable to create directory %s\n\n", net_data);
  471.       else
  472.         done = 1;
  473.     } else {
  474.       if (LAST(s) == '\\')
  475.         LAST(s) = 0;
  476.       strcpy(net_data, s);
  477.       if (make_path(net_data) < 0)
  478.         err_exit("\nUnable to create directory %s\n\n", net_data);
  479.       else
  480.         done = 1;
  481.     }
  482.     strcat(net_data, "\\");
  483.     strcpy(net_networks[net_num_max].dir, net_data);
  484.   }
  485.   done = 0;
  486.   sprintf(s, "%sNETWORKS.DAT", syscfg.datadir);
  487.   f = open(s, O_RDWR | O_BINARY | O_TRUNC);
  488.   write(f, (void *) net_networks, (net_num_max + 1) * sizeof(net_networks_rec));
  489.   f = close(f);
  490.   read_networks();
  491.   fprintf(stderr, "\n\nYou will be assigned a temporary node assignment of @9999.FILEnet.  This will");
  492.   fprintf(stderr, "\nallow you to send mail immediately.  You will receive your final FILEnet node");
  493.   fprintf(stderr, "\nassignment via email in a couple of days.");
  494.   net_networks[net_num_max].sysnum = 9999;
  495.   getch();
  496. }
  497.  
  498. void nln(int num)
  499. {
  500.   int i;
  501.  
  502.   for (i = 1; i <= num; i++)
  503.     fprintf(stderr, "\n");
  504. }
  505.  
  506. unsigned char getkey(void)
  507. {
  508.   union REGS r;
  509.  
  510.   r.h.ah = 0x08;
  511.   int86(0x21, &r, &r);
  512.   return (r.h.al);
  513. }
  514.  
  515. int yn(void)
  516. {
  517.   char ch = 0;
  518.   int i;
  519.  
  520.   textattr(12);
  521.   cprintf("y/N");
  522.   while (((ch = toupper(getkey())) != 'Y') && (ch != 'N') && (ch != 'n') && (ch != 13));
  523.   for (i = 0; i < 3; i++)
  524.     putchar(BACKSPC);
  525.   if (ch == 'Y')
  526.     cprintf("Yes");
  527.   else
  528.     cprintf("No ");
  529.  
  530.   return (ch == 'Y');
  531. }
  532.  
  533.  
  534. void base_screen(void)
  535. {
  536.   clrscr();
  537.   fprintf(stderr, "FILEnet for PPP Installation Utility %s by Frank Reid.\n", VERSION);
  538.   fprintf(stderr, "Contact edare@abs.net, 1@8213.WWIVNET or 1@1160.FILENET for updates.\n");
  539. }
  540.  
  541.  
  542.  
  543. int copyfile(char *file1, char *file2)
  544. {
  545.   int src, dst, rbytes;
  546.   int error;
  547.   char *buffer;
  548.   struct ftime ft;
  549.  
  550.  
  551.   buffer = (char *) malloc(20480);
  552.   if (!buffer) {
  553.     printf("\n\nInsufficient memory to create copy buffer!");
  554.     return 1;
  555.   }
  556.   src = open(file1, O_RDONLY | O_BINARY);
  557.   if (src == -1) {
  558.     fprintf(stderr, "\n\n%s could not be opened!", file1);
  559.     free(buffer);
  560.     getch();
  561.     return 1;
  562.   }
  563.   getftime(src, &ft);
  564.   dst = open(file2, O_RDWR | O_BINARY | O_CREAT, S_IWRITE);
  565.   if (dst == -1) {
  566.     fprintf(stderr, "\n\n%s could not be opened!", file2);
  567.     close(src);
  568.     free(buffer);
  569.     getch();
  570.     return 1;
  571.   }
  572.   while (1) {
  573.     rbytes = read(src, buffer, 20480);
  574.     if (rbytes == -1) {
  575.       fprintf(stderr, "\n\nRead error on %s", file1);
  576.       close(src);
  577.       close(dst);
  578.       free(buffer);
  579.       return 1;
  580.     }
  581.     if (rbytes == 0)
  582.       break;
  583.  
  584.     error = write(dst, buffer, rbytes);
  585.     if (error == -1) {
  586.       fprintf(stderr, "\n\nWrite error creating %s", file2);
  587.       close(src);
  588.       close(dst);
  589.       free(buffer);
  590.       return 1;
  591.     }
  592.   }
  593.  
  594.   close(src);
  595.   setftime(dst, &ft);
  596.   close(dst);
  597.   free(buffer);
  598.   return 0;
  599. }
  600.  
  601.  
  602. void create_netcfg(void)
  603. {
  604.   FILE *fp;
  605.   char fn[181];
  606.  
  607.   sprintf(fn, "%s\\NET.CFG", instdir);
  608.   fp = fopen(fn, "wt");
  609.   if (!fp)
  610.     err_exit("\n\nUnable to create %s", fn);
  611.   fprintf(fp, "# This file created by INSTPPP %s\n\n", VERSION);
  612.   fprintf(fp, "LINK SUPPORT\n    BUFFERS 4 1504\n    MEMPOOL 8192\n    MAX STACKS 6\n\n");
  613.   fprintf(fp, "LINK DRIVER PPP\n    CONFIGURATION \"FILEnet\"\n    FRAME ETHERNET_II\n    ");
  614.   fprintf(fp, "PORT COM%d\n    BAUD 57600\n    FLOW CONTROL BOTH\n    ", COMPORT);
  615.   fprintf(fp, "CONNECTION AUTODIAL\n    OPEN ACTIVE\n    DIAL %s\n    MODEM NAME \"Generic\"\n    ", ISPPHONE);
  616.   fprintf(fp, "MODEM INIT1 \"AT&F\"\n    MODEM INIT2 \"ATE1V1\"\n    PCOMP ON\n    ACCOMP ON\n    ");
  617.   fprintf(fp, "ACCM FFFFFFFF\n    SCRIPT1 \"%s\" \"%s\\r\" 30\n    ", LOGINPROMPT, LOGINNAME);
  618.   fprintf(fp, "SCRIPT2 \"%s\" \"%s\\r\" 30\n\n", PASSPROMPT, LOGINPASS);
  619.   fprintf(fp, "PROTOCOL TCPIP 1 PPP\n\n");
  620.   fclose(fp);
  621.   fprintf(stderr, "\n\nSuccessfully created %s.  Press any key...", fn);
  622.   getch();
  623.   clrscr();
  624. }
  625.  
  626. void get_netcfg_data(void)
  627. {
  628.   char buf[121];
  629.   int done;
  630.  
  631.   clrscr();
  632.   fprintf(stderr, "\nI'll now ask a series of questions needed to create the necessary data files");
  633.   fprintf(stderr, "\nfor contacting your Internet provider and sending/receiving network packets.");
  634.   fprintf(stderr, "\nNormal editing and cursor movement are supported.");
  635.   cprintf("\r\n\nIf you are unsure of any item, exit the program by hitting <Esc> at the");
  636.   cprintf("\r\nprompt, find out and start INSTPPP again at a later time.");
  637.   fprintf(stderr, "\n\nReady to begin? ");
  638.   if (!yn())
  639.     err_exit("\n\nAborted... try again later!");
  640.   done = 0;
  641.   while (!done) {
  642.     clrscr();
  643.     fprintf(stderr, "\n\nWhat communications port is your modem (1 - 4)?  ");
  644.     buf[0] = 0;
  645.     jgets(buf, 1);
  646.     if (buf[0] != 0) {
  647.       COMPORT = atoi(&buf[0]);
  648.       if ((COMPORT >= 1) && (COMPORT <= 4)) {
  649.         done = 1;
  650.         fprintf(stderr, "\n\nCommunications set to COM%d", COMPORT);
  651.       } else
  652.         fprintf(stderr, "\n\nInvalid port.  Please try again.");
  653.     }
  654.   }
  655.   done = 0;
  656.   while (!done) {
  657.     clrscr();
  658.     fprintf(stderr, "\n\nPhone number to dial your Internet provider : ");
  659.     buf[0] = 0;
  660.     jgets(buf, 20);
  661.     if (buf[0] != 0) {
  662.       strcpy(ISPPHONE, buf);
  663.       fprintf(stderr, "\n\nPhone number is > ");
  664.       textattr(14);
  665.       cprintf(ISPPHONE);
  666.       fprintf(stderr, " < ? ");
  667.       if (yn())
  668.         done = 1;
  669.     }
  670.   }
  671.   done = 0;
  672.   while (!done) {
  673.     clrscr();
  674.     fprintf(stderr, "\n\nPlease provide the prompt where you enter your username on dial-up.");
  675.     fprintf(stderr, "\nThis is case sensitive and can be a subset of the prompt, for example,");
  676.     fprintf(stderr, "\nif your provider sends \"Login:\", you can just enter \"ogin\" here.");
  677.     fprintf(stderr, "\n\nLogin prompt at which to send your username : ");
  678.     buf[0] = 0;
  679.     jgets(buf, 20);
  680.     if (buf[0] != 0) {
  681.       strcpy(LOGINPROMPT, buf);
  682.       fprintf(stderr, "\n\nLogin prompt is > ");
  683.       textattr(14);
  684.       cprintf(LOGINPROMPT);
  685.       fprintf(stderr, " < ? ");
  686.       if (yn())
  687.         done = 1;
  688.     }
  689.   }
  690.   done = 0;
  691.   while (!done) {
  692.     clrscr();
  693.     fprintf(stderr, "\n\nEnter the user name you send at login.  Note: this programs requires");
  694.     fprintf(stderr, "\na PPP session, so if you add something special to activate PPP in your");
  695.     fprintf(stderr, "\nuser name, enter it correctly here.");
  696.     fprintf(stderr, "\n\nUser name to send at login prompt : ");
  697.     buf[0] = 0;
  698.     jgets(buf, 20);
  699.     if (buf[0] != 0) {
  700.       strcpy(LOGINNAME, buf);
  701.       fprintf(stderr, "\n\nLogin name is > ");
  702.       textattr(14);
  703.       cprintf(LOGINNAME);
  704.       fprintf(stderr, " < ? ");
  705.       if (yn())
  706.         done = 1;
  707.     }
  708.   }
  709.   done = 0;
  710.   while (!done) {
  711.     clrscr();
  712.     fprintf(stderr, "\n\nPlease enter the prompt where you provide your password after your");
  713.     fprintf(stderr, "\nuser name.  This prompt can also be a subset of the prompt, for example,");
  714.     fprintf(stderr, "\nif your provider prompts \"Password:\", enter just \"word\" here.");
  715.     fprintf(stderr, "\n\nPrompt at which to send your password : ");
  716.     buf[0] = 0;
  717.     jgets(buf, 20);
  718.     if (buf[0] != 0) {
  719.       strcpy(PASSPROMPT, buf);
  720.       fprintf(stderr, "\n\nPassword prompt is > ");
  721.       textattr(14);
  722.       cprintf(PASSPROMPT);
  723.       fprintf(stderr, " < ? ");
  724.       if (yn())
  725.         done = 1;
  726.     }
  727.   }
  728.   done = 0;
  729.   while (!done) {
  730.     clrscr();
  731.     fprintf(stderr, "\n\nEnter the actual password to send at this prompt : ");
  732.     buf[0] = 0;
  733.     jgets(buf, 20);
  734.     if (buf[0] != 0) {
  735.       strcpy(LOGINPASS, buf);
  736.       fprintf(stderr, "\n\nLogin password is > ");
  737.       textattr(14);
  738.       cprintf(LOGINPASS);
  739.       fprintf(stderr, " < ? ");
  740.       if (yn())
  741.         done = 1;
  742.     }
  743.   }
  744.   create_netcfg();
  745. }
  746.  
  747. void create_netini(void)
  748. {
  749.   FILE *fp;
  750.   char fn[181];
  751.  
  752.   sprintf(fn, "%s\\NET.INI", instdir);
  753.   fp = fopen(fn, "wt");
  754.   if (!fp)
  755.     err_exit("\n\nUnable to create %s", fn);
  756.   fprintf(fp, "; NET.INI created by INSTPPP %s\n", VERSION);
  757.   fprintf(fp, "; See documentation for an explanation of parameters.\n;\n");
  758.   fprintf(fp, "[FILENET]\n");
  759.   fprintf(fp, "SMTPHOST = %s\n", SMTPHOST);
  760.   fprintf(fp, "POPHOST = %s\n", POPHOST);
  761.   fprintf(fp, "POPNAME = %s\n", POPNAME);
  762.   fprintf(fp, "POPPASS = %s\n", POPPASS);
  763.   fprintf(fp, "[GENERAL]\n");
  764.   fprintf(fp, "TIMEOUT = 90\n");
  765.   fprintf(fp, "SOCK_DELAY = 60\n");
  766.   fprintf(fp, "SOCK_INACTIVE = 90\n");
  767.   fprintf(fp, "KEEPSENT = 1\n");
  768.   fprintf(fp, "ONECALL = Y\n");
  769.   fprintf(fp, "ALLMAIL = %s\n", ALLMAIL ? "Y" : "N");
  770.   fprintf(fp, "MOREINFO = N\n");
  771.   fprintf(fp, "CLEANUP = N\n");
  772.   fprintf(fp, "IPADDR = 0.0.0.0\n");
  773.   fprintf(fp, "NETMASK = %s\n", NETMASK);
  774.   fprintf(fp, "DNS = %s\n", DNS);
  775.   fprintf(fp, "DOMAIN = %s\n", DOMAIN);
  776.   fprintf(fp, "GATEWAY = 0.0.0.0\n");
  777.   fprintf(fp, "[NEWS]\n");
  778.   fprintf(fp, "NEWSHOST = news.%s\n", DOMAIN);
  779.   fprintf(fp, "POSTMASTER = 1\n");
  780.   fprintf(fp, "REALNAME = N\n");
  781.   fprintf(fp, "SPAMCONTROL = Y\n");
  782.   fprintf(fp, "SIGNATURE = C:\\PATH\\INTERNET.TAG");
  783.   fclose(fp);
  784.   fprintf(stderr, "\n\nSuccessfully created %s.  Press any key...", fn);
  785.   getch();
  786.   clrscr();
  787. }
  788.  
  789.  
  790. void get_netini_data(void)
  791. {
  792.   char buf[121];
  793.   int done;
  794.  
  795.   clrscr();
  796.   fprintf(stderr, "\nThe next series of questions determines information about your Internet service");
  797.   fprintf(stderr, "\nprovider, including required Internet host names, IP addresses and the other");
  798.   fprintf(stderr, "\ninformation required for proper program operation.");
  799.   fprintf(stderr, "\n\nReady to begin? ");
  800.   if (!yn())
  801.     err_exit("\n\nAborted... try again later!");
  802.   done = 0;
  803.   while (!done) {
  804.     clrscr();
  805.     fprintf(stderr, "\n\nYour Internet domain is the group assigned by your provider.  Typically, this");
  806.     fprintf(stderr, "\nis the trailing part of your mailing address, e.g. if your Internet address is");
  807.     fprintf(stderr, "\n\"jdoe@somenet.com\" your domain would be \"somenet.com\".");
  808.     fprintf(stderr, "\n\nYour Internet domain : ");
  809.     buf[0] = 0;
  810.     jgets(buf, 20);
  811.     if (buf[0] != 0) {
  812.       strcpy(DOMAIN, buf);
  813.       fprintf(stderr, "\n\nInternet domain is > ");
  814.       textattr(14);
  815.       cprintf(DOMAIN);
  816.       fprintf(stderr, " < ? ");
  817.       if (yn())
  818.         done = 1;
  819.     }
  820.   }
  821.   done = 0;
  822.   while (!done) {
  823.     clrscr();
  824.     fprintf(stderr, "\n\nPlease provide the host name of your POP3 server.  This is the host where your");
  825.     fprintf(stderr, "\nmail is stored for retrieval, and will correspond to the POP host defined in");
  826.     fprintf(stderr, "\nEudora or Pegasus Mail program, e.g. \"pop.host.com\".");
  827.     fprintf(stderr, "\n\nHost name of your POP3 host : ");
  828.     buf[0] = 0;
  829.     jgets(buf, 20);
  830.     if (buf[0] != 0) {
  831.       strcpy(POPHOST, buf);
  832.       fprintf(stderr, "\n\nMail server or POP host is > ");
  833.       textattr(14);
  834.       cprintf(POPHOST);
  835.       fprintf(stderr, " < ? ");
  836.       if (yn())
  837.         done = 1;
  838.     }
  839.   }
  840.   done = 0;
  841.   while (!done) {
  842.     clrscr();
  843.     fprintf(stderr, "\n\nEnter the name of your sendmail or SMTP host.  This may not be the same host");
  844.     fprintf(stderr, "\nas your POP3 server.  If you have trouble sending outbound mail, you can try");
  845.     fprintf(stderr, "\nsetting this field to the numeric IP address of your DNS.");
  846.     fprintf(stderr, "\n\nHost name for your SMTP/sendmail host : ");
  847.     buf[0] = 0;
  848.     jgets(buf, 20);
  849.     if (buf[0] != 0) {
  850.       strcpy(SMTPHOST, buf);
  851.       fprintf(stderr, "\n\nSendmail or SMTP host is > ");
  852.       textattr(14);
  853.       cprintf(SMTPHOST);
  854.       fprintf(stderr, " < ? ");
  855.       if (yn())
  856.         done = 1;
  857.     }
  858.   }
  859.   done = 0;
  860.   while (!done) {
  861.     clrscr();
  862.     fprintf(stderr, "\n\nEnter the name of your Domain Name Server (DNS).  This setting is critical");
  863.     fprintf(stderr, "\nfor successful program operation.  Host names must be translated by the DNS,");
  864.     fprintf(stderr, "\nand the DNS must be in numeric form, e.g. \"207.123.123.10\".");
  865.     fprintf(stderr, "\n\nNumeric DNS address for your service provider  : ");
  866.     buf[0] = 0;
  867.     jgets(buf, 16);
  868.     if (buf[0] != 0) {
  869.       strcpy(DNS, buf);
  870.       fprintf(stderr, "\n\nYour Domain Name Server (DNS) is > ");
  871.       textattr(14);
  872.       cprintf(DNS);
  873.       fprintf(stderr, " < ? ");
  874.       if (yn())
  875.         done = 1;
  876.     }
  877.   }
  878.   done = 0;
  879.   while (!done) {
  880.     clrscr();
  881.     fprintf(stderr, "\n\nEnter the netmask for your Internet provider's host.  Typically, a netmask is");
  882.     fprintf(stderr, "\n\"255.255.255.0\" unless your provider has directed you to use something");
  883.     fprintf(stderr, "\ndifferent.");
  884.     fprintf(stderr, "\n\nProvider netmask - <Enter> to use 255.255.255.0 : ");
  885.     buf[0] = 0;
  886.     jgets(buf, 20);
  887.     if (buf[0] != 0) {
  888.       strcpy(NETMASK, buf);
  889.     } else
  890.       strcpy(NETMASK, "255.255.255.0");
  891.     fprintf(stderr, "\n\nSet netmask to > ");
  892.     textattr(14);
  893.     cprintf(NETMASK);
  894.     fprintf(stderr, " < ? ");
  895.     if (yn())
  896.       done = 1;
  897.   }
  898.   done = 0;
  899.   while (!done) {
  900.     clrscr();
  901.     fprintf(stderr, "\n\nPlease enter your POP3 account user name.  This is not necessarily the same");
  902.     fprintf(stderr, "\nname you use to log onto your Internet provider, but rather the name defined in");
  903.     fprintf(stderr, "\nEudora or other standard Internet mail readers.");
  904.     fprintf(stderr, "\n\nYour mail account login name : ");
  905.     buf[0] = 0;
  906.     jgets(buf, 20);
  907.     if (buf[0] != 0) {
  908.       strcpy(POPNAME, buf);
  909.       fprintf(stderr, "\n\nMail account name is > ");
  910.       textattr(14);
  911.       cprintf(POPNAME);
  912.       fprintf(stderr, " < ? ");
  913.       if (yn())
  914.         done = 1;
  915.     }
  916.   }
  917.   done = 0;
  918.   while (!done) {
  919.     clrscr();
  920.     fprintf(stderr, "\n\nEnter the password to access this POP3 account : ");
  921.     buf[0] = 0;
  922.     jgets(buf, 20);
  923.     if (buf[0] != 0) {
  924.       strcpy(POPPASS, buf);
  925.       fprintf(stderr, "\n\nMail account password is > ");
  926.       textattr(14);
  927.       cprintf(POPPASS);
  928.       fprintf(stderr, " < ? ");
  929.       if (yn())
  930.         done = 1;
  931.     }
  932.   }
  933.   clrscr();
  934.   fprintf(stderr, "\n\nThis program can retrieve all messages from your mail host, or just those it");
  935.   fprintf(stderr, "\nidentifies as network packets and UUE archives.  Retrieved messages are placed");
  936.   fprintf(stderr, "\nin user accounts on the BBS and files are stored in the \"CHECKNET\" directory.");
  937.   fprintf(stderr, "\nIf you do not retrieve all mail from your POP3 mailbox, you will not be able");
  938.   fprintf(stderr, "\nto receive Internet email to your accounts on the BBS!");
  939.   fprintf(stderr, "\n\nWould you like to retrieve ALL mail from your host? ");
  940.   ALLMAIL = yn();
  941.   create_netini();
  942. }
  943.  
  944. void create_app(void)
  945. {
  946.   char s[181], fn[181];
  947.   FILE *fp;
  948.  
  949.   sprintf(s, "%sMQUEUE", net_data);
  950.   if (make_path(s) < 0)
  951.     err_exit("\n\nUnable to create %s\n\n", s);
  952.   sprintf(fn, "%s\\FILENET.APP", s);
  953.   fp = fopen(fn, "wt");
  954.   if (!fp)
  955.     err_exit("\n\nUnable to create %s\n\n", fn);
  956.   fprintf(fp, "From: %s@%s\n", POPNAME, DOMAIN);
  957.   fprintf(fp, "To: edare@abs.net\n");
  958.   fprintf(fp, "Subject: FILEnet app for @%hd generated by INSTPPP\n\n", net_sysnum);
  959.   fprintf(fp, "BBS Name         : %s\n", syscfg.systemname);
  960.   fprintf(fp, "BBS Phone        : %s\n", syscfg.systemphone);
  961.   fprintf(fp, "Sysop Alias      : %s\n", syscfg.sysopname);
  962.   fprintf(fp, "Internet Address : %s@%s\n", POPNAME, DOMAIN);
  963.   fprintf(fp, "Requested Node   : @%hd.FILEnet\n", net_sysnum);
  964.   fprintf(fp, "WWIV Regnum      : %ld\n", syscfg.wwiv_reg_number);
  965.   fprintf(fp, "----------------------------------------\n");
  966.   fprintf(stderr, "\nEnter your voice phone number : ");
  967.   jgets(s, 12);
  968.   fprintf(fp, "Voice Phone      : %s\n", s);
  969.   fprintf(stderr, "\nEnter your date of birth : ");
  970.   jgets(s, 8);
  971.   fprintf(fp, "Date of Birth    : %s\n", s);
  972.   fprintf(stderr, "\nMaximum modem speed : ");
  973.   jgets(s, 6);
  974.   fprintf(fp, "Max Modem Speed  : %s\n", s);
  975.   fprintf(stderr, "\nStreet Address      : ");
  976.   jgets(s, 50);
  977.   fprintf(fp, "Address          : %s\n", s);
  978.   fprintf(stderr, "\nCity, State and ZIP : ");
  979.   jgets(s, 50);
  980.   fprintf(fp, "City/State/ZIP   : %s\n", s);
  981.   fprintf(stderr, "\nAny Added Comments  : ");
  982.   jgets(s, 50);
  983.   fprintf(fp, "Comments         : %s\n", s);
  984.   fclose(fp);
  985.   clrscr();
  986.   fprintf(stderr, "FILEnet application created in %s", fn);
  987.   fprintf(stderr, "\nand will be transmitted automatically upon first connection!\n");
  988.   fp = fopen(fn, "rt");
  989.   while (fgets(s, 80, fp) != NULL)
  990.     fprintf(stderr, "%s", s);
  991.   fclose(fp);
  992.   fprintf(stderr, "\n\nApplication saved in %s for review.\n\n", fn);
  993. }
  994.  
  995. int copy_files(char *srcpath, char *dstpath)
  996. {
  997.   int i;
  998.   char s[MAXPATH], s1[MAXPATH];
  999.  
  1000.   for (i = 0; instfile[i]; i++) {
  1001.     sprintf(s, "%s\\%s", srcpath, instfile[i]);
  1002.     if (!exist(s)) {
  1003.       fprintf(stderr, "\n%s not found in current directory.\n", instfile[i]);
  1004.       return 1;
  1005.     }
  1006.     sprintf(s1, "%s\\%s", dstpath, instfile[i]);
  1007.     if (copyfile(s, s1)) {
  1008.       fprintf(stderr, "\nUnable to create %s.\n", s1);
  1009.       return 1;
  1010.     } else
  1011.       fprintf(stderr, "\nCopying %s to %s...", instfile[i], dstpath);
  1012.   }
  1013.   return 0;
  1014. }
  1015.  
  1016. main(void)
  1017. {
  1018.  
  1019.   int i, f, found, done = 0;
  1020.   long l;
  1021.   char s[MAXPATH], s1[MAXPATH], s2[MAXPATH], tempdir[181];
  1022.  
  1023.   base_screen();
  1024.  
  1025.   get_dir(maindir, 1);
  1026.  
  1027.   done = 0;
  1028.   while (!done) {
  1029.     nln(1);
  1030.     sprintf(tempdir, "%c:\\WWIV", maindir[0]);
  1031.     if (cd_to(tempdir) != 0) {
  1032.       sprintf(tempdir, "%c:\\BBS", maindir[0]);
  1033.       if (cd_to(tempdir) != 0) {
  1034.         tempdir[0] = 0;
  1035.       } else {
  1036.         sprintf(s1, "%s\\NETWORK.EXE", tempdir);
  1037.         if (!exist(s1))
  1038.           tempdir[0] = 0;
  1039.       }
  1040.     } else {
  1041.       sprintf(s1, "%s\\NETWORK.EXE", tempdir);
  1042.       if (!exist(s1))
  1043.         tempdir[0] = 0;
  1044.     }
  1045.     cd_to(maindir);
  1046.     if (tempdir[0] != 0)
  1047.       fprintf(stderr, "BBS path, <Enter> for %s : ", tempdir);
  1048.     else
  1049.       fprintf(stderr, "Path to your BBS main directory : ");
  1050.     jgets(instdir, 40);
  1051.     if (instdir[0] == 0)
  1052.       strcpy(instdir, tempdir);
  1053.     if (LAST(instdir) == '\\')
  1054.       LAST(instdir) = 0;
  1055.     if (cd_to(instdir) != 0)
  1056.       err_exit("\n%s does not exist... aborting installation!", instdir);
  1057.     else {
  1058.       sprintf(s1, "%s\\NETWORK.EXE", instdir);
  1059.       if (!exist(s1))
  1060.         err_exit("\nCannot find %s.  Ensure net36 is properly installed!\n\n");
  1061.       sprintf(s2, "%s\\CONFIG.DAT", instdir);
  1062.       f = open(s2, O_BINARY | O_RDONLY);
  1063.       if (f < 0) {
  1064.         err_exit("\nUnable to open %s... aborting!\n\n", s2);
  1065.       }
  1066.       read(f, (void *) (&syscfg), sizeof(configrec));
  1067.       close(f);
  1068.       sprintf(s, "%sNETWORKS.DAT", syscfg.datadir);
  1069.       f=open(s, O_RDONLY | O_BINARY);
  1070.       if (f < 0) {
  1071.         fprintf(stderr, "\nError -- NETWORKS.DAT not found in %s.", syscfg.datadir);
  1072.         return(1);
  1073.       }
  1074.       net_num_max=(char)(filelength(f)/sizeof(net_networks_rec));
  1075.       if ((net_networks=(net_networks_rec *) malloc(filelength(f)))==NULL) {
  1076.         fprintf(stderr, "\nError -- insufficient memory to load network information.\m");
  1077.         close(f);
  1078.         return(1);
  1079.       }
  1080.       read(f, net_networks, filelength(f));
  1081.       close(f);
  1082.       found = 0;
  1083.       for (i = 0; i < net_num_max; i++) {
  1084.         set_net_num(i);
  1085.         if (strnicmp(net_name, "FILEnet", 7) == 0) {
  1086.           fprintf(stderr, "\n\nFILEnet defined as %d%s network in INIT!\n",
  1087.                   i + 1, ordinal_text(i + 1));
  1088.           found = 1;
  1089.           break;
  1090.         }
  1091.       }
  1092.       if (!found) {
  1093.         clrscr();
  1094.         fprintf(stderr, "\nFILEnet network not defined it INIT... add it!");
  1095.         exit(1);
  1096.       }
  1097.       sprintf(s2, "%s\\NETWORK.EXE", instdir);
  1098.       if (exist(s2)) {
  1099.         f = open(s2, O_BINARY | O_RDONLY);
  1100.         l = filelength(f);
  1101.         f = close(f);
  1102.         fprintf(stderr, "\nChecking %s... ", s2);
  1103.         switch (l) {
  1104.           case 77482L:
  1105.             fprintf(stderr, "identified as net33.\n");
  1106.             break;
  1107.           case 80170L:
  1108.             fprintf(stderr, "identified as net34.\n");
  1109.             break;
  1110.           case 103376L:
  1111.             fprintf(stderr, "identified as net35.\n");
  1112.             break;
  1113.           case 104986L:
  1114.             fprintf(stderr, "identified as net36.\n");
  1115.             break;
  1116.           default:
  1117.             fprintf(stderr, "unable to identify current network version.\n");
  1118.             done = 1;
  1119.             sprintf(s2, "%s\\NETWORK0.EXE", instdir);
  1120.             if (exist(s2)) {
  1121.               done = 0;
  1122.               fprintf(stderr, "\nFound %s... ", s2);
  1123.               f = open(s2, O_BINARY | O_RDONLY);
  1124.               l = filelength(f);
  1125.               f = close(f);
  1126.               switch (l) {
  1127.                 case 77482L:
  1128.                   fprintf(stderr, "from net33 package.\n");
  1129.                   break;
  1130.                 case 80170L:
  1131.                   fprintf(stderr, "from net34 package.\n");
  1132.                   break;
  1133.                 case 103376L:
  1134.                   fprintf(stderr, "from net35 package.\n");
  1135.                   break;
  1136.                 case 104986L:
  1137.                   fprintf(stderr, "from net36 package.\n");
  1138.                   break;
  1139.                 default:
  1140.                   fprintf(stderr, "unidentified... skipping NETWORK0.EXE creation!\n\n");
  1141.                   done = 1;
  1142.                   break;
  1143.               }
  1144.               if (!done) {
  1145.                 fprintf(stderr, "\nAre you reinstalling the FILEnet NETWORK.EXE? ");
  1146.                 if (yn()) {
  1147.                   sprintf(s1, "%s\\NETWORK.EXE", maindir);
  1148.                   sprintf(s2, "%s\\NETWORK.EXE", instdir);
  1149.                   if (copyfile(s1, s2))
  1150.                     fprintf(stderr, "\nError creating %s.  Please copy file manually!\n\n", s2);
  1151.                 }
  1152.               }
  1153.             }
  1154.         }
  1155.       }
  1156.       if (done) {
  1157.         fprintf(stderr, "\n\nThe program was unable to identify the network version currently installed");
  1158.         fprintf(stderr, "\nas %s.", s2);
  1159.         fprintf(stderr, "\nYou must copy NETWORK.EXE after renaming yours to NETWORK0.EXE!");
  1160.         fprintf(stderr, "\nPress any key.");
  1161.         getch();
  1162.       } else {
  1163.           sprintf(s1, "%s\\NETWORK.EXE", instdir);
  1164.           sprintf(s2, "%s\\NETWORK0.EXE", instdir);
  1165.           if (copyfile(s1, s2))
  1166.             err_exit("\nError renaming NETWORK.EXE to NETWORK0.EXE.  Please copy files manually!\n\n");
  1167.           else
  1168.             fprintf(stderr, "\nRenaming WWIV's NETWORK.EXE to NETWORK0.EXE\n");
  1169.           sprintf(s1, "%s\\NETWORK.EXE", maindir);
  1170.           sprintf(s2, "%s\\NETWORK.EXE", instdir);
  1171.           if (copyfile(s1, s2))
  1172.             fprintf(stderr, "\nError creating %s.  Please copy file manually!\n\n", s2);
  1173.           else
  1174.             fprintf(stderr, "\nCreating %s", s2);
  1175.       }
  1176.       fprintf(stderr, "\nPress a key to begin configuration items.");
  1177.       getch();
  1178.       get_netcfg_data();
  1179.       get_netini_data();
  1180.       clrscr();
  1181.       if (copy_files(maindir, instdir)) {
  1182.         fprintf(stderr, "\n\nA file required by the installation program is missing!\n\n");
  1183.         fprintf(stderr, "\nPress any key to exit.");
  1184.         getch();
  1185.       } else {
  1186.         clrscr();
  1187.         fprintf(stderr, "\nProgram installation appears to have been successful!");
  1188.         fprintf(stderr, "\n\nYou should now execute the LOAD.BAT to ensure all configuration files");
  1189.         fprintf(stderr, "\nwere properly created.  If you have trouble, run PPPMENU and/or edit");
  1190.         fprintf(stderr, "\nthe configuration files \"NET.INI\" and \"NET.CFG\" to fix any problems.");
  1191.         fprintf(stderr, "\n\nFinally, and most importantly, you MUST send me your network application");
  1192.         fprintf(stderr, "\nvia Internet email >ONLY< along with the node number you requested.  If");
  1193.         fprintf(stderr, "\nyou send it on FILEnet, I won't receive it because my system does not know");
  1194.         fprintf(stderr, "\nthe node you just requested!\n\n");
  1195.         fprintf(stderr, "\n\nWould you like me to create the completed application for you? ");
  1196.         if (yn())
  1197.           create_app();
  1198.         fprintf(stderr, "Press any key to exit...");
  1199.         getch();
  1200.         cd_to(instdir);
  1201.         exit(EXIT_SUCCESS);
  1202.       }
  1203.     }
  1204.     exit(EXIT_FAILURE);
  1205.   }
  1206.   return 0;
  1207. }
  1208.  
  1209. /* ═════════════════════════════════════════════════════════════════════════ */
  1210.