source: trunk/src/ddraw/initterm.cpp@ 210

Last change on this file since 210 was 210, checked in by hugh, 26 years ago

DX 6 Version of ddraw rel files

File size: 4.8 KB
Line 
1
2/*
3
4 * This file was created for Sander van Leeuwen
5
6 * by Project Smarts on 8 May 1997.
7
8 */
9
10/*-------------------------------------------------------------*/
11/* INITERM.C -- Source for a custom dynamic link library */
12/* initialization and termination (_DLL_InitTerm) */
13/* function. */
14/* */
15/* When called to perform initialization, this sample function */
16/* gets storage for an array of integers, and initializes its */
17/* elements with random integers. At termination time, it */
18/* frees the array. Substitute your own special processing. */
19/*-------------------------------------------------------------*/
20
21
22/* Include files */
23#define INCL_DOSMODULEMGR
24#define INCL_DOSPROCESS
25#include <os2wrap.h>
26#include <stdlib.h>
27#include <stdio.h>
28#include <string.h>
29#include <odin.h>
30#include <misc.h> /*PLF Wed 98-03-18 23:18:29*/
31
32/*-------------------------------------------------------------------*/
33/* _CRT_init is the C run-time environment initialization function. */
34/* It will return 0 to indicate success and -1 to indicate failure. */
35/*-------------------------------------------------------------------*/
36int _CRT_init(void);
37/*-------------------------------------------------------------------*/
38/* _CRT_term is the C run-time environment termination function. */
39/* It only needs to be called when the C run-time functions are */
40/* statically linked. */
41/*-------------------------------------------------------------------*/
42void _CRT_term(void);
43void __ctordtorInit( void );
44void __ctordtorTerm( void );
45
46/*-------------------------------------------------------------------*/
47/* A clean up routine registered with DosExitList must be used if */
48/* runtime calls are required and the runtime is dynamically linked. */
49/* This will guarantee that this clean up routine is run before the */
50/* library DLL is terminated. */
51/*-------------------------------------------------------------------*/
52static void APIENTRY cleanup(ULONG reason);
53
54
55
56/****************************************************************************/
57/* _DLL_InitTerm is the function that gets called by the operating system */
58/* loader when it loads and frees this DLL for each process that accesses */
59/* this DLL. However, it only gets called the first time the DLL is loaded */
60/* and the last time it is freed for a particular process. The system */
61/* linkage convention MUST be used because the operating system loader is */
62/* calling this function. */
63/****************************************************************************/
64unsigned long _System _DLL_InitTerm(unsigned long hModule, unsigned long
65 ulFlag)
66{
67 size_t i;
68 APIRET rc;
69
70 /*-------------------------------------------------------------------------*/
71 /* If ulFlag is zero then the DLL is being loaded so initialization should */
72 /* be performed. If ulFlag is 1 then the DLL is being freed so */
73 /* termination should be performed. */
74 /*-------------------------------------------------------------------------*/
75
76 switch (ulFlag) {
77 case 0 :
78
79 /*******************************************************************/
80 /* The C run-time environment initialization function must be */
81 /* called before any calls to C run-time functions that are not */
82 /* inlined. */
83 /*******************************************************************/
84
85 if (_CRT_init() == -1)
86 return 0UL;
87 __ctordtorInit();
88
89//SvL: Temporarily disabled
90#if 0
91 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
92#endif
93
94 /*******************************************************************/
95 /* A DosExitList routine must be used to clean up if runtime calls */
96 /* are required and the runtime is dynamically linked. */
97 /*******************************************************************/
98
99 rc = DosExitList(0x0000FF00|EXLST_ADD, cleanup);
100 if(rc)
101 return 0UL;
102
103 break;
104 case 1 :
105 break;
106 default :
107 return 0UL;
108 }
109
110 /***********************************************************/
111 /* A non-zero value must be returned to indicate success. */
112 /***********************************************************/
113 return 1UL;
114}
115
116
117static void APIENTRY cleanup(ULONG ulReason)
118{
119 __ctordtorTerm();
120 _CRT_term();
121 DosExitList(EXLST_EXIT, cleanup);
122 return ;
123}
Note: See TracBrowser for help on using the repository browser.