home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcltk805.zip / tcl805s.zip / tk8.0.5 / os2 / tkOS2Dll.c < prev    next >
C/C++ Source or Header  |  2001-07-30  |  2KB  |  85 lines

  1. /* 
  2.  * tkOS2Dll.c --
  3.  *
  4.  *    This file contains a stub dll entry point.
  5.  *
  6.  * Copyright (c) 1995 Sun Microsystems, Inc.
  7.  * Copyright (c) 1996-2000 Illya Vaes
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  */
  13.  
  14. #include "tkPort.h"
  15. #include "tkOS2Int.h"
  16.  
  17. int _CRT_init(void);
  18. void _CRT_term(void);
  19.  
  20. /* Save the Tk DLL handle for TkPerl */
  21. unsigned long dllHandle = (unsigned long) NULLHANDLE;
  22.  
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * _DLL_InitTerm --
  28.  *
  29.  *    DLL entry point.
  30.  *
  31.  * Results:
  32.  *    TRUE on sucess, FALSE on failure.
  33.  *
  34.  * Side effects:
  35.  *    None.
  36.  *
  37.  *----------------------------------------------------------------------
  38.  */
  39.  
  40. unsigned long _DLL_InitTerm(unsigned long modHandle, unsigned long flag)
  41. {
  42.     /*
  43.      * If we are attaching to the DLL from a new process, tell Tk about
  44.      * the handle to use. If we are detaching then clean up any
  45.      * data structures related to this DLL.
  46.      */
  47.  
  48.     switch (flag) {
  49.     case 0: {    /* INIT */
  50.         PPIB pibPtr;
  51.         PTIB tibPtr;
  52.  
  53.         /*
  54.          * Warp ourselves to PM; only of interest for CLI that really want
  55.          * to use PM services etc. and using the Tk DLL.
  56.          */
  57.         rc = DosGetInfoBlocks(&tibPtr, &pibPtr);
  58.         pibPtr->pib_ultype = 3;
  59.  
  60.         if (TkOS2InitPM() == (HAB)NULLHANDLE) {
  61. #ifdef VERBOSE
  62.             FILE *errFile = fopen("tk80dll.err", "w");
  63.             if (errFile != NULL) {
  64.                 fprintf(errFile, "TkOS2InitPM returns NULLHANDLE\n");
  65.             }
  66. #endif
  67.             return FALSE;
  68.         }
  69.         /* Save handle */
  70.         dllHandle = modHandle;
  71.         TkOS2XInit(dllHandle);
  72.         return TRUE;
  73.     }
  74.  
  75.     case 1:     /* TERM */
  76.         TkOS2XCleanup(dllHandle);
  77.         TkOS2ExitPM(dllHandle);
  78.         /* Invalidate handle */
  79.         dllHandle = (unsigned long)NULLHANDLE;
  80.         return TRUE;
  81.     }
  82.  
  83.     return FALSE;
  84. }
  85.