This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gutsupport for C++ exceptions
[perl5.git] / win32 / runperl.c
... / ...
CommitLineData
1#include "EXTERN.h"
2#include "perl.h"
3
4#ifdef PERL_OBJECT
5
6#define NO_XSLOCKS
7#include "XSUB.H"
8#include "win32iop.h"
9
10#include <fcntl.h>
11#include "perlhost.h"
12
13
14char *staticlinkmodules[] = {
15 "DynaLoader",
16 NULL,
17};
18
19EXTERN_C void boot_DynaLoader _((CV* cv _CPERLarg));
20
21static void
22xs_init(CPERLarg)
23{
24 char *file = __FILE__;
25 dXSUB_SYS;
26 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
27}
28
29CPerlObj *pPerl;
30
31#undef PERL_SYS_INIT
32#define PERL_SYS_INIT(a, c)
33
34int
35main(int argc, char **argv, char **env)
36{
37 CPerlHost host;
38 int exitstatus = 1;
39#ifndef __BORLANDC__
40 /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
41 * want to free() argv after main() returns. As luck would have it,
42 * Borland's CRT does the right thing to argv[0] already. */
43 char szModuleName[MAX_PATH];
44 char *ptr;
45
46 GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
47 (void)win32_longpath(szModuleName);
48 argv[0] = szModuleName;
49#endif
50
51 if (!host.PerlCreate())
52 exit(exitstatus);
53
54 exitstatus = host.PerlParse(xs_init, argc, argv, NULL);
55
56 if (!exitstatus)
57 exitstatus = host.PerlRun();
58
59 host.PerlDestroy();
60
61 return exitstatus;
62}
63
64#else /* PERL_OBJECT */
65
66#ifdef __GNUC__
67/*
68 * GNU C does not do __declspec()
69 */
70#define __declspec(foo)
71
72/* Mingw32 defaults to globing command line
73 * This is inconsistent with other Win32 ports and
74 * seems to cause trouble with passing -DXSVERSION=\"1.6\"
75 * So we turn it off like this:
76 */
77int _CRT_glob = 0;
78
79#endif
80
81
82__declspec(dllimport) int RunPerl(int argc, char **argv, char **env, void *ios);
83
84int
85main(int argc, char **argv, char **env)
86{
87#ifndef __BORLANDC__
88 /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
89 * want to free() argv after main() returns. As luck would have it,
90 * Borland's CRT does the right thing to argv[0] already. */
91 char szModuleName[MAX_PATH];
92 char *ptr;
93
94 GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
95 (void)win32_longpath(szModuleName);
96 argv[0] = szModuleName;
97#endif
98 return RunPerl(argc, argv, env, (void*)0);
99}
100
101#endif /* PERL_OBJECT */