Commit | Line | Data |
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 |
10 | static void xs_init _((void)); |
11 | |
852c2e52 |
12 | DllExport int |
68dc0745 |
13 | RunPerl(int argc, char **argv, char **env, void *iosubsystem) |
0a753a76 |
14 | { |
68dc0745 |
15 | int exitstatus; |
16 | PerlInterpreter *my_perl; |
0a753a76 |
17 | |
22239a37 |
18 | #ifdef PERL_GLOBAL_STRUCT |
19 | #define PERLVAR(var,type) /**/ |
533c011a |
20 | #define PERLVARI(var,type,init) PL_Vars.var = init; |
21 | #define PERLVARIC(var,type,init) PL_Vars.var = init; |
22239a37 |
22 | #include "perlvars.h" |
23 | #undef PERLVAR |
24 | #undef PERLVARI |
3fe35a81 |
25 | #undef PERLVARIC |
22239a37 |
26 | #endif |
27 | |
0a753a76 |
28 | PERL_SYS_INIT(&argc,&argv); |
29 | |
30 | perl_init_i18nl10n(1); |
31 | |
68dc0745 |
32 | if (!(my_perl = perl_alloc())) |
33 | return (1); |
34 | perl_construct( my_perl ); |
b28d0864 |
35 | PL_perl_destruct_level = 0; |
0a753a76 |
36 | |
37 | exitstatus = perl_parse( my_perl, xs_init, argc, argv, env); |
38 | if (!exitstatus) { |
39 | exitstatus = perl_run( my_perl ); |
40 | } |
41 | |
0a753a76 |
42 | perl_destruct( my_perl ); |
43 | perl_free( my_perl ); |
44 | |
45 | PERL_SYS_TERM(); |
46 | |
68dc0745 |
47 | return (exitstatus); |
0a753a76 |
48 | } |
49 | |
2d7a9237 |
50 | extern HANDLE w32_perldll_handle; |
0a753a76 |
51 | |
68dc0745 |
52 | BOOL APIENTRY |
53 | DllMain(HANDLE hModule, /* DLL module handle */ |
54 | DWORD fdwReason, /* reason called */ |
55 | LPVOID lpvReserved) /* reserved */ |
0a753a76 |
56 | { |
68dc0745 |
57 | switch (fdwReason) { |
58 | /* The DLL is attaching to a process due to process |
59 | * initialization or a call to LoadLibrary. |
60 | */ |
61 | case DLL_PROCESS_ATTACH: |
62 | /* #define DEFAULT_BINMODE */ |
0a753a76 |
63 | #ifdef DEFAULT_BINMODE |
3e3baf6d |
64 | setmode( fileno( stdin ), O_BINARY ); |
65 | setmode( fileno( stdout ), O_BINARY ); |
66 | setmode( fileno( stderr ), O_BINARY ); |
67 | _fmode = O_BINARY; |
0a753a76 |
68 | #endif |
2d7a9237 |
69 | w32_perldll_handle = hModule; |
68dc0745 |
70 | break; |
0a753a76 |
71 | |
68dc0745 |
72 | /* The DLL is detaching from a process due to |
73 | * process termination or call to FreeLibrary. |
74 | */ |
75 | case DLL_PROCESS_DETACH: |
76 | break; |
0a753a76 |
77 | |
68dc0745 |
78 | /* The attached process creates a new thread. */ |
79 | case DLL_THREAD_ATTACH: |
80 | break; |
0a753a76 |
81 | |
68dc0745 |
82 | /* The thread of the attached process terminates. */ |
83 | case DLL_THREAD_DETACH: |
84 | break; |
0a753a76 |
85 | |
68dc0745 |
86 | default: |
87 | break; |
88 | } |
89 | return TRUE; |
0a753a76 |
90 | } |
8b10511d |
91 | |
92 | /* Register any extra external extensions */ |
93 | |
94 | char *staticlinkmodules[] = { |
95 | "DynaLoader", |
96 | NULL, |
97 | }; |
98 | |
99 | EXTERN_C void boot_DynaLoader _((CV* cv)); |
100 | |
8b10511d |
101 | static void |
102 | xs_init() |
103 | { |
104 | char *file = __FILE__; |
105 | dXSUB_SYS; |
106 | newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
8b10511d |
107 | } |
108 | |