upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / os / netware / util_nw.c
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "httpd.h"
18 #include "http_log.h"
19
20 #include <netware.h>
21 #include <nks\netware.h>
22
23 int nlmUnloadSignaled(int wait);
24 event_handle_t eh;
25 Warn_t ref;
26 Report_t dum;
27
28 AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
29     const request_rec *r,
30     apr_proc_t *newproc, const char *progname,
31     const char * const *args,
32     const char * const *env,
33     apr_procattr_t *attr, apr_pool_t *p)
34 {
35     return apr_proc_create(newproc, progname, args, env, attr, p);
36 }
37
38 int  _NonAppCheckUnload( void )
39 {
40         return nlmUnloadSignaled(1);
41 }
42
43 // down server event callback
44 void ap_down_server_cb(void *, void *)
45 {
46         nlmUnloadSignaled(0);
47     return;
48 }
49
50 // Required place holder event callback
51 void ap_dummy_cb(void *, void *)
52 {
53     return;
54 }
55
56 // destroy callback resources
57 void ap_cb_destroy(void *)
58 {
59   // cleanup down event notification
60   UnRegisterEventNotification(eh);
61   NX_UNWRAP_INTERFACE(ref);
62   NX_UNWRAP_INTERFACE(dum);
63 }
64
65 int _NonAppStart
66 (
67     void        *NLMHandle,
68     void        *errorScreen,
69     const char  *cmdLine,
70     const char  *loadDirPath,
71     size_t      uninitializedDataLength,
72     void        *NLMFileHandle,
73     int         (*readRoutineP)( int conn, void *fileHandle, size_t offset,
74                     size_t nbytes, size_t *bytesRead, void *buffer ),
75     size_t      customDataOffset,
76     size_t      customDataSize,
77     int         messageCount,
78     const char  **messages
79 )
80 {
81 #pragma unused(cmdLine)
82 #pragma unused(loadDirPath)
83 #pragma unused(uninitializedDataLength)
84 #pragma unused(NLMFileHandle)
85 #pragma unused(readRoutineP)
86 #pragma unused(customDataOffset)
87 #pragma unused(customDataSize)
88 #pragma unused(messageCount)
89 #pragma unused(messages)
90
91     // register for down server event
92     rtag_t rt = AllocateResourceTag(NLMHandle, "Apache2 Down Server Callback",
93                                     EventSignature);
94
95     NX_WRAP_INTERFACE((void *)ap_down_server_cb, 2, (void **)&ref);
96     NX_WRAP_INTERFACE((void *)ap_dummy_cb, 2, (void **)&dum);
97     eh = RegisterForEventNotification(rt, EVENT_DOWN_SERVER,
98                                       EVENT_PRIORITY_APPLICATION,
99                                       ref, dum, NULL);
100
101     // clean-up
102     NXVmRegisterExitHandler(ap_cb_destroy, NULL);
103
104 }
105