home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / wpshidl / samples / wpcar / initterm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-25  |  1.5 KB  |  70 lines

  1. /*static char *SCCSID = "@(#)initterm.c    6.1 91/11/03";*/
  2. /*
  3.  * DLL init and term routine for the Toronto Compiler
  4.  *
  5.  */
  6.  
  7.  #define  INCL_DOSPROCESS
  8.  
  9.  #include <stdlib.h>
  10.  #include <stdio.h>
  11.  #include <os2.h>
  12.  
  13. /*
  14.  * _edcinit is the C-runtime environment init. function.
  15.  * Returns 0 to indicate success and -1 to indicate failure
  16.  */
  17.   int _CRT_init(void);
  18.  
  19. /*
  20.  * _edcterm is the C-runtime termination function.
  21.  */
  22.   int _CRT_term(unsigned long);
  23.  
  24. extern DLLInit( void );
  25. extern DLLUninit( void );
  26.  
  27. /*
  28.  * _DLL_InitTerm is the function that tets called by the operation system
  29.  * loader when it lads and frees the dll for each process that accesses
  30.  * the dll.
  31.  */
  32. #pragma linkage( _DLL_InitTerm, system )
  33.  
  34. unsigned long _DLL_InitTerm (unsigned long modhandle, unsigned long flag)
  35. {
  36.   /*
  37.    * If flag is 0 the the DLL is being loaded so initialization should be
  38.    * preformed. If flag is 1 then the DLL is being freed , so termination
  39.    * should be preformed.
  40.    */
  41.    switch (flag)
  42.      {
  43.      case 0:
  44.         /*
  45.          * Call the C run-time init function before any thing else.
  46.          */
  47.          if (_CRT_init() == -1)
  48.            return 0UL;
  49.          DLLInit();
  50.  
  51.          break;
  52.  
  53.      case 1:
  54.         /*
  55.          * Call the C run-time termination function.
  56.          */
  57.          DLLUninit();
  58.          _CRT_term(0UL);
  59.          break;
  60.      } /* endswitch */
  61.  
  62.   return 1UL;
  63.  
  64. }
  65.  
  66. APIRET DosGetThreadInfo(PTIB *pptib,PPIB *pppib)
  67. {
  68.      return(DosGetInfoBlocks(pptib,pppib) );
  69. }
  70.