| 1 | /*
|
|---|
| 2 | * "The Road goes ever on and on, down from the door where it began."
|
|---|
| 3 | */
|
|---|
| 4 | #define PERLIO_NOT_STDIO 0
|
|---|
| 5 | #include "EXTERN.h"
|
|---|
| 6 | #include "perl.h"
|
|---|
| 7 |
|
|---|
| 8 | #include "XSUB.h"
|
|---|
| 9 |
|
|---|
| 10 | #ifdef PERL_IMPLICIT_SYS
|
|---|
| 11 | #include "win32iop.h"
|
|---|
| 12 | #include <fcntl.h>
|
|---|
| 13 | #endif /* PERL_IMPLICIT_SYS */
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | /* Register any extra external extensions */
|
|---|
| 17 | char *staticlinkmodules[] = {
|
|---|
| 18 | "DynaLoader",
|
|---|
| 19 | /* other similar records will be included from "perllibst.h" */
|
|---|
| 20 | #define STATIC1
|
|---|
| 21 | #include "perllibst.h"
|
|---|
| 22 | NULL,
|
|---|
| 23 | };
|
|---|
| 24 |
|
|---|
| 25 | EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
|
|---|
| 26 | /* other similar records will be included from "perllibst.h" */
|
|---|
| 27 | #define STATIC2
|
|---|
| 28 | #include "perllibst.h"
|
|---|
| 29 |
|
|---|
| 30 | static void
|
|---|
| 31 | xs_init(pTHX)
|
|---|
| 32 | {
|
|---|
| 33 | char *file = __FILE__;
|
|---|
| 34 | dXSUB_SYS;
|
|---|
| 35 | newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
|
|---|
| 36 | /* other similar records will be included from "perllibst.h" */
|
|---|
| 37 | #define STATIC3
|
|---|
| 38 | #include "perllibst.h"
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | #ifdef PERL_IMPLICIT_SYS
|
|---|
| 42 |
|
|---|
| 43 | #include "perlhost.h"
|
|---|
| 44 |
|
|---|
| 45 | void
|
|---|
| 46 | win32_checkTLS(PerlInterpreter *host_perl)
|
|---|
| 47 | {
|
|---|
| 48 | dTHX;
|
|---|
| 49 | if (host_perl != my_perl) {
|
|---|
| 50 | int *nowhere = NULL;
|
|---|
| 51 | *nowhere = 0;
|
|---|
| 52 | abort();
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | EXTERN_C void
|
|---|
| 57 | perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
|
|---|
| 58 | struct IPerlMemInfo* perlMemSharedInfo,
|
|---|
| 59 | struct IPerlMemInfo* perlMemParseInfo,
|
|---|
| 60 | struct IPerlEnvInfo* perlEnvInfo,
|
|---|
| 61 | struct IPerlStdIOInfo* perlStdIOInfo,
|
|---|
| 62 | struct IPerlLIOInfo* perlLIOInfo,
|
|---|
| 63 | struct IPerlDirInfo* perlDirInfo,
|
|---|
| 64 | struct IPerlSockInfo* perlSockInfo,
|
|---|
| 65 | struct IPerlProcInfo* perlProcInfo)
|
|---|
| 66 | {
|
|---|
| 67 | if (perlMemInfo) {
|
|---|
| 68 | Copy(&perlMem, &perlMemInfo->perlMemList, perlMemInfo->nCount, void*);
|
|---|
| 69 | perlMemInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
|
|---|
| 70 | }
|
|---|
| 71 | if (perlMemSharedInfo) {
|
|---|
| 72 | Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*);
|
|---|
| 73 | perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
|
|---|
| 74 | }
|
|---|
| 75 | if (perlMemParseInfo) {
|
|---|
| 76 | Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*);
|
|---|
| 77 | perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
|
|---|
| 78 | }
|
|---|
| 79 | if (perlEnvInfo) {
|
|---|
| 80 | Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*);
|
|---|
| 81 | perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*));
|
|---|
| 82 | }
|
|---|
| 83 | if (perlStdIOInfo) {
|
|---|
| 84 | Copy(&perlStdIO, &perlStdIOInfo->perlStdIOList, perlStdIOInfo->nCount, void*);
|
|---|
| 85 | perlStdIOInfo->nCount = (sizeof(struct IPerlStdIO)/sizeof(void*));
|
|---|
| 86 | }
|
|---|
| 87 | if (perlLIOInfo) {
|
|---|
| 88 | Copy(&perlLIO, &perlLIOInfo->perlLIOList, perlLIOInfo->nCount, void*);
|
|---|
| 89 | perlLIOInfo->nCount = (sizeof(struct IPerlLIO)/sizeof(void*));
|
|---|
| 90 | }
|
|---|
| 91 | if (perlDirInfo) {
|
|---|
| 92 | Copy(&perlDir, &perlDirInfo->perlDirList, perlDirInfo->nCount, void*);
|
|---|
| 93 | perlDirInfo->nCount = (sizeof(struct IPerlDir)/sizeof(void*));
|
|---|
| 94 | }
|
|---|
| 95 | if (perlSockInfo) {
|
|---|
| 96 | Copy(&perlSock, &perlSockInfo->perlSockList, perlSockInfo->nCount, void*);
|
|---|
| 97 | perlSockInfo->nCount = (sizeof(struct IPerlSock)/sizeof(void*));
|
|---|
| 98 | }
|
|---|
| 99 | if (perlProcInfo) {
|
|---|
| 100 | Copy(&perlProc, &perlProcInfo->perlProcList, perlProcInfo->nCount, void*);
|
|---|
| 101 | perlProcInfo->nCount = (sizeof(struct IPerlProc)/sizeof(void*));
|
|---|
| 102 | }
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | EXTERN_C PerlInterpreter*
|
|---|
| 106 | perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
|
|---|
| 107 | struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
|
|---|
| 108 | struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
|
|---|
| 109 | struct IPerlDir** ppDir, struct IPerlSock** ppSock,
|
|---|
| 110 | struct IPerlProc** ppProc)
|
|---|
| 111 | {
|
|---|
| 112 | PerlInterpreter *my_perl = NULL;
|
|---|
| 113 | CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv,
|
|---|
| 114 | ppStdIO, ppLIO, ppDir, ppSock, ppProc);
|
|---|
| 115 |
|
|---|
| 116 | if (pHost) {
|
|---|
| 117 | my_perl = perl_alloc_using(pHost->m_pHostperlMem,
|
|---|
| 118 | pHost->m_pHostperlMemShared,
|
|---|
| 119 | pHost->m_pHostperlMemParse,
|
|---|
| 120 | pHost->m_pHostperlEnv,
|
|---|
| 121 | pHost->m_pHostperlStdIO,
|
|---|
| 122 | pHost->m_pHostperlLIO,
|
|---|
| 123 | pHost->m_pHostperlDir,
|
|---|
| 124 | pHost->m_pHostperlSock,
|
|---|
| 125 | pHost->m_pHostperlProc);
|
|---|
| 126 | if (my_perl) {
|
|---|
| 127 | w32_internal_host = pHost;
|
|---|
| 128 | pHost->host_perl = my_perl;
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 | return my_perl;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | EXTERN_C PerlInterpreter*
|
|---|
| 135 | perl_alloc(void)
|
|---|
| 136 | {
|
|---|
| 137 | PerlInterpreter* my_perl = NULL;
|
|---|
| 138 | CPerlHost* pHost = new CPerlHost();
|
|---|
| 139 | if (pHost) {
|
|---|
| 140 | my_perl = perl_alloc_using(pHost->m_pHostperlMem,
|
|---|
| 141 | pHost->m_pHostperlMemShared,
|
|---|
| 142 | pHost->m_pHostperlMemParse,
|
|---|
| 143 | pHost->m_pHostperlEnv,
|
|---|
| 144 | pHost->m_pHostperlStdIO,
|
|---|
| 145 | pHost->m_pHostperlLIO,
|
|---|
| 146 | pHost->m_pHostperlDir,
|
|---|
| 147 | pHost->m_pHostperlSock,
|
|---|
| 148 | pHost->m_pHostperlProc);
|
|---|
| 149 | if (my_perl) {
|
|---|
| 150 | w32_internal_host = pHost;
|
|---|
| 151 | pHost->host_perl = my_perl;
|
|---|
| 152 | }
|
|---|
| 153 | }
|
|---|
| 154 | return my_perl;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | EXTERN_C void
|
|---|
| 158 | win32_delete_internal_host(void *h)
|
|---|
| 159 | {
|
|---|
| 160 | CPerlHost *host = (CPerlHost*)h;
|
|---|
| 161 | delete host;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | #endif /* PERL_IMPLICIT_SYS */
|
|---|
| 165 |
|
|---|
| 166 | EXTERN_C HANDLE w32_perldll_handle;
|
|---|
| 167 |
|
|---|
| 168 | EXTERN_C DllExport int
|
|---|
| 169 | RunPerl(int argc, char **argv, char **env)
|
|---|
| 170 | {
|
|---|
| 171 | int exitstatus;
|
|---|
| 172 | PerlInterpreter *my_perl, *new_perl = NULL;
|
|---|
| 173 |
|
|---|
| 174 | #ifndef __BORLANDC__
|
|---|
| 175 | /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
|
|---|
| 176 | * want to free() argv after main() returns. As luck would have it,
|
|---|
| 177 | * Borland's CRT does the right thing to argv[0] already. */
|
|---|
| 178 | char szModuleName[MAX_PATH];
|
|---|
| 179 |
|
|---|
| 180 | GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
|
|---|
| 181 | (void)win32_longpath(szModuleName);
|
|---|
| 182 | argv[0] = szModuleName;
|
|---|
| 183 | #endif
|
|---|
| 184 |
|
|---|
| 185 | #ifdef PERL_GLOBAL_STRUCT
|
|---|
| 186 | #define PERLVAR(var,type) /**/
|
|---|
|
|---|