|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <Windows.h>
#include <shlobj.h>
#ifndef CSIDL_APPDATA
#define CSIDL_APPDATA 0x001a
#endif
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
EXTERN_C void xs_init (pTHX);
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_Win32CORE (pTHX_ CV* cv);
EXTERN_C void
xs_init(pTHX)
{
static const char file[] = __FILE__;
dXSUB_SYS;
PERL_UNUSED_CONTEXT;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Win32CORE::bootstrap", boot_Win32CORE, file);
}
int main( int argc , char **argv , char **env )
{
// shift argv and force parameters
int num_forced_parameters = 4;
argc += num_forced_parameters;
int i;
for(i=argc-1;i>num_forced_parameters;i--){
argv[i]=argv[i-num_forced_parameters];
}
//argv[0] stores the relative path of the executable
argv[1] = "-Ilib";
argv[2] = "-Isite/lib";
argv[3] = "-Ivendor/lib";
//Construct absolute path to script so exe can be launched from anywhere.
char script = "\\FileMorph_App\\filemorph\\filemorph.pl\0";
char appdata = "";
BOOL ok = SHGetSpecialFolderPath(NULL, appdata, CSIDL_APPDATA, TRUE);
char path; //strlen(appdata) + strlen(script)];
strcpy(path, appdata);
strcat(path, script);
argv[4] = path;
PERL_SYS_INIT3( &argc , &argv , &env );
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse( my_perl , xs_init , argc , argv , (char **)NULL );
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run( my_perl );
perl_destruct( my_perl );
perl_free( my_perl );
PERL_SYS_TERM();
return 0;
}
|