Updated.
[p5sagit/p5-mst-13.2.git] / miniperlmain.c
1 /*
2  * "The Road goes ever on and on, down from the door where it began."
3  */
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 #include "EXTERN.h"
10 #include "perl.h"
11
12 #ifdef __cplusplus
13 }
14 #  define EXTERN_C extern "C"
15 #else
16 #  define EXTERN_C extern
17 #endif
18
19 static void xs_init _((void));
20 static PerlInterpreter *my_perl;
21
22 int
23 #ifndef CAN_PROTOTYPE
24 main(argc, argv, env)
25 int argc;
26 char **argv;
27 char **env;
28 #else  /* def(CAN_PROTOTYPE) */
29 main(int argc, char **argv, char **env)
30 #endif  /* def(CAN_PROTOTYPE) */
31 {
32     int exitstatus;
33
34 #ifdef OS2
35     _response(&argc, &argv);
36     _wildcard(&argc, &argv);
37 #endif
38
39 #ifdef VMS
40     getredirection(&argc,&argv);
41 #endif
42
43 #if defined(HAS_SETLOCALE) && defined(LC_CTYPE)
44     if (setlocale(LC_CTYPE, "") == NULL) {
45         fprintf(stderr,
46                "setlocale(LC_CTYPE, \"\") failed (LC_CTYPE = \"%s\").\n",
47                getenv("LC_CTYPE"));
48        exit(1);
49     }
50 #endif
51
52     if (!do_undump) {
53         my_perl = perl_alloc();
54         if (!my_perl)
55             exit(1);
56         perl_construct( my_perl );
57     }
58
59     exitstatus = perl_parse( my_perl, xs_init, argc, argv, NULL );
60     if (exitstatus)
61         exit( exitstatus );
62
63     exitstatus = perl_run( my_perl );
64
65     perl_destruct( my_perl );
66     perl_free( my_perl );
67
68     exit( exitstatus );
69 }
70
71 /* Register any extra external extensions */
72
73 /* Do not delete this line--writemain depends on it */
74
75 static void
76 xs_init()
77 {
78 }