3 * Copyright © 2001 Novell, Inc. All Rights Reserved.
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * FILENAME : perllib.c
12 * DESCRIPTION : Library functions for parsing and running Perl.
13 * This is based on the perllib.c file of Win32 port.
15 * Date : January 2001.
20 * "The Road goes ever on and on, down from the door where it began."
34 //Including this is giving premature end-of-file error during compilation
37 #ifdef PERL_IMPLICIT_SYS
42 #endif //PERL_IMPLICIT_SYS
45 #ifdef PERL_IMPLICIT_SYS
47 #include "nwperlhost.h"
48 #define w32_internal_host (PL_sys_intern.internal_host) // (J)
52 perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
53 struct IPerlMemInfo* perlMemSharedInfo,
54 struct IPerlMemInfo* perlMemParseInfo,
55 struct IPerlEnvInfo* perlEnvInfo,
56 struct IPerlStdIOInfo* perlStdIOInfo,
57 struct IPerlLIOInfo* perlLIOInfo,
58 struct IPerlDirInfo* perlDirInfo,
59 struct IPerlSockInfo* perlSockInfo,
60 struct IPerlProcInfo* perlProcInfo)
63 Copy(&perlMem, &perlMemInfo->perlMemList, perlMemInfo->nCount, void*);
64 perlMemInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
66 if (perlMemSharedInfo) {
67 Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*);
68 perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
70 if (perlMemParseInfo) {
71 Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*);
72 perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
75 Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*);
76 perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*));
79 Copy(&perlStdIO, &perlStdIOInfo->perlStdIOList, perlStdIOInfo->nCount, void*);
80 perlStdIOInfo->nCount = (sizeof(struct IPerlStdIO)/sizeof(void*));
83 Copy(&perlLIO, &perlLIOInfo->perlLIOList, perlLIOInfo->nCount, void*);
84 perlLIOInfo->nCount = (sizeof(struct IPerlLIO)/sizeof(void*));
87 Copy(&perlDir, &perlDirInfo->perlDirList, perlDirInfo->nCount, void*);
88 perlDirInfo->nCount = (sizeof(struct IPerlDir)/sizeof(void*));
91 Copy(&perlSock, &perlSockInfo->perlSockList, perlSockInfo->nCount, void*);
92 perlSockInfo->nCount = (sizeof(struct IPerlSock)/sizeof(void*));
95 Copy(&perlProc, &perlProcInfo->perlProcList, perlProcInfo->nCount, void*);
96 perlProcInfo->nCount = (sizeof(struct IPerlProc)/sizeof(void*));
100 EXTERN_C PerlInterpreter*
101 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
102 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
103 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
104 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
105 struct IPerlProc** ppProc)
107 PerlInterpreter *my_perl = NULL;
108 CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv,
109 ppStdIO, ppLIO, ppDir, ppSock, ppProc);
112 my_perl = perl_alloc_using(pHost->m_pHostperlMem,
113 pHost->m_pHostperlMemShared,
114 pHost->m_pHostperlMemParse,
115 pHost->m_pHostperlEnv,
116 pHost->m_pHostperlStdIO,
117 pHost->m_pHostperlLIO,
118 pHost->m_pHostperlDir,
119 pHost->m_pHostperlSock,
120 pHost->m_pHostperlProc);
123 CPerlObj* pPerl = (CPerlObj*)my_perl;
125 w32_internal_host = pHost;
131 EXTERN_C PerlInterpreter*
134 PerlInterpreter* my_perl = NULL;
135 CPerlHost* pHost = new CPerlHost();
137 my_perl = perl_alloc_using(pHost->m_pHostperlMem,
138 pHost->m_pHostperlMemShared,
139 pHost->m_pHostperlMemParse,
140 pHost->m_pHostperlEnv,
141 pHost->m_pHostperlStdIO,
142 pHost->m_pHostperlLIO,
143 pHost->m_pHostperlDir,
144 pHost->m_pHostperlSock,
145 pHost->m_pHostperlProc);
148 CPerlObj* pPerl = (CPerlObj*)my_perl;
150 //The following Should be uncommented - CHKSGP
151 w32_internal_host = pHost;
158 nw_delete_internal_host(void *h)
160 CPerlHost *host = (CPerlHost*)h;
172 perl_construct(PerlInterpreter* my_perl)
174 CPerlObj* pPerl = (CPerlObj*)my_perl;
181 win32_fprintf(stderr, "%s\n",
182 "Error: Unable to construct data structures");
188 perl_destruct(PerlInterpreter* my_perl)
190 CPerlObj* pPerl = (CPerlObj*)my_perl;
205 perl_free(PerlInterpreter* my_perl)
207 CPerlObj* pPerl = (CPerlObj*)my_perl;
208 void *host = w32_internal_host;
220 win32_delete_internal_host(host);
225 perl_run(PerlInterpreter* my_perl)
227 CPerlObj* pPerl = (CPerlObj*)my_perl;
238 win32_fprintf(stderr, "Error: Runtime exception\n");
246 perl_parse(PerlInterpreter* my_perl, void (*xsinit)(CPerlObj*), int argc, char** argv, char** env)
249 CPerlObj* pPerl = (CPerlObj*)my_perl;
251 retVal = Perl_parse(xsinit, argc, argv, env);
255 retVal = Perl_parse(xsinit, argc, argv, env);
259 win32_fprintf(stderr, "Error: Parse exception\n");
267 #undef PL_perl_destruct_level
268 #define PL_perl_destruct_level int dummy
270 #endif /* PERL_OBJECT */
271 #endif /* PERL_IMPLICIT_SYS */