xref: /PHP-5.5/netware/start.c (revision 73c1be26)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2015 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: Novell, Inc.                                                 |
16    +----------------------------------------------------------------------+
17  */
18 
19 
20 #include <library.h>
21 #include <netware.h>
22 #include <nks/synch.h>
23 
24 void		*gLibHandle = (void *) NULL;
25 rtag_t		gAllocTag = (rtag_t) NULL;
26 NXMutex_t	*gLibLock = (NXMutex_t *) NULL;
27 int		gLibId = 0;
28 
29 
DisposeLibraryData(void * data)30 int DisposeLibraryData(	void	*data)
31 {
32 	return 0;
33 }
34 
35 
_NonAppStart(void * NLMHandle,void * errorScreen,const char * cmdLine,const char * loadDirPath,size_t uninitializedDataLength,void * NLMFileHandle,int (* readRoutineP)(int conn,void * fileHandle,size_t offset,size_t nbytes,size_t * bytesRead,void * buffer),size_t customDataOffset,size_t customDataSize,int messageCount,const char ** messages)36 int _NonAppStart
37 (
38 	void		*NLMHandle,
39 	void		*errorScreen,
40 	const char	*cmdLine,
41 	const char	*loadDirPath,
42 	size_t		uninitializedDataLength,
43 	void		*NLMFileHandle,
44 	int		(*readRoutineP)( int conn, void *fileHandle, size_t offset,
45 			size_t nbytes, size_t *bytesRead, void *buffer ),
46 	size_t		customDataOffset,
47 	size_t		customDataSize,
48 	int		messageCount,
49 	const char	**messages
50 )
51 {
52 	NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
53 
54 #pragma unused(cmdLine)
55 #pragma unused(loadDirPath)
56 #pragma unused(uninitializedDataLength)
57 #pragma unused(NLMFileHandle)
58 #pragma unused(readRoutineP)
59 #pragma unused(customDataOffset)
60 #pragma unused(customDataSize)
61 #pragma unused(messageCount)
62 #pragma unused(messages)
63 
64 /* Here we process our command line, post errors (to the error screen),
65  * perform initializations and anything else we need to do before being able
66  * to accept calls into us. If we succeed, we return non-zero and the NetWare
67  * Loader will leave us up, otherwise we fail to load and get dumped.
68  */
69 /**
70 	gAllocTag = AllocateResourceTag(NLMHandle,
71 								"<library-name> memory allocations", AllocSignature);
72 	if (!gAllocTag) {
73 		OutputToScreen(errorScreen, "Unable to allocate resource tag for "
74 											"library memory allocations.\n");
75 		return -1;
76 	}
77 **/
78 	gLibId = register_library(DisposeLibraryData);
79 	if (gLibId == -1) {
80 		OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
81 		return -1;
82 	}
83 
84 	gLibHandle = NLMHandle;
85 
86 	gLibLock = NXMutexAlloc(0, 0, &liblock);
87 	if (!gLibLock) {
88 		OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
89 		return -1;
90 	}
91 
92 	return 0;
93 }
94 
95 
_NonAppStop(void)96 void _NonAppStop( void )
97 {
98 /* Here we clean up any resources we allocated. Resource tags is a big part
99  * of what we created, but NetWare doesn't ask us to free those.
100  */
101 	(void) unregister_library(gLibId);
102 	NXMutexFree(gLibLock);
103 }
104 
105 
_NonAppCheckUnload(void)106 int  _NonAppCheckUnload( void )
107 {
108 /* This function cannot be the first in the file for if the file is linked
109  * first, then the check-unload function's offset will be nlmname.nlm+0
110  * which is how to tell that there isn't one. When the check function is
111  * first in the linked objects, it is ambiguous. For this reason, we will
112  * put it inside this file after the stop function.
113  *
114  * Here we check to see if it's alright to ourselves to be unloaded. If not,
115  * we return a non-zero value. Right now, there isn't any reason not to allow
116  * it.
117  */
118 	return 0;
119 }
120