NetWare updates from Ananth Kesari.
[p5sagit/p5-mst-13.2.git] / NetWare / nwperlsys.h
CommitLineData
2986a63f 1/*
2 * Copyright © 2001 Novell, Inc. All Rights Reserved.
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Artistic License, as specified in the README file.
6 *
7 */
8
9/*
8dbfbba0 10 * FILENAME : nwperlsys.h
11 * DESCRIPTION : Derives from iperlsys.h and define the
12 * platform specific function
13 * Author : SGP
14 * Date Created : June 12th 2001.
32ce01bc 15 * Date Modified: June 30th 2001.
2986a63f 16 */
17
18#ifndef ___NWPerlSys_H___
19#define ___NWPerlSys_H___
20
21
22#include "iperlsys.h"
32ce01bc 23#include "nwstdio.h"
2986a63f 24
8dbfbba0 25#include "nw5iop.h"
26#include <fcntl.h>
27
2986a63f 28//Socket related calls
29#include "nw5sck.h"
30
31//Store the Watcom hash list
32#include "nwtinfo.h"
33
34//Watcom hash list
35#include <wchash.h>
36
8dbfbba0 37#include "win32ish.h"
38
39START_EXTERN_C
40extern int do_spawn2(char *cmd, int exectype);
41extern int do_aspawn(void *vreally, void **vmark, void **vsp);
42extern void Perl_init_os_extras(void);
43BOOL fnGetHashListAddrs(void *addrs, BOOL *dontTouchHashList);
44END_EXTERN_C
45
46/* IPerlMem - Memory management functions - Begin ========================================*/
2986a63f 47
8dbfbba0 48void*
49PerlMemMalloc(struct IPerlMem* piPerl, size_t size)
50{
51 void *ptr = NULL;
52 ptr = malloc(size);
53 if (ptr) {
54 void **listptr;
55 BOOL m_dontTouchHashLists;
56 if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
57 if (listptr) {
58 WCValHashTable<void*>* m_allocList= (WCValHashTable<void*>*)listptr;
59 (WCValHashTable<void*>*)m_allocList->insert(ptr);
60 }
61 }
62 }
63 return(ptr);
64}
65
66void*
67PerlMemRealloc(struct IPerlMem* piPerl, void* ptr, size_t size)
68{
69 void *newptr = NULL;
70 WCValHashTable<void*>* m_allocList;
71
72 newptr = realloc(ptr, size);
73
74 if (ptr)
75 {
76 void **listptr;
77 BOOL m_dontTouchHashLists;
78 if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
79 m_allocList= (WCValHashTable<void*>*)listptr;
80 (WCValHashTable<void*>*)m_allocList->remove(ptr);
81 }
82 }
83 if (newptr)
84 {
85 if (m_allocList)
86 (WCValHashTable<void*>*)m_allocList->insert(newptr);
87 }
88
89 return(newptr);
90}
91
92void
93PerlMemFree(struct IPerlMem* piPerl, void* ptr)
94{
95 BOOL m_dontTouchHashLists;
96 WCValHashTable<void*>* m_allocList;
97
98 void **listptr;
99 if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
100 m_allocList= (WCValHashTable<void*>*)listptr;
101 // Final clean up, free all the nodes from the hash list
102 if (m_dontTouchHashLists)
103 {
104 if(ptr)
105 {
106 free(ptr);
107 ptr = NULL;
108 }
109 }
110 else
111 {
112 if(ptr && m_allocList)
113 {
114 if ((WCValHashTable<void*>*)m_allocList->remove(ptr))
115 {
116 free(ptr);
117 ptr = NULL;
118 }
119 else
120 {
121 // If it comes here, that means that the memory pointer is not contained in the hash list.
122 // But no need to free now, since if is deleted here, it will result in an abend!!
123 // If the memory is still there, it will be cleaned during final cleanup anyway.
124 }
125 }
126 }
127 }
128 return;
129}
130
131void*
132PerlMemCalloc(struct IPerlMem* piPerl, size_t num, size_t size)
133{
134 void *ptr = NULL;
135
136 ptr = calloc(num, size);
137 if (ptr) {
138 void **listptr;
139 BOOL m_dontTouchHashLists;
140 if(fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
141 if (listptr) {
142 WCValHashTable<void*>* m_allocList= (WCValHashTable<void*>*)listptr;
143 (WCValHashTable<void*>*)m_allocList->insert(ptr);
144 }
145 }
146 }
147 return(ptr);
148}
2986a63f 149
150struct IPerlMem perlMem =
151{
152 PerlMemMalloc,
153 PerlMemRealloc,
154 PerlMemFree,
155 PerlMemCalloc,
156};
157
8dbfbba0 158/* IPerlMem - Memory management functions - End ========================================*/
159
160/* IPerlDir - Directory Manipulation functions - Begin ===================================*/
2986a63f 161
8dbfbba0 162int
163PerlDirMakedir(struct IPerlDir* piPerl, const char *dirname, int mode)
164{
165 return mkdir(dirname);
166}
2986a63f 167
8dbfbba0 168int
169PerlDirChdir(struct IPerlDir* piPerl, const char *dirname)
170{
171 return nw_chdir(dirname);
172}
173
174int
175PerlDirRmdir(struct IPerlDir* piPerl, const char *dirname)
176{
177 return nw_rmdir(dirname);
178}
179
180int
181PerlDirClose(struct IPerlDir* piPerl, DIR *dirp)
182{
183 return nw_closedir(dirp);
184}
185
186DIR*
187PerlDirOpen(struct IPerlDir* piPerl, char *filename)
188{
189 return nw_opendir(filename);
190}
191
192struct direct *
193PerlDirRead(struct IPerlDir* piPerl, DIR *dirp)
194{
195 return nw_readdir(dirp);
196}
197
198void
199PerlDirRewind(struct IPerlDir* piPerl, DIR *dirp)
200{
201 nw_rewinddir(dirp);
202}
203
204void
205PerlDirSeek(struct IPerlDir* piPerl, DIR *dirp, long loc)
206{
207 nw_seekdir(dirp, loc);
208}
209
210long
211PerlDirTell(struct IPerlDir* piPerl, DIR *dirp)
212{
213 return nw_telldir(dirp);
214}
2986a63f 215
216struct IPerlDir perlDir =
217{
218 PerlDirMakedir,
219 PerlDirChdir,
220 PerlDirRmdir,
221 PerlDirClose,
222 PerlDirOpen,
223 PerlDirRead,
224 PerlDirRewind,
225 PerlDirSeek,
226 PerlDirTell,
227};
228
8dbfbba0 229/* IPerlDir - Directory Manipulation functions - End ===================================*/
2986a63f 230
231/* IPerlEnv - Environment related functions - Begin ======================================*/
232
8dbfbba0 233char*
234PerlEnvGetenv(struct IPerlEnv* piPerl, const char *varname)
235{
236 return(getenv(varname));
237};
238
239int
240PerlEnvPutenv(struct IPerlEnv* piPerl, const char *envstring)
241{
242 return(putenv(envstring));
243};
244
245char*
246PerlEnvGetenv_len(struct IPerlEnv* piPerl, const char* varname, unsigned long* len)
247{
248 *len = 0;
249 char *e = getenv(varname);
250 if (e)
251 *len = strlen(e);
252 return e;
253}
2986a63f 254
8dbfbba0 255int
256PerlEnvUname(struct IPerlEnv* piPerl, struct utsname *name)
257{
258 return nw_uname(name);
259}
2986a63f 260
8dbfbba0 261void
262PerlEnvClearenv(struct IPerlEnv* piPerl)
263{
264
265}
2986a63f 266
267struct IPerlEnv perlEnv =
268{
269 PerlEnvGetenv,
270 PerlEnvPutenv,
271 PerlEnvGetenv_len,
272 PerlEnvUname,
273 PerlEnvClearenv,
274/* PerlEnvGetChildenv,
275 PerlEnvFreeChildenv,
276 PerlEnvGetChilddir,
277 PerlEnvFreeChilddir,*/
278};
279
8dbfbba0 280/* IPerlEnv - Environment related functions - End ======================================*/
2986a63f 281
282/* IPerlStdio - Stdio functions - Begin ================================================*/
283
8dbfbba0 284FILE*
285PerlStdIOStdin(struct IPerlStdIO* piPerl)
286{
287 return nw_stdin();
288}
289
290FILE*
291PerlStdIOStdout(struct IPerlStdIO* piPerl)
292{
293 return nw_stdout();
294}
295
296FILE*
297PerlStdIOStderr(struct IPerlStdIO* piPerl)
298{
299 return nw_stderr();
300}
301
302FILE*
303PerlStdIOOpen(struct IPerlStdIO* piPerl, const char *path, const char *mode)
304{
305 return nw_fopen(path, mode);
306}
307
308int
309PerlStdIOClose(struct IPerlStdIO* piPerl, FILE* pf)
310{
311 return nw_fclose(pf);
312}
313
314int
315PerlStdIOEof(struct IPerlStdIO* piPerl, FILE* pf)
316{
317 return nw_feof(pf);
318}
319
320int
321PerlStdIOError(struct IPerlStdIO* piPerl, FILE* pf)
322{
323 return nw_ferror(pf);
324}
325
326void
327PerlStdIOClearerr(struct IPerlStdIO* piPerl, FILE* pf)
328{
329 nw_clearerr(pf);
330}
331
332int
333PerlStdIOGetc(struct IPerlStdIO* piPerl, FILE* pf)
334{
335 return nw_getc(pf);
336}
337
338char*
339PerlStdIOGetBase(struct IPerlStdIO* piPerl, FILE* pf)
340{
341#ifdef FILE_base
342 FILE *f = pf;
343 return FILE_base(f);
344#else
345 return Nullch;
346#endif
347}
348
349int
350PerlStdIOGetBufsiz(struct IPerlStdIO* piPerl, FILE* pf)
351{
352#ifdef FILE_bufsiz
353 FILE *f = pf;
354 return FILE_bufsiz(f);
355#else
356 return (-1);
357#endif
358}
359
360int
361PerlStdIOGetCnt(struct IPerlStdIO* piPerl, FILE* pf)
362{
363#ifdef USE_STDIO_PTR
364 FILE *f = pf;
365 return FILE_cnt(f);
366#else
367 return (-1);
368#endif
369}
370
371char*
372PerlStdIOGetPtr(struct IPerlStdIO* piPerl, FILE* pf)
373{
374#ifdef USE_STDIO_PTR
375 FILE *f = pf;
376 return FILE_ptr(f);
377#else
378 return Nullch;
379#endif
380}
381
382char*
383PerlStdIOGets(struct IPerlStdIO* piPerl, FILE* pf, char* s, int n)
384{
385 return nw_fgets(s, n, pf);
386}
387
388int
389PerlStdIOPutc(struct IPerlStdIO* piPerl, FILE* pf, int c)
390{
391 return nw_fputc(c, pf);
392}
393
394int
395PerlStdIOPuts(struct IPerlStdIO* piPerl, FILE* pf, const char *s)
396{
397 return nw_fputs(s, pf);
398}
399
400int
401PerlStdIOFlush(struct IPerlStdIO* piPerl, FILE* pf)
402{
403 return nw_fflush(pf);
404}
405
406int
407PerlStdIOUngetc(struct IPerlStdIO* piPerl, int c, FILE* pf)
408{
409 return nw_ungetc(c, pf);
410}
411
412int
413PerlStdIOFileno(struct IPerlStdIO* piPerl, FILE* pf)
414{
415 return nw_fileno(pf);
416}
417
418FILE*
419PerlStdIOFdopen(struct IPerlStdIO* piPerl, int fd, const char *mode)
420{
421 return nw_fdopen(fd, mode);
422}
423
424FILE*
425PerlStdIOReopen(struct IPerlStdIO* piPerl, const char*path, const char*mode, FILE* pf)
426{
427 return nw_freopen(path, mode, pf);
428}
429
430SSize_t
431PerlStdIORead(struct IPerlStdIO* piPerl, void *buffer, Size_t size, Size_t count, FILE* pf)
432{
433 return nw_fread(buffer, size, count, pf);
434}
435
436SSize_t
437PerlStdIOWrite(struct IPerlStdIO* piPerl, const void *buffer, Size_t size, Size_t count, FILE* pf)
438{
439 return nw_fwrite(buffer, size, count, pf);
440}
441
442void
443PerlStdIOSetBuf(struct IPerlStdIO* piPerl, FILE* pf, char* buffer)
444{
445 nw_setbuf(pf, buffer);
446}
447
448int
449PerlStdIOSetVBuf(struct IPerlStdIO* piPerl, FILE* pf, char* buffer, int type, Size_t size)
450{
451 return nw_setvbuf(pf, buffer, type, size);
452}
453
454void
455PerlStdIOSetCnt(struct IPerlStdIO* piPerl, FILE* pf, int n)
456{
457#ifdef STDIO_CNT_LVALUE
458 FILE *f = pf;
459 FILE_cnt(f) = n;
460#endif
461}
462
463void
464PerlStdIOSetPtr(struct IPerlStdIO* piPerl, FILE* pf, char * ptr)
465{
466#ifdef STDIO_PTR_LVALUE
467 FILE *f = pf;
468 FILE_ptr(f) = ptr;
469#endif
470}
471
472void
473PerlStdIOSetlinebuf(struct IPerlStdIO* piPerl, FILE* pf)
474{
475 nw_setvbuf(pf, NULL, _IOLBF, 0);
476}
477
478int
479PerlStdIOPrintf(struct IPerlStdIO* piPerl, FILE* pf, const char *format,...)
480{
481 va_list(arglist);
482 va_start(arglist, format);
483 return nw_vfprintf(pf, format, arglist);
484}
485
486int
487PerlStdIOVprintf(struct IPerlStdIO* piPerl, FILE* pf, const char *format, va_list arglist)
488{
489 return nw_vfprintf(pf, format, arglist);
490}
491
492long
493PerlStdIOTell(struct IPerlStdIO* piPerl, FILE* pf)
494{
495 return nw_ftell(pf);
496}
497
498int
499PerlStdIOSeek(struct IPerlStdIO* piPerl, FILE* pf, off_t offset, int origin)
500{
501 return nw_fseek(pf, offset, origin);
502}
503
504void
505PerlStdIORewind(struct IPerlStdIO* piPerl, FILE* pf)
506{
507 nw_rewind(pf);
508}
509
510FILE*
511PerlStdIOTmpfile(struct IPerlStdIO* piPerl)
512{
513 return nw_tmpfile();
514}
515
516int
517PerlStdIOGetpos(struct IPerlStdIO* piPerl, FILE* pf, Fpos_t *p)
518{
519 return nw_fgetpos(pf, p);
520}
521
522int
523PerlStdIOSetpos(struct IPerlStdIO* piPerl, FILE* pf, const Fpos_t *p)
524{
525 return nw_fsetpos(pf, p);
526}
527
528void
529PerlStdIOInit(struct IPerlStdIO* piPerl)
530{
531}
532
533void
534PerlStdIOInitOSExtras(struct IPerlStdIO* piPerl)
535{
536 Perl_init_os_extras();
537}
538
539
540int
541PerlStdIOOpenOSfhandle(struct IPerlStdIO* piPerl, long osfhandle, int flags)
542{
543 return nw_open_osfhandle(osfhandle, flags);
544}
545
546int
547PerlStdIOGetOSfhandle(struct IPerlStdIO* piPerl, int filenum)
548{
549 return nw_get_osfhandle(filenum);
550}
551
552FILE*
553PerlStdIOFdupopen(struct IPerlStdIO* piPerl, FILE* pf)
554{
555 FILE* pfdup=NULL;
556 fpos_t pos=0;
557 char mode[3]={'\0'};
558 int fileno = nw_dup(nw_fileno(pf));
559
560 /* open the file in the same mode */
561 if(((FILE*)pf)->_flag & _IOREAD) {
562 mode[0] = 'r';
563 mode[1] = 0;
564 }
565 else if(((FILE*)pf)->_flag & _IOWRT) {
566 mode[0] = 'a';
567 mode[1] = 0;
568 }
569 else if(((FILE*)pf)->_flag & _IORW) {
570 mode[0] = 'r';
571 mode[1] = '+';
572 mode[2] = 0;
573 }
574
575 /* it appears that the binmode is attached to the
576 * file descriptor so binmode files will be handled
577 * correctly
578 */
579 pfdup = nw_fdopen(fileno, mode);
580
581 /* move the file pointer to the same position */
582 if (!fgetpos(pf, &pos)) {
583 fsetpos(pfdup, &pos);
584 }
585 return pfdup;
586}
2986a63f 587
588struct IPerlStdIO perlStdIO =
589{
590 PerlStdIOStdin,
591 PerlStdIOStdout,
592 PerlStdIOStderr,
593 PerlStdIOOpen,
594 PerlStdIOClose,
595 PerlStdIOEof,
596 PerlStdIOError,
597 PerlStdIOClearerr,
598 PerlStdIOGetc,
599 PerlStdIOGetBase,
600 PerlStdIOGetBufsiz,
601 PerlStdIOGetCnt,
602 PerlStdIOGetPtr,
603 PerlStdIOGets,
604 PerlStdIOPutc,
605 PerlStdIOPuts,
606 PerlStdIOFlush,
607 PerlStdIOUngetc,
608 PerlStdIOFileno,
609 PerlStdIOFdopen,
610 PerlStdIOReopen,
611 PerlStdIORead,
612 PerlStdIOWrite,
613 PerlStdIOSetBuf,
614 PerlStdIOSetVBuf,
615 PerlStdIOSetCnt,
616 PerlStdIOSetPtr,
617 PerlStdIOSetlinebuf,
618 PerlStdIOPrintf,
619 PerlStdIOVprintf,
620 PerlStdIOTell,
621 PerlStdIOSeek,
622 PerlStdIORewind,
623 PerlStdIOTmpfile,
624 PerlStdIOGetpos,
625 PerlStdIOSetpos,
626 PerlStdIOInit,
627 PerlStdIOInitOSExtras,
628 PerlStdIOFdupopen,
629};
630
631/* IPerlStdio - Stdio functions - End ================================================*/
632
633/* IPerlLIO - Low-level IO functions - Begin =============================================*/
634
8dbfbba0 635int
636PerlLIOAccess(struct IPerlLIO* piPerl, const char *path, int mode)
637{
638 return nw_access(path, mode);
639}
640
641int
642PerlLIOChmod(struct IPerlLIO* piPerl, const char *filename, int pmode)
643{
644 return nw_chmod(filename, pmode);
645}
646
647int
648PerlLIOChown(struct IPerlLIO* piPerl, const char *filename, uid_t owner, gid_t group)
649{
acfe0abc 650 dTHX;
8dbfbba0 651 Perl_croak(aTHX_ "chown not implemented!\n");
652 return 0;
653}
654
655int
656PerlLIOChsize(struct IPerlLIO* piPerl, int handle, long size)
657{
658 return (nw_chsize(handle,size));
659}
660
661int
662PerlLIOClose(struct IPerlLIO* piPerl, int handle)
663{
664 return nw_close(handle);
665}
666
667int
668PerlLIODup(struct IPerlLIO* piPerl, int handle)
669{
670 return nw_dup(handle);
671}
672
673int
674PerlLIODup2(struct IPerlLIO* piPerl, int handle1, int handle2)
675{
676 return nw_dup2(handle1, handle2);
677}
678
679int
680PerlLIOFlock(struct IPerlLIO* piPerl, int fd, int oper)
681{
682 //On NetWare simulate flock by locking a range on the file
683 return nw_flock(fd, oper);
684}
685
686int
687PerlLIOFileStat(struct IPerlLIO* piPerl, int handle, struct stat *buffer)
688{
689 return fstat(handle, buffer);
690}
691
692int
693PerlLIOIOCtl(struct IPerlLIO* piPerl, int i, unsigned int u, char *data)
694{
695 return 0;
696}
697
698int
699PerlLIOIsatty(struct IPerlLIO* piPerl, int fd)
700{
701 return nw_isatty(fd);
702}
703
704int
705PerlLIOLink(struct IPerlLIO* piPerl, const char*oldname, const char *newname)
706{
707 return nw_link(oldname, newname);
708}
709
710long
711PerlLIOLseek(struct IPerlLIO* piPerl, int handle, long offset, int origin)
712{
713 return nw_lseek(handle, offset, origin);
714}
715
716int
717PerlLIOLstat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer)
718{
719 return nw_stat(path, buffer);
720}
721
722char*
723PerlLIOMktemp(struct IPerlLIO* piPerl, char *Template)
724{
725 return(nw_mktemp(Template));
726}
727
728int
729PerlLIOOpen(struct IPerlLIO* piPerl, const char *filename, int oflag)
730{
731 return nw_open(filename, oflag);
732}
733
734int
735PerlLIOOpen3(struct IPerlLIO* piPerl, const char *filename, int oflag, int pmode)
736{
737 return nw_open(filename, oflag, pmode);
738}
739
740int
741PerlLIORead(struct IPerlLIO* piPerl, int handle, void *buffer, unsigned int count)
742{
743 return nw_read(handle, buffer, count);
744}
745
746int
747PerlLIORename(struct IPerlLIO* piPerl, const char *OldFileName, const char *newname)
748{
749 return nw_rename(OldFileName, newname);
750}
751
752int
753PerlLIOSetmode(struct IPerlLIO* piPerl, FILE *fp, int mode)
754{
755 return nw_setmode(fp, mode);
756}
757
758int
759PerlLIONameStat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer)
760{
761 return nw_stat(path, buffer);
762}
763
764char*
765PerlLIOTmpnam(struct IPerlLIO* piPerl, char *string)
766{
767 return tmpnam(string);
768}
769
770int
771PerlLIOUmask(struct IPerlLIO* piPerl, int pmode)
772{
773 return umask(pmode);
774}
775
776int
777PerlLIOUnlink(struct IPerlLIO* piPerl, const char *filename)
778{
779 return nw_unlink(filename);
780}
781
782int
783PerlLIOUtime(struct IPerlLIO* piPerl, char *filename, struct utimbuf *times)
784{
785 return nw_utime(filename, times);
786}
787
788int
789PerlLIOWrite(struct IPerlLIO* piPerl, int handle, const void *buffer, unsigned int count)
790{
791 return nw_write(handle, buffer, count);
792}
2986a63f 793
794struct IPerlLIO perlLIO =
795{
796 PerlLIOAccess,
797 PerlLIOChmod,
798 PerlLIOChown,
799 PerlLIOChsize,
800 PerlLIOClose,
801 PerlLIODup,
802 PerlLIODup2,
803 PerlLIOFlock,
804 PerlLIOFileStat,
805 PerlLIOIOCtl,
806 PerlLIOIsatty,
807 PerlLIOLink,
808 PerlLIOLseek,
809 PerlLIOLstat,
810 PerlLIOMktemp,
811 PerlLIOOpen,
812 PerlLIOOpen3,
813 PerlLIORead,
814 PerlLIORename,
815 PerlLIOSetmode,
816 PerlLIONameStat,
817 PerlLIOTmpnam,
818 PerlLIOUmask,
819 PerlLIOUnlink,
820 PerlLIOUtime,
821 PerlLIOWrite,
822};
823
8dbfbba0 824/* IPerlLIO - Low-level IO functions - End =============================================*/
2986a63f 825
826/* IPerlProc - Process control functions - Begin =========================================*/
827
8dbfbba0 828#define EXECF_EXEC 1
829#define EXECF_SPAWN 2
830
831void
832PerlProcAbort(struct IPerlProc* piPerl)
833{
834 nw_abort();
835}
836
837char *
838PerlProcCrypt(struct IPerlProc* piPerl, const char* clear, const char* salt)
839{
840 return nw_crypt(clear, salt);
841}
842
843void
844PerlProcExit(struct IPerlProc* piPerl, int status)
845{
846// exit(status);
847 dTHX;
848 dJMPENV;
849 JMPENV_JUMP(2);
850}
851
852void
853PerlProc_Exit(struct IPerlProc* piPerl, int status)
854{
855// _exit(status);
856 dTHX;
857 dJMPENV;
858 JMPENV_JUMP(2);
859}
860
861int
862PerlProcExecl(struct IPerlProc* piPerl, const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3)
863{
acfe0abc 864 dTHX;
8dbfbba0 865 Perl_croak(aTHX_ "execl not implemented!\n");
866 return 0;
867}
868
869int
870PerlProcExecv(struct IPerlProc* piPerl, const char *cmdname, const char *const *argv)
871{
872 return nw_execvp((char *)cmdname, (char **)argv);
873}
874
875int
876PerlProcExecvp(struct IPerlProc* piPerl, const char *cmdname, const char *const *argv)
877{
878 return nw_execvp((char *)cmdname, (char **)argv);
879}
880
881uid_t
882PerlProcGetuid(struct IPerlProc* piPerl)
883{
884 return 0;
885}
886
887uid_t
888PerlProcGeteuid(struct IPerlProc* piPerl)
889{
890 return 0;
891}
892
893gid_t
894PerlProcGetgid(struct IPerlProc* piPerl)
895{
896 return 0;
897}
898
899gid_t
900PerlProcGetegid(struct IPerlProc* piPerl)
901{
902 return 0;
903}
904
905char *
906PerlProcGetlogin(struct IPerlProc* piPerl)
907{
908 return NULL;
909}
910
911int
912PerlProcKill(struct IPerlProc* piPerl, int pid, int sig)
913{
914 return nw_kill(pid, sig);
915}
916
917int
918PerlProcKillpg(struct IPerlProc* piPerl, int pid, int sig)
919{
acfe0abc 920 dTHX;
8dbfbba0 921 Perl_croak(aTHX_ "killpg not implemented!\n");
922 return 0;
923}
924
925int
926PerlProcPauseProc(struct IPerlProc* piPerl)
927{
928 return nw_sleep((32767L << 16) + 32767);
929}
930
931PerlIO*
932PerlProcPopen(struct IPerlProc* piPerl, const char *command, const char *mode)
933{
acfe0abc 934 dTHX;
8dbfbba0 935 PERL_FLUSHALL_FOR_CHILD;
936
937 return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno);
938}
939
940int
941PerlProcPclose(struct IPerlProc* piPerl, PerlIO *stream)
942{
943 return nw_Pclose((FILE*)stream, (int *)errno);
944}
945
946int
947PerlProcPipe(struct IPerlProc* piPerl, int *phandles)
948{
949 return nw_Pipe((int *)phandles, (int *)errno);
950}
951
952int
953PerlProcSetuid(struct IPerlProc* piPerl, uid_t u)
954{
955 return 0;
956}
957
958int
959PerlProcSetgid(struct IPerlProc* piPerl, gid_t g)
960{
961 return 0;
962}
963
964int
965PerlProcSleep(struct IPerlProc* piPerl, unsigned int s)
966{
967 return nw_sleep(s);
968}
969
970int
971PerlProcTimes(struct IPerlProc* piPerl, struct tms *timebuf)
972{
973 return nw_times(timebuf);
974}
975
976int
977PerlProcWait(struct IPerlProc* piPerl, int *status)
978{
979 return nw_wait(status);
980}
981
982int
983PerlProcWaitpid(struct IPerlProc* piPerl, int pid, int *status, int flags)
984{
985 return nw_waitpid(pid, status, flags);
986}
987
988Sighandler_t
989PerlProcSignal(struct IPerlProc* piPerl, int sig, Sighandler_t subcode)
990{
991 return 0;
992}
993
994int
995PerlProcFork(struct IPerlProc* piPerl)
996{
997 return 0;
998}
999
1000int
1001PerlProcGetpid(struct IPerlProc* piPerl)
1002{
1003 return nw_getpid();
1004}
1005
1006/*BOOL
1007PerlProcDoCmd(struct IPerlProc* piPerl, char *cmd)
1008{
1009 do_spawn2(cmd, EXECF_EXEC);
1010 return FALSE;
1011}*/
1012
1013int
1014PerlProcSpawn(struct IPerlProc* piPerl, char* cmds)
1015{
1016 return do_spawn2(cmds, EXECF_SPAWN);
1017}
1018
1019int
1020PerlProcSpawnvp(struct IPerlProc* piPerl, int mode, const char *cmdname, const char *const *argv)
1021{
1022 return nw_spawnvp(mode, (char *)cmdname, (char **)argv);
1023}
1024
1025int
1026PerlProcASpawn(struct IPerlProc* piPerl, void *vreally, void **vmark, void **vsp)
1027{
1028 return do_aspawn(vreally, vmark, vsp);
1029}
2986a63f 1030
1031struct IPerlProc perlProc =
1032{
1033 PerlProcAbort,
1034 PerlProcCrypt,
1035 PerlProcExit,
1036 PerlProc_Exit,
1037 PerlProcExecl,
1038 PerlProcExecv,
1039 PerlProcExecvp,
1040 PerlProcGetuid,
1041 PerlProcGeteuid,
1042 PerlProcGetgid,
1043 PerlProcGetegid,
1044 PerlProcGetlogin,
1045 PerlProcKill,
1046 PerlProcKillpg,
1047 PerlProcPauseProc,
1048 PerlProcPopen,
1049 PerlProcPclose,
1050 PerlProcPipe,
1051 PerlProcSetuid,
1052 PerlProcSetgid,
1053 PerlProcSleep,
1054 PerlProcTimes,
1055 PerlProcWait,
1056 PerlProcWaitpid,
1057 PerlProcSignal,
1058 PerlProcFork,
1059 PerlProcGetpid,
1060 //PerlProcLastHost;
1061 //PerlProcPopenList;
1062};
1063
1064/* IPerlProc - Process control functions - End =========================================*/
1065
1066/* IPerlSock - Socket functions - Begin ==================================================*/
1067
8dbfbba0 1068u_long
1069PerlSockHtonl(struct IPerlSock* piPerl, u_long hostlong)
1070{
1071 return(nw_htonl(hostlong));
1072}
1073
1074u_short
1075PerlSockHtons(struct IPerlSock* piPerl, u_short hostshort)
1076{
1077 return(nw_htons(hostshort));
1078}
1079
1080u_long
1081PerlSockNtohl(struct IPerlSock* piPerl, u_long netlong)
1082{
1083 return nw_ntohl(netlong);
1084}
1085
1086u_short
1087PerlSockNtohs(struct IPerlSock* piPerl, u_short netshort)
1088{
1089 return nw_ntohs(netshort);
1090}
1091
1092SOCKET PerlSockAccept(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* addr, int* addrlen)
1093{
1094 return nw_accept(s, addr, addrlen);
1095}
1096
1097int
1098PerlSockBind(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
1099{
1100 return nw_bind(s, name, namelen);
1101}
1102
1103int
1104PerlSockConnect(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen)
1105{
1106 return nw_connect(s, name, namelen);
1107}
1108
1109void
1110PerlSockEndhostent(struct IPerlSock* piPerl)
1111{
1112 nw_endhostent();
1113}
1114
1115void
1116PerlSockEndnetent(struct IPerlSock* piPerl)
1117{
1118 nw_endnetent();
1119}
1120
1121void
1122PerlSockEndprotoent(struct IPerlSock* piPerl)
1123{
1124 nw_endprotoent();
1125}
1126
1127void
1128PerlSockEndservent(struct IPerlSock* piPerl)
1129{
1130 nw_endservent();
1131}
1132
1133struct hostent*
1134PerlSockGethostbyaddr(struct IPerlSock* piPerl, const char* addr, int len, int type)
1135{
1136 return(nw_gethostbyaddr(addr,len,type));
1137}
1138
1139struct hostent*
1140PerlSockGethostbyname(struct IPerlSock* piPerl, const char* name)
1141{
1142 return nw_gethostbyname(name);
1143}
1144
1145struct hostent*
1146PerlSockGethostent(struct IPerlSock* piPerl)
1147{
1148 return(nw_gethostent());
1149}
1150
1151int
1152PerlSockGethostname(struct IPerlSock* piPerl, char* name, int namelen)
1153{
1154 return nw_gethostname(name,namelen);
1155}
1156
1157struct netent *
1158PerlSockGetnetbyaddr(struct IPerlSock* piPerl, long net, int type)
1159{
1160 return nw_getnetbyaddr(net, type);
1161}
1162
1163struct netent *
1164PerlSockGetnetbyname(struct IPerlSock* piPerl, const char *name)
1165{
1166 return nw_getnetbyname((char*)name);
1167}
1168
1169struct netent *
1170PerlSockGetnetent(struct IPerlSock* piPerl)
1171{
1172 return nw_getnetent();
1173}
1174
1175int PerlSockGetpeername(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen)
1176{
1177 return nw_getpeername(s, name, namelen);
1178}
1179
1180struct protoent*
1181PerlSockGetprotobyname(struct IPerlSock* piPerl, const char* name)
1182{
1183 return nw_getprotobyname(name);
1184}
1185
1186struct protoent*
1187PerlSockGetprotobynumber(struct IPerlSock* piPerl, int number)
1188{
1189 return nw_getprotobynumber(number);
1190}
1191
1192struct protoent*
1193PerlSockGetprotoent(struct IPerlSock* piPerl)
1194{
1195 return nw_getprotoent();
1196}
1197
1198struct servent*
1199PerlSockGetservbyname(struct IPerlSock* piPerl, const char* name, const char* proto)
1200{
1201 return nw_getservbyname((char*)name, (char*)proto);
1202}
1203
1204struct servent*
1205PerlSockGetservbyport(struct IPerlSock* piPerl, int port, const char* proto)
1206{
1207 return nw_getservbyport(port, proto);
1208}
1209
1210struct servent*
1211PerlSockGetservent(struct IPerlSock* piPerl)
1212{
1213 return nw_getservent();
1214}
1215
1216int
1217PerlSockGetsockname(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen)
1218{
1219 return nw_getsockname(s, name, namelen);
1220}
1221
1222int
1223PerlSockGetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, char* optval, int* optlen)
1224{
1225 return nw_getsockopt(s, level, optname, optval, optlen);
1226}
1227
1228unsigned long
1229PerlSockInetAddr(struct IPerlSock* piPerl, const char* cp)
1230{
1231 return(nw_inet_addr(cp));
1232}
1233
1234char*
1235PerlSockInetNtoa(struct IPerlSock* piPerl, struct in_addr in)
1236{
1237 return NULL;
1238}
1239
1240int
1241PerlSockListen(struct IPerlSock* piPerl, SOCKET s, int backlog)
1242{
1243 return (nw_listen(s, backlog));
1244}
1245
1246int
1247PerlSockRecv(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags)
1248{
1249 return (nw_recv(s, buffer, len, flags));
1250}
1251
1252int
1253PerlSockRecvfrom(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags, struct sockaddr* from, int* fromlen)
1254{
1255 return nw_recvfrom(s, buffer, len, flags, from, fromlen);
1256}
1257
1258int
1259PerlSockSelect(struct IPerlSock* piPerl, int nfds, char* readfds, char* writefds, char* exceptfds, const struct timeval* timeout)
1260{
1261 return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout);
1262}
1263
1264int
1265PerlSockSend(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags)
1266{
1267 return (nw_send(s, buffer, len, flags));
1268}
1269
1270int
1271PerlSockSendto(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags, const struct sockaddr* to, int tolen)
1272{
1273 return(nw_sendto(s, buffer, len, flags, to, tolen));
1274}
1275
1276void
1277PerlSockSethostent(struct IPerlSock* piPerl, int stayopen)
1278{
1279 nw_sethostent(stayopen);
1280}
1281
1282void
1283PerlSockSetnetent(struct IPerlSock* piPerl, int stayopen)
1284{
1285 nw_setnetent(stayopen);
1286}
1287
1288void
1289PerlSockSetprotoent(struct IPerlSock* piPerl, int stayopen)
1290{
1291 nw_setprotoent(stayopen);
1292}
1293
1294void
1295PerlSockSetservent(struct IPerlSock* piPerl, int stayopen)
1296{
1297 nw_setservent(stayopen);
1298}
1299
1300int
1301PerlSockSetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, const char* optval, int optlen)
1302{
acfe0abc 1303 dTHX;
8dbfbba0 1304 Perl_croak(aTHX_ "setsockopt not implemented!\n");
1305 return 0;
1306}
1307
1308int
1309PerlSockShutdown(struct IPerlSock* piPerl, SOCKET s, int how)
1310{
1311 return nw_shutdown(s, how);
1312}
1313
1314SOCKET
1315PerlSockSocket(struct IPerlSock* piPerl, int af, int type, int protocol)
1316{
1317 return nw_socket(af, type, protocol);
1318}
1319
1320int
1321PerlSockSocketpair(struct IPerlSock* piPerl, int domain, int type, int protocol, int* fds)
1322{
acfe0abc 1323 dTHX;
8dbfbba0 1324 Perl_croak(aTHX_ "socketpair not implemented!\n");
1325 return 0;
1326}
1327
1328int
1329PerlSockIoctlsocket(struct IPerlSock* piPerl, SOCKET s, long cmd, u_long *argp)
1330{
acfe0abc 1331 dTHX;
8dbfbba0 1332 Perl_croak(aTHX_ "ioctlsocket not implemented!\n");
1333 return 0;
1334}
2986a63f 1335
1336struct IPerlSock perlSock =
1337{
1338 PerlSockHtonl,
1339 PerlSockHtons,
1340 PerlSockNtohl,
1341 PerlSockNtohs,
1342 PerlSockAccept,
1343 PerlSockBind,
1344 PerlSockConnect,
1345 PerlSockEndhostent,
1346 PerlSockEndnetent,
1347 PerlSockEndprotoent,
1348 PerlSockEndservent,
1349 PerlSockGethostname,
1350 PerlSockGetpeername,
1351 PerlSockGethostbyaddr,
1352 PerlSockGethostbyname,
1353 PerlSockGethostent,
1354 PerlSockGetnetbyaddr,
1355 PerlSockGetnetbyname,
1356 PerlSockGetnetent,
1357 PerlSockGetprotobyname,
1358 PerlSockGetprotobynumber,
1359 PerlSockGetprotoent,
1360 PerlSockGetservbyname,
1361 PerlSockGetservbyport,
1362 PerlSockGetservent,
1363 PerlSockGetsockname,
1364 PerlSockGetsockopt,
1365 PerlSockInetAddr,
1366 PerlSockInetNtoa,
1367 PerlSockListen,
1368 PerlSockRecv,
1369 PerlSockRecvfrom,
1370 PerlSockSelect,
1371 PerlSockSend,
1372 PerlSockSendto,
1373 PerlSockSethostent,
1374 PerlSockSetnetent,
1375 PerlSockSetprotoent,
1376 PerlSockSetservent,
1377 PerlSockSetsockopt,
1378 PerlSockShutdown,
1379 PerlSockSocket,
1380 PerlSockSocketpair,
1381};
1382
8dbfbba0 1383/* IPerlSock - Socket functions - End ==================================================*/
2986a63f 1384
1385#endif /* ___NWPerlSys_H___ */