import source from 1.3.40
[external/swig.git] / Lib / perl5 / perlmain.i
1 /* -----------------------------------------------------------------------------
2  * See the LICENSE file for information on copyright, usage and redistribution
3  * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4  *
5  * perlmain.i
6  *
7  * Code to statically rebuild perl5.
8  * ----------------------------------------------------------------------------- */
9
10 #ifdef AUTODOC
11 %subsection "perlmain.i"
12 %text %{
13 This module provides support for building a new version of the
14 Perl executable.  This will be necessary on systems that do
15 not support shared libraries and may be necessary with C++
16 extensions.  
17
18 This module may only build a stripped down version of the
19 Perl executable.   Thus, it may be necessary (or desirable)
20 to hand-edit this file for your particular application.  To
21 do this, simply copy this file from swig_lib/perl5/perlmain.i
22 to your working directory and make the appropriate modifications.
23
24 This library file works with Perl 5.003.  It may work with earlier
25 versions, but it hasn't been tested.  As far as I know, this
26 library is C++ safe.
27 %}
28 #endif
29
30 %{
31
32 static void xs_init _((pTHX));
33 static PerlInterpreter *my_perl;
34
35 int perl_eval(char *string) {
36   char *argv[2];
37   argv[0] = string;
38   argv[1] = (char *) 0;
39   return perl_call_argv("eval",0,argv);
40 }
41
42 int
43 main(int argc, char **argv, char **env)
44 {
45     int exitstatus;
46
47     my_perl = perl_alloc();
48     if (!my_perl)
49        exit(1);
50     perl_construct( my_perl );
51
52     exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
53     if (exitstatus)
54         exit( exitstatus );
55
56     /* Initialize all of the module variables */
57
58     exitstatus = perl_run( my_perl );
59
60     perl_destruct( my_perl );
61     perl_free( my_perl );
62
63     exit( exitstatus );
64 }
65
66 /* Register any extra external extensions */
67
68 /* Do not delete this line--writemain depends on it */
69 /* EXTERN_C void boot_DynaLoader _((CV* cv)); */
70
71 static void
72 xs_init(pTHX)
73 {
74 /*  dXSUB_SYS; */
75     char *file = __FILE__;
76     {
77       /*        newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */
78         newXS(SWIG_name, SWIG_init, file);
79 #ifdef SWIGMODINIT
80         SWIGMODINIT
81 #endif
82     }
83 }
84
85 %}