Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

initterm.cpp

Go to the documentation of this file.
00001 /* $Id: initterm.cpp,v 1.33 2001/09/05 13:53:50 bird Exp $ */
00002 /*
00003  * USER32 DLL entry point
00004  *
00005  * Copyright 1998 Sander van Leeuwen
00006  * Copyright 1998 Peter Fitzsimmons
00007  *
00008  *
00009  * Project Odin Software License can be found in LICENSE.TXT
00010  *
00011  */
00012 
00013 /*-------------------------------------------------------------*/
00014 /* INITERM.C -- Source for a custom dynamic link library       */
00015 /*              initialization and termination (_DLL_InitTerm) */
00016 /*              function.                                      */
00017 /*                                                             */
00018 /* When called to perform initialization, this sample function */
00019 /* gets storage for an array of integers, and initializes its  */
00020 /* elements with random integers.  At termination time, it     */
00021 /* frees the array.  Substitute your own special processing.   */
00022 /*-------------------------------------------------------------*/
00023 
00024 
00025 /* Include files */
00026 #define  INCL_DOSMODULEMGR
00027 #define  INCL_DOSPROCESS
00028 #define  INCL_DOSSEMAPHORES
00029 #define  INCL_DOSMISC
00030 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
00031 #include <stdlib.h>
00032 #include <stdio.h>
00033 #include <string.h>
00034 #include <odin.h>
00035 #include <misc.h>       /*PLF Wed  98-03-18 23:18:29*/
00036 #include <win32type.h>
00037 #include <win32api.h>
00038 #include <winconst.h>
00039 #include <odinlx.h>
00040 #include "initterm.h"
00041 #include <exitlist.h>
00042 #include <initdll.h>
00043 
00044 #define DBG_LOCALLOG    DBG_initterm
00045 #include "dbglocal.h"
00046 
00047 /*-------------------------------------------------------------------*/
00048 /* A clean up routine registered with DosExitList must be used if    */
00049 /* runtime calls are required and the runtime is dynamically linked. */
00050 /* This will guarantee that this clean up routine is run before the  */
00051 /* library DLL is terminated.                                        */
00052 /*-------------------------------------------------------------------*/
00053 static void APIENTRY cleanup(ULONG reason);
00054 
00055 BOOL  fVersionWarp3 = FALSE;
00056 
00057 /****************************************************************************/
00058 /* _DLL_InitTerm is the function that gets called by the operating system   */
00059 /* loader when it loads and frees this DLL for each process that accesses   */
00060 /* this DLL.  However, it only gets called the first time the DLL is loaded */
00061 /* and the last time it is freed for a particular process.  The system      */
00062 /* linkage convention MUST be used because the operating system loader is   */
00063 /* calling this function.                                                   */
00064 /****************************************************************************/
00065 ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
00066 {
00067    size_t i;
00068    APIRET rc;
00069    ULONG  version[2];
00070 
00071    /*-------------------------------------------------------------------------*/
00072    /* If ulFlag is zero then the DLL is being loaded so initialization should */
00073    /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
00074    /* termination should be performed.                                        */
00075    /*-------------------------------------------------------------------------*/
00076 
00077    switch (ulFlag) {
00078       case 0 :
00079          ctordtorInit();
00080 
00081          rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version));
00082          if(rc == 0){
00083               if(version[0] >= 20 && version[1] <= 30) {
00084                   fVersionWarp3 = TRUE;
00085               }
00086          }
00087 
00088          /*******************************************************************/
00089          /* A DosExitList routine must be used to clean up if runtime calls */
00090          /* are required and the runtime is dynamically linked.             */
00091          /*******************************************************************/
00092 
00093          rc = DosExitList(EXITLIST_USER32|EXLST_ADD, cleanup);
00094          if(rc)
00095                 return 0UL;
00096 
00097          rc = inittermUser32(hModule, ulFlag);
00098          break;
00099       case 1 :
00100          rc = inittermUser32(hModule, ulFlag);
00101          break;
00102       default  :
00103          return 0UL;
00104    }
00105 
00106    /***********************************************************/
00107    /* A non-zero value must be returned to indicate success.  */
00108    /***********************************************************/
00109    return 1UL;
00110 }
00111 
00112 static void APIENTRY cleanup(ULONG ulReason)
00113 {
00114    cleanupUser32(ulReason);
00115    ctordtorTerm();
00116 
00117    DosExitList(EXLST_EXIT, cleanup);
00118 }
00119 

Generated on Wed Jan 23 23:17:32 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001