extra code in pp_concat, Take 2
[p5sagit/p5-mst-13.2.git] / NetWare / nwperlhost.h
CommitLineData
011f1a1a 1
2/*
3 * Copyright © 2001 Novell, Inc. All Rights Reserved.
4 *
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.
7 *
8 */
9
10/*
11 * FILENAME : nwperlhost.h
12 * DESCRIPTION : This is modelled on the perlhost.h module of Win32 port.
13 * This is the host that include all the functions for running Perl within a class.
14 * Author : SGP, HYAK
15 * Date : January 2001.
16 *
17 */
18
19
20
21#ifndef ___NWPerlHost_H___
22#define ___NWPerlHost_H___
23
24
25#include "iperlsys.h"
26#include "nwvmem.h"
27
28#include "nw5sck.h"
29#include "netware.h"
30
31#define LPBYTE unsigned char *
32
33#if !defined(PERL_OBJECT)
34START_EXTERN_C
35#endif /* PERL_OBJECT */
36
37extern int do_spawn2(char *cmd, int exectype);
38extern int do_aspawn(void *vreally, void **vmark, void **vsp);
39extern void Perl_init_os_extras(void);
40
41#if !defined(PERL_OBJECT)
42END_EXTERN_C
43#endif /* PERL_OBJECT */
44
45#ifdef PERL_OBJECT
46extern int g_do_aspawn(void *vreally, void **vmark, void **vsp);
47#define do_aspawn g_do_aspawn
48#endif /* PERL_OBJECT */
49
50class CPerlHost
51{
52public:
53 CPerlHost(void);
54 CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
55 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
56 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
57 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
58 struct IPerlProc** ppProc);
59 CPerlHost(const CPerlHost& host);
60 virtual ~CPerlHost(void);
61
62 static CPerlHost* IPerlMem2Host(struct IPerlMem* piPerl);
63 static CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl);
64 static CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl);
65 static CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl);
66 static CPerlHost* IPerlStdIO2Host(struct IPerlStdIO* piPerl);
67 static CPerlHost* IPerlLIO2Host(struct IPerlLIO* piPerl);
68 static CPerlHost* IPerlDir2Host(struct IPerlDir* piPerl);
69 static CPerlHost* IPerlSock2Host(struct IPerlSock* piPerl);
70 static CPerlHost* IPerlProc2Host(struct IPerlProc* piPerl);
71
72/* IPerlMem */
73 inline void* Malloc(size_t size) { return m_pVMem->Malloc(size); };
74 inline void* Realloc(void* ptr, size_t size) { return m_pVMem->Realloc(ptr, size); };
75 inline void Free(void* ptr) { m_pVMem->Free(ptr); };
76 inline void* Calloc(size_t num, size_t size){ return m_pVMem->Calloc(num, size); };
77
78/* IPerlMemShared */
79 inline void* MallocShared(size_t size)
80 {
81 return m_pVMemShared->Malloc(size);
82 };
83 inline void* ReallocShared(void* ptr, size_t size) { return m_pVMemShared->Realloc(ptr, size); };
84 inline void FreeShared(void* ptr) { m_pVMemShared->Free(ptr); };
85 inline void* CallocShared(size_t num, size_t size)
86 {
87 size_t count = num*size;
88 void* lpVoid = MallocShared(count);
89
90 return lpVoid;
91 };
92
93/* IPerlMemParse */
94 inline void* MallocParse(size_t size) { return m_pVMemParse->Malloc(size); };
95 inline void* ReallocParse(void* ptr, size_t size) { return m_pVMemParse->Realloc(ptr, size); };
96 inline void FreeParse(void* ptr) { m_pVMemParse->Free(ptr); };
97 inline void* CallocParse(size_t num, size_t size)
98 {
99 size_t count = num*size;
100 void* lpVoid = MallocParse(count);
101
102 return lpVoid;
103 };
104
105/* IPerlEnv */
106 char *Getenv(const char *varname);
107 int Putenv(const char *envstring);
108 inline char *Getenv(const char *varname, unsigned long *len)
109 {
110 *len = 0;
111 char *e = Getenv(varname);
112 if (e)
113 *len = strlen(e);
114 return e;
115 }
116
117
118public:
119
120/* IPerlDIR */
121
122
123/* IPerllProc */
124 void Abort(void);
125 void Exit(int status);
126 void _Exit(int status);
127 int Execl(const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3);
128 int Execv(const char *cmdname, const char *const *argv);
129 int Execvp(const char *cmdname, const char *const *argv);
130
131public:
132
133 struct IPerlMem m_hostperlMem;
134 struct IPerlMem m_hostperlMemShared;
135 struct IPerlMem m_hostperlMemParse;
136 struct IPerlEnv m_hostperlEnv;
137 struct IPerlStdIO m_hostperlStdIO;
138 struct IPerlLIO m_hostperlLIO;
139 struct IPerlDir m_hostperlDir;
140 struct IPerlSock m_hostperlSock;
141 struct IPerlProc m_hostperlProc;
142
143 struct IPerlMem* m_pHostperlMem;
144 struct IPerlMem* m_pHostperlMemShared;
145 struct IPerlMem* m_pHostperlMemParse;
146 struct IPerlEnv* m_pHostperlEnv;
147 struct IPerlStdIO* m_pHostperlStdIO;
148 struct IPerlLIO* m_pHostperlLIO;
149 struct IPerlDir* m_pHostperlDir;
150 struct IPerlSock* m_pHostperlSock;
151 struct IPerlProc* m_pHostperlProc;
152
153protected:
154
155 VMem* m_pVMem;
156 VMem* m_pVMemShared;
157 VMem* m_pVMemParse;
158};
159
160
161#define STRUCT2PTR(x, y) (CPerlHost*)(((LPBYTE)x)-offsetof(CPerlHost, y))
162
163inline CPerlHost* IPerlMem2Host(struct IPerlMem* piPerl)
164{
165 return STRUCT2PTR(piPerl, m_hostperlMem);
166}
167
168inline CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl)
169{
170 return STRUCT2PTR(piPerl, m_hostperlMemShared);
171}
172
173inline CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl)
174{
175 return STRUCT2PTR(piPerl, m_hostperlMemParse);
176}
177
178inline CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl)
179{
180 return STRUCT2PTR(piPerl, m_hostperlEnv);
181}
182
183inline CPerlHost* IPerlStdIO2Host(struct IPerlStdIO* piPerl)
184{
185 return STRUCT2PTR(piPerl, m_hostperlStdIO);
186}
187
188inline CPerlHost* IPerlLIO2Host(struct IPerlLIO* piPerl)
189{
190 return STRUCT2PTR(piPerl, m_hostperlLIO);
191}
192
193inline CPerlHost* IPerlDir2Host(struct IPerlDir* piPerl)
194{
195 return STRUCT2PTR(piPerl, m_hostperlDir);
196}
197
198inline CPerlHost* IPerlSock2Host(struct IPerlSock* piPerl)
199{
200 return STRUCT2PTR(piPerl, m_hostperlSock);
201}
202
203inline CPerlHost* IPerlProc2Host(struct IPerlProc* piPerl)
204{
205 return STRUCT2PTR(piPerl, m_hostperlProc);
206}
207
208
209#undef IPERL2HOST
210#define IPERL2HOST(x) IPerlMem2Host(x)
211
212
213/* IPerlMem */
214void*
215PerlMemMalloc(struct IPerlMem* piPerl, size_t size)
216{
217 return IPERL2HOST(piPerl)->Malloc(size);
218}
219void*
220PerlMemRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
221{
222 return IPERL2HOST(piPerl)->Realloc(ptr, size);
223}
224void
225PerlMemFree(struct IPerlMem* piPerl, void* ptr)
226{
227 IPERL2HOST(piPerl)->Free(ptr);
228}
229void*
230PerlMemCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
231{
232 return IPERL2HOST(piPerl)->Calloc(num, size);
233}
234
235
236struct IPerlMem perlMem =
237{
238 PerlMemMalloc,
239 PerlMemRealloc,
240 PerlMemFree,
241 PerlMemCalloc,
242};
243
244#undef IPERL2HOST
245#define IPERL2HOST(x) IPerlMemShared2Host(x)
246
247/* IPerlMemShared */
248void*
249PerlMemSharedMalloc(struct IPerlMem* piPerl, size_t size)
250{
251 return IPERL2HOST(piPerl)->MallocShared(size);
252}
253void*
254PerlMemSharedRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
255{
256 return IPERL2HOST(piPerl)->ReallocShared(ptr, size);
257}
258void
259PerlMemSharedFree(struct IPerlMem* piPerl, void* ptr)
260{
261 IPERL2HOST(piPerl)->FreeShared(ptr);
262}
263void*
264PerlMemSharedCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
265{
266 return IPERL2HOST(piPerl)->CallocShared(num, size);
267}
268
269
270struct IPerlMem perlMemShared =
271{
272 PerlMemSharedMalloc,
273 PerlMemSharedRealloc,
274 PerlMemSharedFree,
275 PerlMemSharedCalloc,
276};
277
278#undef IPERL2HOST
279#define IPERL2HOST(x) IPerlMemParse2Host(x)
280
281/* IPerlMemParse */
282void*
283PerlMemParseMalloc(struct IPerlMem* piPerl, size_t size)
284{
285 return IPERL2HOST(piPerl)->MallocParse(size);
286}
287void*
288PerlMemParseRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
289{
290 return IPERL2HOST(piPerl)->ReallocParse(ptr, size);
291}
292void
293PerlMemParseFree(struct IPerlMem* piPerl, void* ptr)
294{
295 IPERL2HOST(piPerl)->FreeParse(ptr);
296}
297void*
298PerlMemParseCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
299{
300 return IPERL2HOST(piPerl)->CallocParse(num, size);
301}
302
303
304struct IPerlMem perlMemParse =
305{
306 PerlMemParseMalloc,
307 PerlMemParseRealloc,
308 PerlMemParseFree,
309 PerlMemParseCalloc,
310};
311
312
313#undef IPERL2HOST
314#define IPERL2HOST(x) IPerlEnv2Host(x)
315
316/* IPerlEnv */
317char*
318PerlEnvGetenv(struct IPerlEnv* piPerl, const char *varname)
319{
320 return IPERL2HOST(piPerl)->Getenv(varname);
321};
322
323int
324PerlEnvPutenv(struct IPerlEnv* piPerl, const char *envstring)
325{
326 return IPERL2HOST(piPerl)->Putenv(envstring);
327};
328
329char*
330PerlEnvGetenv_len(struct IPerlEnv* piPerl, const char* varname, unsigned long* len)
331{
332 return IPERL2HOST(piPerl)->Getenv(varname, len);
333}
334
335int
336PerlEnvUname(struct IPerlEnv* piPerl, struct utsname *name)
337{
338 return nw_uname(name);
339}
340
341void
342PerlEnvClearenv(struct IPerlEnv* piPerl)
343{
344 // If removed, compilation fails while compiling CGI2Perl.
345}
346
347void*
348PerlEnvGetChildenv(struct IPerlEnv* piPerl)
349{
350 // If removed, compilation fails while compiling CGI2Perl.
351 return NULL;
352}
353
354void
355PerlEnvFreeChildenv(struct IPerlEnv* piPerl, void* childEnv)
356{
357 // If removed, compilation fails while compiling CGI2Perl.
358}
359
360char*
361PerlEnvGetChilddir(struct IPerlEnv* piPerl)
362{
363 // If removed, compilation fails while compiling CGI2Perl.
364 return NULL;
365}
366
367void
368PerlEnvFreeChilddir(struct IPerlEnv* piPerl, char* childDir)
369{
370 // If removed, compilation fails while compiling CGI2Perl.
371}
372
373struct IPerlEnv perlEnv =
374{
375 PerlEnvGetenv,
376 PerlEnvPutenv,
377 PerlEnvGetenv_len,
378 PerlEnvUname,
379 PerlEnvClearenv,
380 PerlEnvGetChildenv,
381 PerlEnvFreeChildenv,
382 PerlEnvGetChilddir,
383 PerlEnvFreeChilddir,
384};
385
386#undef IPERL2HOST
387#define IPERL2HOST(x) IPerlStdIO2Host(x)
388
389/* PerlStdIO */
390PerlIO*
391PerlStdIOStdin(struct IPerlStdIO* piPerl)
392{
393 return (PerlIO*)nw_stdin();
394}
395
396PerlIO*
397PerlStdIOStdout(struct IPerlStdIO* piPerl)
398{
399 return (PerlIO*)nw_stdout();
400}
401
402PerlIO*
403PerlStdIOStderr(struct IPerlStdIO* piPerl)
404{
405 return (PerlIO*)nw_stderr();
406}
407
408PerlIO*
409PerlStdIOOpen(struct IPerlStdIO* piPerl, const char *path, const char *mode)
410{
411 return (PerlIO*)nw_fopen(path, mode);
412}
413
414int
415PerlStdIOClose(struct IPerlStdIO* piPerl, PerlIO* pf)
416{
417 return nw_fclose(((FILE*)pf));
418}
419
420int
421PerlStdIOEof(struct IPerlStdIO* piPerl, PerlIO* pf)
422{
423 return nw_feof((FILE*)pf);
424}
425
426int
427PerlStdIOError(struct IPerlStdIO* piPerl, PerlIO* pf)
428{
429 return nw_ferror((FILE*)pf);
430}
431
432void
433PerlStdIOClearerr(struct IPerlStdIO* piPerl, PerlIO* pf)
434{
435 nw_clearerr((FILE*)pf);
436}
437
438int
439PerlStdIOGetc(struct IPerlStdIO* piPerl, PerlIO* pf)
440{
441 return nw_getc((FILE*)pf);
442}
443
444char*
445PerlStdIOGetBase(struct IPerlStdIO* piPerl, PerlIO* pf)
446{
447#ifdef FILE_base
448 FILE *f = (FILE*)pf;
449 return FILE_base(f);
450#else
451 return Nullch;
452#endif
453}
454
455int
456PerlStdIOGetBufsiz(struct IPerlStdIO* piPerl, PerlIO* pf)
457{
458#ifdef FILE_bufsiz
459 FILE *f = (FILE*)pf;
460 return FILE_bufsiz(f);
461#else
462 return (-1);
463#endif
464}
465
466int
467PerlStdIOGetCnt(struct IPerlStdIO* piPerl, PerlIO* pf)
468{
469#ifdef USE_STDIO_PTR
470 FILE *f = (FILE*)pf;
471 return FILE_cnt(f);
472#else
473 return (-1);
474#endif
475}
476
477char*
478PerlStdIOGetPtr(struct IPerlStdIO* piPerl, PerlIO* pf)
479{
480#ifdef USE_STDIO_PTR
481 FILE *f = (FILE*)pf;
482 return FILE_ptr(f);
483#else
484 return Nullch;
485#endif
486}
487
488char*
489PerlStdIOGets(struct IPerlStdIO* piPerl, PerlIO* pf, char* s, int n)
490{
491 return nw_fgets(s, n, (FILE*)pf);
492}
493
494int
495PerlStdIOPutc(struct IPerlStdIO* piPerl, PerlIO* pf, int c)
496{
497 return nw_fputc(c, (FILE*)pf);
498}
499
500int
501PerlStdIOPuts(struct IPerlStdIO* piPerl, PerlIO* pf, const char *s)
502{
503 return nw_fputs(s, (FILE*)pf);
504}
505
506int
507PerlStdIOFlush(struct IPerlStdIO* piPerl, PerlIO* pf)
508{
509 return nw_fflush((FILE*)pf);
510}
511
512int
513PerlStdIOUngetc(struct IPerlStdIO* piPerl, int c, PerlIO* pf) //(J)
514{
515 return nw_ungetc(c, (FILE*)pf);
516}
517
518int
519PerlStdIOFileno(struct IPerlStdIO* piPerl, PerlIO* pf)
520{
521 return nw_fileno((FILE*)pf);
522}
523
524PerlIO*
525PerlStdIOFdopen(struct IPerlStdIO* piPerl, int fd, const char *mode)
526{
527 return (PerlIO*)nw_fdopen(fd, mode);
528}
529
530PerlIO*
531PerlStdIOReopen(struct IPerlStdIO* piPerl, const char*path, const char*mode, PerlIO* pf)
532{
533 return (PerlIO*)nw_freopen(path, mode, (FILE*)pf);
534}
535
536SSize_t
537PerlStdIORead(struct IPerlStdIO* piPerl, void *buffer, Size_t size, Size_t dummy, PerlIO* pf)
538{
539 return nw_fread(buffer, 1, size, (FILE*)pf);
540}
541
542SSize_t
543PerlStdIOWrite(struct IPerlStdIO* piPerl, const void *buffer, Size_t size, Size_t dummy, PerlIO* pf)
544//PerlStdIOWrite(struct IPerlStdIO* piPerl, PerlIO* pf, const void *buffer, Size_t size)
545{
546 return nw_fwrite(buffer, 1, size, (FILE*)pf);
547}
548
549void
550PerlStdIOSetBuf(struct IPerlStdIO* piPerl, PerlIO* pf, char* buffer)
551{
552 nw_setbuf((FILE*)pf, buffer);
553}
554
555int
556PerlStdIOSetVBuf(struct IPerlStdIO* piPerl, PerlIO* pf, char* buffer, int type, Size_t size)
557{
558 return nw_setvbuf((FILE*)pf, buffer, type, size);
559}
560
561void
562PerlStdIOSetCnt(struct IPerlStdIO* piPerl, PerlIO* pf, int n)
563{
564#ifdef STDIO_CNT_LVALUE
565 FILE *f = (FILE*)pf;
566 FILE_cnt(f) = n;
567#endif
568}
569
570void
571PerlStdIOSetPtrCnt(struct IPerlStdIO* piPerl, PerlIO* pf, char * ptr, int n)
572{
573#ifdef STDIO_PTR_LVALUE
574 FILE *f = (FILE*)pf;
575 FILE_ptr(f) = ptr;
576 FILE_cnt(f) = n;
577#endif
578}
579
580void
581PerlStdIOSetlinebuf(struct IPerlStdIO* piPerl, PerlIO* pf)
582{
583 nw_setvbuf((FILE*)pf, NULL, _IOLBF, 0);
584}
585
586int
587PerlStdIOPrintf(struct IPerlStdIO* piPerl, PerlIO* pf, const char *format,...)
588{
589 va_list(arglist);
590 va_start(arglist, format);
591 return nw_vfprintf((FILE*)pf, format, arglist);
592}
593
594int
595PerlStdIOVprintf(struct IPerlStdIO* piPerl, PerlIO* pf, const char *format, va_list arglist)
596{
597 return nw_vfprintf((FILE*)pf, format, arglist);
598}
599
600long
601PerlStdIOTell(struct IPerlStdIO* piPerl, PerlIO* pf)
602{
603 return nw_ftell((FILE*)pf);
604}
605
606int
607PerlStdIOSeek(struct IPerlStdIO* piPerl, PerlIO* pf, off_t offset, int origin)
608{
609 return nw_fseek((FILE*)pf, offset, origin);
610}
611
612void
613PerlStdIORewind(struct IPerlStdIO* piPerl, PerlIO* pf)
614{
615 nw_rewind((FILE*)pf);
616}
617
618PerlIO*
619PerlStdIOTmpfile(struct IPerlStdIO* piPerl)
620{
621 return (PerlIO*)nw_tmpfile();
622}
623
624int
625PerlStdIOGetpos(struct IPerlStdIO* piPerl, PerlIO* pf, Fpos_t *p)
626{
627 return nw_fgetpos((FILE*)pf, p);
628}
629
630int
631PerlStdIOSetpos(struct IPerlStdIO* piPerl, PerlIO* pf, const Fpos_t *p)
632{
633 return nw_fsetpos((FILE*)pf, p);
634}
635
636void
637PerlStdIOInit(struct IPerlStdIO* piPerl)
638{
639 // If removed, compilation error occurs.
640}
641
642void
643PerlStdIOInitOSExtras(struct IPerlStdIO* piPerl)
644{
645 Perl_init_os_extras();
646}
647
648
649int
650PerlStdIOOpenOSfhandle(struct IPerlStdIO* piPerl, long osfhandle, int flags)
651{
652 return nw_open_osfhandle(osfhandle, flags);
653}
654
655int
656PerlStdIOGetOSfhandle(struct IPerlStdIO* piPerl, int filenum)
657{
658 return nw_get_osfhandle(filenum);
659}
660
661PerlIO*
662PerlStdIOFdupopen(struct IPerlStdIO* piPerl, PerlIO* pf)
663{
664 PerlIO* pfdup=NULL;
665 fpos_t pos=0;
666 char mode[3]={'\0'};
667 int fileno = nw_dup(nw_fileno((FILE*)pf));
668
669 /* open the file in the same mode */
670 if(((FILE*)pf)->_flag & _IOREAD) {
671 mode[0] = 'r';
672 mode[1] = 0;
673 }
674 else if(((FILE*)pf)->_flag & _IOWRT) {
675 mode[0] = 'a';
676 mode[1] = 0;
677 }
678 else if(((FILE*)pf)->_flag & _IORW) {
679 mode[0] = 'r';
680 mode[1] = '+';
681 mode[2] = 0;
682 }
683
684 /* it appears that the binmode is attached to the
685 * file descriptor so binmode files will be handled
686 * correctly
687 */
688 pfdup = (PerlIO*)nw_fdopen(fileno, mode);
689
690 /* move the file pointer to the same position */
691 if (!fgetpos((FILE*)pf, &pos)) {
692 fsetpos((FILE*)pfdup, &pos);
693 }
694 return pfdup;
695}
696
697struct IPerlStdIO perlStdIO =
698{
699 PerlStdIOStdin,
700 PerlStdIOStdout,
701 PerlStdIOStderr,
702 PerlStdIOOpen,
703 PerlStdIOClose,
704 PerlStdIOEof,
705 PerlStdIOError,
706 PerlStdIOClearerr,
707 PerlStdIOGetc,
708 PerlStdIOGetBase,
709 PerlStdIOGetBufsiz,
710 PerlStdIOGetCnt,
711 PerlStdIOGetPtr,
712 PerlStdIOGets,
713 PerlStdIOPutc,
714 PerlStdIOPuts,
715 PerlStdIOFlush,
716 PerlStdIOUngetc,
717 PerlStdIOFileno,
718 PerlStdIOFdopen,
719 PerlStdIOReopen,
720 PerlStdIORead,
721 PerlStdIOWrite,
722 PerlStdIOSetBuf,
723 PerlStdIOSetVBuf,
724 PerlStdIOSetCnt,
725 PerlStdIOSetPtrCnt,
726 PerlStdIOSetlinebuf,
727 PerlStdIOPrintf,
728 PerlStdIOVprintf,
729 PerlStdIOTell,
730 PerlStdIOSeek,
731 PerlStdIORewind,
732 PerlStdIOTmpfile,
733 PerlStdIOGetpos,
734 PerlStdIOSetpos,
735 PerlStdIOInit,
736 PerlStdIOInitOSExtras,
737 PerlStdIOFdupopen,
738};
739
740
741#undef IPERL2HOST
742#define IPERL2HOST(x) IPerlLIO2Host(x)
743
744/* IPerlLIO */
745int
746PerlLIOAccess(struct IPerlLIO* piPerl, const char *path, int mode)
747{
748 return nw_access(path, mode);
749}
750
751int
752PerlLIOChmod(struct IPerlLIO* piPerl, const char *filename, int pmode)
753{
754 return nw_chmod(filename, pmode);
755}
756
757int
758PerlLIOChown(struct IPerlLIO* piPerl, const char *filename, uid_t owner, gid_t group)
759{
760 // If removed, compilation error occurs.
761 return 0;
762}
763
764int
765PerlLIOChsize(struct IPerlLIO* piPerl, int handle, long size)
766{
767 return (nw_chsize(handle,size));
768}
769
770int
771PerlLIOClose(struct IPerlLIO* piPerl, int handle)
772{
773 return nw_close(handle);
774}
775
776int
777PerlLIODup(struct IPerlLIO* piPerl, int handle)
778{
779 return nw_dup(handle);
780}
781
782int
783PerlLIODup2(struct IPerlLIO* piPerl, int handle1, int handle2)
784{
785 return nw_dup2(handle1, handle2);
786}
787
788int
789PerlLIOFlock(struct IPerlLIO* piPerl, int fd, int oper)
790{
791 //On NetWare simulate flock by locking a range on the file
792 return nw_flock(fd, oper);
793}
794
795int
796PerlLIOFileStat(struct IPerlLIO* piPerl, int handle, struct stat *buffer)
797{
798 return fstat(handle, buffer);
799}
800
801int
802PerlLIOIOCtl(struct IPerlLIO* piPerl, int i, unsigned int u, char *data)
803{
804 // If removed, compilation error occurs.
805 return 0;
806}
807
808int
809PerlLIOIsatty(struct IPerlLIO* piPerl, int fd)
810{
811 return nw_isatty(fd);
812}
813
814int
815PerlLIOLink(struct IPerlLIO* piPerl, const char*oldname, const char *newname)
816{
817 return nw_link(oldname, newname);
818}
819
820long
821PerlLIOLseek(struct IPerlLIO* piPerl, int handle, long offset, int origin)
822{
823 return nw_lseek(handle, offset, origin);
824}
825
826int
827PerlLIOLstat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer)
828{
829 return nw_stat(path, buffer);
830}
831
832char*
833PerlLIOMktemp(struct IPerlLIO* piPerl, char *Template)
834{
835 return(nw_mktemp(Template));
836}
837
838int
839PerlLIOOpen(struct IPerlLIO* piPerl, const char *filename, int oflag)
840{
841 return nw_open(filename, oflag);
842}
843
844int
845PerlLIOOpen3(struct IPerlLIO* piPerl, const char *filename, int oflag, int pmode)
846{
847 return nw_open(filename, oflag, pmode);
848}
849
850int
851PerlLIORead(struct IPerlLIO* piPerl, int handle, void *buffer, unsigned int count)
852{
853 return nw_read(handle, buffer, count);
854}
855
856int
857PerlLIORename(struct IPerlLIO* piPerl, const char *OldFileName, const char *newname)
858{
859 return nw_rename(OldFileName, newname);
860}
861
862int
863PerlLIOSetmode(struct IPerlLIO* piPerl, FILE *fp, int mode)
864{
865 return nw_setmode(fp, mode);
866}
867
868int
869PerlLIONameStat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer)
870{
871 return nw_stat(path, buffer);
872}
873
874char*
875PerlLIOTmpnam(struct IPerlLIO* piPerl, char *string)
876{
877 return tmpnam(string);
878}
879
880int
881PerlLIOUmask(struct IPerlLIO* piPerl, int pmode)
882{
883 return umask(pmode);
884}
885
886int
887PerlLIOUnlink(struct IPerlLIO* piPerl, const char *filename)
888{
889 return nw_unlink(filename);
890}
891
892int
893PerlLIOUtime(struct IPerlLIO* piPerl, char *filename, struct utimbuf *times)
894{
895 return nw_utime(filename, times);
896}
897
898int
899PerlLIOWrite(struct IPerlLIO* piPerl, int handle, const void *buffer, unsigned int count)
900{
901 return nw_write(handle, buffer, count);
902}
903
904struct IPerlLIO perlLIO =
905{
906 PerlLIOAccess,
907 PerlLIOChmod,
908 PerlLIOChown,
909 PerlLIOChsize,
910 PerlLIOClose,
911 PerlLIODup,
912 PerlLIODup2,
913 PerlLIOFlock,
914 PerlLIOFileStat,
915 PerlLIOIOCtl,
916 PerlLIOIsatty,
917 PerlLIOLink,
918 PerlLIOLseek,
919 PerlLIOLstat,
920 PerlLIOMktemp,
921 PerlLIOOpen,
922 PerlLIOOpen3,
923 PerlLIORead,
924 PerlLIORename,
925 PerlLIOSetmode,
926 PerlLIONameStat,
927 PerlLIOTmpnam,
928 PerlLIOUmask,
929 PerlLIOUnlink,
930 PerlLIOUtime,
931 PerlLIOWrite,
932};
933
934
935#undef IPERL2HOST
936#define IPERL2HOST(x) IPerlDir2Host(x)
937
938/* IPerlDIR */
939int
940PerlDirMakedir(struct IPerlDir* piPerl, const char *dirname, int mode)
941{
942 return mkdir(dirname);
943}
944
945int
946PerlDirChdir(struct IPerlDir* piPerl, const char *dirname)
947{
948 return nw_chdir(dirname);
949}
950
951int
952PerlDirRmdir(struct IPerlDir* piPerl, const char *dirname)
953{
954 return nw_rmdir(dirname);
955}
956
957int
958PerlDirClose(struct IPerlDir* piPerl, DIR *dirp)
959{
960 return nw_closedir(dirp);
961}
962
963DIR*
964PerlDirOpen(struct IPerlDir* piPerl, char *filename)
965{
966 return nw_opendir(filename);
967}
968
969struct direct *
970PerlDirRead(struct IPerlDir* piPerl, DIR *dirp)
971{
972 return nw_readdir(dirp);
973}
974
975void
976PerlDirRewind(struct IPerlDir* piPerl, DIR *dirp)
977{
978 nw_rewinddir(dirp);
979}
980
981void
982PerlDirSeek(struct IPerlDir* piPerl, DIR *dirp, long loc)
983{
984 nw_seekdir(dirp, loc);
985}
986
987long
988PerlDirTell(struct IPerlDir* piPerl, DIR *dirp)
989{
990 return nw_telldir(dirp);
991}
992
993struct IPerlDir perlDir =
994{
995 PerlDirMakedir,
996 PerlDirChdir,
997 PerlDirRmdir,
998 PerlDirClose,
999 PerlDirOpen,
1000 PerlDirRead,
1001 PerlDirRewind,
1002 PerlDirSeek,
1003 PerlDirTell,
1004};
1005
1006
1007/* IPerlSock */
1008u_long
1009PerlSockHtonl(struct IPerlSock* piPerl, u_long hostlong)
1010{
1011 return(nw_htonl(hostlong));
1012}
1013
1014u_short
1015PerlSockHtons(struct IPerlSock* piPerl, u_short hostshort)
1016{
1017 return(nw_htons(hostshort));
1018}
1019
1020u_long
1021PerlSockNtohl(struct IPerlSock* piPerl, u_long netlong)
1022{
1023 return nw_ntohl(netlong);
1024}
1025
1026u_short
1027PerlSockNtohs(struct IPerlSock* piPerl, u_short netshort)
1028{
1029 return nw_ntohs(netshort);
1030}
1031
1032SOCKET PerlSockAccept(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* addr, int* addrlen)
1033{
1034 return nw_accept(s, addr, addrlen);
1035}
1036
1037int
1038PerlSockBind(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
1039{
1040 return nw_bind(s, name, namelen);
1041}
1042
1043int
1044PerlSockConnect(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
1045{
1046 return nw_connect(s, name, namelen);
1047}
1048
1049void
1050PerlSockEndhostent(struct IPerlSock* piPerl)
1051{
1052 nw_endhostent();
1053}
1054
1055void
1056PerlSockEndnetent(struct IPerlSock* piPerl)
1057{
1058 nw_endnetent();
1059}
1060
1061void
1062PerlSockEndprotoent(struct IPerlSock* piPerl)
1063{
1064 nw_endprotoent();
1065}
1066
1067void
1068PerlSockEndservent(struct IPerlSock* piPerl)
1069{
1070 nw_endservent();
1071}
1072
1073struct hostent*
1074PerlSockGethostbyaddr(struct IPerlSock* piPerl, const char* addr, int len, int type)
1075{
1076 return(nw_gethostbyaddr(addr,len,type));
1077}
1078
1079struct hostent*
1080PerlSockGethostbyname(struct IPerlSock* piPerl, const char* name)
1081{
1082 return nw_gethostbyname(name);
1083}
1084
1085struct hostent*
1086PerlSockGethostent(struct IPerlSock* piPerl)
1087{
1088 return(nw_gethostent());
1089}
1090
1091int
1092PerlSockGethostname(struct IPerlSock* piPerl, char* name, int namelen)
1093{
1094 return nw_gethostname(name,namelen);
1095}
1096
1097struct netent *
1098PerlSockGetnetbyaddr(struct IPerlSock* piPerl, long net, int type)
1099{
1100 return nw_getnetbyaddr(net, type);
1101}
1102
1103struct netent *
1104PerlSockGetnetbyname(struct IPerlSock* piPerl, const char *name)
1105{
1106 return nw_getnetbyname((char*)name);
1107}
1108
1109struct netent *
1110PerlSockGetnetent(struct IPerlSock* piPerl)
1111{
1112 return nw_getnetent();
1113}
1114
1115int PerlSockGetpeername(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen)
1116{
1117 return nw_getpeername(s, name, namelen);
1118}
1119
1120struct protoent*
1121PerlSockGetprotobyname(struct IPerlSock* piPerl, const char* name)
1122{
1123 return nw_getprotobyname(name);
1124}
1125
1126struct protoent*
1127PerlSockGetprotobynumber(struct IPerlSock* piPerl, int number)
1128{
1129 return nw_getprotobynumber(number);
1130}
1131
1132struct protoent*
1133PerlSockGetprotoent(struct IPerlSock* piPerl)
1134{
1135 return nw_getprotoent();
1136}
1137
1138struct servent*
1139PerlSockGetservbyname(struct IPerlSock* piPerl, const char* name, const char* proto)
1140{
1141 return nw_getservbyname((char*)name, (char*)proto);
1142}
1143
1144struct servent*
1145PerlSockGetservbyport(struct IPerlSock* piPerl, int port, const char* proto)
1146{
1147 return nw_getservbyport(port, proto);
1148}
1149
1150struct servent*
1151PerlSockGetservent(struct IPerlSock* piPerl)
1152{
1153 return nw_getservent();
1154}
1155
1156int
1157PerlSockGetsockname(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen)
1158{
1159 return nw_getsockname(s, name, namelen);
1160}
1161
1162int
1163PerlSockGetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, char* optval, int* optlen)
1164{
1165 return nw_getsockopt(s, level, optname, optval, optlen);
1166}
1167
1168unsigned long
1169PerlSockInetAddr(struct IPerlSock* piPerl, const char* cp)
1170{
1171 return(nw_inet_addr(cp));
1172}
1173
1174char*
1175PerlSockInetNtoa(struct IPerlSock* piPerl, struct in_addr in)
1176{
1177 return nw_inet_ntoa(in);
1178}
1179
1180int
1181PerlSockListen(struct IPerlSock* piPerl, SOCKET s, int backlog)
1182{
1183 return (nw_listen(s, backlog));
1184}
1185
1186int
1187PerlSockRecv(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags)
1188{
1189 return (nw_recv(s, buffer, len, flags));
1190}
1191
1192int
1193PerlSockRecvfrom(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags, struct sockaddr* from, int* fromlen)
1194{
1195 return nw_recvfrom(s, buffer, len, flags, from, fromlen);
1196}
1197
1198int
1199PerlSockSelect(struct IPerlSock* piPerl, int nfds, char* readfds, char* writefds, char* exceptfds, const struct timeval* timeout)
1200{
1201 return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout);
1202}
1203
1204int
1205PerlSockSend(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags)
1206{
1207 return (nw_send(s, buffer, len, flags));
1208}
1209
1210int
1211PerlSockSendto(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags, const struct sockaddr* to, int tolen)
1212{
1213 return(nw_sendto(s, buffer, len, flags, to, tolen));
1214}
1215
1216void
1217PerlSockSethostent(struct IPerlSock* piPerl, int stayopen)
1218{
1219 nw_sethostent(stayopen);
1220}
1221
1222void
1223PerlSockSetnetent(struct IPerlSock* piPerl, int stayopen)
1224{
1225 nw_setnetent(stayopen);
1226}
1227
1228void
1229PerlSockSetprotoent(struct IPerlSock* piPerl, int stayopen)
1230{
1231 nw_setprotoent(stayopen);
1232}
1233
1234void
1235PerlSockSetservent(struct IPerlSock* piPerl, int stayopen)
1236{
1237 nw_setservent(stayopen);
1238}
1239
1240int
1241PerlSockSetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, const char* optval, int optlen)
1242{
1243 return nw_setsockopt(s, level, optname, optval, optlen);
1244}
1245
1246int
1247PerlSockShutdown(struct IPerlSock* piPerl, SOCKET s, int how)
1248{
1249 return nw_shutdown(s, how);
1250}
1251
1252SOCKET
1253PerlSockSocket(struct IPerlSock* piPerl, int af, int type, int protocol)
1254{
1255 return nw_socket(af, type, protocol);
1256}
1257
1258int
1259PerlSockSocketpair(struct IPerlSock* piPerl, int domain, int type, int protocol, int* fds)
1260{
1261 dTHX; // (J) dTHXo
1262 Perl_croak(aTHX_ "socketpair not implemented!\n");
1263 return 0;
1264}
1265
1266int
1267PerlSockIoctlsocket(struct IPerlSock* piPerl, SOCKET s, long cmd, u_long *argp)
1268{
1269 dTHX; // (J) dTHXo
1270 Perl_croak(aTHX_ "ioctlsocket not implemented!\n");
1271 return 0;
1272}
1273
1274struct IPerlSock perlSock =
1275{
1276 PerlSockHtonl,
1277 PerlSockHtons,
1278 PerlSockNtohl,
1279 PerlSockNtohs,
1280 PerlSockAccept,
1281 PerlSockBind,
1282 PerlSockConnect,
1283 PerlSockEndhostent,
1284 PerlSockEndnetent,
1285 PerlSockEndprotoent,
1286 PerlSockEndservent,
1287 PerlSockGethostname,
1288 PerlSockGetpeername,
1289 PerlSockGethostbyaddr,
1290 PerlSockGethostbyname,
1291 PerlSockGethostent,
1292 PerlSockGetnetbyaddr,
1293 PerlSockGetnetbyname,
1294 PerlSockGetnetent,
1295 PerlSockGetprotobyname,
1296 PerlSockGetprotobynumber,
1297 PerlSockGetprotoent,
1298 PerlSockGetservbyname,
1299 PerlSockGetservbyport,
1300 PerlSockGetservent,
1301 PerlSockGetsockname,
1302 PerlSockGetsockopt,
1303 PerlSockInetAddr,
1304 PerlSockInetNtoa,
1305 PerlSockListen,
1306 PerlSockRecv,
1307 PerlSockRecvfrom,
1308 PerlSockSelect,
1309 PerlSockSend,
1310 PerlSockSendto,
1311 PerlSockSethostent,
1312 PerlSockSetnetent,
1313 PerlSockSetprotoent,
1314 PerlSockSetservent,
1315 PerlSockSetsockopt,
1316 PerlSockShutdown,
1317 PerlSockSocket,
1318 PerlSockSocketpair,
1319 //Following commented by sgp bcos of comiplation error too many initializers (E279)
1320// PerlSockClosesocket,
1321};
1322
1323
1324/* IPerlProc */
1325
1326#define EXECF_EXEC 1
1327#define EXECF_SPAWN 2
1328
1329void
1330PerlProcAbort(struct IPerlProc* piPerl)
1331{
1332 nw_abort();
1333}
1334
1335char *
1336PerlProcCrypt(struct IPerlProc* piPerl, const char* clear, const char* salt)
1337{
1338 return nw_crypt(clear, salt);
1339}
1340
1341void
1342PerlProcExit(struct IPerlProc* piPerl, int status)
1343{
1344// exit(status);
1345 dTHX;
1346 //dJMPENV;
1347 JMPENV_JUMP(2);
1348}
1349
1350void
1351PerlProc_Exit(struct IPerlProc* piPerl, int status)
1352{
1353// _exit(status);
1354 dTHX;
1355 //dJMPENV;
1356 JMPENV_JUMP(2);
1357}
1358
1359int
1360PerlProcExecl(struct IPerlProc* piPerl, const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3)
1361{
1362 // If removed, compilation error occurs.
1363 return 0;
1364}
1365
1366int
1367PerlProcExecv(struct IPerlProc* piPerl, const char *cmdname, const char *const *argv)
1368{
1369 return nw_execvp((char *)cmdname, (char **)argv);
1370}
1371
1372int
1373PerlProcExecvp(struct IPerlProc* piPerl, const char *cmdname, const char *const *argv)
1374{
1375 return nw_execvp((char *)cmdname, (char **)argv);
1376}
1377
1378uid_t
1379PerlProcGetuid(struct IPerlProc* piPerl)
1380{
1381 // If removed, compilation error occurs.
1382 return 0;
1383}
1384
1385uid_t
1386PerlProcGeteuid(struct IPerlProc* piPerl)
1387{
1388 // If removed, compilation error occurs.
1389 return 0;
1390}
1391
1392gid_t
1393PerlProcGetgid(struct IPerlProc* piPerl)
1394{
1395 // If removed, compilation error occurs.
1396 return 0;
1397}
1398
1399gid_t
1400PerlProcGetegid(struct IPerlProc* piPerl)
1401{
1402 // If removed, compilation error occurs.
1403 return 0;
1404}
1405
1406char *
1407PerlProcGetlogin(struct IPerlProc* piPerl)
1408{
1409 // If removed, compilation error occurs.
1410 return NULL;
1411}
1412
1413int
1414PerlProcKill(struct IPerlProc* piPerl, int pid, int sig)
1415{
1416 return nw_kill(pid, sig);
1417}
1418
1419int
1420PerlProcKillpg(struct IPerlProc* piPerl, int pid, int sig)
1421{
1422 dTHX; // (J) dTHXo
1423 Perl_croak(aTHX_ "killpg not implemented!\n");
1424 return 0;
1425}
1426
1427int
1428PerlProcPauseProc(struct IPerlProc* piPerl)
1429{
1430 return nw_sleep((32767L << 16) + 32767);
1431}
1432
1433PerlIO*
1434PerlProcPopen(struct IPerlProc* piPerl, const char *command, const char *mode)
1435{
1436 dTHX; // (J) dTHXo
1437 PERL_FLUSHALL_FOR_CHILD;
1438
1439 return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno);
1440}
1441
1442int
1443PerlProcPclose(struct IPerlProc* piPerl, PerlIO *stream)
1444{
1445 return nw_Pclose((FILE*)stream, (int *)errno);
1446}
1447
1448int
1449PerlProcPipe(struct IPerlProc* piPerl, int *phandles)
1450{
1451 return nw_Pipe((int *)phandles, (int *)errno);
1452}
1453
1454int
1455PerlProcSetuid(struct IPerlProc* piPerl, uid_t u)
1456{
1457 // If removed, compilation error occurs.
1458 return 0;
1459}
1460
1461int
1462PerlProcSetgid(struct IPerlProc* piPerl, gid_t g)
1463{
1464 // If removed, compilation error occurs.
1465 return 0;
1466}
1467
1468int
1469PerlProcSleep(struct IPerlProc* piPerl, unsigned int s)
1470{
1471 return nw_sleep(s);
1472}
1473
1474int
1475PerlProcTimes(struct IPerlProc* piPerl, struct tms *timebuf)
1476{
1477 return nw_times(timebuf);
1478}
1479
1480int
1481PerlProcWait(struct IPerlProc* piPerl, int *status)
1482{
1483 return nw_wait(status);
1484}
1485
1486int
1487PerlProcWaitpid(struct IPerlProc* piPerl, int pid, int *status, int flags)
1488{
1489 return nw_waitpid(pid, status, flags);
1490}
1491
1492Sighandler_t
1493PerlProcSignal(struct IPerlProc* piPerl, int sig, Sighandler_t subcode)
1494{
1495 // If removed, compilation error occurs.
1496 return 0;
1497}
1498
1499int
1500PerlProcFork(struct IPerlProc* piPerl)
1501{
1502 // If removed, compilation error occurs.
1503 return 0;
1504}
1505
1506int
1507PerlProcGetpid(struct IPerlProc* piPerl)
1508{
1509 return nw_getpid();
1510}
1511
1512BOOL
1513PerlProcDoCmd(struct IPerlProc* piPerl, char *cmd)
1514{
1515 do_spawn2(cmd, EXECF_EXEC);
1516 return FALSE;
1517}
1518
1519int
1520PerlProcSpawn(struct IPerlProc* piPerl, char* cmds)
1521{
1522 return do_spawn2(cmds, EXECF_SPAWN);
1523}
1524
1525int
1526PerlProcSpawnvp(struct IPerlProc* piPerl, int mode, const char *cmdname, const char *const *argv)
1527{
1528 return nw_spawnvp(mode, (char *)cmdname, (char **)argv);
1529}
1530
1531int
1532PerlProcASpawn(struct IPerlProc* piPerl, void *vreally, void **vmark, void **vsp)
1533{
1534 return do_aspawn(vreally, vmark, vsp);
1535}
1536
1537struct IPerlProc perlProc =
1538{
1539 PerlProcAbort,
1540 PerlProcCrypt,
1541 PerlProcExit,
1542 PerlProc_Exit,
1543 PerlProcExecl,
1544 PerlProcExecv,
1545 PerlProcExecvp,
1546 PerlProcGetuid,
1547 PerlProcGeteuid,
1548 PerlProcGetgid,
1549 PerlProcGetegid,
1550 PerlProcGetlogin,
1551 PerlProcKill,
1552 PerlProcKillpg,
1553 PerlProcPauseProc,
1554 PerlProcPopen,
1555 PerlProcPclose,
1556 PerlProcPipe,
1557 PerlProcSetuid,
1558 PerlProcSetgid,
1559 PerlProcSleep,
1560 PerlProcTimes,
1561 PerlProcWait,
1562 PerlProcWaitpid,
1563 PerlProcSignal,
1564 PerlProcFork,
1565 PerlProcGetpid,
1566/* PerlProcDynaLoader,
1567 PerlProcGetOSError,
1568 PerlProcDoCmd,
1569 PerlProcSpawn,
1570 PerlProcSpawnvp,
1571 PerlProcASpawn,*/
1572};
1573
1574
1575/*
1576 * CPerlHost
1577 */
1578
1579CPerlHost::CPerlHost(void)
1580{
1581 m_pVMem = new VMem();
1582 m_pVMemShared = new VMem();
1583 m_pVMemParse = new VMem();
1584
1585 memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
1586 memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
1587 memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
1588 memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
1589 memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
1590 memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
1591 memcpy(&m_hostperlDir, &perlDir, sizeof(perlDir));
1592 memcpy(&m_hostperlSock, &perlSock, sizeof(perlSock));
1593 memcpy(&m_hostperlProc, &perlProc, sizeof(perlProc));
1594
1595 m_pHostperlMem = &m_hostperlMem;
1596 m_pHostperlMemShared = &m_hostperlMemShared;
1597 m_pHostperlMemParse = &m_hostperlMemParse;
1598 m_pHostperlEnv = &m_hostperlEnv;
1599 m_pHostperlStdIO = &m_hostperlStdIO;
1600 m_pHostperlLIO = &m_hostperlLIO;
1601 m_pHostperlDir = &m_hostperlDir;
1602 m_pHostperlSock = &m_hostperlSock;
1603 m_pHostperlProc = &m_hostperlProc;
1604}
1605
1606#define SETUPEXCHANGE(xptr, iptr, table) \
1607 STMT_START { \
1608 if (xptr) { \
1609 iptr = *xptr; \
1610 *xptr = &table; \
1611 } \
1612 else { \
1613 iptr = &table; \
1614 } \
1615 } STMT_END
1616
1617CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
1618 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
1619 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
1620 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
1621 struct IPerlProc** ppProc)
1622{
1623 m_pVMem = new VMem();
1624 m_pVMemShared = new VMem();
1625 m_pVMemParse = new VMem();
1626
1627 memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
1628 memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
1629 memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
1630 memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
1631 memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
1632 memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
1633 memcpy(&m_hostperlDir, &perlDir, sizeof(perlDir));
1634 memcpy(&m_hostperlSock, &perlSock, sizeof(perlSock));
1635 memcpy(&m_hostperlProc, &perlProc, sizeof(perlProc));
1636
1637 SETUPEXCHANGE(ppMem, m_pHostperlMem, m_hostperlMem);
1638 SETUPEXCHANGE(ppMemShared, m_pHostperlMemShared, m_hostperlMemShared);
1639 SETUPEXCHANGE(ppMemParse, m_pHostperlMemParse, m_hostperlMemParse);
1640 SETUPEXCHANGE(ppEnv, m_pHostperlEnv, m_hostperlEnv);
1641 SETUPEXCHANGE(ppStdIO, m_pHostperlStdIO, m_hostperlStdIO);
1642 SETUPEXCHANGE(ppLIO, m_pHostperlLIO, m_hostperlLIO);
1643 SETUPEXCHANGE(ppDir, m_pHostperlDir, m_hostperlDir);
1644 SETUPEXCHANGE(ppSock, m_pHostperlSock, m_hostperlSock);
1645 SETUPEXCHANGE(ppProc, m_pHostperlProc, m_hostperlProc);
1646}
1647#undef SETUPEXCHANGE
1648
1649CPerlHost::CPerlHost(const CPerlHost& host)
1650{
1651 memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem));
1652 memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared));
1653 memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse));
1654 memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv));
1655 memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO));
1656 memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO));
1657 memcpy(&m_hostperlDir, &perlDir, sizeof(perlDir));
1658 memcpy(&m_hostperlSock, &perlSock, sizeof(perlSock));
1659 memcpy(&m_hostperlProc, &perlProc, sizeof(perlProc));
1660
1661 m_pHostperlMem = &m_hostperlMem;
1662 m_pHostperlMemShared = &m_hostperlMemShared;
1663 m_pHostperlMemParse = &m_hostperlMemParse;
1664 m_pHostperlEnv = &m_hostperlEnv;
1665 m_pHostperlStdIO = &m_hostperlStdIO;
1666 m_pHostperlLIO = &m_hostperlLIO;
1667 m_pHostperlDir = &m_hostperlDir;
1668 m_pHostperlSock = &m_hostperlSock;
1669 m_pHostperlProc = &m_hostperlProc;
1670
1671}
1672
1673CPerlHost::~CPerlHost(void)
1674{
1675 if ( m_pVMemParse ) delete m_pVMemParse;
1676 if ( m_pVMemShared ) delete m_pVMemShared;
1677 if ( m_pVMem ) delete m_pVMem;
1678}
1679
1680char*
1681CPerlHost::Getenv(const char *varname)
1682{
1683 // getenv is always present. In old CLIB, it is implemented
1684 // to always return NULL. With java loaded on NW411, it will
1685 // return values set by envset. Is correctly implemented by
1686 // CLIB on MOAB.
1687 //
1688 return getenv(varname);
1689}
1690
1691int
1692CPerlHost::Putenv(const char *envstring)
1693{
1694 return(putenv(envstring));
1695}
1696
1697
1698#endif /* ___NWPerlHost_H___ */
1699