blob: 511c3d9679be641040d2a7e3be86118becd547c1 [file] [log] [blame]
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00001/*
2 This is the entry point for Python DLL(s).
3 It also provides an getenv() function that works from within DLLs.
4*/
5
6#define NULL 0
7
8/* Make references to imported symbols to pull them from static library */
9#define REF(s) extern void s (); void *____ref_##s = &s;
10
11REF (Py_Main);
12
13#if defined (__EMX__)
14
15#include <signal.h>
16
17extern int _CRT_init (void);
18extern void _CRT_term (void);
19extern void __ctordtorInit (void);
20extern void __ctordtorTerm (void);
21
22unsigned long _DLL_InitTerm (unsigned long mod_handle, unsigned long flag)
23{
24 switch (flag)
25 {
26 case 0:
27 if (_CRT_init ()) return 0;
28 __ctordtorInit ();
29 /* Ignore fatal signals */
30 signal (SIGSEGV, SIG_IGN);
31 signal (SIGFPE, SIG_IGN);
32 return 1;
33 case 1:
34 __ctordtorTerm ();
35 _CRT_term ();
36 return 1;
37 default:
38 return 0;
39 }
40}
41
42#endif
43
44/* A version of getenv() that works from DLLs */
45extern int DosScanEnv (const char *pszName, char **ppszValue);
46
47char *getenv (const char *name)
48{
49 char *value;
50 if (DosScanEnv (name, &value))
51 return NULL;
52 else
53 return value;
54}