home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / winkerm.zip / WINKRM.C < prev    next >
C/C++ Source or Header  |  1986-10-10  |  5KB  |  147 lines

  1.  
  2. /***************************************************************************
  3. *
  4. * Winkrm
  5. *
  6. * Windows Kermit Application, main module
  7. *
  8. * Written by William S. Hall with the assistance of Ray Washburn
  9. * AT&T Information Systems
  10. * Juniper Office Plaza
  11. * Freehold, NJ 07728
  12. *
  13. * This program implements:
  14. *    1.  dumb terminal emulation at 300, 1200, or 2400 baud,
  15. *    2.  Kermit protocol file transfer, on any PC running Microsoft Windows
  16. *     and having at least one communications port.  Because it runs in
  17. *     Windows, background and simultaneous file transfer
  18. *     (if a second port is installed) are possible.  Binary file
  19. *     transfer is not supported.
  20. *
  21. * The current version lacks the following desirable features:
  22. *    1.  Smart terminal emulation (VT-52, VT-100, Heath-19).
  23. *    2.  The ability to display current directories or to change to
  24. *     another directory within the program.
  25. *    3.  Accelerator keys for certain operations.
  26. *    4.  A wider selection of baud rates, parity, and wordsize.
  27. *    5.  Server commands.
  28. *    6.  A better user interface for selecting files to send, i. e.
  29. *     wild cards and multiple selections.
  30. *    7.  Memory pages.
  31. *    8.  Tiny text for more, longer lines on the screen.
  32. *    9.  Hayes modem interface (but this could be a separate program).
  33. *   10.  File logging.
  34. *   11.  Help.
  35. *   12.  Local-echo.
  36. *   13.  Definable keys
  37. *   14.  Status window.
  38. *   15.  CRC checksum.
  39. *   16.  Debugging and packet debugging.
  40. *   17.  Selectable flow control.
  41. *   18.  Printer support.
  42. *   19.  Timeout
  43. *   20   File Warning.
  44. *   21.  Binary file transfer.
  45. *
  46. * Usage:  After running the program:
  47. *          1.  Select a communications port with the Port menu.
  48. *          2.  Select a baud rate with the Baud Menu.  A default
  49. *          baud rate can be placed in Win.ini with the following
  50. *          entry:
  51. *          [WinKrm]
  52. *              Baud=nnnn        ; default is 1200
  53. *          3.  Connect to the port using the Connect option under
  54. *          the State memu.
  55. *          4.  To receive file(s) using Kermit, set the other side
  56. *          to send the file(s), then select Receive under the State
  57. *          menu.  The state returns to no state after completing
  58. *          the transfer.
  59. *          5.  To send files, select Send under the State menu.
  60. *              Give a list of pathnames separated by commas in the
  61. *          dialogue box.
  62. *
  63. * Acknowledgements:
  64. *    Much of the Kermit code is taken directly from the Kermit
  65. *    protocol manual and the sample program Kermit.c provided by
  66. *    Columbia University.
  67. *
  68. ***************************************************************************/
  69.      
  70. #include <windows.h>
  71. #define EXTERN
  72. #include "winkrm.h"
  73.      
  74. /***************************************************************************
  75. *
  76. * WinMain
  77. *
  78. * Called by Windows when program is invoked
  79. *
  80. * Entry: previous and current instance handles,
  81. *        lp to command line,
  82. *     command show (display as icon or window).
  83. *
  84. * Exit: Never until State is set to NULL.
  85. *
  86. ***************************************************************************/
  87. int FAR PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  88. HANDLE hInstance, hPrevInstance;
  89. LPSTR lpszCmdLine;
  90. int cmdShow;
  91. {
  92.      
  93.   /* Initialize all variables */
  94.     if (!WinKermInit(hInstance, hPrevInstance,lpszCmdLine,cmdShow))
  95.     return FALSE;
  96.      
  97.   /* Switch among these states until program terminates */
  98.     while (TRUE) {
  99.     switch(CurrentState) {
  100.         case CONNECTSTATE:    /* terminal emulation */
  101.         connect();
  102.         break;
  103.         case RECEIVESTATE:    /* receive a file using Kermit protocol */
  104.         receive();
  105.         break;
  106.         case SENDSTATE:    /* send a file using Kermit protocol */
  107.         send();
  108.         break;
  109.         default:
  110.         DoMessage();    /* if nothing else happpens, read messages */
  111.         break;
  112.     }
  113.     }
  114. }
  115.      
  116. /***************************************************************************
  117. *
  118. * DoMessage - read Windows messages
  119. *
  120. * Entry: None
  121. *
  122. * Exit: TRUE if message other than WM_QUIT,
  123. *    FALSE if no message handled,
  124. *    exit to Windows if WM_QUIT received.
  125. *
  126. * Notes; Tasking of other applications will fail if this routine
  127. *     is not called frequently.  See the routine GetBuf.
  128. *
  129. ***************************************************************************/
  130. BOOL FAR DoMessage()
  131. {
  132.      
  133.     MSG msg;
  134.      
  135.     if (PeekMessage((LPMSG)&msg, NULL,0,0,TRUE)) {
  136.     if (msg.message == WM_QUIT)
  137.         exit((int)msg.wParam);    /* Quit, back to Windows exec */
  138.     else {
  139.         TranslateMessage((LPMSG)&msg); /* Message found, process it */
  140.         DispatchMessage((LPMSG)&msg);
  141.     }
  142.     return TRUE;
  143.     }
  144.     else
  145.     return FALSE;    /* No message processed */
  146. }
  147.