Emacs/tags update:
[p5sagit/p5-mst-13.2.git] / win32 / perllib.c
CommitLineData
0a753a76 1/*
2 * "The Road goes ever on and on, down from the door where it began."
3 */
4
0a753a76 5
6#include "EXTERN.h"
7#include "perl.h"
96e4d5b1 8#include "XSUB.h"
0a753a76 9
0a753a76 10static void xs_init _((void));
11
68dc0745 12__declspec(dllexport) int
13RunPerl(int argc, char **argv, char **env, void *iosubsystem)
0a753a76 14{
68dc0745 15 int exitstatus;
16 PerlInterpreter *my_perl;
0a753a76 17
18 PERL_SYS_INIT(&argc,&argv);
19
20 perl_init_i18nl10n(1);
21
68dc0745 22 if (!(my_perl = perl_alloc()))
23 return (1);
24 perl_construct( my_perl );
25 perl_destruct_level = 0;
0a753a76 26
27 exitstatus = perl_parse( my_perl, xs_init, argc, argv, env);
28 if (!exitstatus) {
29 exitstatus = perl_run( my_perl );
30 }
31
0a753a76 32 perl_destruct( my_perl );
33 perl_free( my_perl );
34
35 PERL_SYS_TERM();
36
68dc0745 37 return (exitstatus);
0a753a76 38}
39
0a753a76 40extern HANDLE PerlDllHandle;
41
68dc0745 42BOOL APIENTRY
43DllMain(HANDLE hModule, /* DLL module handle */
44 DWORD fdwReason, /* reason called */
45 LPVOID lpvReserved) /* reserved */
0a753a76 46{
68dc0745 47 switch (fdwReason) {
48 /* The DLL is attaching to a process due to process
49 * initialization or a call to LoadLibrary.
50 */
51 case DLL_PROCESS_ATTACH:
52/* #define DEFAULT_BINMODE */
0a753a76 53#ifdef DEFAULT_BINMODE
3e3baf6d 54 setmode( fileno( stdin ), O_BINARY );
55 setmode( fileno( stdout ), O_BINARY );
56 setmode( fileno( stderr ), O_BINARY );
57 _fmode = O_BINARY;
0a753a76 58#endif
68dc0745 59 PerlDllHandle = hModule;
60 break;
0a753a76 61
68dc0745 62 /* The DLL is detaching from a process due to
63 * process termination or call to FreeLibrary.
64 */
65 case DLL_PROCESS_DETACH:
66 break;
0a753a76 67
68dc0745 68 /* The attached process creates a new thread. */
69 case DLL_THREAD_ATTACH:
70 break;
0a753a76 71
68dc0745 72 /* The thread of the attached process terminates. */
73 case DLL_THREAD_DETACH:
74 break;
0a753a76 75
68dc0745 76 default:
77 break;
78 }
79 return TRUE;
0a753a76 80}
8b10511d 81
82/* Register any extra external extensions */
83
84char *staticlinkmodules[] = {
85 "DynaLoader",
86 NULL,
87};
88
89EXTERN_C void boot_DynaLoader _((CV* cv));
90
8b10511d 91static void
92xs_init()
93{
94 char *file = __FILE__;
95 dXSUB_SYS;
96 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
8b10511d 97}
98