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

Last change on this file since 354 was 354, checked in by sandervl, 26 years ago

Getting rid of some linker errors

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
32extern "C" {
33/*-------------------------------------------------------------------*/
34/* _CRT_init is the C run-time environment initialization function. */
35/* It will return 0 to indicate success and -1 to indicate failure. */
36/*-------------------------------------------------------------------*/
37int CDECL CRT_init(void);
38/*-------------------------------------------------------------------*/
39/* _CRT_term is the C run-time environment termination function. */
40/* It only needs to be called when the C run-time functions are */
41/* statically linked. */
42/*-------------------------------------------------------------------*/
43void CDECL CRT_term(void);
44void CDECL _ctordtorInit( void );
45void CDECL _ctordtorTerm( void );
46}
47/*-------------------------------------------------------------------*/
48/* A clean up routine registered with DosExitList must be used if */
49/* runtime calls are required and the runtime is dynamically linked. */
50/* This will guarantee that this clean up routine is run before the */
51/* library DLL is terminated. */
52/*-------------------------------------------------------------------*/
53static void APIENTRY cleanup(ULONG reason);
54
55
56
57/****************************************************************************/
58/* _DLL_InitTerm is the function that gets called by the operating system */
59/* loader when it loads and frees this DLL for each process that accesses */
60/* this DLL. However, it only gets called the first time the DLL is loaded */
61/* and the last time it is freed for a particular process. The system */
62/* linkage convention MUST be used because the operating system loader is */
63/* calling this function. */
64/****************************************************************************/
65unsigned long _System _DLL_InitTerm(unsigned long hModule, unsigned long
66 ulFlag)
67{
68 size_t i;
69 APIRET rc;
70
71 /*-------------------------------------------------------------------------*/
72 /* If ulFlag is zero then the DLL is being loaded so initialization should */
73 /* be performed. If ulFlag is 1 then the DLL is being freed so */
74 /* termination should be performed. */
75 /*-------------------------------------------------------------------------*/
76
77 switch (ulFlag) {
78 case 0 :
79
80 /*******************************************************************/
81 /* The C run-time environment initialization function must be */
82 /* called before any calls to C run-time functions that are not */
83 /* inlined. */
84 /*******************************************************************/
85
86 if (CRT_init() == -1)
87 return 0UL;
88 _ctordtorInit();
89
90//SvL: Temporarily disabled
91#if 0
92 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
93#endif
94
95 /*******************************************************************/
96 /* A DosExitList routine must be used to clean up if runtime calls */
97 /* are required and the runtime is dynamically linked. */
98 /*******************************************************************/
99
100 rc = DosExitList(0x0000FF00|EXLST_ADD, cleanup);
101 if(rc)
102 return 0UL;
103
104 break;
105 case 1 :
106 break;
107 default :
108 return 0UL;
109 }
110
111 /***********************************************************/
112 /* A non-zero value must be returned to indicate success. */
113 /***********************************************************/
114 return 1UL;
115}
116
117
118static void APIENTRY cleanup(ULONG ulReason)
119{
120 _ctordtorTerm();
121 CRT_term();
122 DosExitList(EXLST_EXIT, cleanup);
123 return ;
124}
Note: See TracBrowser for help on using the repository browser.