source: trunk/essentials/dev-lang/perl/NetWare/Main.c@ 3298

Last change on this file since 3298 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 6.8 KB
Line 
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
53void 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
65void 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
76void 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");