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