home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pytho152.zip / emx / src / Python / PC / os2emx / dllentry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-26  |  1.1 KB  |  55 lines

  1. /*
  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.  
  11. REF (Py_Main);
  12.  
  13. #if defined (__EMX__)
  14.  
  15. #include <signal.h>
  16.  
  17. extern int _CRT_init (void);
  18. extern void _CRT_term (void);
  19. extern void __ctordtorInit (void);
  20. extern void __ctordtorTerm (void);
  21.  
  22. unsigned 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 */
  45. extern int DosScanEnv (const char *pszName, char **ppszValue);
  46.  
  47. char *getenv (const char *name)
  48. {
  49.   char *value;
  50.   if (DosScanEnv (name, &value))
  51.     return NULL;
  52.   else
  53.     return value;
  54. }
  55.