This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix a few places that said 'int', but meant 'STRLEN'
[perl5.git] / win32 / perllib.c
1 /*
2  * "The Road goes ever on and on, down from the door where it began."
3  */
4
5
6 #include "EXTERN.h"
7 #include "perl.h"
8 #include "XSUB.h"
9
10 static void xs_init _((void));
11
12 DllExport int
13 RunPerl(int argc, char **argv, char **env, void *iosubsystem)
14 {
15     int exitstatus;
16     PerlInterpreter *my_perl;
17
18 #ifdef PERL_GLOBAL_STRUCT
19 #define PERLVAR(var,type) /**/
20 #define PERLVARI(var,type,init) PL_Vars.var = init;
21 #define PERLVARIC(var,type,init) PL_Vars.var = init;
22 #include "perlvars.h"
23 #undef PERLVAR
24 #undef PERLVARI
25 #undef PERLVARIC
26 #endif
27
28     PERL_SYS_INIT(&argc,&argv);
29
30     perl_init_i18nl10n(1);
31
32     if (!(my_perl = perl_alloc()))
33         return (1);
34     perl_construct( my_perl );
35     PL_perl_destruct_level = 0;
36
37     exitstatus = perl_parse( my_perl, xs_init, argc, argv, env);
38     if (!exitstatus) {
39         exitstatus = perl_run( my_perl );
40     }
41
42     perl_destruct( my_perl );
43     perl_free( my_perl );
44
45     PERL_SYS_TERM();
46
47     return (exitstatus);
48 }
49
50 extern HANDLE w32_perldll_handle;
51
52 BOOL APIENTRY
53 DllMain(HANDLE hModule,         /* DLL module handle */
54         DWORD fdwReason,        /* reason called */
55         LPVOID lpvReserved)     /* reserved */
56
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 */
63 #ifdef DEFAULT_BINMODE
64         setmode( fileno( stdin  ), O_BINARY );
65         setmode( fileno( stdout ), O_BINARY );
66         setmode( fileno( stderr ), O_BINARY );
67         _fmode = O_BINARY;
68 #endif
69         w32_perldll_handle = hModule;
70         break;
71
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;
77
78         /* The attached process creates a new thread. */
79     case DLL_THREAD_ATTACH:
80         break;
81
82         /* The thread of the attached process terminates. */
83     case DLL_THREAD_DETACH:
84         break;
85
86     default:
87         break;
88     }
89     return TRUE;
90 }
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
101 static void
102 xs_init()
103 {
104     char *file = __FILE__;
105     dXSUB_SYS;
106     newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
107 }
108