This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] Revert to keeping (some) constant strings as globals
[perl5.git] / win32 / perllib.c
CommitLineData
0a753a76
PP
1/*
2 * "The Road goes ever on and on, down from the door where it began."
3 */
4
0a753a76
PP
5
6#include "EXTERN.h"
7#include "perl.h"
96e4d5b1 8#include "XSUB.h"
0a753a76 9
0a753a76
PP
10static void xs_init _((void));
11
68dc0745
PP
12__declspec(dllexport) int
13RunPerl(int argc, char **argv, char **env, void *iosubsystem)
0a753a76 14{
68dc0745
PP
15 int exitstatus;
16 PerlInterpreter *my_perl;
0a753a76 17
22239a37
NIS
18#ifdef PERL_GLOBAL_STRUCT
19#define PERLVAR(var,type) /**/
20#define PERLVARI(var,type,init) Perl_Vars.var = init;
3fe35a81 21#define PERLVARIC(var,type,init) Perl_Vars.var = init;
22239a37
NIS
22#include "perlvars.h"
23#undef PERLVAR
24#undef PERLVARI
3fe35a81 25#undef PERLVARIC
22239a37
NIS
26#endif
27
0a753a76
PP
28 PERL_SYS_INIT(&argc,&argv);
29
30 perl_init_i18nl10n(1);
31
68dc0745
PP
32 if (!(my_perl = perl_alloc()))
33 return (1);
34 perl_construct( my_perl );
35 perl_destruct_level = 0;
0a753a76
PP
36
37 exitstatus = perl_parse( my_perl, xs_init, argc, argv, env);
38 if (!exitstatus) {
39 exitstatus = perl_run( my_perl );
40 }
41
0a753a76
PP
42 perl_destruct( my_perl );
43 perl_free( my_perl );
44
45 PERL_SYS_TERM();
46
68dc0745 47 return (exitstatus);
0a753a76
PP
48}
49
0a753a76
PP
50extern HANDLE PerlDllHandle;
51
68dc0745
PP
52BOOL APIENTRY
53DllMain(HANDLE hModule, /* DLL module handle */
54 DWORD fdwReason, /* reason called */
55 LPVOID lpvReserved) /* reserved */
0a753a76 56{
68dc0745
PP
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
TB
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
68dc0745
PP
69 PerlDllHandle = hModule;
70 break;
0a753a76 71
68dc0745
PP
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
PP
78 /* The attached process creates a new thread. */
79 case DLL_THREAD_ATTACH:
80 break;
0a753a76 81
68dc0745
PP
82 /* The thread of the attached process terminates. */
83 case DLL_THREAD_DETACH:
84 break;
0a753a76 85
68dc0745
PP
86 default:
87 break;
88 }
89 return TRUE;
0a753a76 90}
8b10511d
GS
91
92/* Register any extra external extensions */
93
94char *staticlinkmodules[] = {
95 "DynaLoader",
96 NULL,
97};
98
99EXTERN_C void boot_DynaLoader _((CV* cv));
100
8b10511d
GS
101static void
102xs_init()
103{
104 char *file = __FILE__;
105 dXSUB_SYS;
106 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
8b10511d
GS
107}
108