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