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