summaryrefslogtreecommitdiffstats
path: root/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware
diff options
context:
space:
mode:
authorhongbotian <hongbo.tianhongbo@huawei.com>2015-11-30 01:45:08 -0500
committerhongbotian <hongbo.tianhongbo@huawei.com>2015-11-30 01:45:08 -0500
commite8ec7aa8e38a93f5b034ac74cebce5de23710317 (patch)
treeaa031937bf856c1f8d6ad7877b8d2cb0224da5ef /rubbos/app/httpd-2.0.64/srclib/apr/misc/netware
parentcc40af334e619bb549038238507407866f774f8f (diff)
upload http
JIRA: BOTTLENECK-10 Change-Id: I7598427ff904df438ce77c2819ee48ac75ffa8da Signed-off-by: hongbotian <hongbo.tianhongbo@huawei.com>
Diffstat (limited to 'rubbos/app/httpd-2.0.64/srclib/apr/misc/netware')
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/apr.xdcbin0 -> 128 bytes
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/aprlib.def3
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/charset.c34
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/libprews.c179
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/rand.c72
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/start.c180
6 files changed, 468 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/apr.xdc b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/apr.xdc
new file mode 100644
index 00000000..12a7f6ba
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/apr.xdc
Binary files differ
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/aprlib.def b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/aprlib.def
new file mode 100644
index 00000000..0a2a01eb
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/aprlib.def
@@ -0,0 +1,3 @@
+MODULE LIBC.NLM
+MODULE WS2_32.NLM
+EXPORT @aprlib.imp
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/charset.c b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/charset.c
new file mode 100644
index 00000000..b79add10
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/charset.c
@@ -0,0 +1,34 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "apr_portable.h"
+
+/* static struct utsname sysinfo; */
+
+/* XXX This needs to be fixed to produce the correct system language */
+
+APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool)
+{
+ return apr_pstrdup(pool, "CP1252");
+}
+
+
+APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool)
+{
+ return apr_os_default_encoding(pool);
+}
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/libprews.c b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/libprews.c
new file mode 100644
index 00000000..53a630d2
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/libprews.c
@@ -0,0 +1,179 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <netware.h>
+#include <library.h>
+#include <nks/synch.h>
+#include "novsock2.h"
+
+#include "apr_pools.h"
+#include "apr_private.h"
+
+
+/* library-private data...*/
+int gLibId = -1;
+void *gLibHandle = (void *) NULL;
+NXMutex_t *gLibLock = (NXMutex_t *) NULL;
+
+/* internal library function prototypes...*/
+int DisposeLibraryData(void *);
+
+int _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
+)
+{
+ WSADATA wsaData;
+ apr_status_t status;
+
+ NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
+
+#pragma unused(cmdLine)
+#pragma unused(loadDirPath)
+#pragma unused(uninitializedDataLength)
+#pragma unused(NLMFileHandle)
+#pragma unused(readRoutineP)
+#pragma unused(customDataOffset)
+#pragma unused(customDataSize)
+#pragma unused(messageCount)
+#pragma unused(messages)
+
+
+ gLibId = register_library(DisposeLibraryData);
+
+ if (gLibId < -1)
+ {
+ OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
+ return -1;
+ }
+
+ gLibHandle = NLMHandle;
+
+ gLibLock = NXMutexAlloc(0, 0, &liblock);
+
+ if (!gLibLock)
+ {
+ OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
+ return -1;
+ }
+
+ apr_netware_setup_time();
+
+ if ((status = apr_pool_initialize()) != APR_SUCCESS)
+ return status;
+
+ return WSAStartup((WORD) MAKEWORD(2, 0), &wsaData);
+}
+
+void _NonAppStop( void )
+{
+ apr_pool_terminate();
+
+ WSACleanup();
+
+ unregister_library(gLibId);
+ NXMutexFree(gLibLock);
+}
+
+int _NonAppCheckUnload( void )
+{
+ return 0;
+}
+
+int register_NLM(void *NLMHandle)
+{
+ APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
+
+ NXLock(gLibLock);
+ if (!app_data) {
+ app_data = (APP_DATA*)library_malloc(gLibHandle, sizeof(APP_DATA));
+
+ if (app_data) {
+ memset (app_data, 0, sizeof(APP_DATA));
+ set_app_data(gLibId, app_data);
+ app_data->gs_nlmhandle = NLMHandle;
+ }
+ }
+
+ if (app_data && (!app_data->initialized)) {
+ app_data->initialized = 1;
+ NXUnlock(gLibLock);
+ return 0;
+ }
+
+ NXUnlock(gLibLock);
+ return 1;
+}
+
+int unregister_NLM(void *NLMHandle)
+{
+ APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
+
+ NXLock(gLibLock);
+ if (app_data) {
+ app_data->initialized = 0;
+ NXUnlock(gLibLock);
+ return 0;
+ }
+ NXUnlock(gLibLock);
+ return 1;
+}
+
+int DisposeLibraryData(void *data)
+{
+ if (data)
+ {
+ library_free(data);
+ }
+
+ return 0;
+}
+
+int setGlobalPool(void *data)
+{
+ APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
+
+ NXLock(gLibLock);
+
+ if (app_data && !app_data->gPool) {
+ app_data->gPool = data;
+ }
+
+ NXUnlock(gLibLock);
+ return 1;
+}
+
+void* getGlobalPool()
+{
+ APP_DATA *app_data = (APP_DATA*) get_app_data(gLibId);
+
+ if (app_data) {
+ return app_data->gPool;
+ }
+
+ return NULL;
+}
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/rand.c b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/rand.c
new file mode 100644
index 00000000..f1f43bec
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/rand.c
@@ -0,0 +1,72 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define APR_WANT_MEMFUNC
+#include "apr_want.h"
+#include "apr_general.h"
+#include "apr_private.h"
+
+#if APR_HAS_RANDOM
+
+#include <nks/plat.h>
+
+static int NXSeedRandomInternal( size_t width, void *seed )
+{
+ static int init = 0;
+ int *s = (int *) seed;
+ union { int x; char y[4]; } u;
+
+ if (!init) {
+ srand(NXGetSystemTick());
+ init = 1;
+ }
+
+ if (width > 3)
+ {
+ do
+ {
+ *s++ = rand();
+ }
+ while ((width -= 4) > 3);
+ }
+
+ if (width > 0)
+ {
+ char *p = (char *) s;
+
+ u.x = rand();
+
+ while (width > 0)
+ *p++ = u.y[width--];
+ }
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf,
+#ifdef APR_ENABLE_FOR_1_0
+ apr_size_t length)
+#else
+ int length)
+#endif
+{
+ if (NXSeedRandom(length, buf) != 0) {
+ return NXSeedRandomInternal (length, buf);
+ }
+ return APR_SUCCESS;
+}
+
+#endif /* APR_HAS_RANDOM */
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/start.c b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/start.c
new file mode 100644
index 00000000..29488e3a
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/misc/netware/start.c
@@ -0,0 +1,180 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_general.h"
+#include "apr_pools.h"
+#include "apr_signal.h"
+
+#include "apr_arch_misc.h" /* for WSAHighByte / WSALowByte */
+#include "apr_arch_proc_mutex.h" /* for apr_proc_mutex_unix_setup_lock() */
+#include "apr_arch_internal_time.h"
+
+/*
+** Resource tag signatures for using NetWare WinSock 2. These will no longer
+** be needed by anyone once the new WSAStartupWithNlmHandle() is available
+** since WinSock will make the calls to AllocateResourceTag().
+*/
+#define WS_LOAD_ENTRY_SIGNATURE (*(unsigned long *) "WLDE")
+#define WS_SKT_SIGNATURE (*(unsigned long *) "WSKT")
+#define WS_LOOKUP_SERVICE_SIGNATURE (*(unsigned long *) "WLUP")
+#define WS_WSAEVENT_SIGNATURE (*(unsigned long *) "WEVT")
+#define WS_CPORT_SIGNATURE (*(unsigned long *) "WCPT")
+
+
+int (*WSAStartupWithNLMHandle)( WORD version, LPWSADATA data, void *handle ) = NULL;
+int (*WSACleanupWithNLMHandle)( void *handle ) = NULL;
+
+static int wsa_startup_with_handle (WORD wVersionRequested, LPWSADATA data, void *handle)
+{
+ APP_DATA *app_data;
+
+ if (!(app_data = (APP_DATA*) get_app_data(gLibId)))
+ return APR_EGENERAL;
+
+ app_data->gs_startup_rtag = AllocateResourceTag(handle, "WinSock Start-up", WS_LOAD_ENTRY_SIGNATURE);
+ app_data->gs_socket_rtag = AllocateResourceTag(handle, "WinSock socket()", WS_SKT_SIGNATURE);
+ app_data->gs_lookup_rtag = AllocateResourceTag(handle, "WinSock Look-up", WS_LOOKUP_SERVICE_SIGNATURE);
+ app_data->gs_event_rtag = AllocateResourceTag(handle, "WinSock Event", WS_WSAEVENT_SIGNATURE);
+ app_data->gs_pcp_rtag = AllocateResourceTag(handle, "WinSock C-Port", WS_CPORT_SIGNATURE);
+
+ return WSAStartupRTags(wVersionRequested, data,
+ app_data->gs_startup_rtag,
+ app_data->gs_socket_rtag,
+ app_data->gs_lookup_rtag,
+ app_data->gs_event_rtag,
+ app_data->gs_pcp_rtag);
+}
+
+static int wsa_cleanup_with_handle (void *handle)
+{
+ APP_DATA *app_data;
+
+ if (!(app_data = (APP_DATA*) get_app_data(gLibId)))
+ return APR_EGENERAL;
+
+ return WSACleanupRTag(app_data->gs_startup_rtag);
+}
+
+static int UnregisterAppWithWinSock (void *nlm_handle)
+{
+ if (!WSACleanupWithNLMHandle)
+ {
+ if (!(WSACleanupWithNLMHandle = ImportPublicObject(gLibHandle, "WSACleanupWithNLMHandle")))
+ WSACleanupWithNLMHandle = wsa_cleanup_with_handle;
+ }
+
+ return (*WSACleanupWithNLMHandle)(nlm_handle);
+}
+
+static int RegisterAppWithWinSock (void *nlm_handle)
+{
+ int err;
+ WSADATA wsaData;
+ WORD wVersionRequested = MAKEWORD(WSAHighByte, WSALowByte);
+
+ if (!WSAStartupWithNLMHandle)
+ {
+ if (!(WSAStartupWithNLMHandle = ImportPublicObject(gLibHandle, "WSAStartupWithNLMHandle")))
+ WSAStartupWithNLMHandle = wsa_startup_with_handle;
+ }
+
+ err = (*WSAStartupWithNLMHandle)(wVersionRequested, &wsaData, nlm_handle);
+
+ if (LOBYTE(wsaData.wVersion) != WSAHighByte ||
+ HIBYTE(wsaData.wVersion) != WSALowByte) {
+
+ UnregisterAppWithWinSock (nlm_handle);
+ return APR_EEXIST;
+ }
+
+ return err;
+}
+
+APR_DECLARE(apr_status_t) apr_app_initialize(int *argc,
+ const char * const * *argv,
+ const char * const * *env)
+{
+ /* An absolute noop. At present, only Win32 requires this stub, but it's
+ * required in order to move command arguments passed through the service
+ * control manager into the process, and it's required to fix the char*
+ * data passed in from win32 unicode into utf-8, win32's apr internal fmt.
+ */
+ return apr_initialize();
+}
+
+APR_DECLARE(apr_status_t) apr_initialize(void)
+{
+ apr_pool_t *pool;
+ int err;
+ void *nlmhandle = getnlmhandle();
+
+ /* Register the NLM as using APR. If it is already
+ registered then just return. */
+ if (register_NLM(nlmhandle) != 0) {
+ return APR_SUCCESS;
+ }
+
+ /* apr_pool_initialize() is being called from the library
+ startup code since all of the memory resources belong
+ to the library rather than the application. */
+
+ if (apr_pool_create(&pool, NULL) != APR_SUCCESS) {
+ return APR_ENOPOOL;
+ }
+
+ apr_pool_tag(pool, "apr_initilialize");
+
+ err = RegisterAppWithWinSock (nlmhandle);
+
+ if (err) {
+ return err;
+ }
+
+ apr_signal_init(pool);
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE_NONSTD(void) apr_terminate(void)
+{
+ APP_DATA *app_data;
+
+ /* Get our instance data for shutting down. */
+ if (!(app_data = (APP_DATA*) get_app_data(gLibId)))
+ return;
+
+ /* Unregister the NLM. If it is not registered
+ then just return. */
+ if (unregister_NLM(app_data->gs_nlmhandle) != 0) {
+ return;
+ }
+
+ /* apr_pool_terminate() is being called from the
+ library shutdown code since the memory resources
+ belong to the library rather than the application */
+
+ /* Just clean up the memory for the app that is going
+ away. */
+ netware_pool_proc_cleanup ();
+
+ UnregisterAppWithWinSock (app_data->gs_nlmhandle);
+}
+
+APR_DECLARE(void) apr_terminate2(void)
+{
+ apr_terminate();
+}