Chip noticed that the intended optionality of the 'IV' was
[p5sagit/p5-mst-13.2.git] / NetWare / Main.c
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             :       Main.c
12  * DESCRIPTION  :       The purpose of clibstuf is to make sure that Perl, cgi2perl and
13  *                  all the perl extension nlm's (*.NLP) use the Novell Netware CLIB versions
14  *                  of standard functions. This code loads up a whole bunch of function pointers
15  *                  to point at the standard CLIB functions.
16  * Author               :       HYAK
17  * Date                 :       January 2001.
18  *
19  */
20
21
22
23 #define DEFINE_GPF
24
25 #include <nwthread.h>
26 #include <nwadv.h>
27 #include <nwconio.h>
28
29 #include "string.h"             // Our version of string.h will include clibstr.h
30 #include "stdio.h"              // Our version of stdio.h will include clibsdio.h
31 #include "clibstuf.h"
32 #include "clibstuf.h"
33
34 #ifdef MPK_ON
35         #include <mpktypes.h>
36         #include <mpkapis.h>
37 #endif  //MPK_ON
38
39
40
41 /*============================================================================================
42
43  Function               :       main
44
45  Description    :       This is called as the first step in an extension.
46
47  Parameters             :       None
48
49  Returns                :       Nothing.
50
51 ==============================================================================================*/
52
53 void main(void)
54 {
55         fnInitGpfGlobals();             // For importing the CLIB calls in place of the Watcom calls
56         SynchronizeStart();             // Don't allow anything else to happen until all the symbols are imported
57         #ifdef MPK_ON
58                 ExitThread(TSR_THREAD, 0);
59         #else
60                 ExitThread(TSR_THREAD, 0);
61         #endif
62 }
63
64
65 void ImportFromCLIB (unsigned int nlmHandle, void** psymbol, char* symbolName)
66 {
67         *psymbol = ImportSymbol(nlmHandle, symbolName);
68         if (*psymbol == NULL)
69         {
70                 ConsolePrintf("Symbol %s not found, unable to continue\n", symbolName);
71                 exit(1);
72         }
73 }
74
75
76 void fnInitGpfGlobals(void)
77 {
78         unsigned int nlmHandle = GetNLMHandle();
79
80         ImportFromCLIB(nlmHandle, &gpf___get_stdin, "__get_stdin");
81         ImportFromCLIB(nlmHandle, &gpf___get_stdout, "__get_stdout");
82         ImportFromCLIB(nlmHandle, &gpf___get_stderr, "__get_stderr");
83         ImportFromCLIB(nlmHandle, &gpf_clearerr, "clearerr");
84         ImportFromCLIB(nlmHandle, &gpf_fclose, "fclose");
85         ImportFromCLIB(nlmHandle, &gpf_feof, "feof");
86         ImportFromCLIB(nlmHandle, &gpf_ferror, "ferror");
87         ImportFromCLIB(nlmHandle, &gpf_fflush, "fflush");
88         ImportFromCLIB(nlmHandle, &gpf_fgetc, "fgetc");
89         ImportFromCLIB(nlmHandle, &gpf_fgetpos, "fgetpos");
90         ImportFromCLIB(nlmHandle, &gpf_fgets, "fgets");
91         ImportFromCLIB(nlmHandle, &gpf_fopen, "fopen");
92         ImportFromCLIB(nlmHandle, &gpf_fputc, "fputc");
93         ImportFromCLIB(nlmHandle, &gpf_fputs, "fputs");
94         ImportFromCLIB(nlmHandle, &gpf_fread, "fread");
95         ImportFromCLIB(nlmHandle, &gpf_freopen, "freopen");
96         ImportFromCLIB(nlmHandle, &gpf_fscanf, "fscanf");
97         ImportFromCLIB(nlmHandle, &gpf_fseek, "fseek");
98         ImportFromCLIB(nlmHandle, &gpf_fsetpos, "fsetpos");
99         ImportFromCLIB(nlmHandle, &gpf_ftell, "ftell");
100         ImportFromCLIB(nlmHandle, &gpf_fwrite, "fwrite");
101         ImportFromCLIB(nlmHandle, &gpf_getc, "getc");
102         ImportFromCLIB(nlmHandle, &gpf_getchar, "getchar");
103         ImportFromCLIB(nlmHandle, &gpf_gets, "gets");
104         ImportFromCLIB(nlmHandle, &gpf_perror, "perror");
105         ImportFromCLIB(nlmHandle, &gpf_putc, "putc");
106         ImportFromCLIB(nlmHandle, &gpf_putchar, "putchar");
107         ImportFromCLIB(nlmHandle, &gpf_puts, "puts");
108         ImportFromCLIB(nlmHandle, &gpf_rename, "rename");
109         ImportFromCLIB(nlmHandle, &gpf_rewind, "rewind");
110         ImportFromCLIB(nlmHandle, &gpf_scanf, "scanf");
111         ImportFromCLIB(nlmHandle, &gpf_setbuf, "setbuf");
112         ImportFromCLIB(nlmHandle, &gpf_setvbuf, "setvbuf");
113         ImportFromCLIB(nlmHandle, &gpf_sscanf, "sscanf");
114         ImportFromCLIB(nlmHandle, &gpf_tmpfile, "tmpfile");
115         ImportFromCLIB(nlmHandle, &gpf_tmpnam, "tmpnam");
116         ImportFromCLIB(nlmHandle, &gpf_ungetc, "ungetc");
117         ImportFromCLIB(nlmHandle, &gpf_vfscanf, "vfscanf");
118         ImportFromCLIB(nlmHandle, &gpf_vscanf, "vscanf");
119         ImportFromCLIB(nlmHandle, &gpf_vsscanf, "vsscanf");
120         ImportFromCLIB(nlmHandle, &gpf_fdopen, "fdopen");
121         ImportFromCLIB(nlmHandle, &gpf_fileno, "fileno");
122         ImportFromCLIB(nlmHandle, &gpf_cgets, "cgets");
123         ImportFromCLIB(nlmHandle, &gpf_cprintf, "cprintf");
124         ImportFromCLIB(nlmHandle, &gpf_cputs, "cputs");
125         ImportFromCLIB(nlmHandle, &gpf_cscanf, "cscanf");
126         ImportFromCLIB(nlmHandle, &gpf_fcloseall, "fcloseall");
127         ImportFromCLIB(nlmHandle, &gpf_fgetchar, "fgetchar");
128         ImportFromCLIB(nlmHandle, &gpf_flushall, "flushall");
129         ImportFromCLIB(nlmHandle, &gpf_fputchar, "fputchar");
130         ImportFromCLIB(nlmHandle, &gpf_getch, "getch");
131         ImportFromCLIB(nlmHandle, &gpf_getche, "getche");
132         ImportFromCLIB(nlmHandle, &gpf_putch, "putch");
133         ImportFromCLIB(nlmHandle, &gpf_ungetch, "ungetch");
134         ImportFromCLIB(nlmHandle, &gpf_vcprintf, "vcprintf");
135         ImportFromCLIB(nlmHandle, &gpf_vcscanf, "vcscanf");
136
137         ImportFromCLIB(nlmHandle, &gpf_memchr, "memchr");
138         ImportFromCLIB(nlmHandle, &gpf_memcmp, "memcmp");
139         ImportFromCLIB(nlmHandle, &gpf_memcpy, "memcpy");
140         ImportFromCLIB(nlmHandle, &gpf_memmove, "memmove");
141         ImportFromCLIB(nlmHandle, &gpf_memset, "memset");
142         ImportFromCLIB(nlmHandle, &gpf_memicmp, "memicmp");
143
144         ImportFromCLIB(nlmHandle, &gpf_strerror, "strerror");
145         ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
146         
147         ImportFromCLIB(nlmHandle, &gpf_strcpy, "strcpy");
148         ImportFromCLIB(nlmHandle, &gpf_strcat, "strcat");
149         ImportFromCLIB(nlmHandle, &gpf_strchr, "strchr");
150         ImportFromCLIB(nlmHandle, &gpf_strstr, "strstr");
151         ImportFromCLIB(nlmHandle, &gpf_strcoll, "strcoll");
152         ImportFromCLIB(nlmHandle, &gpf_strcspn, "strcspn");
153         ImportFromCLIB(nlmHandle, &gpf_strpbrk, "strpbrk");
154         ImportFromCLIB(nlmHandle, &gpf_strrchr, "strrchr");
155         ImportFromCLIB(nlmHandle, &gpf_strrev, "strrev");
156         ImportFromCLIB(nlmHandle, &gpf_strspn, "strspn");
157         ImportFromCLIB(nlmHandle, &gpf_strupr, "strupr");
158         ImportFromCLIB(nlmHandle, &gpf_strxfrm, "strxfrm");
159         ImportFromCLIB(nlmHandle, &gpf_strcmp, "strcmp");
160         ImportFromCLIB(nlmHandle, &gpf_stricmp, "stricmp");
161         ImportFromCLIB(nlmHandle, &gpf_strtok, "strtok");
162         ImportFromCLIB(nlmHandle, &gpf_strlen, "strlen");
163         ImportFromCLIB(nlmHandle, &gpf_strncpy, "strncpy");
164         ImportFromCLIB(nlmHandle, &gpf_strncat, "strncat");
165         ImportFromCLIB(nlmHandle, &gpf_strncmp, "strncmp");
166         ImportFromCLIB(nlmHandle, &gpf_strcmpi, "strcmpi");
167         ImportFromCLIB(nlmHandle, &gpf_strnicmp, "strnicmp");
168         ImportFromCLIB(nlmHandle, &gpf_strdup, "strdup");
169         ImportFromCLIB(nlmHandle, &gpf_strlist, "strlist");
170         ImportFromCLIB(nlmHandle, &gpf_strlwr, "strlwr");
171         ImportFromCLIB(nlmHandle, &gpf_strnset, "strnset");
172         ImportFromCLIB(nlmHandle, &gpf_strset, "strset");
173         ImportFromCLIB(nlmHandle, &gpf_strtok_r, "strtok_r");
174         ImportFromCLIB(nlmHandle, &gpf_printf, "printf");
175         ImportFromCLIB(nlmHandle, &gpf_fprintf, "fprintf");
176         ImportFromCLIB(nlmHandle, &gpf_sprintf, "sprintf");
177         ImportFromCLIB(nlmHandle, &gpf_vprintf, "vprintf");
178         ImportFromCLIB(nlmHandle, &gpf_vfprintf, "vfprintf");
179         ImportFromCLIB(nlmHandle, &gpf_vsprintf, "vsprintf");
180
181 }
182