home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / win100b / wkkmsc.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  37KB  |  1,310 lines

  1. /*
  2.  * Windows Kermit dialog box routines
  3.  *
  4.  * Copyright (c) 1990, 1991 by
  5.  * William S. Hall
  6.  * 3665 Benton Street, #66
  7.  * Santa Clara, CA 95051
  8.  *
  9.  */
  10.  
  11. #define NOKANJI
  12. #define NOMINMAX
  13. #define NOATOM
  14. #define NOSOUND
  15. #include <windows.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>    
  19. #ifdef COLUMBIA
  20. #include "wkasci.h"
  21. #include "wkkerm.h"
  22. #include "wkkdlg.h"
  23. #else
  24. #include "ascii.h"
  25. #include "wnkerm.h"
  26. #include "wnkdlg.h"
  27. #endif
  28.  
  29. #define MAXPATHLEN    128
  30. static char *defstring = "*.*";        /* default file type */
  31. BOOL fOverflow;
  32.  
  33. /* local function declarations */
  34. static    void    NEAR    krmProtocolInit(HWND hDlg);
  35. static    void    NEAR    krmProtocolSet(HWND hDlg);
  36. static    void    NEAR    krmPacketsInit(HWND hDlg);
  37. static    void    NEAR    krmPacketsSet(HWND hDlg);
  38. static    void    NEAR    krmSetCancelFlags(HWND hDlg);
  39. static    void    NEAR    krmSendFileInit(HWND hDlg);
  40. static    int    NEAR    krmCheckSelect(HWND hDlg);
  41. static    void    NEAR    krmGetSendFileList(HWND hDlg, LONG lParam);
  42. static    BOOL    NEAR    krmListSelect(HWND hDlg, LONG lParam);
  43. static    void    NEAR    krmListBoxOK(HWND hDlg, LONG lParam);
  44. static    void    NEAR    krmPathSelect(HWND hDlg, LONG lParam);
  45. static    int    NEAR    GetCheckedRadioButton(HWND hDlg, WORD start, WORD end);
  46. static  int    NEAR    GetComboboxSelection(HWND hDlg, WORD id, char * buffer);
  47. static    int    NEAR    GetComboboxIndex(HWND hDlg, int id);
  48. static  char*   NEAR    getnamestr(char *str, int len);
  49. static  void    NEAR    krmGetFileInit(HWND hDlg);
  50. static  HANDLE    NEAR    krmGetFileSet(HWND hDlg);
  51. static    void    NEAR    krmCWDInit(HWND hDlg);
  52. static    HANDLE    NEAR    krmCWDSet(HWND hDlg);
  53. static    void    NEAR    krmInitRemoteBox(HWND hDlg);
  54. static    void    NEAR    krmRemote1ParamInit(register HWND hDlg, int mode);
  55. static    HANDLE    NEAR    krmRemote1ParamSet(register HWND hDlg, int mode);
  56. static    void    NEAR    krmRemote1ParamEnable(HWND hDlg, HWND hctl, int mode);
  57. static    HANDLE    NEAR    krmRemote1ParamCommand(HWND hDlg);
  58. static    HANDLE    NEAR    krmRemote1ParamGeneric(HWND hDlg, char cmd);
  59. static    void    NEAR    krmLocalInit(HWND hDlg);
  60. static    void    NEAR    krmLocalFilesOK(HWND hDlg);
  61. static    void    NEAR    krmLocalDirs(HWND hDlg, LONG lParam);
  62. static    void    NEAR    setoemconvert(HWND hDlg, WORD id);
  63.  
  64. /*
  65.  * krmOpenDlgBox
  66.  *
  67.  * Open a modal dialog box
  68.  */
  69. int FAR krmOpenDlgBox(HWND hWnd, FARPROC fpProc, WORD boxnum)
  70. {
  71.  
  72.     FARPROC fp;
  73.     BOOL result;
  74.  
  75.   /* make a proc instance for the about box window function */
  76.     fp = MakeProcInstance(fpProc, Kermit.hInst);
  77.   /* create a modal dialog box */
  78.     result = DialogBox(Kermit.hInst, MAKEINTRESOURCE(boxnum),hWnd,fp);
  79.     FreeProcInstance(fp);
  80.     return result;
  81.  
  82. }
  83.  
  84. /*
  85.  * krmProtocol
  86.  *
  87.  * This dialog box sets general parameters affecting the
  88.  * Kermit protocol.
  89.  */
  90. BOOL FAR PASCAL krmProtocol(HWND hDlg,unsigned message,WORD wParam,LONG lParam)
  91. {
  92.     switch(message) {
  93.     case WM_INITDIALOG:
  94.     krmProtocolInit(hDlg);
  95.     break;
  96.  
  97.     case WM_COMMAND:
  98.         switch(wParam) {
  99.         case IDOK:
  100.             krmProtocolSet(hDlg);
  101.             EndDialog(hDlg, TRUE);
  102.             break;
  103.         case IDCANCEL:
  104.             EndDialog(hDlg, FALSE);
  105.             break;
  106.         default:
  107.             return FALSE;
  108.         }
  109.         break;
  110.     default:
  111.         return FALSE;
  112.     }
  113.     return TRUE;
  114. }
  115.  
  116. /*
  117.  * krmProtocolSet
  118.  *
  119.  * In response to values chosen by the user, this
  120.  * routine sets the various protocol data structures.
  121.  * If requested, values are saved to WIN.INI
  122.  */
  123. static void NEAR krmProtocolSet(HWND hDlg)
  124. {
  125.  
  126.     char szAppStr[80];
  127.     char szKeyStr[80];
  128.     char szValStr[80];
  129.  
  130.     KermParams.Bell = IsDlgButtonChecked(hDlg, IDD_KRM_BELL);
  131.     KermParams.Timer = IsDlgButtonChecked(hDlg, IDD_KRM_TIMER);
  132.     KermParams.DiscardPartialFile = IsDlgButtonChecked(hDlg, IDD_KRM_DISCARD);
  133.     KermParams.FileWarning = IsDlgButtonChecked(hDlg, IDD_KRM_FILEWARNING);
  134. //    KermParams.verbose = IsDlgButtonChecked(hDlg, IDD_KRM_VERBOSE);
  135.  
  136.     KermParams.BlockCheckType = GetCheckedRadioButton(hDlg, 
  137.                     IDD_KRM_1BYTECHK,
  138.                     IDD_KRM_3BYTECHK)
  139.                 - IDD_KRM_1BYTECHK + 1;
  140.  
  141.     GetComboboxSelection(hDlg, IDD_KRM_RETRYLIMIT, szValStr);
  142.     KermParams.RetryLimit = atoi(szValStr);
  143.  
  144.     GetComboboxSelection(hDlg, IDD_KRM_SENDDELAY, szValStr);
  145.     KermParams.SendDelay = atoi(szValStr);
  146.  
  147.   /* user wants to save the values, so write them to WIN.INI */
  148.     if (IsDlgButtonChecked(hDlg, IDD_KRM_SAVE)) {
  149.     LoadString(Kermit.hInst,IDS_KRM_KERMIT,szAppStr,sizeof(szAppStr));
  150.  
  151.         LoadString(Kermit.hInst, IDS_KRM_TIMER, szKeyStr, sizeof(szKeyStr));
  152.         itoa(KermParams.Timer, szValStr, 10);
  153.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  154. /*
  155.         LoadString(Kermit.hInst, IDS_KRM_VERBOSE, szKeyStr, sizeof(szKeyStr));
  156.         itoa(KermParams.verbose, szValStr, 10);
  157.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  158. */
  159.         LoadString(Kermit.hInst, IDS_KRM_DISCARD, szKeyStr, sizeof(szKeyStr));
  160.         itoa(KermParams.DiscardPartialFile, szValStr, 10);
  161.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  162.  
  163.         LoadString(Kermit.hInst, IDS_KRM_BELL, szKeyStr, sizeof(szKeyStr));
  164.         itoa(KermParams.Bell, szValStr, 10);
  165.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  166.  
  167.         LoadString(Kermit.hInst, IDS_KRM_FILEWARN, szKeyStr, sizeof(szKeyStr));
  168.         itoa(KermParams.FileWarning, szValStr, 10);
  169.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  170.  
  171.         LoadString(Kermit.hInst,IDS_KRM_BLOCKCHECKTYPE,
  172.            szKeyStr,sizeof(szKeyStr));
  173.         itoa(KermParams.BlockCheckType, szValStr, 10);
  174.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  175.  
  176.         LoadString(Kermit.hInst, IDS_KRM_RETRYLIMIT,
  177.            szKeyStr, sizeof(szKeyStr));
  178.         itoa(KermParams.RetryLimit, szValStr, 10);
  179.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  180.  
  181.         LoadString(Kermit.hInst,IDS_KRM_SENDDELAY,szKeyStr,sizeof(szKeyStr));
  182.         itoa(KermParams.SendDelay, szValStr, 10);
  183.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  184.  
  185.     SendMessage((HWND)(-1), WM_WININICHANGE, 0, (LONG)(LPSTR)szAppStr);
  186.     }
  187. }
  188.  
  189. /*
  190.  * krmProtocolInit
  191.  *
  192.  * Initialize the Kermit protocol settings
  193.  * dialog box.
  194.  */
  195. static void NEAR krmProtocolInit(HWND hDlg)
  196. {
  197.     register int i;
  198.     char buf[80];
  199.  
  200.     CheckDlgButton(hDlg, IDD_KRM_BELL, KermParams.Bell);
  201.     CheckDlgButton(hDlg, IDD_KRM_TIMER, KermParams.Timer);
  202.     CheckDlgButton(hDlg, IDD_KRM_DISCARD, KermParams.DiscardPartialFile);
  203.     CheckDlgButton(hDlg, IDD_KRM_FILEWARNING, KermParams.FileWarning);
  204. //    CheckDlgButton(hDlg, IDD_KRM_VERBOSE, KermParams.verbose);
  205.     CheckRadioButton(hDlg, IDD_KRM_1BYTECHK, IDD_KRM_3BYTECHK,
  206.                IDD_KRM_1BYTECHK + KermParams.BlockCheckType - 1);
  207.  
  208.     for (i = 1; i <= 63; i++)
  209.     SendDlgItemMessage(hDlg, IDD_KRM_RETRYLIMIT, CB_INSERTSTRING,
  210.                 -1, (LONG)(LPSTR)itoa(i, buf, 10));
  211.     SendDlgItemMessage(hDlg, IDD_KRM_RETRYLIMIT, CB_SELECTSTRING,
  212.             -1, (LONG)(LPSTR)itoa(KermParams.RetryLimit, buf, 10));
  213.                 
  214.     for (i = 0; i <= 63; i++)
  215.     SendDlgItemMessage(hDlg, IDD_KRM_SENDDELAY, CB_INSERTSTRING,
  216.                 -1, (LONG)(LPSTR)itoa(i, buf, 10));
  217.     SendDlgItemMessage(hDlg, IDD_KRM_SENDDELAY, CB_SELECTSTRING,
  218.             -1, (LONG)(LPSTR)itoa(KermParams.SendDelay, buf, 10));
  219. }
  220.  
  221. /*
  222.  * krmPackets
  223.  *
  224.  * This dialog box sets the various Kermit packet parameters.
  225.  */
  226. BOOL FAR PASCAL krmPackets(HWND hDlg,unsigned message,WORD wParam,LONG lParam)
  227. {
  228.     switch(message) {
  229.     case WM_INITDIALOG:
  230.     krmPacketsInit(hDlg);
  231.     break;
  232.  
  233.     case WM_COMMAND:
  234.         switch(wParam) {
  235.         case IDOK:
  236.             krmPacketsSet(hDlg);
  237.             EndDialog(hDlg, TRUE);
  238.             break;
  239.         case IDCANCEL:
  240.             EndDialog(hDlg, FALSE);
  241.             break;
  242.         default:
  243.             return FALSE;
  244.         }
  245.         break;
  246.     default:
  247.         return FALSE;
  248.     }
  249.     return TRUE;
  250. }
  251.  
  252. /*
  253.  * krmPacketsSet
  254.  *
  255.  * In response to values chosen by the user, this
  256.  * routine sets the various packet data structures.
  257.  * If requested, values are saved to WIN.INI
  258.  */
  259. static void NEAR krmPacketsSet(HWND hDlg)
  260. {
  261.     char szAppStr[80];
  262.     char szKeyStr[80];
  263.     char szValStr[80];
  264.  
  265.     sndparams.mark = (BYTE)GetComboboxIndex(hDlg, IDD_KRM_SENDMARK);
  266.     rcvparams.mark = (BYTE)GetComboboxIndex(hDlg, IDD_KRM_RECEIVEMARK);
  267.     sndparams.maxpktsize = (short)GetComboboxIndex(hDlg,IDD_KRM_SENDMAXSIZE)
  268.                + KRM_MINPACKETSIZE;
  269.     rcvparams.maxpktsize = (short)GetComboboxIndex(hDlg,IDD_KRM_RECEIVEMAXSIZE)
  270.                + KRM_MINPACKETSIZE;
  271.     sndparams.timeout = (short)GetComboboxIndex(hDlg, IDD_KRM_SENDTIMEOUT)
  272.                + KRM_MINTIMEOUT;
  273.     rcvparams.timeout = (short)GetComboboxIndex(hDlg, IDD_KRM_RECEIVETIMEOUT)
  274.                + KRM_MINTIMEOUT;
  275.     sndparams.padcount = (short)GetComboboxIndex(hDlg,IDD_KRM_SENDPADCOUNT);
  276.     rcvparams.padcount = (short)GetComboboxIndex(hDlg,IDD_KRM_RECEIVEPADCOUNT);
  277.     sndparams.padchar = (BYTE)GetComboboxIndex(hDlg, IDD_KRM_SENDPADCHAR);
  278.     if (sndparams.padchar >= ' ')
  279.     sndparams.padchar = DEL;
  280.     rcvparams.padchar = (BYTE)GetComboboxIndex(hDlg, IDD_KRM_RECEIVEPADCHAR);
  281.     if (rcvparams.padchar >= ' ')
  282.     sndparams.padchar = DEL;
  283.     sndparams.eol = (BYTE)GetComboboxIndex(hDlg, IDD_KRM_SENDEOL);
  284.     rcvparams.eol = (BYTE)GetComboboxIndex(hDlg, IDD_KRM_RECEIVEEOL);
  285.     sndparams.quote = (BYTE)(GetComboboxIndex(hDlg, IDD_KRM_SENDQUOTE) + '!');
  286.     if (sndparams.quote >= '?')
  287.     sndparams.quote += 30;
  288.     rcvparams.quote = (BYTE)(GetComboboxIndex(hDlg,IDD_KRM_RECEIVEQUOTE)+'!');
  289.     if (rcvparams.quote >= '?')
  290.     rcvparams.quote += 30;
  291.  
  292.     if (IsDlgButtonChecked(hDlg, IDD_KRM_SAVE)) {
  293.     LoadString(Kermit.hInst,IDS_KRM_KERMIT,szAppStr,sizeof(szAppStr));
  294.  
  295.         LoadString(Kermit.hInst, IDS_KRM_SENDMARK, szKeyStr, sizeof(szKeyStr));
  296.         itoa(sndparams.mark, szValStr, 10);
  297.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  298.  
  299.         LoadString(Kermit.hInst, IDS_KRM_RCVMARK, szKeyStr, sizeof(szKeyStr));
  300.         itoa(rcvparams.mark, szValStr, 10);
  301.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  302.  
  303.         LoadString(Kermit.hInst,IDS_KRM_SENDMAXLEN,szKeyStr,sizeof(szKeyStr));
  304.         itoa(sndparams.maxpktsize, szValStr, 10);
  305.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  306.  
  307.         LoadString(Kermit.hInst,IDS_KRM_RCVMAXLEN,szKeyStr,sizeof(szKeyStr));
  308.         itoa(rcvparams.maxpktsize, szValStr, 10);
  309.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  310.  
  311.         LoadString(Kermit.hInst,IDS_KRM_SENDTIMEOUT,szKeyStr,sizeof(szKeyStr));
  312.         itoa(sndparams.timeout, szValStr, 10);
  313.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  314.  
  315.         LoadString(Kermit.hInst,IDS_KRM_RCVTIMEOUT,szKeyStr,sizeof(szKeyStr));
  316.         itoa(rcvparams.timeout, szValStr, 10);
  317.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  318.  
  319.         LoadString(Kermit.hInst,IDS_KRM_SENDPADCOUNT,
  320.            szKeyStr,sizeof(szKeyStr));
  321.         itoa(sndparams.padcount, szValStr, 10);
  322.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  323.  
  324.         LoadString(Kermit.hInst,IDS_KRM_RCVPADCOUNT,szKeyStr,sizeof(szKeyStr));
  325.         itoa(rcvparams.padcount, szValStr, 10);
  326.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  327.  
  328.         LoadString(Kermit.hInst,IDS_KRM_SENDPADCHAR,szKeyStr,sizeof(szKeyStr));
  329.         itoa(sndparams.padchar, szValStr, 10);
  330.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  331.  
  332.         LoadString(Kermit.hInst,IDS_KRM_RCVPADCHAR,szKeyStr,sizeof(szKeyStr));
  333.         itoa(rcvparams.padchar, szValStr, 10);
  334.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  335.  
  336.         LoadString(Kermit.hInst, IDS_KRM_SENDEOL, szKeyStr, sizeof(szKeyStr));
  337.         itoa(sndparams.eol, szValStr, 10);
  338.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  339.  
  340.         LoadString(Kermit.hInst, IDS_KRM_RCVEOL, szKeyStr, sizeof(szKeyStr));
  341.         itoa(rcvparams.eol, szValStr, 10);
  342.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  343.  
  344.         LoadString(Kermit.hInst,IDS_KRM_SENDQUOTE,szKeyStr,sizeof(szKeyStr));
  345.         itoa(sndparams.quote, szValStr, 10);
  346.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  347.  
  348.         LoadString(Kermit.hInst, IDS_KRM_RCVQUOTE, szKeyStr, sizeof(szKeyStr));
  349.         itoa(rcvparams.quote, szValStr, 10);
  350.         WriteProfileString(szAppStr, szKeyStr, szValStr);
  351.  
  352.     SendMessage((HWND)(-1), WM_WININICHANGE, 0, (LONG)(LPSTR)szAppStr);
  353.     }
  354. }
  355.  
  356. /*
  357.  * krmPacketsInit
  358.  *
  359.  * Initialize the Kermit packets settings
  360.  * dialog box.
  361.  */
  362. static void NEAR krmPacketsInit(HWND hDlg)
  363. {
  364.  
  365.     register int i;
  366.     char buf[80];
  367.  
  368.     for (i = 0; i < ' '; i++) {
  369.     sprintf(buf, "CTRL-%c", '@'+i);
  370.     SendDlgItemMessage(hDlg, IDD_KRM_SENDMARK, CB_INSERTSTRING,
  371.                -1, (LONG)(LPSTR)buf);
  372.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEMARK, CB_INSERTSTRING,
  373.                -1, (LONG)(LPSTR)buf);
  374.     }
  375.     SendDlgItemMessage(hDlg,IDD_KRM_SENDMARK,CB_SETCURSEL,sndparams.mark, 0L);
  376.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVEMARK,
  377.                CB_SETCURSEL,rcvparams.mark,0L);
  378.  
  379.     for (i = KRM_MINPACKETSIZE; i <= KRM_MAXPACKETSIZE; i++) {
  380.     itoa(i, buf, 10);
  381.     SendDlgItemMessage(hDlg, IDD_KRM_SENDMAXSIZE, CB_INSERTSTRING,
  382.                -1, (LONG)(LPSTR)buf);
  383.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEMAXSIZE, CB_INSERTSTRING,
  384.                -1, (LONG)(LPSTR)buf);
  385.     }
  386.     SendDlgItemMessage(hDlg,IDD_KRM_SENDMAXSIZE, CB_SETCURSEL,
  387.                sndparams.maxpktsize - KRM_MINPACKETSIZE, 0L);
  388.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVEMAXSIZE, CB_SETCURSEL,
  389.                rcvparams.maxpktsize - KRM_MINPACKETSIZE, 0L);
  390.  
  391.     for (i = KRM_MINTIMEOUT; i <= KRM_MAXTIMEOUT; i++) {
  392.     itoa(i, buf, 10);
  393.     SendDlgItemMessage(hDlg, IDD_KRM_SENDTIMEOUT, CB_INSERTSTRING,
  394.                -1, (LONG)(LPSTR)buf);
  395.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVETIMEOUT, CB_INSERTSTRING,
  396.                -1, (LONG)(LPSTR)buf);
  397.     }
  398.     SendDlgItemMessage(hDlg,IDD_KRM_SENDTIMEOUT, CB_SETCURSEL,
  399.                sndparams.timeout - KRM_MINTIMEOUT, 0L);
  400.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVETIMEOUT, CB_SETCURSEL,
  401.                rcvparams.timeout - KRM_MINTIMEOUT, 0L);
  402.  
  403.     for (i = 0; i <= KRM_MAXPADCOUNT; i++) {
  404.     itoa(i, buf, 10);
  405.     SendDlgItemMessage(hDlg, IDD_KRM_SENDPADCOUNT, CB_INSERTSTRING,
  406.                -1, (LONG)(LPSTR)buf);
  407.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEPADCOUNT, CB_INSERTSTRING,
  408.                -1, (LONG)(LPSTR)buf);
  409.     }
  410.     SendDlgItemMessage(hDlg,IDD_KRM_SENDPADCOUNT,CB_SETCURSEL,
  411.                sndparams.padcount, 0L);
  412.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVEPADCOUNT,CB_SETCURSEL,
  413.                rcvparams.padcount, 0L);
  414.     for (i = 0; i < ' '; i++) {
  415.     sprintf(buf, "CTRL-%c", '@'+i);
  416.     SendDlgItemMessage(hDlg, IDD_KRM_SENDPADCHAR, CB_INSERTSTRING,
  417.                -1, (LONG)(LPSTR)buf);
  418.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEPADCHAR, CB_INSERTSTRING,
  419.                -1, (LONG)(LPSTR)buf);
  420.     }
  421.     strcpy(buf, "CTRL ?");
  422.     SendDlgItemMessage(hDlg, IDD_KRM_SENDPADCHAR, CB_INSERTSTRING,
  423.                -1, (LONG)(LPSTR)buf);
  424.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEPADCHAR, CB_INSERTSTRING,
  425.                -1, (LONG)(LPSTR)buf);
  426.     SendDlgItemMessage(hDlg,IDD_KRM_SENDPADCHAR,CB_SETCURSEL,
  427.                sndparams.padchar != DEL ? sndparams.padchar : 32, 0L);
  428.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVEPADCHAR,CB_SETCURSEL,
  429.                rcvparams.padchar != DEL ? rcvparams.padchar : 32, 0L);
  430.  
  431.     for (i = 0; i < 32; i++) {
  432.     sprintf(buf, "CTRL-%c", '@'+i);
  433.     SendDlgItemMessage(hDlg, IDD_KRM_SENDEOL, CB_INSERTSTRING,
  434.                -1, (LONG)(LPSTR)buf);
  435.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEEOL, CB_INSERTSTRING,
  436.                -1, (LONG)(LPSTR)buf);
  437.     }
  438.     SendDlgItemMessage(hDlg,IDD_KRM_SENDEOL, CB_SETCURSEL,sndparams.eol, 0L);
  439.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVEEOL,CB_SETCURSEL,rcvparams.eol,0L);
  440.  
  441.     for (i = 33; i <= 126; i++) {
  442.     if ((i >= 63) && (i <= 95))
  443.         continue;
  444.     sprintf(buf, "%c", i);
  445.     SendDlgItemMessage(hDlg, IDD_KRM_SENDQUOTE, CB_INSERTSTRING,
  446.                -1, (LONG)(LPSTR)buf);
  447.     SendDlgItemMessage(hDlg, IDD_KRM_RECEIVEQUOTE, CB_INSERTSTRING,
  448.                -1, (LONG)(LPSTR)buf);
  449.     }
  450.     SendDlgItemMessage(hDlg,IDD_KRM_SENDQUOTE, CB_SETCURSEL,
  451.             (33 <= sndparams.quote) && (sndparams.quote < 63) ? 
  452.             sndparams.quote - 33 : sndparams.quote - 63, 0L);
  453.     SendDlgItemMessage(hDlg,IDD_KRM_RECEIVEQUOTE, CB_SETCURSEL,
  454.             (33 <= rcvparams.quote) && (rcvparams.quote < 63) ? 
  455.             rcvparams.quote - 33 : rcvparams.quote - 63, 0L);
  456.     
  457. }
  458.  
  459. /* 
  460.  * krmSendFileProc
  461.  *
  462.  * This dialog box allows the user to choose a list of
  463.  * files to send to a remote Kermit.
  464.  */
  465. BOOL FAR PASCAL krmSendFileProc(HWND hDlg,unsigned message,
  466.                 WORD wParam,LONG lParam)
  467. {
  468.  
  469.     switch (message) {
  470.     case WM_INITDIALOG:
  471.         krmSendFileInit(hDlg);
  472.         break;
  473.  
  474.     case WM_COMMAND:
  475.         switch (wParam) {
  476.  
  477.         /* turn off SEND button if no files selected */
  478.         case IDD_KRM_LISTSELECT:
  479.             if (HIWORD(lParam) == LBN_SELCHANGE)
  480.             EnableWindow(GetDlgItem(hDlg, IDD_KRM_SEND),
  481.                       krmListSelect(hDlg, lParam));
  482.             break;
  483.  
  484.         /* in this dialog box, IDOK sets selections */
  485.         case IDOK:            
  486.             krmListBoxOK(hDlg, lParam);
  487.             EnableWindow(GetDlgItem(hDlg, IDD_KRM_SEND),
  488.                  krmListSelect(hDlg, lParam));
  489.             break;
  490.         
  491.         case IDCANCEL:
  492.             EndDialog(hDlg, FALSE);
  493.             break;
  494.  
  495.         /* get selected files into a buffer */
  496.         case IDD_KRM_SEND:
  497.             krmGetSendFileList(hDlg, lParam);
  498.             break;
  499.  
  500.         /* move to another directory */
  501.         case IDD_KRM_PATHSELECT:
  502.             krmPathSelect(hDlg, lParam);
  503.             break;
  504.  
  505.         default:
  506.             return FALSE;
  507.         }
  508.         break;
  509.  
  510.     default:
  511.         return FALSE;
  512.     }
  513.     return TRUE;
  514. }
  515.  
  516. /*
  517.  * krmListSelect
  518.  *
  519.  * Look through the file name list box for a selection.
  520.  */
  521. static BOOL NEAR krmListSelect(HWND hDlg, LONG lParam)
  522. {
  523.     BOOL select = FALSE;
  524.     register int i;
  525.     register int num = (int)SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT,
  526.                                 LB_GETCOUNT, 0, 0L);
  527.  
  528.     for (i = 0; i < num; i++) {
  529.     select = (BOOL)SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT, 
  530.                       LB_GETSEL, i, 0L);
  531.     if (select)
  532.         break;
  533.     }
  534.     return select;
  535. }
  536.  
  537. /*
  538.  * krmPathSelect
  539.  *
  540.  * Move to a new directory in the Send File dialog box.
  541.  */
  542. static void NEAR krmPathSelect(HWND hDlg, LONG lParam)
  543. {
  544.  
  545.     char buf[MAXPATHLEN];
  546.     char str[MAXPATHLEN];
  547.     int len;
  548.  
  549.     if (HIWORD(lParam) == LBN_SELCHANGE) {
  550.     len = GetDlgItemText(hDlg, IDD_KRM_EDITSELECT,(LPSTR)str,80);
  551.         DlgDirSelect(hDlg, (LPSTR)buf, IDD_KRM_PATHSELECT);
  552.     if (strchr(str,'*') || strchr(str,'?'))
  553.         strcat(buf,getnamestr(str,len));
  554.     else
  555.         strcat(buf, defstring);
  556.         SetDlgItemText(hDlg, IDD_KRM_EDITSELECT, (LPSTR)buf);
  557.     }
  558.     else if (HIWORD(lParam) == LBN_DBLCLK) {
  559.     GetDlgItemText(hDlg, IDD_KRM_EDITSELECT,(LPSTR)buf,80);
  560.     DlgDirList(hDlg, buf, IDD_KRM_LISTSELECT,IDD_KRM_PATHDISPLAY, 0);
  561.     DlgDirList(hDlg, buf,IDD_KRM_PATHSELECT,IDD_KRM_PATHDISPLAY,0xC010);
  562.     SetDlgItemText(hDlg, IDD_KRM_EDITSELECT, (LPSTR)buf);
  563.     }
  564. }
  565.  
  566. /*
  567.  * krmSendFileInit
  568.  *
  569.  * Initialize the Send File Select dialog box
  570.  */
  571. static void NEAR krmSendFileInit(HWND hDlg)
  572. {
  573.  
  574.     char buf[10];
  575.     strcpy(buf, defstring);
  576.  
  577.     DlgDirList(hDlg, buf, IDD_KRM_LISTSELECT,IDD_KRM_PATHDISPLAY, 0);
  578.     DlgDirList(hDlg, buf, IDD_KRM_PATHSELECT,IDD_KRM_PATHDISPLAY, 0xC010);
  579.     SetDlgItemText(hDlg, IDD_KRM_EDITSELECT, (LPSTR)buf);
  580.     SendDlgItemMessage(hDlg, IDD_KRM_EDITSELECT,EM_LIMITTEXT,128,0L);
  581.     EnableWindow(GetDlgItem(hDlg, IDD_KRM_SEND), FALSE);
  582.     setoemconvert(hDlg, IDD_KRM_EDITSELECT);
  583. }
  584.  
  585. /*
  586.  * krmCheckSelect
  587.  *
  588.  * Count the number of files selected in the Send File Selection
  589.  * dialog box.
  590.  */
  591. static int NEAR krmCheckSelect(HWND hDlg)
  592. {
  593.  
  594.     register int num, i;
  595.     register int count = 0;
  596.  
  597.     num = (int)SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT,LB_GETCOUNT,0,0L);
  598.  
  599.     for (i = 0; i < num; i++)
  600.         if (SendDlgItemMessage(hDlg,IDD_KRM_LISTSELECT,LB_GETSEL,(WORD)i,0L))
  601.         count += 1;
  602.  
  603.     return count;
  604. }
  605.  
  606. /*
  607.  * krmGetSendFileList
  608.  *
  609.  * Read the list box for the names of the files selected
  610.  * to be sent by Kermit and store them in a locally allocated buffer
  611.  * as a single string delimited by spaces.
  612.  */
  613. static void NEAR krmGetSendFileList(HWND hDlg, LONG lParam)
  614. {
  615.  
  616.     char buf[MAXPATHLEN];
  617.     int count, i, num;
  618.  
  619.     count = krmCheckSelect(hDlg);
  620.     if (count > 0) {
  621.         Kermit.hFilelist = LocalAlloc(LPTR, count * 13);
  622.     if (Kermit.hFilelist != NULL) {
  623.         Kermit.pFilelist = LocalLock(Kermit.hFilelist);
  624.         num = (int)SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT,
  625.                         LB_GETCOUNT,0,0L);
  626.         for (i = 0; i < num; i++) {
  627.             if (SendDlgItemMessage(hDlg,IDD_KRM_LISTSELECT,
  628.                        LB_GETSEL,(WORD)i,0L)) {
  629.                    SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT,LB_GETTEXT, 
  630.                         (WORD)i, (LONG)(LPSTR)buf);
  631.             strcat(Kermit.pFilelist, buf);
  632.             strcat(Kermit.pFilelist, " ");
  633.             }
  634.             }
  635.         }
  636.         else
  637.         count = 0;
  638.     }
  639.     if (count == 0) {
  640.     /* no files selected or local alloc error */
  641.     }
  642.     EndDialog(hDlg,count);
  643. }
  644.  
  645. /*
  646.  * krmListBoxOK
  647.  *
  648.  * If user chooses the SELECT button (IDOK), highlight those files
  649.  * which match the specification in the associated edit select box.
  650.  * If nothing selected, remove all highlighting.
  651.  */
  652. static void NEAR krmListBoxOK(HWND hDlg, LONG lParam)
  653. {
  654.  
  655.     char buf[MAXPATHLEN];
  656.     int validsspec, count;
  657.     OFSTRUCT myoff;
  658.     int hfile;
  659.     char oldpath[MAXPATHLEN];
  660.     char *ptr;
  661.  
  662. /* if nothing in the edit box */
  663.     if (GetDlgItemText(hDlg, IDD_KRM_EDITSELECT,(LPSTR)buf,sizeof(buf)) == 0)
  664. /* remove highlighting from file list box */
  665.         SendDlgItemMessage(hDlg,IDD_KRM_LISTSELECT,LB_SETSEL,FALSE,(LONG)(-1));
  666.     else {
  667. /* otherwise, save the path */
  668.         GetDlgItemText(hDlg, IDD_KRM_PATHDISPLAY,(LPSTR)oldpath,128);
  669. /* see if valid search spec */
  670.     SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT, WM_SETREDRAW, FALSE, 0L);
  671.     SendDlgItemMessage(hDlg, IDD_KRM_PATHSELECT, WM_SETREDRAW, FALSE, 0L);
  672.     validsspec = DlgDirList(hDlg,buf,IDD_KRM_LISTSELECT,
  673.                 IDD_KRM_PATHDISPLAY,0);
  674.     SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT, WM_SETREDRAW, TRUE, 0L);
  675.     SendDlgItemMessage(hDlg, IDD_KRM_PATHSELECT, WM_SETREDRAW, TRUE, 0L);
  676. /* if valid, get the new path */
  677.     if (validsspec) {
  678. /* buf modified, so update it */
  679.         SetDlgItemText(hDlg, IDD_KRM_EDITSELECT, (LPSTR)buf);
  680.         GetDlgItemText(hDlg, IDD_KRM_PATHDISPLAY, (LPSTR)buf, sizeof(buf));
  681. /* if the same as before */
  682.         if (strcmp(oldpath, buf) == 0)
  683. /* select the whole list box */
  684.                 SendDlgItemMessage(hDlg,IDD_KRM_LISTSELECT,
  685.                    LB_SETSEL,TRUE,(LONG)(-1));
  686.         else {
  687. /* update the directory change box */
  688.                 SendDlgItemMessage(hDlg,IDD_KRM_LISTSELECT,
  689.                    LB_SETSEL,FALSE,(LONG)(-1));
  690.             DlgDirList(hDlg,(LPSTR)buf,IDD_KRM_PATHSELECT,
  691.                IDD_KRM_PATHDISPLAY, 0xC010);
  692.         }
  693. /* not a valid search spec */
  694.     } else {
  695. /* clear box */
  696.             SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT, LB_RESETCONTENT,0,0L);
  697. /* see if it exists */
  698.         hfile = OpenFile((LPSTR)buf, (OFSTRUCT FAR *)&myoff, OF_EXIST);
  699.         if (hfile != -1) {
  700. /* get the file name and add it to list box */
  701.             ptr = strrchr(myoff.szPathName,'\\') + 1;
  702.             SendDlgItemMessage(hDlg, IDD_KRM_LISTSELECT,LB_ADDSTRING,0,
  703.                             (LONG)(LPSTR)ptr);
  704. /* get the pathname */
  705.             strcpy(buf, myoff.szPathName);
  706.             count = strlen(buf) - strlen(ptr);
  707.             buf[count] = NUL;
  708. /* select it */
  709.                 SendDlgItemMessage(hDlg,IDD_KRM_LISTSELECT,LB_SETSEL,TRUE,-1L);
  710. /* update the path select box */
  711.             SetDlgItemText(hDlg, IDD_KRM_EDITSELECT, (LPSTR)ptr);
  712.             DlgDirList(hDlg,buf,IDD_KRM_PATHSELECT,
  713.                IDD_KRM_PATHDISPLAY,0xC010);
  714.         }
  715.         }
  716.     }
  717. /* select text in edit box */
  718.     SendDlgItemMessage(hDlg,IDD_KRM_EDITSELECT,EM_SETSEL,0,MAKELONG(0,32767));
  719. }
  720.  
  721. /* 
  722.  * krmXferDlgBox
  723.  *
  724.  * Show the progress of the file transfer
  725.  */
  726. BOOL FAR PASCAL krmXferDlgBox(HWND hDlg,unsigned message,
  727.                   WORD wParam,LONG lParam)
  728. {
  729.  
  730.     char buf[40];
  731.     FARPROC fp;
  732.  
  733.     switch (message) {
  734.  
  735.     case WM_INITDIALOG:
  736.         if (Kermit.mode == IDM_KRM_SEND) {
  737.                 LoadString(Kermit.hInst,IDS_KRM_SENDING, buf, sizeof(buf));
  738.         SetDlgItemText(hDlg, IDD_KRM_OPERATION, buf);
  739.         }
  740.         break;
  741.  
  742.     case WM_COMMAND:
  743.         switch (wParam) {
  744.         case IDCANCEL:
  745.             if (Kermit.InTransfer) {
  746.                 fp = MakeProcInstance((FARPROC)krmCancelBoxProc,
  747.                            Kermit.hInst);
  748.                 DialogBox(Kermit.hInst,
  749.                   MAKEINTRESOURCE(DT_KRM_CANCEL),hDlg,fp);
  750.                 FreeProcInstance(fp);
  751.             }
  752.             else {
  753.                 DestroyWindow(hDlg);
  754.                 Kermit.hWndXfer = NULL;
  755.             }
  756.             break;
  757.  
  758.         default:
  759.             return FALSE;
  760.         }
  761.         break;
  762.  
  763.     default:
  764.         return FALSE;
  765.     }
  766.     return TRUE;
  767. }
  768.  
  769. BOOL FAR PASCAL krmXferRemote(HWND hDlg,unsigned message,
  770.                   WORD wParam,LONG lParam)
  771. {
  772.  
  773.     FARPROC fp;
  774.  
  775.     switch (message) {
  776.  
  777.     case WM_INITDIALOG:
  778.         krmInitRemoteBox(hDlg);
  779.         fOverflow = FALSE;
  780.         break;
  781.  
  782.     case WM_DESTROY:
  783.         Kermit.hWndXfer = NULL;
  784.         break;
  785.  
  786.     case WM_COMMAND:
  787.         switch (wParam) {
  788.         case IDD_KRM_REMOTEDATA:
  789.             if (HIWORD(lParam) == EN_MAXTEXT)
  790.             fOverflow = TRUE;
  791.             break;
  792.  
  793.         case IDCANCEL:
  794.             if (Kermit.InTransfer) {
  795.                 fp = MakeProcInstance((FARPROC)krmCancelBoxProc,
  796.                            Kermit.hInst);
  797.                 DialogBox(Kermit.hInst,
  798.                   MAKEINTRESOURCE(DT_KRM_CANCEL),hDlg,fp);
  799.                 FreeProcInstance(fp);
  800.             }
  801.             else {
  802.                 DestroyWindow(hDlg);
  803.                 Kermit.hWndXfer = NULL;
  804.             }
  805.             break;
  806.  
  807.         default:
  808.             return FALSE;
  809.         }
  810.         break;
  811.  
  812.     default:
  813.         return FALSE;
  814.     }
  815.     return TRUE;
  816. }
  817.  
  818. static void NEAR krmInitRemoteBox(HWND hDlg)
  819. {
  820.     char buf[80];
  821.  
  822.     SendDlgItemMessage(hDlg, IDD_KRM_REMOTEDATA, WM_SETFONT,
  823.                GetStockObject(SYSTEM_FIXED_FONT), 0L);
  824.     SetDlgItemText(hDlg,IDD_KRM_BYTESMOVED, ultoa(Kermit.bytesmoved, buf, 10));
  825.     SetDlgItemText(hDlg, IDD_KRM_PACKETS, ultoa(Kermit.packetcount, buf, 10));
  826.     SetDlgItemText(hDlg,IDD_KRM_RETRIES, itoa(Kermit.totalretries, buf, 10));
  827.  
  828. }
  829.  
  830. /*
  831.  * krmCancelBoxProc
  832.  *
  833.  * Check the file transfer cancel mode
  834.  * and set the corresponding cancel flag
  835.  */
  836. BOOL FAR PASCAL krmCancelBoxProc(HWND hDlg, unsigned message,
  837.                  WORD wParam, LONG lParam)
  838. {
  839.  
  840.     switch (message) {
  841.     case WM_INITDIALOG:
  842.         CheckRadioButton(hDlg,IDD_KRM_CANCELFILE, IDD_KRM_CANCELPROTOCOL,
  843.                   IDD_KRM_CANCELFILE);
  844.         break;
  845.  
  846.     case WM_COMMAND:    /* system command */
  847.         switch (wParam) {
  848.  
  849.         case IDD_KRM_CANCELFILE:
  850.         case IDD_KRM_CANCELBATCH:
  851.         case IDD_KRM_CANCELERROR:
  852.         case IDD_KRM_CANCELPROTOCOL:
  853.             CheckRadioButton(hDlg, IDD_KRM_CANCELFILE, 
  854.                        IDD_KRM_CANCELPROTOCOL, wParam);
  855.             break;
  856.  
  857.         case IDOK:
  858.             krmSetCancelFlags(hDlg);
  859.             EndDialog(hDlg,TRUE);
  860.             break;
  861.  
  862.         case IDCANCEL:
  863.             EndDialog(hDlg, FALSE);
  864.             break;
  865.  
  866.         default:
  867.             return FALSE;    /* windows will handle this */
  868.         }
  869.         break;
  870.  
  871.     default:
  872.         return FALSE;    /* and, windows will process this as well */
  873.     }
  874.     return TRUE;        /* if we process message, return TRUE */
  875. }
  876.  
  877. /*
  878.  * krmSetCancelFlags
  879.  *
  880.  * Set the file transfer cancel flags
  881.  * chosen by the user
  882.  */
  883. static void NEAR krmSetCancelFlags(HWND hDlg)
  884. {
  885.     register int i;
  886.     register WORD param;
  887.  
  888.     for (i = IDD_KRM_CANCELFILE; i <= IDD_KRM_CANCELPROTOCOL; i++) {
  889.     if (SendDlgItemMessage(hDlg, i, BM_GETCHECK, 0, 0L)) {
  890.         switch(i) {
  891.         default:
  892.         case IDD_KRM_CANCELFILE:
  893.             param = IDM_KRM_FILEABORT;
  894.             break;
  895.             case IDD_KRM_CANCELBATCH:
  896.             param = IDM_KRM_BATCHABORT;
  897.             break;
  898.         case IDD_KRM_CANCELERROR:
  899.             param = IDM_KRM_ERRORABORT;
  900.             break;
  901.         case IDD_KRM_CANCELPROTOCOL:
  902.             param = IDM_KRM_CANCEL;
  903.             break;
  904.         }
  905.         SendMessage(Kermit.hWnd, WM_COMMAND, param, 0L);
  906.         break;
  907.     }
  908.     }
  909. }
  910.  
  911. BOOL FAR PASCAL krmCWD(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
  912. {
  913.  
  914.     switch(message) {
  915.  
  916.     case WM_INITDIALOG:
  917.         krmCWDInit(hDlg);
  918.         break;
  919.  
  920.     case WM_COMMAND:
  921.         switch(wParam) {
  922.  
  923.         case IDOK:
  924.             EndDialog(hDlg, krmCWDSet(hDlg));
  925.             break;
  926.  
  927.         case IDCANCEL:
  928.             EndDialog(hDlg, FALSE);
  929.             break;
  930.  
  931.         default:
  932.             return FALSE;
  933.         }
  934.         break;
  935.     default:
  936.         return FALSE;
  937.     }
  938.     return TRUE;
  939. }
  940.  
  941. static void NEAR krmCWDInit(HWND hDlg)
  942. {
  943.  
  944.     SendDlgItemMessage(hDlg,IDD_KRM_FILENAME,EM_LIMITTEXT,KRM_MAXDATALEN,0L);
  945.     SendDlgItemMessage(hDlg,IDD_KRM_PASSWORD,EM_LIMITTEXT,KRM_MAXDATALEN,0L);
  946.  
  947. }
  948.  
  949. static HANDLE NEAR krmCWDSet(HWND hDlg)
  950. {
  951.     register int len1, len2;
  952.  
  953.     len1 = (int)SendDlgItemMessage(hDlg,IDD_KRM_FILENAME,
  954.                    WM_GETTEXTLENGTH,0,0L);
  955.     len2 = (int)SendDlgItemMessage(hDlg,IDD_KRM_PASSWORD,
  956.                    WM_GETTEXTLENGTH,0,0L);
  957.  
  958.     Kermit.hFilelist = LocalAlloc(LPTR, len1 + len2 + 4);
  959.     if (Kermit.hFilelist != NULL) {
  960.         Kermit.pFilelist = LocalLock(Kermit.hFilelist);
  961.     *Kermit.pFilelist = 'C';
  962.     *(Kermit.pFilelist + 1) = (BYTE)tochar(len1);
  963.     GetWindowText(GetDlgItem(hDlg, IDD_KRM_FILENAME),
  964.                  Kermit.pFilelist + 2, len1 + 1);
  965.     *(Kermit.pFilelist + len1 + 2) = (BYTE)tochar(len2);
  966.     GetWindowText(GetDlgItem(hDlg, IDD_KRM_PASSWORD),
  967.                  Kermit.pFilelist + len1 + 3, len2 + 1);
  968.     }
  969.     return (Kermit.hFilelist);
  970.     
  971. }
  972.  
  973. BOOL FAR PASCAL krmRemote1ParamCmd(register HWND hDlg, unsigned message, 
  974.                    register WORD wParam, LONG lParam)
  975. {
  976.  
  977.     switch(message) {
  978.  
  979.     case WM_INITDIALOG:
  980.         krmRemote1ParamInit(hDlg, Kermit.mode);
  981.         break;
  982.  
  983.     case WM_COMMAND:
  984.         switch(wParam) {
  985.         case IDD_KRM_FILENAME:
  986.             if (HIWORD(lParam) == EN_CHANGE)
  987.                 krmRemote1ParamEnable(hDlg,LOWORD(lParam),Kermit.mode);
  988.             break;
  989.  
  990.         case IDOK:
  991.             EndDialog(hDlg, krmRemote1ParamSet(hDlg, Kermit.mode));
  992.             break;
  993.  
  994.         case IDCANCEL:
  995.             EndDialog(hDlg, FALSE);
  996.             break;
  997.  
  998.         default:
  999.             return FALSE;
  1000.         }
  1001.         break;
  1002.     default:
  1003.         return FALSE;
  1004.     }
  1005.     return TRUE;
  1006. }
  1007.  
  1008. static void NEAR krmRemote1ParamInit(register HWND hDlg, int mode)
  1009. {
  1010.     char buf[80];
  1011.  
  1012.     SendDlgItemMessage(hDlg,IDD_KRM_FILENAME,EM_LIMITTEXT,KRM_MAXDATALEN,0L);
  1013.  
  1014.     switch(mode) {
  1015.         case IDM_KRM_REMOTETYPE:
  1016.         LoadString(Kermit.hInst, IDS_KRM_REMOTETYPE, buf, sizeof(buf));
  1017.             SetWindowText(hDlg, buf);
  1018.             EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
  1019.         break;
  1020.         case IDM_KRM_REMOTEHELP:
  1021.             LoadString(Kermit.hInst, IDS_KRM_REMOTEHELP, buf, sizeof(buf));
  1022.             SetWindowText(hDlg, buf);
  1023.             LoadString(Kermit.hInst, IDS_KRM_HELPTOPIC, buf, sizeof(buf));
  1024.             SetDlgItemText(hDlg, IDD_KRM_EDITTITLE, buf);
  1025.         break;
  1026.         case IDM_KRM_REMOTEDIR:
  1027.             LoadString(Kermit.hInst, IDS_KRM_REMOTEDIR, buf, sizeof(buf));
  1028.             SetWindowText(hDlg, buf);
  1029.         break;
  1030.     case IDM_KRM_REMOTECOMMAND:
  1031.         LoadString(Kermit.hInst, IDS_KRM_REMOTECOMMAND, buf, sizeof(buf));
  1032.         SetWindowText(hDlg, buf);
  1033.         LoadString(Kermit.hInst, IDS_KRM_CMDTOPIC, buf, sizeof(buf));
  1034.         SetDlgItemText(hDlg, IDD_KRM_EDITTITLE, buf);
  1035.         EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
  1036.         break;
  1037.     case IDM_KRM_REMOTEERASE:
  1038.         LoadString(Kermit.hInst, IDS_KRM_REMOTEERASE, buf, sizeof(buf));
  1039.         SetWindowText(hDlg, buf);
  1040.         EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
  1041.         break;
  1042.     case IDM_KRM_REMOTESPACE:
  1043.         LoadString(Kermit.hInst, IDS_KRM_REMOTESPACE, buf, sizeof(buf));
  1044.         SetWindowText(hDlg, buf);
  1045.         LoadString(Kermit.hInst, IDS_KRM_SPACETOPIC, buf, sizeof(buf));
  1046.         SetDlgItemText(hDlg, IDD_KRM_EDITTITLE, buf);
  1047.         break;
  1048.     case IDM_KRM_REMOTEWHO:
  1049.         LoadString(Kermit.hInst, IDS_KRM_REMOTEWHO, buf, sizeof(buf));
  1050.         SetWindowText(hDlg, buf);
  1051.         LoadString(Kermit.hInst, IDS_KRM_WHOTOPIC, buf, sizeof(buf));
  1052.         SetDlgItemText(hDlg, IDD_KRM_EDITTITLE, buf);
  1053.         break;
  1054.     case IDM_KRM_GET:
  1055.         EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
  1056.         setoemconvert(hDlg, IDD_KRM_FILENAME);
  1057.         break;
  1058.     }
  1059. }
  1060.  
  1061. static HANDLE NEAR krmRemote1ParamSet(register HWND hDlg, int mode)
  1062. {
  1063.  
  1064.     switch (mode) {
  1065.     case IDM_KRM_REMOTETYPE:
  1066.         return krmRemote1ParamGeneric(hDlg, 'T');
  1067.         case IDM_KRM_REMOTEHELP:
  1068.         return krmRemote1ParamGeneric(hDlg, 'H');
  1069.     case IDM_KRM_REMOTEDIR:
  1070.         return krmRemote1ParamGeneric(hDlg, 'D');
  1071.     case IDM_KRM_REMOTEWHO:
  1072.         return krmRemote1ParamGeneric(hDlg, 'W');
  1073.     case IDM_KRM_REMOTEERASE:
  1074.         return krmRemote1ParamGeneric(hDlg, 'E');
  1075.     case IDM_KRM_REMOTESPACE:
  1076.         return krmRemote1ParamGeneric(hDlg, 'U');
  1077.     case IDM_KRM_REMOTECOMMAND:
  1078.     case IDM_KRM_GET:
  1079.         return krmRemote1ParamCommand(hDlg);
  1080.         break;
  1081.     }
  1082. }
  1083.  
  1084. static HANDLE NEAR krmRemote1ParamCommand(HWND hDlg)
  1085. {
  1086.     register int len;
  1087.  
  1088.     len = (int)SendDlgItemMessage(hDlg,IDD_KRM_FILENAME,WM_GETTEXTLENGTH,0,0L);
  1089.     Kermit.hFilelist = LocalAlloc(LPTR, len + 1);
  1090.     if (Kermit.hFilelist != NULL) {
  1091.         Kermit.pFilelist = LocalLock(Kermit.hFilelist);
  1092.     GetWindowText(GetDlgItem(hDlg, IDD_KRM_FILENAME),
  1093.                  Kermit.pFilelist, len + 1);
  1094.     }
  1095.     return (Kermit.hFilelist);
  1096. }
  1097.  
  1098. static HANDLE NEAR krmRemote1ParamGeneric(HWND hDlg, char cmd)
  1099. {
  1100.     register int len;
  1101.  
  1102.     len = (int)SendDlgItemMessage(hDlg,IDD_KRM_FILENAME,WM_GETTEXTLENGTH,0,0L);
  1103.     Kermit.hFilelist = LocalAlloc(LPTR, len + 3);
  1104.     if (Kermit.hFilelist != NULL) {
  1105.         Kermit.pFilelist = LocalLock(Kermit.hFilelist);
  1106.     *Kermit.pFilelist = cmd;
  1107.     *(Kermit.pFilelist + 1) = (BYTE)tochar(len);
  1108.     GetWindowText(GetDlgItem(hDlg, IDD_KRM_FILENAME),
  1109.                  Kermit.pFilelist + 2, len + 1);
  1110.     }
  1111.     return (Kermit.hFilelist);
  1112. }
  1113.  
  1114. static void NEAR krmRemote1ParamEnable(HWND hDlg, HWND hctl, int mode)
  1115. {
  1116.     register int count;
  1117.  
  1118.     if ((mode == IDM_KRM_REMOTETYPE) ||
  1119.     (mode == IDM_KRM_REMOTECOMMAND) ||
  1120.     (mode == IDM_KRM_GET) ||
  1121.     (mode == IDM_KRM_REMOTEERASE)) {
  1122.         count = (int)SendMessage(hctl,WM_GETTEXTLENGTH,0,0L);
  1123.         EnableWindow(GetDlgItem(hDlg, IDOK), count);
  1124.     }
  1125. }
  1126.  
  1127. /*
  1128.  * GetComboboxSelection
  1129.  *
  1130.  * Utility function for combo boxes
  1131.  * Finds the highlighted string and returns its value.
  1132.  *
  1133.  */
  1134. static int NEAR GetComboboxSelection(HWND hDlg, WORD id, char * buffer)
  1135. {
  1136.     register int index;
  1137.  
  1138.     index = (int)SendDlgItemMessage(hDlg, id, CB_GETCURSEL, 0, 0L);
  1139.     if (index != CB_ERR)
  1140.     index = (int)SendDlgItemMessage(hDlg, id, CB_GETLBTEXT,
  1141.                     index, (LONG)(LPSTR)buffer);
  1142.     return index;
  1143. }
  1144.  
  1145. /*
  1146.  * GetComboBoxIndex
  1147.  *
  1148.  * Utility function for combo boxes
  1149.  * Get the index of the current selection
  1150.  */
  1151. static int NEAR GetComboboxIndex(HWND hDlg, int id)
  1152. {
  1153.     return (int)SendDlgItemMessage(hDlg, id, CB_GETCURSEL, 0, 0L);
  1154. }
  1155.  
  1156. /*
  1157.  * GetCheckedRadioButton
  1158.  *
  1159.  * Utility function for radio buttons
  1160.  * Finds the checked button, if any, in a group
  1161.  * of radio buttons.  If none, then returns highest value
  1162.  * of the range plus 1
  1163.  */
  1164. static int NEAR GetCheckedRadioButton(HWND hDlg, WORD start, WORD end)
  1165. {
  1166.  
  1167.     register WORD i;
  1168.  
  1169.     for (i = start; i <= end; i++)
  1170.     if (SendDlgItemMessage(hDlg, i, BM_GETCHECK, 0, 0L))
  1171.         break;
  1172.  
  1173.     return i;
  1174. }
  1175.  
  1176. /*
  1177.  * getnamestr
  1178.  *
  1179.  * Utility function to parse a path name for a file name
  1180.  */
  1181. static char* NEAR getnamestr(char *str, int len)
  1182. {
  1183.     char *tmp;
  1184.  
  1185.     tmp = str + len;
  1186.  
  1187.     while ((*tmp != ':') && (*tmp != '\\') && (tmp > str))
  1188.     tmp--;
  1189.     if (*tmp != ':' && *tmp != '\\')
  1190.     return(tmp);
  1191.     else
  1192.     return(tmp + 1);
  1193.  
  1194. }
  1195.  
  1196. /*
  1197.  * krmLocalFiles
  1198.  *
  1199.  * Dialog box to provide local directory services
  1200.  */
  1201. BOOL FAR PASCAL krmLocalFiles(HWND hDlg, unsigned message,
  1202.                   WORD wParam, LONG lParam)
  1203. {
  1204.     switch(message) {
  1205.     case WM_INITDIALOG:
  1206.     krmLocalInit(hDlg);
  1207.     break;
  1208.  
  1209.     case WM_COMMAND:
  1210.         switch(wParam) {
  1211.         case IDD_KRM_LOCALDIRS:
  1212.             krmLocalDirs(hDlg, lParam);
  1213.             break;
  1214.  
  1215.         case IDOK:
  1216.             krmLocalFilesOK(hDlg);
  1217.             break;
  1218.  
  1219.         case IDCANCEL:
  1220.             EndDialog(hDlg, FALSE);
  1221.             break;
  1222.         default:
  1223.             return FALSE;
  1224.         }
  1225.         break;
  1226.     default:
  1227.         return FALSE;
  1228.     }
  1229.     return TRUE;
  1230. }
  1231.  
  1232. /*
  1233.  * krmLocalFilesOK
  1234.  *
  1235.  * Execute a directory change in krmLocalFiles dialog
  1236.  */
  1237. static void NEAR krmLocalFilesOK(HWND hDlg)
  1238. {
  1239.  
  1240.     char buf[MAXPATHLEN];
  1241.  
  1242.     GetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT,buf,sizeof(buf));
  1243.     DlgDirList(hDlg, buf, IDD_KRM_LOCALFILES,IDD_KRM_LOCALPATH, 0);
  1244.     DlgDirList(hDlg, buf, IDD_KRM_LOCALDIRS,IDD_KRM_LOCALPATH, 0xC010);
  1245.     SetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT, buf);
  1246.     SendDlgItemMessage(hDlg, IDD_KRM_LOCALPATHEDIT, EM_SETSEL, 0,
  1247.             MAKELONG(0, 32767));
  1248. }
  1249.  
  1250. /*
  1251.  * krmLocalInit
  1252.  *
  1253.  * Initialize the krmLocalFiles dialog
  1254.  */
  1255. static void NEAR krmLocalInit(HWND hDlg)
  1256. {
  1257.  
  1258.     DlgDirList(hDlg, defstring, IDD_KRM_LOCALFILES,IDD_KRM_LOCALPATH, 0);
  1259.     DlgDirList(hDlg, defstring, IDD_KRM_LOCALDIRS,IDD_KRM_LOCALPATH, 0xC010);
  1260.     SetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT, defstring);
  1261.     SendDlgItemMessage(hDlg,IDD_KRM_LOCALPATHEDIT,EM_LIMITTEXT,MAXPATHLEN, 0L);
  1262.     setoemconvert(hDlg, IDD_KRM_LOCALPATHEDIT);
  1263.  
  1264. }
  1265.  
  1266. /*
  1267.  * krmLocalDirs
  1268.  *
  1269.  * Change the edit box display and directory in krmLocalDirs dialog
  1270.  */
  1271. static void NEAR krmLocalDirs(HWND hDlg, LONG lParam)
  1272. {
  1273.  
  1274.     char buf[MAXPATHLEN];
  1275.     char str[MAXPATHLEN];
  1276.     int len;
  1277.  
  1278.     if (HIWORD(lParam) == LBN_SELCHANGE) {
  1279.     len = GetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT,str,sizeof(buf) - 13);
  1280.         DlgDirSelect(hDlg, (LPSTR)buf, IDD_KRM_LOCALDIRS);
  1281.     if (strchr(str,'*') || strchr(str,'?'))
  1282.         strcat(buf,getnamestr(str,len));
  1283.     else
  1284.         strcat(buf, defstring);
  1285.         SetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT, (LPSTR)buf);
  1286.     }
  1287.     else if (HIWORD(lParam) == LBN_DBLCLK) {
  1288.     GetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT,buf,sizeof(buf));
  1289.         DlgDirList(hDlg, buf, IDD_KRM_LOCALFILES,IDD_KRM_LOCALPATH, 0);
  1290.         DlgDirList(hDlg, buf, IDD_KRM_LOCALDIRS,IDD_KRM_LOCALPATH, 0xC010);
  1291.     SetDlgItemText(hDlg, IDD_KRM_LOCALPATHEDIT, buf);
  1292.     }
  1293. }
  1294.  
  1295. /*
  1296.  * setoemconvert
  1297.  *
  1298.  * Utility function to set an edit box to ES_OEMCONVERT style
  1299.  */
  1300. static void NEAR setoemconvert(HWND hDlg, WORD id)
  1301. {
  1302.     HWND hctl;
  1303.     LONG style;
  1304.  
  1305.     hctl = GetDlgItem(hDlg, id);
  1306.     style = GetWindowLong(hctl, GWL_STYLE);
  1307.     style |= ES_OEMCONVERT;
  1308.     SetWindowLong(hctl, GWL_STYLE, style);
  1309. }
  1310.