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

  1. /* C K N D D E -- Kermit Dynamic Data Exchange support for Win32 */
  2.  
  3. /*
  4.   Author: Jeffrey Altman (jaltman@secure-endpoints.com),
  5.             Secure Endpoints Inc., New York City.
  6.  
  7.   Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New
  8.   York.
  9. */
  10.  
  11. #include "ckcdeb.h"                     /* Typedefs, debug formats, etc */
  12. #include "ckcasc.h"                     /* ASCII character names */
  13. #include "ckcker.h"                     /* Kermit definitions */
  14. #include "ckuusr.h"                     /* Command definitions - needed for ckokey.h */
  15. #include <ctype.h>                      /* Character types */
  16. #include <stdio.h>                      /* Standard i/o */
  17. #include <io.h>                         /* File io function declarations */
  18. #include <process.h>                    /* Process-control functions */
  19. #include <string.h>                     /* String manipulation declarations */
  20. #include <stdlib.h>                     /* Standard library declarations */
  21. #include <signal.h>
  22.  
  23. #ifdef NT
  24. #include <windows.h>
  25. #include <dde.h>
  26. #include <ddeml.h>
  27. #define strdup _strdup
  28. #endif /* NT */
  29.  
  30. /* Begin Keyboard Handler Thread Code */
  31. int
  32. DDEHandlerInit( void ) {
  33.     int rc = 0 ;
  34.  
  35.     debug(F100,"DDEHandlerInit called","",0);
  36.     DDEActive = 1 ;
  37.  
  38.     CreateDDEThreadSem( FALSE ) ;
  39.     tidDDEHandler = (TID) ckThreadBegin( &DDEHandlerThread,
  40.                                          THRDSTKSIZ, 0, FALSE, 0 ) ;
  41.     if ( tidDDEHandler == (TID) -1 ) {
  42.         printf( "Sorry, can't create DDEHandlerThread\n" ) ;
  43.         rc = -1 ;
  44.     }
  45.     else {
  46.         WaitAndResetDDEThreadSem( SEM_INDEFINITE_WAIT ) ;
  47.     }
  48.     return rc ;
  49. }
  50.  
  51. int
  52. DDEHandlerCleanup( void ) {
  53.     APIRET rc=0 ;
  54.     int n = 0;
  55.     debug(F100,"DDEHandlerCleanup called","",0);
  56.     DDEActive = 0 ;
  57.     while ( !WaitAndResetDDEThreadSem( 1000 ) && n++ < 50) {
  58.         debug(F100,"Waiting for DDEThreadSem","",0) ;
  59.     }
  60.     tidDDEHandler = (TID) 0 ;
  61.     CloseDDEThreadSem() ;
  62.     return 0 ;
  63. }
  64.  
  65. void
  66. DDEHandlerThread( void * pArgList ) {
  67.     DWORD count = 0;
  68.     int rc, c, i ;
  69.     extern BYTE vmode ;
  70.  
  71.     debug(F100,"DDEHandlerThread is born","",0);
  72.  
  73.     PostDDEThreadSem() ;
  74.     debug(F100,"DDEHandlerThread dies","",0);
  75.     ckThreadEnd(pArgList);
  76. }
  77.  
  78.