home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / setup.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  71KB  |  2,651 lines

  1. #define FOR_REAL /* For testing, don't define this. */
  2.  
  3. /*  Kermit 95: Text-mode setup program  */
  4.  
  5. /* For version 1.1.21 */
  6.  
  7. /*
  8.   Copyright (C) 1997, 2000 Trustees of Columbia University in the City of
  9.   New York.  All rights reserved.
  10. */
  11. #define SPACE_NEEDED 6000000L        /* Free disk bytes needed to install */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <direct.h>
  16. #include <string.h>
  17.  
  18. #ifdef OS2
  19. #ifdef NT
  20. #include <windows.h>
  21. #define TAPI_CURRENT_VERSION 0x00010004
  22. #include <tapi.h>
  23. #include <mcx.h>
  24. /* all functions in this module return TRUE to indicate success */
  25. /* or FALSE to indicate failure */
  26. #include "ckcdeb.h"             /* Typedefs, debug formats, etc */
  27. #include "ckcker.h"             /* Kermit definitions */
  28. #include "ckucmd.h"
  29. #include "ckuusr.h"
  30. #include "ckowin.h"
  31. #include "ckntap.h"             /* Kermit Telephony */
  32.  
  33. #ifdef isWin95
  34. #undef isWin95
  35. #endif
  36. #ifdef printf
  37. #undef printf
  38. #endif
  39. #ifdef fprintf
  40. #undef fprintf
  41. #endif
  42.  
  43. #ifdef CLINK
  44. /* These were only needed for CreateLink, which doesn't work. */
  45. #include <shellapi.h>
  46. #include <shlguid.h>
  47. #include <shlobj.h>
  48. #endif /* COMMENT */
  49.  
  50. #else /* not NT */
  51.  
  52. #define INCL_WIN
  53. #define    INCL_WINSWITCHLIST
  54. #define    INCL_ERRORS
  55. #define    INCL_KBD
  56. #ifdef OS2MOUSE
  57. #define INCL_MOU
  58. #endif /* OS2MOUSE */
  59. #define    INCL_VIO
  60. #define    INCL_DOSMISC
  61. #define    INCL_DOSPROCESS
  62. #define INCL_DOSSEMAPHORES
  63. #define    INCL_DOSQUEUES
  64. #define INCL_DOSEXCEPTIONS
  65. #define    INCL_DOSSIGNALS
  66. #define    INCL_DOSDEVICES
  67. #define    INCL_DOSDEVIOCTL
  68. #define    INCL_DOSNLS
  69. #define INCL_DOSASYNCTIMER
  70. #define INCL_DOSDATETIME
  71. #define INCL_DOSFILEMGR
  72. #define INCL_WINWORKPLACE
  73. #ifdef OS2PM
  74. #define  INCL_DOSNMPIPES
  75. #endif /* OS2PM */
  76. #include <os2.h>
  77. #undef COMMENT
  78. #include <sys\types.h>
  79. #include <sys\stat.h>
  80. #include <io.h>
  81. #define S_IFMT 0xF000
  82. #endif /* NT */
  83. #endif /* OS2 */
  84.  
  85. #ifndef MAXPATH
  86. #define MAXPATH 256
  87. #endif /* MAXPATH */
  88.  
  89. #ifdef NT
  90. #define K95EXE  "K95.EXE"
  91. #define ZIPFILE "K95PACK.EXE"
  92. #define ZIPFILE1 "K95PACK1.EXE"
  93. #define ZIPFILE2 "K95PACK2.EXE"
  94. #define ZIPFILE3 "K95PACK3.EXE"
  95. #define ZIPFILE4 "K95PACK4.EXE"
  96. #define DISKLABEL "K95 DISK 1"
  97. #define DISK2LABEL "K95 DISK 2"
  98. #define DISK3LABEL "K95 DISK 3"
  99. #define DISK4LABEL "K95 DISK 4"
  100. #define PRODUCT   "Kermit 95"
  101. #define ABBR      "K95"
  102. #else
  103. #define K95EXE  "K2.EXE"
  104. #define ZIPFILE "K2PACK.EXE"
  105. #define ZIPFILE1 "K2PACK1.EXE"
  106. #define ZIPFILE2 "K2PACK2.EXE"
  107. #define ZIPFILE3 "K2PACK3.EXE"
  108. #define ZIPFILE4 "K2PACK4.EXE"
  109. #define DISKLABEL "K2 DISK 1"
  110. #define DISK2LABEL "K2 DISK 2"
  111. #define DISK3LABEL "K2 DISK 3"
  112. #define DISK4LABEL "K2 DISK 4"
  113. #define PRODUCT   "Kermit/2"
  114. #define ABBR      "K2"
  115. #endif 
  116.  
  117. unsigned char bar[81];
  118.  
  119. #ifdef NT
  120. /* extern */
  121. extern struct keytab * tapilinetab, * _tapilinetab;
  122. extern int ntapiline;
  123. #endif /* NT */
  124.  
  125. /* Global Declarations */
  126.  
  127. struct _kermitinfo {            /* Struct for returning our  */
  128.     char install_dir[260];        /* info to other programs... */
  129.     int dir_exists;            /* Target directory already exists */
  130.     char modem_name[80];        /* Null string if none */
  131.     int com_port;            /* 0 if none */
  132.     long port_speed;            /* 0 if none */
  133.     int c_code;                /* Country code */
  134.     char a_code[256];
  135.     char l_prefix[256];
  136.     char i_prefix[256];
  137.     char t_prefix[16];
  138.     char t_area[16];
  139.     char t_lc_area_codes[256];
  140. } kermitinfo;
  141.  
  142.  
  143. struct mdm {                /* Modem info */
  144.     char * menuname;            /* Name to print in menu */
  145.     char * kermitname;            /* Kermit SET MODEM TYPE name */
  146.     long speed;                /* Default speed */
  147. } mdmtab[] = {
  148.     "3COM US Robotics/Megahertz 56K", "3com-usr-megahertz-56k", 115200L,
  149.     "Atlas Newcom 33,600ifxC", "atlas-newcom-33600ifxC", 57600L,
  150.     "AT&T 1900 STU III",    "att-1900-stu-iii",     57600L,
  151.     "AT&T 1910 STU III",    "att-1910-stu-iii",     57600L,
  152.     "AT&T 7300",            "att-7300",         57600L,
  153.     "AT&T Dataport",        "att-dataport",     57600L,
  154.     "AT&T DTDM",            "att-dtdm",         57600L,
  155.     "AT&T ISN",             "att-isn",          57600L,
  156.     "AT&T KeepInTouch",     "att-keepintouch",  57600L,
  157.     "AT&T Switched Net",    "att-switched-net", 57600L,
  158.     "Best Data",            "bestdata",         57600L,
  159.     "Boca",                 "boca",             57600L,
  160.     "Cardinal",            "cardinal",         57600L,
  161.     "Compaq Data+Fax (Presario)",
  162.                             "compaq",           57600L,
  163.     "Digitel DT22",         "digitel-dt22",      2400L,
  164.     "Fujitsu",              "fujitsu",          57600L,
  165.     "Gateway Telepath",     "gateway-telepath", 57600L,
  166.     "Generic High Speed",   "generic-high-speed", 57600L,
  167.     "Hayes 1200",           "hayes-1200",        1200L,
  168.     "Hayes 2400",           "hayes-2400",        2400L,
  169.     "Hayes Ultra, Optima, or Accura",
  170.                             "hayes-high-speed", 57600L,
  171.     "IBM Mwave",            "mwave",            57600L,
  172.     "Intel 14400 Faxmodem", "intel",            57600L,
  173.     "ITU-T (CCITT) V25bis", "itu-t-v25bis",             2400L,
  174.     "ITU-T (CCITT) V25ter/v250", "itu-t-v25ter/v250", 2400L,
  175.     "Maxtech",              "maxtech",          57600L,
  176.     "Megahertz AT&T V.34",  "megahertz-att-v34",57600L,
  177.     "Megahertz XJack 33.6", "megahertz-xjack-33.6",  57600L,
  178.     "Megahertz XJack 56k",  "megahertz-xjack-56k",  115200L,
  179.     "Microcom in AT mode",  "microcom-at",      57600L,
  180.     "Microcom in SX mode",  "microcom-sx",      57600L,
  181.     "Microlink",            "microlink",        57600L,
  182.     "Microlink V250",       "microlink-v250",        57600L,
  183.     "Motorola Codex",       "motorola-codex",   57600L,
  184.     "Motorola Fastalk",     "motorola-fastalk", 57600L,
  185.     "Motorola Lifestyle",   "motorola-lifestyle", 57600L,
  186.     "Motorola Montana",     "motorola-montana", 57600L,
  187.     "Multitech",            "multitech",        57600L,
  188.     "Practical Peripherals","ppi",              57600L,
  189.     "QuickComm Spirit II",  "spirit-ii",        57600L,
  190.     "Rockwell V32",         "rockwell-v32",     57600L,
  191.     "Rockwell V32bis",      "rockwell-v32bis",  57600L,
  192.     "Rockwell V34",         "rockwell-v34",     57600L,
  193.     "Rockwell V90",         "rockwell-v90",    115200L,
  194.     "Rolm 244pc",           "rolm-244pc",       19200L,
  195.     "Rolm 600 series",      "rolm-600-series",  19200L,
  196.     "Rolm DCM",             "rolm-dcm",         19200L,
  197.     "Supra Fax Modem",      "suprafaxmodem",    57600L,
  198.     "SupraSonic 288+",      "suprasonic",       57600L,
  199.     "Telebit (old models)", "old-telebit",      19200L,
  200.     "Telebit (newer models)","telebit",         38400L,
  201.     "Unknown",              "unknown",           2400L,
  202.     "US Robotics/Megahertz 56k", "usr-megahertz-56k", 115200L,
  203.     "US Robotics Sportster or Courier",
  204.                             "usrobotics",       57600L,
  205.     "Zoltrix",              "zoltrix",          57600L,
  206.     "Zoom",                 "zoom",             57600L,
  207.     "Zyxel",                "zyxel",            57600L
  208. };
  209. int modems = (sizeof(mdmtab) / sizeof(struct mdm));
  210.  
  211. long speedtab[] = {            /* Legal speeds */
  212.     110L,
  213.     300L,
  214.     1200L,
  215.     2400L,
  216.     3600L,
  217.     7200L,
  218.     9600L,
  219.     14400L,
  220.     19200L,
  221.     28800L,
  222.     38400L,
  223.     57600L,
  224.     76800L,
  225.     115200L,
  226.     230400L,
  227.     460800L
  228. };
  229. int speeds = (sizeof(speedtab) / sizeof(long));
  230.  
  231. char * printers[] = {
  232.     "PRN", "LPT1", "LPT2", "LPT3", "NUL", "KERMIT.PRN"
  233. };
  234. int nprinters = (sizeof(printers)/sizeof(char *));
  235.  
  236. FILE *fp;
  237. #ifdef COMMENT
  238. FILE *fopen();
  239. #endif 
  240.  
  241. char buf[256];
  242.  
  243.  
  244. int
  245. isWin95( void ) {
  246. #ifdef NT
  247.     int OSVer = 0;
  248.     OSVERSIONINFO osverinfo ;
  249.     osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
  250.     GetVersionEx( &osverinfo ) ;
  251.     OSVer = osverinfo.dwPlatformId ;
  252.     return(OSVer==VER_PLATFORM_WIN32_WINDOWS);
  253. #else
  254.     return 0;
  255. #endif
  256. }
  257.  
  258. #ifdef OS2
  259. #define DIRSEP       '/'
  260. /* #define DIRSEP       '\\' */
  261. #define ISDIRSEP(c)  ((c)=='/'||(c)=='\\')
  262. #else /* not OS2 */
  263. #define DIRSEP       '/'
  264. #define ISDIRSEP(c)  ((c)=='/')
  265. #endif /* OS2 */
  266.  
  267. /*
  268.    i s d i r  --
  269.    Tells if string pointer s is the name of an existing directory.
  270.    Returns 1 if directory, 0 if not a directory.
  271. */
  272. #include <sys/stat.h>
  273.  
  274. #ifdef OS2
  275. #include <sys/types.h>
  276. #ifdef NT
  277. int os2stat(char *, struct _stat *);
  278. #else /* NT */
  279. int os2stat(char *, struct stat *);
  280. #endif /* NT */
  281. #endif /* OS2 */
  282.  
  283. #ifdef OS2
  284. os2stat(char * path,
  285. #ifdef NT
  286.     struct _stat *st
  287. #else
  288.     struct stat *st
  289. #endif /* NT */
  290.     ) {
  291.     char local[MAXPATH + 1];
  292.     int len;
  293.  
  294.     if (!path) path = "";
  295.     strcpy(local, path);
  296.     len = strlen(local);
  297.  
  298.     if ( len == 2 && local[1] == ':' )
  299.       local[2] = DIRSEP, local[3] = 0;    /* If drive only, append / */
  300.     else if ( len == 0 )
  301.       local[0] = DIRSEP, local[1] = 0;    /* If empty path, take / instead */
  302.     else if ( len > 1 && ISDIRSEP(local[len - 1]) && local[len - 2] != ':' )
  303.       local[len - 1] = 0; /* strip trailing / except after d: */
  304.  
  305. #ifdef NT
  306.     return _stat(local, st);
  307. #else /* NT */
  308.     return stat(local, st);
  309. #endif /* NT */
  310. }
  311. #define stat(x,y) os2stat(x,y)
  312. #endif /* OS2 */
  313.  
  314. int
  315. isdir(char * s) {
  316.     int x;
  317.  
  318. #ifdef NT
  319.     struct _stat statbuf;
  320. #else
  321.     struct stat statbuf;
  322. #endif /* NT */
  323.  
  324.     if (!s) return(0);
  325.     if (!*s) return(0);
  326.  
  327. #ifdef OS2
  328.     /* Disk letter like A: is top-level directory on a disk */
  329.     if (((int)strlen(s) == 2) && (isalpha(*s)) && (*(s+1) == ':'))
  330.       return(1);
  331. #endif /* OS2 */
  332.     x = stat(s,&statbuf);
  333.     if (x == -1) {
  334.     return(0);
  335.     } else {
  336.     return((((statbuf.st_mode) & _S_IFMT) == _S_IFDIR) ? 1 : 0 );
  337.     }
  338. }
  339.  
  340. #ifdef OS2
  341. unsigned long
  342. zdskspace(int diskletter) {
  343. #ifdef NT
  344.     DWORD spc, bps, fc, c ;
  345.     char rootpath[4] ;
  346.     int drive;
  347.     drive = diskletter - 'A' + 1;
  348.      
  349.     if (drive) {
  350.     rootpath[0] = '@' + drive ;
  351.     rootpath[1] = ':' ;
  352.     rootpath[2] = '\\' ;
  353.     rootpath[3] = '\0' ;
  354.     if ( !GetDiskFreeSpace( rootpath, &spc, &bps, &fc, &c ))
  355.       return 0 ;
  356.     } else {
  357.     if ( !GetDiskFreeSpace( NULL, &spc, &bps, &fc, &c ))
  358.       return 0 ;
  359.     }
  360.     return spc * bps * fc ;
  361. #else /* NT */
  362.     int drive = diskletter - 'A' + 1;
  363.     FSALLOCATE fsa;
  364.     if ( DosQueryFSInfo(drive, 1, (PBYTE) &fsa, sizeof(fsa)) )
  365.       return 0;
  366.     return fsa.cUnitAvail * fsa.cSectorUnit * fsa.cbSector;
  367. #endif /* NT */
  368. }
  369. #endif /* OS2 */
  370.  
  371. /* Some systems define these symbols in include files, others don't... */
  372.  
  373. #ifndef R_OK
  374. #define R_OK 4                /* For access */
  375. #endif
  376.  
  377. #ifndef W_OK
  378. #define W_OK 2
  379. #endif
  380.  
  381. #ifndef O_RDONLY
  382. #define O_RDONLY 000
  383. #endif
  384.  
  385. #ifndef S_ISREG
  386. #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
  387. #endif /* S_ISREG */
  388. #ifndef S_ISDIR
  389. #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
  390. #endif /* S_ISDIR */
  391.  
  392. /*  Z C H K I  --  Check if input file exists and is readable  */
  393.  
  394. /*
  395.   Returns:
  396.    >= 0 if the file can be read (returns the size).
  397.      -1 if file doesn't exist or can't be accessed,
  398.      -2 if file exists but is not readable (e.g. a directory file).
  399.      -3 if file exists but protected against read access.
  400. */
  401. /*
  402.  For Berkeley Unix, a file must be of type "regular" to be readable.
  403.  Directory files, special files, and symbolic links are not readable.
  404. */
  405. long
  406. zchki(name) char *name; {
  407. #ifdef NT
  408.     struct _stat buf;
  409. #else
  410.     struct stat buf;
  411. #endif /* NT */
  412.     int x;
  413.  
  414. #ifdef UNIX
  415.     x = strlen(name);
  416.     if (x == 9 && !strcmp(name,"/dev/null"))
  417.       return(0);
  418. #endif /* UNIX */
  419.  
  420.     x = stat(name,&buf);
  421.     if (x < 0) {
  422.        return(-1);
  423.     }
  424.     if (!S_ISREG (buf.st_mode)        /* Must be regular file */
  425. #ifdef S_ISFIFO
  426.     && !S_ISFIFO (buf.st_mode)    /* or FIFO */
  427. #endif /* S_ISFIFO */
  428.     ) {                
  429.        return(-2);
  430.     }
  431.  
  432. #ifdef SW_ACC_ID
  433.     priv_on();
  434. #endif /* SW_ACC_ID */
  435. #ifdef NT
  436.     x = _access(name,R_OK);
  437. #else
  438.     x = access(name,R_OK);
  439. #endif /* NT */
  440. #ifdef SW_ACC_ID
  441.     priv_off();
  442. #endif /* SW_ACC_ID */
  443.     if (x < 0) {     /* Is the file accessible? */
  444.         return(-3);
  445.     } else {
  446.        return( (buf.st_size > -1L) ? buf.st_size : 0L );
  447.     }
  448. }
  449.  
  450. /*  Z C H D S K  --  Change currently selected disk device */
  451.  
  452. /* Returns -1 if error, otherwise 0 */
  453.  
  454. zchdsk(c) int c; {
  455.     int i = toupper(c) - 64;
  456.     return( _chdrive(i));
  457. }
  458.  
  459. /*  Z H O M E  --  Return pointer to user's home directory  */
  460.  
  461. char *
  462. zhome() {
  463.     char *home = getenv("HOME");
  464.     return(home ? home : ".");
  465. }
  466.  
  467. /*  Z C H D I R  --  Change directory  */
  468. /*
  469.   Call with:
  470.     dirnam = pointer to name of directory to change to,
  471.       which may be "" or NULL to indicate user's home directory.
  472.   Returns:
  473.     0 on failure
  474.     1 on success
  475. */
  476. int
  477. zchdir(dirnam) char *dirnam; {
  478.     char *hd, *sp, *p;
  479.  
  480.     if (dirnam == NULL || dirnam == "" || *dirnam == '\0') /* If arg is null */
  481.       dirnam = zhome();            /* use user's home directory. */
  482.     sp = dirnam;
  483.  
  484. #ifdef DTILDE
  485.     hd = tilde_expand(dirnam);        /* Attempt to expand tilde */
  486.     if (*hd == '\0') hd = dirnam;    /* in directory name. */
  487. #else
  488.     hd = dirnam;
  489. #endif /* DTILDE */
  490. #ifdef OS2
  491.     if (isalpha(hd[0]) && hd[1] == ':') {
  492.         if (zchdsk(hd[0]))
  493.       return(0);
  494.     if (hd[2] == 0)
  495.       return(1);            /* Handle drive-only case */
  496.     hd += 2 ;            /* Move pointer forward since we already
  497.                                        handled the drive letter */
  498.     }
  499.     {
  500.     /* strip trailing DIRSEP except after d:; chdir() doesn't like it */
  501.     int len = strlen(hd) ;
  502.     if ( len > 1 && ISDIRSEP(hd[len - 1]) && hd[len - 2] != ':' )
  503.         hd[len - 1] = 0; 
  504.     }
  505. #endif /* OS2 */
  506.     if (
  507. #ifdef NT
  508.     _chdir(hd)
  509. #else
  510.     chdir(hd)
  511. #endif /* NT */
  512.     == 0) return(1);    /* Try to cd */ /* (===OS2===) */
  513.     p = sp;                /* Failed, lowercase it. */
  514.     while (*p) {
  515.     if (isupper(*p)) *p = tolower(*p);
  516.     p++;
  517.     }
  518. #ifdef DTILDE
  519.     hd = tilde_expand(sp);        /* Try again to expand tilde */
  520.     if (*hd == '\0') hd = sp;
  521. #else
  522.     hd = sp;                /* Point to result */
  523. #endif /* DTILDE */
  524.     return((
  525. #ifdef NT
  526.         _chdir(hd)
  527. #else
  528.         chdir(hd)
  529. #endif /* NT */
  530.         == 0) ? 1 : 0);
  531. }
  532.  
  533. /*  Z G T D I R  --  Return pointer to user's current directory  */
  534.  
  535. #define CWDBL 256
  536. static char cwdbuf[CWDBL+1];
  537.  
  538. char *
  539. zgtdir() {
  540.     char *buf;
  541.  
  542. #ifdef OS2
  543. #ifndef __IBMC__ /* which has a macro for this */
  544.     extern char *getcwd();
  545. #endif /* __IBMC__ */
  546.     buf = cwdbuf;
  547. #ifdef NT
  548.     return(_getcwd(buf,CWDBL));
  549. #else
  550.     return(getcwd(buf,CWDBL));
  551. #endif /* NT */
  552. #endif /* OS2 */
  553. }
  554.  
  555. int
  556. isdiskok(char c) {
  557.     char buf[3] = "C:";
  558.     int x; unsigned long z;
  559.     buf[0] = c;
  560.     if (!isdir(buf))            /* (this never seems to fail...) */
  561.       return(0);
  562.     z = zdskspace(c);
  563.     return((z > SPACE_NEEDED) ? 1 : 0);
  564. }
  565.  
  566. char *
  567. mypwd(void) {
  568. #ifdef OS2
  569. #ifdef NT    
  570.     if (_getcwd(buf,256))
  571.       return((char *)buf);
  572.     else
  573.       return("");
  574. #else
  575.     extern char * getcwd();
  576.     return(getcwd(buf,256));
  577. #endif /* NT */
  578. #else
  579.     return("");
  580. #endif /* OS2 */
  581. }
  582.  
  583. char *
  584. getvolid(char c) {
  585. #ifdef NT
  586. /*
  587.   This does not seem to work when given a disk volume root path as the
  588.   first argument.  Therefore the argument to getvolid() is ignored and it
  589.   always goes to the current disk.
  590. */
  591.     char disk[5];
  592.     char tmp[20];
  593.     DWORD volser = 0;
  594.     DWORD maxlength = MAXPATH;
  595.     DWORD flags = 0;
  596.     disk[0] = c;
  597.     disk[1] = ':';
  598.     disk[2] = '\\';
  599.     disk[3] = (char) 0;
  600.     if (!GetVolumeInformation( /* (char *) disk, */ NULL,
  601.                   (char *) buf,
  602.                   (DWORD) 256,
  603.                   &volser,
  604.                   &maxlength,
  605.                   &flags,
  606.                   (char *) tmp,
  607.                   (DWORD) 20
  608.                   )) {
  609.  
  610.     return("");
  611.     } else {
  612.     return((char *)buf);
  613.     }
  614. #else
  615.     return("");    
  616. #endif /* NT */
  617. }
  618.  
  619. #ifdef NT
  620. HANDLE ConsoleHandle = 0;
  621. DWORD  ConsoleMode   = 0;
  622. int  KnowConsoleMode = 0;
  623. #endif /* NT */
  624.  
  625. int
  626. mysystem(char * cmd) {
  627.     int rc = 0;
  628. #ifdef FOR_REAL
  629.     rc = system(cmd) == 0;
  630. #ifdef NT
  631.     if (KnowConsoleMode)        /* Clean up after system()... */
  632.       SetConsoleMode(ConsoleHandle, ConsoleMode);
  633. #endif
  634. #else
  635.     rc = 1;
  636.     printf("%s\n", cmd);
  637. #endif /* FOR_REAL */
  638.     return(rc);
  639. }
  640.  
  641. int
  642. mymkdir(char * dir) {
  643.     int rc = 0;;
  644. #ifdef FOR_REAL
  645. #ifdef OS2
  646.     rc = _mkdir(dir);
  647. #else
  648.     rc = mkdir(dir,0777);
  649. #endif /* OS2 */
  650. #else
  651.     printf("mkdir %s\n", dir);
  652. #endif /* FOR_REAL */
  653.     return((rc < 0) ? 0 : 1);
  654. }
  655.  
  656. int
  657. inchar(char * prompt, char defaultval) {
  658.     int x=0, val, toomany;
  659.     toomany = 0;
  660.     val = 0;
  661.  
  662.     if (defaultval)
  663.       printf("%s [%c]: ", prompt, defaultval);
  664.     else
  665.       printf("%s: ", prompt);
  666.     while (val == 0) {
  667.     while (1) {
  668.         if ((x = getchar()) == EOF)    /* Error */
  669.           return(-1);
  670.         if (x == 10 || x == 13) {    /* Enter key */
  671. #ifdef NODEFAULT
  672.         printf("%s", prompt);    /* Print the prompt again */
  673.         continue;
  674. #else
  675.         return(defaultval);
  676. #endif /* NODEFAULT */
  677.         } else if (x > 32) {    /* Printable character */
  678.         break;
  679.         }                /* Otherwise keep looping */
  680.     }
  681.     val = x;            /* The character we got */
  682.     while (1) {
  683.         if ((x = getchar()) == EOF)    /* Get terminating Enter key */
  684.           return(-1);
  685.         if (x == 32)        /* Trailing spaces */
  686.           continue;
  687.         else if (x == 10 || x == 13) /* Enter key */
  688.           return(toomany ? -1 : val);
  689.         else if (x > 32) {        /* Extraneous character */
  690.         if (!toomany)
  691.           printf("Just one character please.\n");
  692.         toomany = 1;
  693.         continue;
  694.         }
  695.     }
  696.     }
  697.     return(val);
  698. }
  699.  
  700. int
  701. getnum(char * prompt, int defaultval) {
  702.     int x=0, val = 0;
  703.  
  704.     printf("%s [%d]: ", prompt, defaultval);
  705.     while (1) {
  706.     if ((x = getchar()) == EOF)    /* Error */
  707.       return(-1);
  708.     if (x == 10 || x == 13) {    /* Enter key */
  709. #ifdef NODEFAULT
  710.         printf("%s", prompt);    /* Print the prompt again */
  711.         continue;
  712. #else
  713.         return(defaultval);
  714. #endif /* NODEFAULT */
  715.     } else if (x < 33) {        /* Space or control character */
  716.         continue;
  717.     } else if (x >= (char)'0' && x <= (char)'9') { /* Got a digit */
  718.         break;
  719.     } else {            /* Not a digit */
  720.         printf("%c - Not a digit\n", (char) x);
  721.         continue;
  722.     }
  723.     }
  724.     val = x - '0';            /* The character we got */
  725.     while (1) {
  726.     if ((x = getchar()) == EOF)    /* Error */
  727.       return(-1);
  728.     if (x == 10 || x == 13) {    /* Enter key */
  729.         return(val);
  730.     } else if (x < 32) {
  731.         continue;
  732.     } else if (x >= (char)'0' && x <= (char)'9') {
  733.         val = 10 * val + x - '0';
  734.         continue;
  735.     } else {
  736.         printf("%c - Not a digit\n", (char) x);
  737.         continue;
  738.     }
  739.     }
  740. }
  741.  
  742. void
  743. upper(char * c) {            /* Uppercase a character */
  744.     if (*c >= 'a' && *c <= 'z')
  745.       *c -= 'a' - 'A';
  746. }
  747.  
  748. int
  749. getok(char * prompt, char defaultval) {    /* Get Y or N answer to question */
  750.     int x, rc = -1, flag = 0;
  751.     char c;
  752.  
  753.     if (!prompt)
  754.       prompt = "Is that OK (y/n)";
  755.     do {
  756.     if ((x = inchar(prompt, defaultval)) < 0) {
  757.         continue;
  758.     }        
  759.     c = (char) x;            /* Convert to char */
  760.     upper (&c);            /* Uppercase it */
  761.     if (c == 'Y')            /* Yes */
  762.       rc = 1;
  763.     else if (c == 'N')        /* No */
  764.       rc = 0;
  765.     else
  766.       printf("Please type Y for Yes or N for No.\n");
  767.     } while (rc < 0);
  768.     return(rc);
  769. }
  770.  
  771. void
  772. initbar() {
  773.     int i;
  774.     for (i = 0; i < 79; i++)
  775.       bar[i] =
  776. #ifdef OS2
  777.     (char) /* 196 */ 205    /* 196 = single, 205 = double */
  778. #else
  779.     '_'
  780. #endif /* OS2 */
  781.     ;
  782.     bar[79] = (char) 0;
  783. }
  784.  
  785. void
  786. drawbar() {
  787. #ifdef OS2
  788.     printf("\n");
  789. #endif /* OS2 */
  790.     printf("%s\n\n", bar);
  791. }
  792.  
  793. int
  794. getdialinfo() {                /* This can change */
  795.     return(0);                /* when we have TAPI going... */
  796. }
  797.  
  798. #ifdef CLINK
  799. /* Doesn't work in console app... */
  800.  
  801. #define SHORTCUTDEBUG
  802.  
  803. HRESULT
  804. CreateLink(LPCSTR lpszPathObj, LPSTR lpszPathLink, LPSTR lpszDesc) {
  805.     HRESULT hres;
  806.     IShellLink * psl;
  807.  
  808. #ifdef SHORTCUTDEBUG
  809.     DWORD ec = 0L;            /* Error code */
  810.  
  811.     printf("CreateLink entry...\n");
  812.     printf("PathObj=[%s]\n", lpszPathObj);
  813.     printf("PathLink=[%s]\n", lpszPathLink);
  814.     printf("Description=[%s]\n", lpszDesc);
  815. #endif /* SHORTCUTDEBUG */
  816.  
  817.     hres = CoCreateInstance(&CLSID_ShellLink,
  818.                 NULL,
  819.                 CLSCTX_INPROC_SERVER,
  820.                 &IID_IShellLink,
  821.                 &psl
  822.                 );
  823. #ifdef SHORTCUTDEBUG
  824.     if (hres == S_OK)
  825.       printf("CoCreateInstance returns S_OK\n");
  826. #endif /* SHORTCUTDEBUG */
  827.  
  828.     if (SUCCEEDED(hres)) {
  829.     IPersistFile * ppf;
  830.     psl->lpVtbl->SetPath(psl, lpszPathObj);
  831.     psl->lpVtbl->SetDescription(psl, lpszDesc);
  832.     hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf);
  833.     if (SUCCEEDED(hres)) {
  834.         WORD wsz[MAX_PATH];
  835.         MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
  836.         hres = ppf->lpVtbl->Save(ppf, wsz, TRUE);
  837. #ifdef SHORTCUTDEBUG
  838.         if (SUCCEEDED(hres))
  839.           printf("Save succeeded\n");
  840.         else {
  841.         ec = GetLastError();
  842.         printf("Save failed: %ld\n", ec);
  843.         }
  844. #endif /* SHORTCUTDEBUG */
  845.         ppf->lpVtbl->Release(ppf);
  846.     }
  847. #ifdef SHORTCUTDEBUG
  848.     else {
  849.         ec = GetLastError();
  850.         printf("QueryInterface failed: %ld\n", ec);
  851.     }
  852. #endif /* SHORTCUTDEBUG */
  853.     psl->lpVtbl->Release(psl);
  854.     }
  855. #ifdef SHORTCUTDEBUG
  856.     else {
  857.     ec = GetLastError();
  858.     printf("CoCreateInstance failed: %ld\n", ec);
  859.     if (hres == REGDB_E_CLASSNOTREG)
  860.       printf("Class not registered\n");
  861.     else if (hres == E_OUTOFMEMORY)
  862.       printf("Out of memory\n");
  863.     else if (hres == E_INVALIDARG)
  864.       printf("Invalid argument\n");
  865.     else if (hres == E_UNEXPECTED)
  866.       printf("Unexpected error\n");
  867.     else if (hres == CLASS_E_NOAGGREGATION)
  868.       printf("This class cannot be created as part of an aggregate\n");
  869.     }
  870. #endif /* SHORTCUTDEBUG */
  871.     return(hres);
  872. }
  873. #endif /* COMMENT */
  874.  
  875. void
  876. doexit(int rc, int dummy) {
  877.     int x;
  878.     inchar("Press the Enter key to exit SETUP.", 0);
  879.     exit(rc);
  880. }
  881.  
  882. #ifdef NT
  883. int
  884. Win32EnumPrt( struct keytab ** pTable, int * pN )
  885. {
  886.     DWORD  dwBytesNeeded;
  887.     DWORD  dwPrtRet2;
  888.     DWORD  dwMaxPrt;
  889.     LPTSTR lpName = NULL;
  890.     DWORD  dwEnumFlags = PRINTER_ENUM_LOCAL;
  891.     LPPRINTER_INFO_2 pPrtInfo2=NULL;
  892.     int i, n ;
  893.  
  894.     if ( *pTable )
  895.     {
  896.     for ( i=0 ; i < *pN ; i++ )
  897.         free( (*pTable)[i].kwd ) ;
  898.     free ( *pTable )  ;
  899.     }
  900.     *pTable = NULL;
  901.     *pN = 0;
  902.  
  903.     if ( !isWin95() ) {
  904.         dwEnumFlags |= PRINTER_ENUM_CONNECTIONS;
  905.     }
  906.  
  907.     //
  908.     // get byte count needed for buffer, alloc buffer, the enum the printers
  909.     //
  910.  
  911.     EnumPrinters (dwEnumFlags, lpName, 2, NULL, 0, &dwBytesNeeded,
  912.                    &dwPrtRet2);
  913.     
  914.     //
  915.     // (simple error checking, if these work assume rest will too)
  916.     //
  917.  
  918.     if (!(pPrtInfo2 = (LPPRINTER_INFO_2) LocalAlloc (LPTR, dwBytesNeeded)))
  919.     {
  920.         return(FALSE);
  921.     }
  922.  
  923.     if (!EnumPrinters (dwEnumFlags, lpName, 2, (LPBYTE) pPrtInfo2,
  924.                         dwBytesNeeded, &dwBytesNeeded, &dwPrtRet2))
  925.     {
  926.         LocalFree( pPrtInfo2 );
  927.         return(FALSE);
  928.     }
  929.  
  930.     /* we now have an enumeration of all printer names */
  931.  
  932.     (*pTable) = (struct keytab *) malloc( dwPrtRet2 * sizeof(struct keytab) );
  933.     if ( !(*pTable) )
  934.     {
  935.         LocalFree( pPrtInfo2 );
  936.         return(FALSE);
  937.     }
  938.  
  939.     for ( i=0 ; i<dwPrtRet2 ; i++ ) {
  940.         (*pTable)[i].kwd = strdup( pPrtInfo2[i].pPrinterName );
  941.         (*pTable)[i].kwval = i;
  942.         (*pTable)[i].flgs = 0;
  943.     }
  944.     *pN = dwPrtRet2 ;
  945.  
  946.     LocalFree( pPrtInfo2 );
  947.     return(TRUE);
  948. }
  949. struct keytab * w32prttab = NULL;
  950. int             nw32prt = 0;
  951. #endif /* NT */
  952.  
  953.  
  954.  
  955. #ifndef NT
  956. void
  957. os2Folder(char * diskdir, int new_install, int windowable) {
  958.     ICONINFO iconinfo ;
  959.     UCHAR    exefile[256] ;
  960.     UCHAR    iconfile[256] ;
  961.     UCHAR    title[256];
  962.     UCHAR    classname[256] ;
  963.     UCHAR    location[256] ;
  964.     UCHAR    setup[256] ;
  965.     APIRET   rc ;
  966.  
  967.     printf("Assigning the K95F_OS2 icon to %s.EXE\n",ABBR);
  968.     sprintf(exefile,"%s\\%s.EXE",diskdir,ABBR);
  969.     sprintf(iconfile,"%s\\ICONS\\K95F_OS2.ICO",diskdir);
  970.     iconinfo.cb = sizeof(ICONINFO);
  971.     iconinfo.fFormat = ICON_FILE ;
  972.     iconinfo.pszFileName = iconfile;
  973.     iconinfo.hmod = NULL ;
  974.     iconinfo.resid = 0 ;
  975.     iconinfo.cbIconData = 0 ;
  976.     iconinfo.pIconData = NULL ;
  977.     if ( !WinSetFileIcon( exefile, &iconinfo ) ) {
  978.     printf(" ERROR: Unable to assign icon to %s.EXE\n",
  979.         ABBR);
  980.     }
  981.  
  982.     printf("Assigning the K95F_OS2 icon to %sDIAL.EXE\n",ABBR);
  983.     sprintf(exefile,"%s\\%sDIAL.EXE",diskdir,ABBR);
  984.     sprintf(iconfile,"%s\\ICONS\\K95F_OS2.ICO",diskdir);
  985.     iconinfo.cb = sizeof(ICONINFO);
  986.     iconinfo.fFormat = ICON_FILE ;
  987.     iconinfo.pszFileName = iconfile;
  988.     iconinfo.hmod = NULL ;
  989.     iconinfo.resid = 0 ;
  990.     iconinfo.cbIconData = 0 ;
  991.     iconinfo.pIconData = NULL ;
  992.     if ( !WinSetFileIcon( exefile, &iconinfo ) ) {
  993.     printf(" ERROR: Unable to assign icon to %sDIAL.EXE\n",ABBR);
  994.     }
  995.  
  996.     printf("Building %s Folder\n",PRODUCT);
  997.     sprintf(title,"%s 1.1",PRODUCT);
  998.     sprintf(classname,"WPFolder");
  999.     sprintf(location,"<WP_DESKTOP>");
  1000.     sprintf(setup,"OBJECTID=<%sFLDR>",ABBR);
  1001.     if ( !WinCreateObject( classname, title, setup, location, CO_UPDATEIFEXISTS) ) {
  1002.     printf(" ERROR: Unable to create Folder\n");
  1003.     }
  1004.  
  1005.     printf("Building Kermit 95 Hyperlink Manual object\n",PRODUCT);
  1006.     sprintf(title,"Kermit 95 Hyperlink Manual");
  1007.     sprintf(classname,"WPProgram");
  1008.     sprintf(location,"<%sFLDR>",ABBR);
  1009.     sprintf(setup,
  1010.             "EXENAME=NETSCAPE.EXE;STARTUPDIR=%s\\docs\\manual;PARAMETERS=%s\\docs\\manual\\kermit95.htm",
  1011.          diskdir,diskdir);
  1012.     if ( !WinCreateObject( classname, title, setup, location, CO_UPDATEIFEXISTS) ) {
  1013.     printf(" ERROR: Unable to create Program Object\n");
  1014.     }
  1015.  
  1016.     printf("Building Kermit/2 Program Object\n");
  1017.     sprintf(title,"Kermit/2");
  1018.     sprintf(classname,"WPProgram");
  1019.     sprintf(location,"<%sFLDR>",ABBR);
  1020.     if (windowable) 
  1021.     sprintf(setup,"EXENAME=%s\\%s.EXE;STARTUPDIR=%s;PARAMETERS=%%;PROGTYPE=WINDOWABLEVIO;ICONFILE=%s\\ICONS\\%s.ICO;MAXIMIZE=YES;CCVIEW=YES",
  1022.          diskdir,ABBR,diskdir,diskdir,"K95F_OS2");
  1023.     else /* fullscreen */
  1024.     sprintf(setup,"EXENAME=%s\\%s.EXE;STARTUPDIR=%s;PARAMETERS=%%;PROGTYPE=FULLSCREEN;ICONFILE=%s\\ICONS\\%s.ICO;MAXIMIZE=YES;CCVIEW=YES",
  1025.          diskdir,ABBR,diskdir,diskdir,ABBR); 
  1026.     if ( !WinCreateObject( classname, title, setup, location, CO_UPDATEIFEXISTS) ) {
  1027.     printf(" ERROR: Unable to create Program Object\n");
  1028.     }
  1029.  
  1030.     printf("Building Kermit/2 Dialer Program Object\n");
  1031.     sprintf(title,"Kermit/2 Dialer");
  1032.     sprintf(classname,"WPProgram");
  1033.     sprintf(location,"<%sFLDR>",ABBR);
  1034.     sprintf(setup,"EXENAME=%s\\%sDIAL.EXE;STARTUPDIR=%s;PARAMETERS=%%;ICONFILE=%s\\%s.ICO",
  1035.          diskdir,ABBR,diskdir,diskdir,"K95F_OS2");
  1036.     if ( !WinCreateObject( classname, title, setup, location, CO_UPDATEIFEXISTS) ) {
  1037.     printf(" ERROR: Unable to create Program Object\n");
  1038.     }
  1039.  
  1040.     printf("Building %s PM Clipboard Server Program Object\n",PRODUCT);
  1041.     sprintf(title,"%s PM Clipboard Server",PRODUCT);
  1042.     sprintf(classname,"WPProgram");
  1043.     sprintf(location,"<%sFLDR>",ABBR);
  1044.     sprintf(setup,"EXENAME=%s\\k2clip.exe;STARTUPDIR=%s;PARAMETERS=%%;ICONFILE=%s\\ICONS\\k2clip.ICO",
  1045.          diskdir,diskdir,diskdir);
  1046.     if ( !WinCreateObject( classname, title, setup, location, CO_UPDATEIFEXISTS) ) {
  1047.     printf(" ERROR: Unable to create Program Object\n");
  1048.     }
  1049.  
  1050. }
  1051.  
  1052. int
  1053. os2UpdateConfigSys( char * destination )
  1054. {
  1055.     UCHAR backup[256] = "" ;
  1056.     UCHAR source[256] = "" ;
  1057.     UCHAR tempfile[256] = "" ;
  1058.     UCHAR pwd[256] = "" ; 
  1059.     int   drive ;
  1060.     UCHAR filespec[256] = "" ;
  1061.     UCHAR line[2048] = "" ;
  1062.     UCHAR newline[2048] = "" ;
  1063.     UCHAR *envstring = NULL ;
  1064.     int i=0;
  1065.     ULONG bootdrive ; 
  1066.     FILE * pfTemp, * pfConfig ;
  1067.     int len;
  1068.     int timeslice = 0 ;
  1069.     int k2ini = 0 ;
  1070.     int update = 0 ;
  1071.  
  1072.     envstring = (char *) malloc( 2048 ) ;
  1073.     strcpy( envstring, "ENVSTR=" ) ;
  1074.  
  1075.     printf( "\n" );
  1076.     printf( "Your CONFIG.SYS file defines several environment variables that determine\n");
  1077.     printf( "how OS/2 and your applications work.  With your permission, this program\n");
  1078.     printf( "will make the following changes:\n");
  1079.     printf( "\n");
  1080.     printf( " 1. The Kermit/2 directory, %s, will be added to your PATH\n",destination);
  1081.     printf( "    to allow Kermit/2 to be executed from any OS/2 Command Line session.\n");
  1082.     printf( "\n");
  1083.     printf( " 2. The Kermit/2 directory, %s, will be added to your LIBPATH\n",destination);
  1084.     printf( "    to allow Kermit/2 (or external protocols) to find necessary DLLs.\n");
  1085.     printf( "\n");
  1086.     printf( " 3. The Kermit/2 directory, %s, will be added to your DPATH\n",destination);
  1087.     printf( "    to allow the Kermit/2 to find your initialization files.\n");
  1088.     printf( "\n");
  1089. #ifdef COMMENT
  1090.     printf( " 4. The Kermit/2 directory, %s, will be added to your BOOKSHELF\n",destination);
  1091.     printf( "    to allow the view command to find the INF files.\n");
  1092.     printf( "\n");
  1093. #endif /* COMMENT */
  1094.     printf( "Please enter 'Yes' to allow this program to update your CONFIG.SYS file.\n");
  1095.     printf( "A backup copy will be made in the root directory of your boot drive.\n");
  1096.     printf( "\n");
  1097.     if (!getok("Update CONFIG.SYS?",'Y'))
  1098.     {
  1099.         printf( "\n" );
  1100.         printf( "  OK, a modified CONFIG.SYS file will be placed in %s.\n",destination );
  1101.     }
  1102.     else
  1103.     update = 1 ;
  1104.     
  1105.     printf( "\n" );
  1106.  
  1107.     DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &bootdrive, sizeof(ULONG)) ;
  1108.  
  1109.     if ( update ) {
  1110.     /* find a backup file name */
  1111.     for ( i=0;i<1000;i++ ) {
  1112.         if ( i == 0 ) 
  1113.         sprintf(backup, "%c:\\CONFIG.BAK", 'A'+bootdrive-1 );
  1114.         else if ( i <= 9 )
  1115.         sprintf(backup, "%c:\\CONFIG.BK%d", 'A'+bootdrive-1, i ) ;
  1116.         else if ( i <= 99 )
  1117.         sprintf(backup, "%c:\\CONFIG.B%d", 'A'+bootdrive-1, i ) ;
  1118.         else
  1119.         sprintf(backup, "%c:\\CONFIG.%d", 'A'+bootdrive-1, i ) ;
  1120.         pfTemp = fopen(backup, "r");
  1121.         if ( !pfTemp )
  1122.         break;
  1123.         fclose( pfTemp ) ;
  1124.     }
  1125.  
  1126.     /* Now we have the backup file name */
  1127.     sprintf( source, "%c:\\CONFIG.SYS", 'A'+bootdrive-1 ) ;
  1128.     DosCopy( source, backup, 0 ) ;
  1129.  
  1130.     for ( i=0;i<1000;i++ ) {
  1131.         sprintf(tempfile, "%c:\\K2TEMP.%d", 'A'+bootdrive-1, i ) ;
  1132.         pfTemp = fopen(tempfile, "r");
  1133.         if ( !pfTemp )
  1134.         break;
  1135.         fclose( pfTemp ) ;
  1136.     }
  1137.     }
  1138.     else {
  1139.     sprintf(tempfile, "%s\\CONFIG.SYS", destination);
  1140.     sprintf( source, "%c:\\CONFIG.SYS", 'A'+bootdrive-1 ) ;
  1141.     }
  1142.     pfTemp = fopen(tempfile, "w+");
  1143.     pfConfig = fopen(source, "r" ) ;
  1144.     
  1145.     /* Generate the temporary CONFIG.SYS file. */
  1146.     if (update)
  1147.     printf( "Updating CONFIG.SYS...\n" );
  1148.     else
  1149.     printf( "Constructing %s\\CONFIG.SYS...\n", destination ) ;
  1150.     
  1151.     /* Change to a neutral directory so that SearchPath searches will succeed */
  1152.  
  1153.     drive = _getdrive() ;
  1154.     _getcwd( pwd, 256 ) ;
  1155.     _chdrive( bootdrive ) ;
  1156.     chdir( "\\OS2" ) ;
  1157.  
  1158.     /* Setup Environment String for Searches */
  1159.     putenv(envstring);
  1160.  
  1161.     /* Make sure that destination is upper case */
  1162.     strupr( destination ) ;
  1163.  
  1164.     /* Process the CONFIG.SYS file making changes as necessary */
  1165.     while ( !feof(pfConfig) ) {
  1166.     line[0] = '\0';
  1167.     fgets(line, 2048, pfConfig ) ;
  1168.     len = strlen( line ) ;
  1169.     if ( !strnicmp( "SET PATH", line, 8 ) ) {
  1170.         putenv("ENVSTR");
  1171.         strcpy( &envstring[7], &line[9] ) ;
  1172.         putenv(envstring);
  1173.         _searchenv( "k2.exe", "ENVSTR", filespec );
  1174.         if ( filespec[0] ) {    /* Found */
  1175.         if ( !strnicmp( destination, filespec, strlen(destination) ) ) {
  1176.             /* No changes necessary - already in PATH */
  1177.             fprintf(pfTemp, "%s", line ) ;
  1178.         }
  1179.         else {
  1180.             int matchpos ;
  1181.             char * lastslash ;
  1182.             strcpy( newline, line ) ;
  1183.             strupr( newline ) ;
  1184.             strupr( filespec ) ;
  1185.             lastslash = strrchr( filespec, '\\' ) ;
  1186.             if ( lastslash )
  1187.             *lastslash = '\0' ;
  1188.             matchpos = strstr( newline, filespec ) - newline ;
  1189.             if ( matchpos >= 0 && matchpos < 2048 ) {
  1190.             strncpy( newline, line, matchpos ) ;
  1191.             newline[matchpos] = '\0' ;
  1192.             strcat( newline, destination ) ;
  1193.             strcat( newline, line+matchpos+strlen(filespec) ) ;
  1194.             fprintf(pfTemp, "%s", newline ) ;
  1195.             printf( "\n");
  1196.             printf( "  WARNING:\n");
  1197.             printf( "    An earlier version of 'K2.EXE' exists in directory %s.\n",
  1198.                 filespec);
  1199.             }
  1200.             else {
  1201.             printf("\n   ERROR: PATH matchpos = %d\n",matchpos ) ;
  1202.             }
  1203.         }
  1204.         }
  1205.         else { /* Not Found - Add install directory to PATH */
  1206.         if ( line[len-1] == '\n' ) {
  1207.             line[--len] = '\0' ;
  1208.         }
  1209.         if ( line[len-1] != ';' )
  1210.             strcat( line, ";" ) ;
  1211.         strcat( line, destination ) ;
  1212.         strcat( line, ";\n" ) ;
  1213.         fprintf(pfTemp, "%s", line ) ;
  1214.         }
  1215.     }
  1216.     else if ( !strnicmp( "SET DPATH", line, 9 ) ) {
  1217.         putenv("ENVSTR");
  1218.         strcpy( &envstring[7], &line[10] );
  1219.         putenv(envstring);
  1220.         _searchenv( "k2.ini", "ENVSTR", filespec );
  1221.         if ( filespec[0] ) {    /* Found */
  1222.         if ( !strnicmp( destination, filespec, strlen(destination) ) ) {
  1223.             /* No changes necessary - already in DPATH */
  1224.             fprintf(pfTemp, "%s", line ) ;
  1225.         }
  1226.         else {
  1227.             int matchpos ;
  1228.             char * lastslash ;
  1229.             strcpy( newline, line ) ;
  1230.             strupr( newline ) ;
  1231.             strupr( filespec ) ;
  1232.             lastslash = strrchr( filespec, '\\' ) ;
  1233.             if ( lastslash )
  1234.             *lastslash = '\0' ;
  1235.             matchpos = strstr( newline, filespec ) - newline ;
  1236.             if ( matchpos >= 0 && matchpos < 2048 ) {
  1237.             strncpy( newline, line, matchpos ) ;
  1238.             newline[matchpos] = '\0' ;
  1239.             strcat( newline, destination ) ;
  1240.             strcat( newline, line+matchpos+strlen(filespec) ) ;
  1241.             fprintf(pfTemp, "%s", newline ) ;
  1242.             printf( "\n");
  1243.             printf( "  WARNING:\n");
  1244.             printf( "    An earlier version of 'K2.INI' exists in directory %s.\n",
  1245.                 filespec);
  1246.             }
  1247.             else {
  1248.             printf("\n   ERROR: DPATH matchpos = %d\n",matchpos ) ;
  1249.             }
  1250.         }
  1251.         }
  1252.         else { /* Not Found - Add install directory to DPATH */
  1253.         if ( line[len-1] == '\n' ) {
  1254.             line[--len] = '\0' ;
  1255.         }
  1256.         if ( line[len-1] != ';' )
  1257.             strcat( line, ";" ) ;
  1258.         strcat( line, destination ) ;
  1259.         strcat( line, ";\n" ) ;
  1260.         fprintf(pfTemp, "%s", line ) ;
  1261.         }
  1262.     } 
  1263. #ifdef COMMENT
  1264.     else if ( !strnicmp( "SET BOOKSHELF", line, 13 ) ) {
  1265.         putenv("ENVSTR");
  1266.         strcpy( &envstring[7], &line[14] ) ;
  1267.         putenv(envstring);
  1268.         _searchenv( "k2.inf", "ENVSTR", filespec );
  1269.         if ( filespec[0] ) {    /* Found */
  1270.         if ( !strnicmp( destination, filespec, strlen(destination) ) ) {
  1271.             /* No changes necessary - already in BOOKSHELF */
  1272.             fprintf(pfTemp, "%s", line ) ;
  1273.         }
  1274.         else {
  1275.             int matchpos ;
  1276.             char * lastslash ;
  1277.             strcpy( newline, line ) ;
  1278.             strupr( newline ) ;
  1279.             strupr( filespec ) ;
  1280.             lastslash = strrchr( filespec, '\\' ) ;
  1281.             if ( lastslash )
  1282.             *lastslash = '\0' ;
  1283.             matchpos = strstr( newline, filespec ) - newline ;
  1284.             if ( matchpos >= 0 && matchpos < 2048 ) {
  1285.             newline[matchpos] = '\0' ;
  1286.             strncpy( newline, line, matchpos ) ;
  1287.             strcat( newline, destination ) ;
  1288.             strcat( newline, line+matchpos+strlen(filespec) ) ;
  1289.             fprintf(pfTemp, "%s", newline ) ;
  1290.             printf( "\n");
  1291.             printf( "  WARNING:\n");
  1292.             printf( "    An earlier version of 'K2.INF' exists in directory %s.\n",
  1293.                 filespec);
  1294.             }
  1295.             else {
  1296.             printf("\n   ERROR: BOOKSHELF matchpos = %d\n",matchpos ) ;
  1297.             }
  1298.  
  1299.         }
  1300.         }
  1301.         else { /* Not Found - Add install directory to PATH */
  1302.         if ( line[len-1] == '\n' ) {
  1303.             line[--len] = '\0' ;
  1304.         }
  1305.         if ( line[len-1] != ';' )
  1306.             strcat( line, ";" ) ;
  1307.         strcat( line, destination ) ;
  1308.         strcat( line, "\\DOCS;\n" ) ;
  1309.         fprintf(pfTemp, "%s", line ) ;
  1310.         }
  1311.     }
  1312. #endif /* COMMENT */
  1313.     else if ( !strnicmp( "LIBPATH", line, 7 ) ) {
  1314.         putenv("ENVSTR");
  1315.         strcpy( &envstring[7], &line[8] ) ;
  1316.         putenv(envstring);
  1317.         _searchenv( "cko32rt.dll", "ENVSTR", filespec );
  1318.         if ( filespec[0] ) {    /* Found */
  1319.         if ( !strnicmp( destination, filespec, strlen(destination) ) ) {
  1320.             /* No changes necessary - already in LIBPATH */
  1321.             fprintf(pfTemp, "%s", line ) ;
  1322.         }
  1323.         else {
  1324.             int matchpos ;
  1325.             char * lastslash ;
  1326.             strcpy( newline, line ) ;
  1327.             strupr( newline ) ;
  1328.             strupr( filespec ) ;
  1329.             lastslash = strrchr( filespec, '\\' ) ;
  1330.             if ( lastslash )
  1331.             *lastslash = '\0' ;
  1332.             matchpos = strstr( newline, filespec ) - newline ;
  1333.             if ( matchpos >= 0 && matchpos < 2048 ) {
  1334.             strncpy( newline, line, matchpos ) ;
  1335.             newline[matchpos] = '\0' ;
  1336.             strcat( newline, destination ) ;
  1337.             strcat( newline, line+matchpos+strlen(filespec) ) ;
  1338.             fprintf(pfTemp, "%s", newline ) ;
  1339.             printf( "\n");
  1340.             printf( "  WARNING:\n");
  1341.             printf( "     %s is located in the LIBPATH\n",filespec);
  1342.             printf( "     and it appears to be a previous installation of Kermit/2.\n");
  1343.             printf( "     If you have difficulties starting Kermit/2, try removing\n");
  1344.             printf( "     %s from the LIBPATH statement in CONFIG.SYS\n",filespec);
  1345.             printf( "     and restart OS/2.\n");
  1346.             }
  1347.             else {
  1348.             printf("\n   ERROR: LIBPATH matchpos = %d\n",matchpos ) ;
  1349.             }
  1350.         }
  1351.         }
  1352.         else { /* Not Found - Add install directory to LIBPATH */
  1353.         if ( line[len-1] == '\n' ) {
  1354.             line[--len] = '\0' ;
  1355.         }
  1356.         if ( line[len-1] != ';' )
  1357.             strcat( line, ";" ) ;
  1358.         strcat( line, destination ) ;
  1359.         strcat( line, ";\n" ) ;
  1360.         fprintf(pfTemp, "%s", line ) ;
  1361.         }
  1362.     }
  1363.     else if ( !strnicmp( "TIMESLICE", line, 9 ) ) {
  1364.         timeslice = 1 ;
  1365.         fprintf(pfTemp, "%s", line ) ;
  1366.     }
  1367.     else if ( !strnicmp( "SET CKERMIT.INI", line, 15 ) ||
  1368.           !strnicmp( "SET K2.INI", line, 10 )) {
  1369.         k2ini= 1 ;
  1370.         fprintf(pfTemp, "%s", line ) ;
  1371.     }
  1372.     else 
  1373.         fprintf(pfTemp, "%s", line ) ;
  1374.     };
  1375.  
  1376.     /* Free envstring from the environment */
  1377.     putenv("ENVSTR");
  1378.     free(envstring) ;
  1379.     envstring = NULL ;
  1380.  
  1381.     fprintf(pfTemp, "\nREM Begin Kermit/2 configuration and suggestions\n");
  1382.     if ( k2ini )
  1383.     fprintf(pfTemp, "REM ");
  1384.     fprintf(pfTemp, "SET K2.INI=%s\\K2.INI\n", destination ) ;
  1385.     /* if ( timeslice ) */
  1386.     fprintf(pfTemp, "REM ");
  1387.     fprintf(pfTemp, "TIMESLICE=32,125\n");
  1388.     fprintf(pfTemp, "REM PRIORITY_DISK_IO=NO\n");
  1389.     fprintf(pfTemp, "REM PRIORITY=DYNAMIC\n");
  1390.     fprintf(pfTemp, "REM MAXWAIT=3\n");
  1391.     fprintf(pfTemp, "REM End Kermit/2\n");
  1392.  
  1393.     fclose( pfTemp ) ;
  1394.     fclose( pfConfig ) ;
  1395.  
  1396.     if ( update ) {
  1397.     remove( source ) ;
  1398.     rename( tempfile, source ) ;
  1399.     }
  1400.     
  1401.     _chdrive( drive ) ;
  1402.     chdir( pwd ) ;
  1403.     
  1404.     if ( update ) {
  1405.     printf( "\n");
  1406.     printf( "  Your CONFIG.SYS file has been updated.\n");
  1407.     printf( "  Your old CONFIG.SYS has been copied to %s.\n",backup);
  1408.     printf( "  OS/2 must be shutdown and restart to activate the changes.\n");
  1409.     }
  1410.     return 1;
  1411. }
  1412. #endif /* NT */
  1413.  
  1414.  
  1415. /* Main function */
  1416.  
  1417. int
  1418. main(int argc, char ** argv) {
  1419.     int flag, x, y, i;
  1420.     long xx;
  1421.  
  1422.     char * s, * p;
  1423.     char * prompt;
  1424.     char c;
  1425.  
  1426.     int modem = -1;
  1427.     int port = 0;
  1428.     int printer = 0;
  1429.     int tone = 0;
  1430.     char * method = NULL;
  1431.     long portspeed = 0;
  1432.     char disk;
  1433.     char dir[257];
  1434.     char cwd[257];
  1435.     char diskdir[260];
  1436.     char *dirptr;
  1437.     int country = 0;            /* Country code */
  1438.     char area[256] = { (char) 0};
  1439.     char ld_prefix[256] = { (char) 0};
  1440.     char intl_prefix[256] = { (char) 0};
  1441.  
  1442.     int zip_install = 0 ;
  1443.     int new_install = 1 ;
  1444. #ifdef NT
  1445.     int altgr       = 0 ;
  1446.     int tapiavail   = 0 ;
  1447. #endif /* NT */
  1448. #ifndef NT
  1449.     int windowable  = 1 ;
  1450. #endif
  1451.     
  1452.     kermitinfo.dir_exists = 0;
  1453.  
  1454. #ifdef NT
  1455.     ConsoleHandle = GetStdHandle(STD_INPUT_HANDLE);
  1456.     if (GetConsoleMode(ConsoleHandle, &ConsoleMode))
  1457.       KnowConsoleMode = 1;
  1458.     if ( tapiavail = cktapiinit() ) {
  1459.         cktapiopen();
  1460.         cktapiFetchLocationInfoByID(-1);    
  1461.         cktapiBuildLineTable( &tapilinetab, &_tapilinetab, &ntapiline );
  1462.         cktapiclose();
  1463.     }
  1464. #else
  1465.     setbuf( stdout, NULL );
  1466. #endif /* NT */
  1467.  
  1468.     s = argv[0];
  1469.     c = *s++;
  1470.     upper(&c);
  1471.     if (*s == ':') {
  1472.     s = mypwd();
  1473.     if (*(s+1) == ':') {
  1474.         if (*s != c) {
  1475.         printf("\nERROR -\n\n");
  1476.         printf("  Please make \"%c:\" your current disk first.\n", c);
  1477.         printf("  Then run SETUP again.\n\n");
  1478.         doexit(1,0);
  1479.         }
  1480.     }
  1481.     }
  1482.  
  1483.    if ( zchki(ZIPFILE) > 0 )
  1484.    {
  1485.       zip_install = 1 ;
  1486.    }
  1487.    else if ( zchki(ZIPFILE1) > 0 )
  1488.    {
  1489.       zip_install = 2 ;
  1490.    }
  1491.    else
  1492.    {
  1493.       s = getvolid(c);
  1494.       if (strcmp(s,DISKLABEL)) 
  1495.       {
  1496.  
  1497.          printf("\n");
  1498.          printf("Sorry, you must run SETUP from \"%s\".\n",DISKLABEL);
  1499.          doexit(1,0);
  1500.       }
  1501.    }
  1502.     mysystem("cls");
  1503.     initbar();
  1504.     drawbar();
  1505.  
  1506. #ifdef NT
  1507.     printf("Welcome to Kermit 95 for Windows(tm) %s.\n\n",
  1508.        isWin95() ? "95" : "NT"
  1509.        );
  1510. #else
  1511.     printf("Welcome to Kermit95 for OS/2 (Kermit/2).\n\n");
  1512. #endif
  1513.  
  1514.     printf("  This setup program will ask you a few questions.\n");
  1515.     printf("  Each question has a default answer, shown in [brackets].\n");
  1516.     printf("  To accept the default answer, just press the Enter key.\n");
  1517.     printf("\n");
  1518.     printf("  After you have answered the questions, your answers will be\n");
  1519.     printf(
  1520. "  summarized for you, and then you can choose to install the software\n");
  1521.     printf(
  1522. "  or not.  If you choose not to, nothing is done to your hard disk, and\n");
  1523.     printf(
  1524. "  you can run the setup program again if you wish.\n\n");
  1525.  
  1526.     printf("If this is a reinstallation, please be sure to shut down Kermit 95 and\n");
  1527.     printf("any related utilities before proceeding; otherwise they can not be updated.\n");
  1528.  
  1529.     drawbar();
  1530.  
  1531.     if (!getok("Do you wish to install Kermit?",'Y'))
  1532.         exit(0);
  1533.  
  1534.     printf("On which hard disk drive would you like to install %s?\n",PRODUCT);
  1535.     printf("Please type the disk-drive letter (C, D, E, ...).\n\n");
  1536.  
  1537.     prompt = " Disk letter";
  1538.     do {
  1539.        flag = 0;
  1540.        do {
  1541.         if ((x = inchar(prompt, 'C')) < 0)
  1542.           continue;
  1543.         c = (char) x;
  1544.         if (c == 13 || x == 10) {
  1545.         continue;
  1546.         } else {
  1547.         upper(&c);
  1548.         if (c >= 'C' && c <= 'Z') {
  1549.             if (!isdiskok(c)) {
  1550.             printf(
  1551. "\nSorry, disk %c is not available or has insufficient space.\n", c
  1552.                    );
  1553.             printf(
  1554. "Choose a different disk, or use Ctrl-C or Ctrl-Break to cancel SETUP.\n\n"
  1555.                    );
  1556.             continue;
  1557.             } else {
  1558.             flag = 1;
  1559.             }
  1560.         } else {
  1561.             printf("Please type a letter, C - Z.\n");
  1562.         }
  1563.         }
  1564.     } while (flag == 0);
  1565.       printf(
  1566. "\n%s will be installed on disk %c.\n", PRODUCT, c);
  1567.     } while (!getok(NULL,'Y'));
  1568.  
  1569.     disk = c;
  1570.  
  1571.     printf("\n");
  1572.     printf("In which directory on disk %c should %s be installed?\n",
  1573.        disk, PRODUCT );
  1574.     s = dir;
  1575.     do {
  1576.        dir[0] = (char) 0;
  1577.        s = dir;
  1578.        flag = 0 ;
  1579.        do {
  1580.        printf("\n");
  1581.        printf(
  1582. "Please type the directory name or press the Enter key to accept the\n"
  1583. );
  1584.        printf("default directory name, %s.\n\n",ABBR);
  1585.        printf(" Directory name [%s]: ",ABBR);
  1586.        if (!gets(s))
  1587.            continue;
  1588.        if (!dir[0])
  1589.            strcpy(dir,ABBR);
  1590.        x = strlen(dir);
  1591.        if ( x > 255 )
  1592.        {
  1593.            printf("\nplease limit the PATH to 255 characters.\n\n");
  1594.            continue;
  1595.        }    
  1596.        {
  1597.            for ( i = 0, y = 0; i<=8 && y < x && dir[y]; i++, y++ ) {
  1598.            if ( dir[y] == '\\' || dir[y] == '/' )
  1599.                i = -1 ;
  1600.            else if ( dir[y] == '.' ) {
  1601.                int j = 0 ;
  1602.                i=0;
  1603.                for ( y++ ; j<3 && y<x && dir[y]; j++, y++ ) {
  1604.                if ( dir[y] == '\\' || dir[y] == '/' ) {
  1605.                    i = -1;
  1606.                    j = 0;
  1607.                    break;
  1608.                }
  1609.                }
  1610.                if ( j == 3 && dir[y] ) 
  1611.                i = 99 ;
  1612.            }
  1613.            }
  1614.            if ( i > 8) {
  1615.            printf("\nplease limit directories to 8.3 notation.\n\n");
  1616.            continue;
  1617.            }
  1618.        }
  1619.        flag = 1;
  1620.        } while (flag == 0);
  1621.        printf("\n");
  1622.        s = dir + x;
  1623.        while ((*s < (char) 33) && (s > dir))
  1624.           *s-- = (char) 0;
  1625.        dirptr = dir;
  1626.        while (*dirptr && (*dirptr < (char) 33))
  1627.           dirptr++;
  1628.        printf("%s will be installed in:\n\n",PRODUCT);
  1629.        if ( dir[0] == '\\' )
  1630.        {
  1631.           printf("  %c:%s\n\n", c, dirptr);
  1632.        }
  1633.        else 
  1634.        {
  1635.           printf("  %c:\\%s\n\n", c, dirptr);
  1636.        }
  1637.     } while (!getok(NULL,'Y'));
  1638.    if ( dir[0] == '\\' )
  1639.    {
  1640.       sprintf(diskdir, "%c:%s", disk, dir);
  1641.    }
  1642.    else
  1643.    { 
  1644.       sprintf(diskdir, "%c:\\%s", disk, dir);
  1645.    } 
  1646.    if (isdir(diskdir)) {
  1647.       printf("\n");
  1648.       printf("WARNING - %s already exists.\n\n", diskdir);
  1649.       if (!getok("  Do you want to continue? ",'N')) {
  1650.          printf("\n");
  1651.          printf("  OK, run SETUP again to do over.\n\n");
  1652.          printf("Bye.");
  1653.          drawbar();
  1654.          doexit(1,0);
  1655.       }
  1656.       kermitinfo.dir_exists = 1;
  1657.    }
  1658.    printf("\n");
  1659.  
  1660.     /* Check for install type: NEW or UPDATE */
  1661.     /* If CKERMIT.INI or K95.INI or K2.INI exists in the destination directory */
  1662.     /* assume that it is an Update, otherwise assume New install */
  1663.  
  1664.    drawbar();
  1665.    if (getok("Will you be using a modem? ",'Y')) {
  1666.       printf("\n");
  1667. #ifdef NT
  1668.        if ( tapiavail && ntapiline ) {
  1669.            printf("Please choose one of the following TAPI modems:\n\n");
  1670.            for ( i=0; i<ntapiline ; i++ ) {
  1671.                printf(" %2d. %-60s\n",i+1,tapilinetab[i].kwd);
  1672.            }
  1673.            printf("\n");
  1674.            prompt = " Enter a modem number";
  1675.            do {
  1676.                while (1) {
  1677.                    if ((x = getnum(prompt, 1)) < 0)
  1678.                        continue;
  1679.                    if (x < 1 || x > ntapiline) {
  1680.                        printf("Please enter a number between 1 and %d.\n",
  1681.                                ntapiline);
  1682.                        continue;
  1683.                    } else
  1684.                        break;
  1685.                }
  1686.                printf("\n");
  1687.                printf("You picked %d, %s\n", x, tapilinetab[x-1].kwd);
  1688.            } while (!getok(NULL,'Y'));
  1689.            modem = x - 1;
  1690.  
  1691.            printf("\n");
  1692.            drawbar();
  1693.        }
  1694.        else {
  1695. #endif /* NT */
  1696.       printf("Please choose one of the following modem types.\n");
  1697.       printf(
  1698. "If none of them matches yours or you don't know, pick Generic-High-Speed:\n\n"
  1699. );
  1700.       x = modems / 2;
  1701.       if (modems % 2) x++;
  1702. #ifdef COMMENT
  1703.     if (x > 21) {
  1704.         printf("ERROR - Too many modems!\n");
  1705.         doexit(1,0);
  1706.     }
  1707. #endif /* COMMENT */
  1708.     for (i = 0; i < x; i++) {
  1709.         if (i + x < modems) {
  1710.         printf(" %2d. %-34s  %2d. %s\n",
  1711.                i+1,
  1712.                mdmtab[i].menuname,
  1713.                i+x+1,
  1714.                mdmtab[i+x].menuname);
  1715.         } else {
  1716.         printf(" %2d. %s\n",i+1,mdmtab[i].menuname);
  1717.         }
  1718.     }
  1719.     printf("\n");
  1720.     prompt = " Enter a modem number";
  1721.     do {
  1722.         while (1) {
  1723.         if ((x = getnum(prompt, 15)) < 0)
  1724.           continue;
  1725.         if (x < 1 || x > modems) {
  1726.             printf("Please enter a number between 1 and %d.\n",modems);
  1727.             continue;
  1728.         } else
  1729.           break;
  1730.         }
  1731.         printf("\n");
  1732.         printf("You picked %d, %s\n", x, mdmtab[x-1].menuname);
  1733.     } while (!getok(NULL,'Y'));
  1734.     modem = x - 1;
  1735.  
  1736.     printf("\n");
  1737.     drawbar();
  1738.     printf("Should your modem use Tone or Pulse dialing?\n\n");
  1739.     printf(" 1. Tone\n");
  1740.     printf(" 2. Pulse\n");
  1741.     printf(" 3. I don't know\n");
  1742.     printf("\n");
  1743.  
  1744.     printf("Please select 1, 2, or 3.\n");
  1745.     do {
  1746.         while (1) {
  1747.         if ((x = getnum(" Dialing method selection", 1)) < 0)
  1748.           continue;
  1749.         if (x < 1 || x > 3) {
  1750.             printf("Please enter a number between 1 and 3.\n");
  1751.             continue;
  1752.         } else
  1753.           break;
  1754.         }
  1755.         printf("\n");
  1756.         if (x == 1)
  1757.           method = "Tone";
  1758.         else if (x == 2)
  1759.           method = "Pulse";
  1760.         else if (x == 3)
  1761.           method = "Don't know";
  1762.         printf("You picked %d, %s\n", x, method);
  1763.         if (x == 3) {
  1764.         printf("\n");
  1765.         printf(
  1766. " Then I will choose Pulse for you, since pulse dialing should work\n"
  1767.                );
  1768.         printf(
  1769. " everywhere, whereas Tone dialing is only available in certain locations.\n"
  1770.                );
  1771.         printf("\n");
  1772.         x = 2;
  1773.         method = "Pulse";
  1774.         }
  1775.     } while (!getok(NULL,'Y'));
  1776.     if (x > 2) x = 0;
  1777.     tone = x;
  1778.  
  1779.     printf("\n");
  1780.     drawbar();
  1781.     printf("Which communications port is the modem attached to?\n\n");
  1782.     printf(" 1. COM1\n");
  1783.     printf(" 2. COM2\n");
  1784.     printf(" 3. COM3\n");
  1785.     printf(" 4. COM4\n");
  1786.     printf("\n");
  1787.  
  1788.     printf("Please enter a COM port number, 1 - 4\n");
  1789.     do {
  1790.         while (1) {
  1791.         if ((x = getnum(" COM port number", 1)) < 0)
  1792.           continue;
  1793.         if (x < 1 || x > 4) {
  1794.             printf("Please enter a number between 1 and 4.\n");
  1795.             continue;
  1796.         } else
  1797.           break;
  1798.         }
  1799.         printf("\n");
  1800.         printf("You picked %d, COM%d\n", x, x);
  1801.     } while (!getok(NULL,'Y'));
  1802.     port = x;
  1803.  
  1804.     printf("\n");
  1805.     drawbar();
  1806.     printf(
  1807. "The communication speed between COM%d and the modem will be:\n\n", port
  1808.            );
  1809.     printf("  %ld\n\n", mdmtab[modem].speed);
  1810.     printf("bits per second (bps)\n\n");
  1811.     if (getok("Would you like to change the speed? ",'N')) {
  1812.         printf("\n");
  1813.         printf("Please choose one of the following speeds by number:\n");
  1814.         printf("\n");
  1815.         x = speeds / 2;
  1816.         if (speeds % 2) x++;
  1817.         for (i = 0; i < x; i++) {
  1818.         if (i + x < speeds)
  1819.           printf("%2d. %6ld     %2d. %6ld\n",
  1820.              i+1, speedtab[i], i+x+1, speedtab[i+x]
  1821.              );
  1822.         else
  1823.           printf("%2d. %6ld\n", i+1, speedtab[i]);
  1824.         }
  1825.         printf("\n");
  1826.         printf("Please enter speed number, 1 - %d\n", speeds);
  1827.         prompt = " Speed number";
  1828.         do {
  1829.         while (1) {
  1830.             if ((x = getnum(prompt, 4)) < 0)
  1831.               continue;
  1832.             if (x < 1 || x > speeds) {
  1833.             printf("Please enter a number between 1 and %d.\n",
  1834.                    speeds
  1835.                    );
  1836.             continue;
  1837.             } else
  1838.               break;
  1839.         }
  1840.         printf("\n");
  1841.         printf("You picked %d, %ld\n", x, speedtab[x-1]);
  1842.         } while (!getok(NULL,'Y'));
  1843.         portspeed = speedtab[x-1];
  1844.     } else
  1845.       portspeed = mdmtab[modem].speed;
  1846.  
  1847.  
  1848.     if (!getdialinfo()) {
  1849.  
  1850.         printf("\n");
  1851.         drawbar();
  1852.         printf(
  1853. "Now I will ask you a few questions about your dialing location, so I can\n"
  1854.            );
  1855.         printf(
  1856. "tell the difference between local, long-distance, and international phone\n"
  1857.            );
  1858.         printf(
  1859. "numbers, and so I can dial them correctly.  You might already have\n"
  1860.            );
  1861.         printf(
  1862. "answered some of these questions before when you configured your modem\n"
  1863.            );
  1864.         printf(
  1865. "for Windows 95, so if you are not sure of the answers, look in the\n"
  1866.            );
  1867.         printf(
  1868. "Control Panel modem configuration.  These questions are just the mininum\n"
  1869.            );
  1870.         printf(
  1871. "to get you dialing.  For further detail, see Dialing Options menu.\n"
  1872.            );
  1873.         printf("\n");
  1874.         printf(
  1875. "Please enter your country code: a 1-, 2-, or 3-digit number that is used\n"
  1876.            );
  1877.         printf(
  1878. "to call into your country from the outside.  Some examples are: 1 for the\n"
  1879.            );
  1880.         printf(
  1881. "USA and Canada (etc), 44 for the UK, 49 for Germany, 7 for Russia.\n"
  1882.            );
  1883.         printf("\n");
  1884.  
  1885.         do {
  1886.         while (1) {
  1887.             if ((x = getnum(" Country code", 1)) < 0)
  1888.               continue;
  1889.             if (x < 1 || x > 999) {
  1890.             printf("Please enter a number between 1 and 999.\n");
  1891.             continue;
  1892.             } else
  1893.               break;
  1894.         }
  1895.         printf("\n");
  1896.         printf("You picked country code %d\n", x);
  1897.         } while (!getok(NULL,'Y'));
  1898.         country = x;
  1899.         
  1900.         printf("\n");
  1901.         printf("Now please enter your area or city code.\n");
  1902.         if (country != 1)
  1903.           printf(
  1904. "If your country does not have city or areas codes, just press Enter\n"
  1905.            );
  1906.         printf("\n");
  1907.         flag = 0;
  1908.         s = "";
  1909.         do {
  1910.         buf[0] = (char) 0;
  1911.         s = buf;
  1912.         do {
  1913.             printf("\n");
  1914.             printf(" Area code: ");
  1915.             if (!gets(s))
  1916.               continue;
  1917.             if (!buf[0] && country == 1) {
  1918.             printf(
  1919. "An area code is required for country code %d\n\n", country
  1920.                    );
  1921.             continue;
  1922.             }
  1923.             flag = 1;
  1924.         } while (flag == 0);
  1925.         printf("\n");
  1926.         if (!buf[0]) {
  1927.             printf("Your country has no area codes.\n");
  1928.         } else {
  1929.             printf("Your area code is %s\n", buf);
  1930.         }
  1931.         } while (!getok(NULL,'Y'));
  1932.         strcpy(area,buf);
  1933.  
  1934.         printf("\n");
  1935.         printf(
  1936. "Please enter your long-distance dialing prefix, for dialing long-distance\n"
  1937.            );
  1938.         printf(
  1939. "calls within your country.  If your country does not have long-distance\n"
  1940.            );
  1941.         printf(
  1942. "calls, just press the Enter key.\n"
  1943.            );
  1944.         printf("\n");
  1945.         flag = 0;
  1946.         s = "";
  1947.         do {
  1948.         buf[0] = (char) 0;
  1949.         s = buf;
  1950.         do {
  1951.             printf("\n");
  1952.             if (country == 1)
  1953.               printf(" Long-distance prefix [1]: ");
  1954.             else
  1955.               printf(" Long-distance prefix: ");
  1956.             if (!gets(s))
  1957.               continue;
  1958.             if (!buf[0] && country == 1)
  1959.               strcpy(buf,"1");
  1960.             flag = 1;
  1961.         } while (flag == 0);
  1962.         printf("\n");
  1963.         if (!buf[0]) {
  1964.             printf("No long-distance prefix..\n");
  1965.         } else {
  1966.             printf("Your long-distance prefix is %s\n", buf);
  1967.         }
  1968.         } while (!getok(NULL,'Y'));
  1969.         strcpy(ld_prefix,buf);
  1970.  
  1971.         printf("\n");
  1972.         printf(
  1973. "Finally, please enter your international dialing prefix, for dialing\n"
  1974.            );
  1975.         printf(
  1976. "numbers that are outside of your country.  If you don't know, or you do not\n"
  1977.            );
  1978.         printf(
  1979. "plan to make international calls, just press Enter.\n"
  1980.            );
  1981.         printf("\n");
  1982.         flag = 0;
  1983.         s = "";
  1984.         do {
  1985.         buf[0] = (char) 0;
  1986.         s = buf;
  1987.         do {
  1988.             printf("\n");
  1989.             if (country == 1)
  1990.               printf(" International prefix [011]: ");
  1991.             else
  1992.               printf(" International prefix: ");
  1993.             if (!gets(s))
  1994.               continue;
  1995.             if (!buf[0] && country == 1)
  1996.               strcpy(buf,"011");
  1997.             flag = 1;
  1998.         } while (flag == 0);
  1999.         printf("\n");
  2000.         if (!buf[0]) {
  2001.             printf("No international prefix..\n");
  2002.         } else {
  2003.             printf("Your international prefix is %s\n", buf);
  2004.         }
  2005.         } while (!getok(NULL,'Y'));
  2006.         strcpy(intl_prefix,buf);
  2007.     }
  2008.            printf("\n");
  2009.            drawbar();
  2010. #ifdef NT
  2011.        }
  2012. #endif /* NT */
  2013.    }
  2014.  
  2015.     /* Lets get the default printer */
  2016.     printf("Which printer/port would you like as your default?\n\n");
  2017.     printf(" 1. PRN  (DOS device)\n");
  2018.     printf(" 2. LPT1 (DOS device)\n");
  2019.     printf(" 3. LPT2 (DOS device)\n");
  2020.     printf(" 4. LPT3 (DOS device)\n");
  2021.     printf(" 5. NUL  (DOS device)\n");
  2022.     printf(" 6. KERMIT.PRN (file)\n");
  2023. #ifdef NT
  2024.     if ( Win32EnumPrt( &w32prttab, &nw32prt ) ) {
  2025.         int i;
  2026.         for ( i=0 ; i<nw32prt ; i++ ) {
  2027.             printf("%2d. %s (Windows printer)\n",i+nprinters+1,w32prttab[i].kwd);
  2028.         }
  2029.     }
  2030. #endif /* NT */
  2031.     printf("\n");
  2032.  
  2033.     printf("Please enter a printer number, 1 - %d\n",
  2034. #ifdef NT
  2035.             nprinters + nw32prt 
  2036. #else
  2037.             nprinters
  2038. #endif
  2039.             );
  2040.     do {
  2041.         while (1) {
  2042.             if ((x = getnum(" printer number", 1)) < 0)
  2043.                 continue;
  2044.             if (x < 1 || x > 
  2045. #ifdef NT
  2046.                  nprinters + nw32prt 
  2047. #else
  2048.                  nprinters
  2049. #endif
  2050.                  ) {
  2051.                 printf("Please enter a number between 1 and %d.\n",
  2052. #ifdef NT
  2053.                         nprinters + nw32prt 
  2054. #else
  2055.                         nprinters
  2056. #endif
  2057.                         );
  2058.                 continue;
  2059.             } else
  2060.                 break;
  2061.         }
  2062.         printf("\n");
  2063.         printf("You picked %d, %s\n", x,
  2064. #ifdef NT
  2065.                 ( x <= nprinters ) ? printers[x-1] : w32prttab[x-nprinters-1].kwd
  2066. #else
  2067.                 printers[x-1]
  2068. #endif
  2069.                 );
  2070.     } while (!getok(NULL,'Y'));
  2071.     printer = x;
  2072.  
  2073. #ifdef NT
  2074.     /* Lets take care of the Alt-Gr key situation on Windows 95 */
  2075.     if ( isWin95() && country != 1 ) {
  2076.     printf("\n");
  2077.     drawbar();
  2078.     printf("Microsoft Windows 95 has a bug in the Console Agent which affects\n");
  2079.     printf("Kermit-95's ability to recognize characters generated by Alt-Gr key\n");
  2080.         printf("combinations.  To implement a work-around for this bug, Kermit-95\n");
  2081.     printf("needs to know if your keyboard has an Alt-Gr key.\n");
  2082.     printf("\n");
  2083.     do {
  2084.         altgr = getok("Does your keyboard have an Alt-Gr key?",
  2085.                            tapiavail?'N':'Y');
  2086.         printf("\n");
  2087.         printf("You picked %s\n",altgr?"yes, you have an Alt-Gr key":
  2088.             "no, you don't have an Alt-Gr key");
  2089.     } while ( !getok(NULL,'Y') );
  2090.     }
  2091. #endif /* NT */
  2092.  
  2093. #ifndef NT
  2094.     printf("\n");
  2095.     drawbar();
  2096.     printf("How would you like %s to be executed?\n\n", PRODUCT);
  2097.     printf(" 1. In a Window\n");
  2098.     printf(" 2. Full Screen\n");
  2099.     printf("\n");
  2100.  
  2101.     printf("Please enter a number, 1 - 2\n");
  2102.     do {
  2103.     while (1) {
  2104.         if ((x = getnum(" Run mode", 1)) < 0)
  2105.         continue;
  2106.         if (x < 1 || x > 2) {
  2107.         printf("Please enter a number between 1 and 2.\n");
  2108.         continue;
  2109.         } else
  2110.         break;
  2111.     }
  2112.     printf("\n");
  2113.     printf("You picked %d, %s\n", x, x==1?"In a Window":"Full Screen");
  2114.     } while (!getok(NULL,'Y'));
  2115.     windowable = (x==1);
  2116. #endif /* NT */
  2117.  
  2118.     printf("\n");
  2119.     drawbar();
  2120.     printf("SUMMARY\n\n");
  2121.     printf("You have chosen:\n\n");
  2122.     printf(" Disk:                 %c\n", disk);
  2123.     printf(" Directory:            %s\n\n", dirptr);
  2124.     if (modem > -1) {
  2125. #ifdef NT
  2126.         if ( tapiavail && ntapiline ) {
  2127.             printf(" Modem:                %s\n", _tapilinetab[modem].kwd);
  2128.         }
  2129.         else {
  2130. #endif
  2131.             printf(" Modem:                %s\n", mdmtab[modem].menuname);
  2132.             printf(" Port:                 COM%d\n", port);
  2133.             printf(" Speed:                %ld\n\n", portspeed);
  2134.             printf(" Dialing Method:       %s\n", method);
  2135.             printf(" Country Code:         %d\n", country);
  2136.             printf(" Area Code:            %s\n", area);
  2137.             printf(" Long-distance prefix: %s\n", ld_prefix);
  2138.             printf(" International prefix: %s\n", intl_prefix);
  2139. #ifdef NT
  2140.         }
  2141. #endif
  2142.     } else {
  2143.     printf(" Modem:                (none)\n");
  2144.     }
  2145.     printf(" Printer:              %s\n", 
  2146. #ifdef NT
  2147.             ( printer <= nprinters ) ? printers[printer-1] : 
  2148.             w32prttab[printer-nprinters-1].kwd
  2149. #else
  2150.             printers[printer-1]
  2151. #endif
  2152.             );
  2153. #ifdef NT
  2154.     if ( isWin95() && country != 1 ) {
  2155.     printf(" Alt-Gr key:           %s\n",altgr?"Yes":"No");
  2156.     }
  2157. #endif /* NT */
  2158. #ifndef NT
  2159.     printf(    " Run Mode:             %s\n", windowable?"In a Window":"Full Screen");
  2160. #endif
  2161.  
  2162.     printf("\n");
  2163.     if (!getok(
  2164. #ifdef NT
  2165.         "May I install Kermit 95 now? "
  2166. #else
  2167.         "May I install Kermit/2 now? "           
  2168. #endif
  2169.         ,'Y')) {
  2170.     printf("\n");
  2171.     printf("  %s will NOT be installed.\n",PRODUCT);
  2172.     printf("  Run SETUP again to do over.\n");
  2173.     printf("\n");    
  2174.     printf("Bye!\n");
  2175.     drawbar();
  2176.     doexit(0,0);
  2177.     }
  2178.     printf("\n");
  2179.     drawbar();
  2180.     if (!kermitinfo.dir_exists) {
  2181.     printf("Creating %s...\n", diskdir);
  2182.     if (!mymkdir(diskdir)) {
  2183.         printf("ERROR - Can't create directory: %s\n\n", diskdir);
  2184.         printf(
  2185. "  Please check writeability and space on disk %c and then run SETUP again.\n",
  2186.            disk
  2187.            );
  2188.         printf("\nBye.\n");
  2189.         drawbar();
  2190.         doexit(1,0);
  2191.     }
  2192.     }
  2193.     printf("\n");
  2194.    if ( zip_install )
  2195.    {
  2196.       strcpy(cwd, zgtdir() ) ;
  2197.  
  2198.       if ( zip_install == 1 ) /* Packed in one file */
  2199.       {
  2200.          printf("Expanding files from %s distribution to %s...\n\n",
  2201.          PRODUCT,diskdir);
  2202.  
  2203.       if ( !zchdir(diskdir) ) {
  2204.          printf("Unable to cd to %s\n",diskdir);
  2205.           doexit(1,0);
  2206.       }
  2207.  
  2208.          if ( cwd[strlen(cwd)-1] == '\\' )
  2209.             sprintf(buf,"\"%s%s\"", cwd, ZIPFILE ) ;
  2210.          else
  2211.             sprintf(buf,"\"%s\\%s\"", cwd, ZIPFILE ) ;
  2212.          if ( !mysystem(buf) )
  2213.          {
  2214.             zchdir( cwd ) ;
  2215.             printf("\nFile expansion failed.\n");
  2216.             printf("Please check your %c disk and try again.\n",disk);
  2217.             printf("\n");
  2218.             doexit(1,0) ;
  2219.          }
  2220.       }
  2221.       else
  2222.       {
  2223.          /* Expand first Pack File */
  2224.          printf("Expanding files from %s distribution to %s...\n\n",
  2225.          PRODUCT,
  2226.                  diskdir);
  2227.  
  2228.          zchdir(diskdir) ;
  2229.  
  2230.          if ( cwd[strlen(cwd)-1] == '\\' )
  2231.             sprintf(buf,"\"%s%s\"", cwd, ZIPFILE1 ) ;
  2232.          else
  2233.             sprintf(buf,"\"%s\\%s\"", cwd, ZIPFILE1 ) ;
  2234.          if ( !mysystem(buf) )
  2235.          {
  2236.             zchdir( cwd ) ;
  2237.             printf("\nFile expansion failed.\n");
  2238.             printf("Please check your %c disk and try again.\n\n",disk);
  2239.             doexit(1,0) ;
  2240.          }
  2241.  
  2242.           if ( zchki(K95EXE) <= 0 ) {
  2243.               zchdir( cwd ) ;
  2244.  
  2245.               while (zchki(ZIPFILE2) <= 0) {       /* Get second disk */
  2246.                   printf("\nPlease insert %s Diskette 2.\n",PRODUCT);    
  2247.                   while (!getok("Ready? (y/n)",'Y'))
  2248.                       ;
  2249.               }
  2250.  
  2251.               /* Expand second Pack File */
  2252.               printf("\nExpanding files from %s distribution to %s...\n\n",
  2253.                       PRODUCT, diskdir);
  2254.  
  2255.               zchdir(diskdir) ;
  2256.  
  2257.               if ( cwd[strlen(cwd)-1] == '\\' )
  2258.                   sprintf(buf,"\"%s%s\"", cwd, ZIPFILE2 ) ;
  2259.               else
  2260.                   sprintf(buf,"\"%s\\%s\"", cwd, ZIPFILE2 ) ;
  2261.               if ( !mysystem(buf) )
  2262.               {
  2263.                   zchdir( cwd ) ;
  2264.                   printf("\nFile expansion failed.\n");
  2265.                   printf("Please check your %c disk and try again.\n",disk);
  2266.                   printf("\n");
  2267.                   doexit(1,0) ;
  2268.               }
  2269.           }
  2270.           if ( zchki(K95EXE) <= 0 ) {
  2271.               zchdir( cwd ) ;
  2272.  
  2273.               while (zchki(ZIPFILE3) <= 0) {       /* Get second disk */
  2274.                   printf("\nPlease insert %s Diskette 3.\n",PRODUCT);    
  2275.                   while (!getok("Ready? (y/n)",'Y'))
  2276.                       ;
  2277.               }
  2278.  
  2279.               /* Expand second Pack File */
  2280.               printf("\nExpanding files from %s distribution to %s...\n\n",
  2281.                       PRODUCT, diskdir);
  2282.  
  2283.               zchdir(diskdir) ;
  2284.  
  2285.               if ( cwd[strlen(cwd)-1] == '\\' )
  2286.                   sprintf(buf,"\"%s%s\"", cwd, ZIPFILE3 ) ;
  2287.               else
  2288.                   sprintf(buf,"\"%s\\%s\"", cwd, ZIPFILE3 ) ;
  2289.               if ( !mysystem(buf) )
  2290.               {
  2291.                   zchdir( cwd ) ;
  2292.                   printf("\nFile expansion failed.\n");
  2293.                   printf("Please check your %c disk and try again.\n",disk);
  2294.                   printf("\n");
  2295.                   doexit(1,0) ;
  2296.               }
  2297.           }
  2298.           if ( zchki(K95EXE) <= 0 ) {
  2299.               zchdir( cwd ) ;
  2300.  
  2301.               while (zchki(ZIPFILE4) <= 0) {       /* Get second disk */
  2302.                   printf("\nPlease insert %s Diskette 4.\n",PRODUCT);    
  2303.                   while (!getok("Ready? (y/n)",'Y'))
  2304.                       ;
  2305.               }
  2306.  
  2307.               /* Expand second Pack File */
  2308.               printf("\nExpanding files from %s distribution to %s...\n\n",
  2309.                       PRODUCT, diskdir);
  2310.  
  2311.               zchdir(diskdir) ;
  2312.  
  2313.               if ( cwd[strlen(cwd)-1] == '\\' )
  2314.                   sprintf(buf,"\"%s%s\"", cwd, ZIPFILE4 ) ;
  2315.               else
  2316.                   sprintf(buf,"\"%s\\%s\"", cwd, ZIPFILE4 ) ;
  2317.               if ( !mysystem(buf) )
  2318.               {
  2319.                   zchdir( cwd ) ;
  2320.                   printf("\nFile expansion failed.\n");
  2321.                   printf("Please check your %c disk and try again.\n",disk);
  2322.                   printf("\n");
  2323.                   doexit(1,0) ;
  2324.               }
  2325.           }
  2326.       }
  2327.        zchdir( cwd ) ;
  2328.    }
  2329.    else
  2330.    {
  2331.       printf("Copying files from %s diskette 1 to %s...\n\n",PRODUCT,diskdir);
  2332.  
  2333.       sprintf(buf,"XCOPY *.* \"%s\" /S", diskdir);
  2334.       if (!mysystem(buf)) {
  2335.          printf("\nFile copy failed.\n");
  2336.          printf("Please check your %c disk and try again.\n", disk);
  2337.          printf("\n");
  2338.          doexit(1,0);
  2339.       }
  2340.       while (1) {                /* Get second disk */
  2341.          printf("\n");
  2342.          printf("Please insert %s Diskette 2.\n",PRODUCT);    
  2343.          while (!getok("Ready? (y/n)",'Y'))
  2344.             ;
  2345.          s = getvolid(c);
  2346.          if (strcmp(s,DISK2LABEL)) {
  2347.             printf("\n");
  2348.             printf("Sorry, \"%s\" is not \"%s\".\n",s,DISK2LABEL);
  2349.             continue;
  2350.          } else
  2351.             break;
  2352.       }
  2353.       printf("\n");
  2354.       printf("Copying files from %s diskette 2 to %s...\n\n",PRODUCT,diskdir);
  2355.       sprintf(buf,"XCOPY *.* \"%s\" /S", diskdir);
  2356.       if (!mysystem(buf)) {
  2357.          printf("\nFile copy failed.\n");
  2358.          printf("Please check your %c disk and try again.\n", disk);
  2359.          printf("\n");
  2360.          doexit(1,0);
  2361.       }
  2362.     
  2363.    }
  2364.  
  2365.     /* Create INIT file for Dialer */
  2366.     sprintf(buf,"%s\\%sDIAL.INF",diskdir,ABBR);
  2367. #ifdef FOR_REAL
  2368.     if (!(fp = fopen(buf,"w"))) {
  2369.     printf("WARNING - Can't create %s\n", buf);
  2370.     /* doexit(1,0); */
  2371.     }
  2372. #else
  2373.     fp = stdout;
  2374.     fprintf(fp, "\n");
  2375. #endif /* FOR_REAL */
  2376.  
  2377.     if (modem > -1) {
  2378. #ifdef NT
  2379.         if ( tapiavail && ntapiline ) {
  2380.             fprintf(fp, "directory %s\n",diskdir);
  2381.             fprintf(fp, "modem tapi\n"); 
  2382.             fprintf(fp, "port %s\n", _tapilinetab[modem].kwd);
  2383.             fprintf(fp," printer %s\n", 
  2384. #ifdef NT
  2385.                 ( printer < nprinters ) ? printers[printer-1] : 
  2386.                      w32prttab[printer-nprinters-1].kwd
  2387. #else
  2388.                 printers[printer-1]
  2389. #endif
  2390.                     );
  2391.         }
  2392.         else {
  2393. #endif /* NT */
  2394.             fprintf(fp, "directory %s\n",diskdir);
  2395.             fprintf(fp, "modem %s\n", mdmtab[modem].kermitname);
  2396.             fprintf(fp, "port com%d\n", port); 
  2397.             fprintf(fp," printer %s\n", 
  2398. #ifdef NT
  2399.                 ( printer < nprinters ) ? printers[printer-1] : 
  2400.                      w32prttab[printer-nprinters-1].kwd
  2401. #else
  2402.                 printers[printer-1]
  2403. #endif
  2404.                     );
  2405.             if (method && tone > 0)
  2406.                 fprintf(fp, "method %s\n", method);
  2407.             fprintf(fp, "speed %ld\n", portspeed);
  2408.             fprintf(fp, "country %d\n", country);
  2409.             fprintf(fp, "area %s\n", area);
  2410.             fprintf(fp, "ldprefix %s\n", ld_prefix);
  2411.             if (country == 1) {
  2412.                 fprintf(fp, "tfprefix %s\n", ld_prefix);
  2413.         fprintf(fp, "tfarea %s\n", "800 888 877 866");
  2414.             }
  2415.             fprintf(fp, "intlprefix %s\n", intl_prefix);
  2416. #ifdef NT
  2417.         }
  2418. #endif /* NT */
  2419.     }
  2420.     else {
  2421.     fprintf(fp, "directory %s\n",diskdir);
  2422.     fprintf(fp, "modem generic-high-speed\n");
  2423.     fprintf(fp, "port com1\n", port); 
  2424.         fprintf(fp," printer %s\n", 
  2425. #ifdef NT
  2426.                 ( printer < nprinters ) ? printers[printer-1] : 
  2427.                  w32prttab[printer-nprinters-1].kwd
  2428. #else
  2429.                 printers[printer-1]
  2430. #endif
  2431.                     );
  2432.     fprintf(fp, "method Pulse\n");
  2433.     fprintf(fp, "speed 57600\n");
  2434.     }
  2435. #ifdef FOR_REAL
  2436.     fclose(fp);
  2437. #endif /* FOR_REAL */
  2438.  
  2439. #ifdef FOR_REAL
  2440.     sprintf(buf,"%s\\%sCUSTOM.INI",diskdir,ABBR);
  2441.  
  2442.     if ( zchki(buf) >= 0 ) {
  2443.     printf("WARNING - %s already exists.\n",buf);
  2444.     sprintf(buf,"%s\\%sCUSTOM.INS",diskdir,ABBR);
  2445.     printf("          Output from SETUP will be placed in %s.\n",buf);
  2446.     }
  2447.     if (!(fp = fopen(buf,"w"))) {
  2448.     printf("WARNING - Can't create %s\n", buf);
  2449.     }
  2450. #else
  2451.     fp = stdout;
  2452.     fprintf(fp, "\n");
  2453. #endif /* FOR_REAL */
  2454.     fprintf(fp, "; FILE %sCUSTOM.INI -- %s Customizations\n\n",ABBR,PRODUCT);
  2455.     fprintf(fp, "; Created by SETUP.EXE\n\n");
  2456.     
  2457.     if ( modem > -1 ) {
  2458. #ifdef NT
  2459.         if ( tapiavail && ntapiline ) {
  2460.             fprintf(fp, "set modem type none\n");
  2461.             fprintf(fp, "xif not started-from-dialer {\n");
  2462.             fprintf(fp, "set tapi line %s\n", _tapilinetab[modem].kwd); 
  2463.             fprintf(fp, "set modem type tapi\n");
  2464.             fprintf(fp, "}\n");
  2465.         }
  2466.         else {
  2467. #endif /* NT */
  2468.     fprintf(fp, "set modem type %s\n", mdmtab[modem].kermitname);
  2469.     fprintf(fp, "xif not started-from-dialer {\n");
  2470.     fprintf(fp, "set port com%d\n", port); 
  2471.     fprintf(fp, "set speed %ld\n", portspeed);
  2472.     fprintf(fp, "}\n");
  2473.  
  2474.     if (tone > 0)
  2475.         fprintf(fp, "set dial method %s\n", method);
  2476.     fprintf(fp, "set dial country-code %d\n", country);
  2477.     fprintf(fp, "set dial area-code %s\n", area);
  2478.     fprintf(fp, "set dial ld-prefix %s\n", ld_prefix);
  2479.     if (country == 1) {
  2480.         fprintf(fp, "set dial tf-prefix %s\n", ld_prefix);
  2481.         fprintf(fp, "set dial tf-area %s\n", "800 888 877 866");
  2482.     }
  2483.     fprintf(fp, "set dial intl-prefix %s\n", intl_prefix);
  2484. #ifdef NT
  2485.         }
  2486. #endif /* NT */
  2487.     }
  2488.     else {
  2489.     fprintf(fp, ";set modem type <modem_type>\n");
  2490.     fprintf(fp, ";xif not started-from-dialer {\n");
  2491.     fprintf(fp, ";set port <port>\n"); 
  2492.     fprintf(fp, ";set speed <speed>\n");
  2493.     fprintf(fp, ";}\n");
  2494.     fprintf(fp, ";set dial method <tone or pulse>\n");
  2495.     fprintf(fp, ";set dial country-code <country_code>\n");
  2496.     fprintf(fp, ";set dial area-code <area_code>\n");
  2497.     fprintf(fp, ";set dial ld-prefix <long_dist_prefix>\n");
  2498.     fprintf(fp, ";set dial tf-prefix <toll_free_prefix>\n");
  2499.     fprintf(fp, ";set dial tf-area <800 and/or 888>\n");
  2500.     fprintf(fp, ";set dial intl-prefix <international_prefix>\n");
  2501.     }
  2502.  
  2503. #ifdef NT
  2504.     if ( printer < nprinters ) 
  2505.         fprintf(fp,"set printer /DOS-DEVICE:{%s}\n", printers[printer-1] );
  2506.     else
  2507.         fprintf(fp,"set printer /WINDOWS-QUEUE:{%s}\n", 
  2508.                  w32prttab[printer-nprinters-1].kwd);
  2509. #else
  2510.     fprintf(fp,"set printer {%s}\n", printers[printer-1] );
  2511. #endif
  2512. #ifdef NT
  2513.     if ( altgr )
  2514.     fprintf(fp, "set win95 alt-gr on\n");
  2515. #endif /* NT */
  2516.     fprintf(fp, "\n");
  2517.     fprintf(fp, "; (Fill in your other customization commands here...)\n");
  2518.     fprintf(fp, "End ; of %sCUSTOM.INI\n",ABBR);
  2519. #ifdef FOR_REAL
  2520.     fclose(fp);
  2521. #endif /* FOR_REAL */
  2522.  
  2523.     strcpy(kermitinfo.install_dir,diskdir);
  2524.     strcpy(kermitinfo.modem_name,
  2525.        (modem > -1) ?
  2526.        mdmtab[modem].kermitname :
  2527.        ""
  2528.        );
  2529.     kermitinfo.com_port = port;
  2530.     kermitinfo.port_speed = portspeed;
  2531.     kermitinfo.c_code = country;
  2532.     strcpy(kermitinfo.a_code,area);
  2533.     strcpy(kermitinfo.l_prefix,ld_prefix);
  2534.     if (country == 1) {
  2535.     strcpy(kermitinfo.t_area,"800 888 877 866");
  2536.     strcpy(kermitinfo.t_prefix,ld_prefix);
  2537.     }
  2538.     strcpy(kermitinfo.i_prefix,intl_prefix);
  2539.  
  2540.     zchdir(diskdir);            /* Change to the K-95 directory */
  2541.  
  2542. #ifdef NT
  2543.     /* Make sure that CTL3D32.DLL is installed */
  2544.     drawbar();
  2545.     printf("\n");
  2546.     mysystem("ctl3dins.exe");
  2547.     printf("\n");
  2548. #endif /* NT */
  2549.  
  2550. #ifdef CLINK
  2551. /* This doesn't work in a console app */
  2552.     if (isWin95()) {            /* Put shortcut on desktop */
  2553.     char * WinDir;
  2554.     if (WinDir = getenv("winbootdir")) {
  2555.         sprintf(buf,"%s\\Desktop", WinDir);
  2556.         printf("Creating Shortcut: \"%s\" => K95DIAL.EXE...\n", buf);
  2557.         (void) CreateLink((LPCSTR) "k95dial.exe",
  2558.                   (LPSTR) buf,
  2559.                   (LPSTR) "K-95 Dialer"
  2560.                   );
  2561.     }
  2562.     }
  2563.     printf("\n");
  2564. #endif /* COMMENT */
  2565. #ifdef NT
  2566.     drawbar();
  2567.     printf("\n");
  2568.     printf(
  2569. " Now please enter your name, your company (optional), and %s serial\n",PRODUCT
  2570.        );
  2571.     printf(
  2572. " number into the Registration Window...\n\n"
  2573.        );    
  2574.    printf(
  2575. " In the Serial Number box, type your entire %s serial number, beginning with\n",ABBR);
  2576. printf(" %s and ending with 1.1, over the template that is shown in the box,\n",ABBR);
  2577. printf(" including the punctuation.\n\n");
  2578.  
  2579. printf(" When you have finished registering, click the mouse back on this window to\n");
  2580. printf(" continue SETUP (if necessary)...\n");
  2581.  
  2582.     mysystem("ckreg");
  2583.  
  2584.     printf("\n");
  2585.     drawbar();
  2586.     printf("\n");
  2587.     mysystem("k95regtl");
  2588.  
  2589. #else
  2590.     mysystem("k2reg");
  2591. #endif
  2592.     printf("\n");
  2593.     drawbar();
  2594.     printf("\n");
  2595.  
  2596. #ifndef NT
  2597.     os2Folder(diskdir,new_install,windowable);
  2598.     os2UpdateConfigSys(diskdir);
  2599.     printf("\n");
  2600.     drawbar();
  2601.     printf("\n");
  2602. #endif
  2603.  
  2604.     if (getok("Would you like to read the README.TXT file now? (y/n)",'Y')) {
  2605. #ifdef NT
  2606.     sprintf(buf,"edit README.TXT",diskdir);
  2607. #else /* NT */
  2608.     sprintf(buf,"e README.TXT",diskdir);
  2609. #endif /* NT */
  2610.     mysystem(buf);
  2611.     }
  2612.  
  2613.     printf("\n");
  2614.     printf(
  2615. "  %s has been installed in %s.\n", PRODUCT,diskdir);
  2616.     printf(
  2617. "  To run it, open the folder and click on the colorful %sDIAL icon.\n",ABBR);
  2618.     printf(
  2619. "  To create a shortcut icon for %s on your desktop, follow the\n",PRODUCT);
  2620.     printf(
  2621. "  instructions in the README.TXT file.\n");
  2622.     printf("\n");
  2623.     printf(
  2624. "  Please be sure to fill out and mail in your registration card with one\n");
  2625.     printf(
  2626. "  of your serial-number stickers attached to it.  This gives you access\n");
  2627.     printf(
  2628. "  to the %s support BBS for news and patches, and it entitles you\n",PRODUCT);
  2629.     printf(
  2630. "   to a discount on the next major release.\n");
  2631.     printf("\n");
  2632.     printf("Thank you for choosing %s!\n",PRODUCT);
  2633.     drawbar();
  2634.     printf("\n");
  2635. #ifdef NT
  2636.     if (getok("Would you like to start Kermit 95 now? (y/n)",'Y')) {
  2637.     mysystem("k95dial.exe");
  2638.     } else {
  2639.     printf("\n");
  2640.     }
  2641. #else
  2642.     if (getok("Would you like to start Kermit/2 now? (y/n)",'Y')) {
  2643.        mysystem("k2dial.exe");
  2644.     } else {
  2645.     printf("\n");
  2646.     }
  2647. #endif
  2648.     doexit(0,0);
  2649.     return(0);
  2650. }
  2651.