1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <nks/synch.h>
21 #include "apr_pools.h"
22 #include "apr_private.h"
25 /* library-private data...*/
27 void *gLibHandle = (void *) NULL;
28 NXMutex_t *gLibLock = (NXMutex_t *) NULL;
30 /* internal library function prototypes...*/
31 int DisposeLibraryData(void *);
38 const char *loadDirPath,
39 size_t uninitializedDataLength,
41 int (*readRoutineP)( int conn, void *fileHandle, size_t offset,
42 size_t nbytes, size_t *bytesRead, void *buffer ),
43 size_t customDataOffset,
44 size_t customDataSize,
52 NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
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)
65 gLibId = register_library(DisposeLibraryData);
69 OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
73 gLibHandle = NLMHandle;
75 gLibLock = NXMutexAlloc(0, 0, &liblock);
79 OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
83 apr_netware_setup_time();
85 if ((status = apr_pool_initialize()) != APR_SUCCESS)
88 return WSAStartup((WORD) MAKEWORD(2, 0), &wsaData);
91 void _NonAppStop( void )
97 unregister_library(gLibId);
98 NXMutexFree(gLibLock);
101 int _NonAppCheckUnload( void )
106 int register_NLM(void *NLMHandle)
108 APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
112 app_data = (APP_DATA*)library_malloc(gLibHandle, sizeof(APP_DATA));
115 memset (app_data, 0, sizeof(APP_DATA));
116 set_app_data(gLibId, app_data);
117 app_data->gs_nlmhandle = NLMHandle;
121 if (app_data && (!app_data->initialized)) {
122 app_data->initialized = 1;
131 int unregister_NLM(void *NLMHandle)
133 APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
137 app_data->initialized = 0;
145 int DisposeLibraryData(void *data)
155 int setGlobalPool(void *data)
157 APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
161 if (app_data && !app_data->gPool) {
162 app_data->gPool = data;
169 void* getGlobalPool()
171 APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
174 return app_data->gPool;