Sun, 27 Nov 2022 13:33:30 +0100
improve daemon startup
parent will wait until daemon is started and returns error code if startup failed
daemon startup log messages will be printed by parent
1 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2008 Sun Microsystems, Inc. All rights reserved. | |
5 | * | |
6 | * THE BSD LICENSE | |
7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions are met: | |
10 | * | |
11 | * Redistributions of source code must retain the above copyright notice, this | |
12 | * list of conditions and the following disclaimer. | |
13 | * Redistributions in binary form must reproduce the above copyright notice, | |
14 | * this list of conditions and the following disclaimer in the documentation | |
15 | * and/or other materials provided with the distribution. | |
16 | * | |
17 | * Neither the name of the nor the names of its contributors may be | |
18 | * used to endorse or promote products derived from this software without | |
19 | * specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | |
25 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
28 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | #ifndef NETSITE_H | |
35 | #define NETSITE_H | |
36 | ||
37 | #ifndef NOINTNSAPI | |
38 | #define INTNSAPI | |
39 | #endif /* !NOINTNSAPI */ | |
40 | ||
41 | /* | |
42 | * Standard defs for NetSite servers. | |
43 | */ | |
44 | ||
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
45 | //include <mps/nspr.h> |
1 | 46 | #ifndef BASE_SYSTEMS_H |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
47 | #include "../util/systems.h" |
1 | 48 | #endif /* !BASE_SYSTEMS_H */ |
49 | ||
50 | ||
51 | ||
52 | #define MAGNUS_VERSION_STRING INTsystem_version() | |
53 | #define MAGNUS_VERSION PRODUCT_VERSION_ID | |
54 | ||
55 | /* Include the public nsapi.h definitions */ | |
56 | #ifndef PUBLIC_NETSITE_H | |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
57 | #include "../public/nsapi.h" |
1 | 58 | #endif /* PUBLIC_NETSITE_H */ |
59 | ||
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
60 | #ifdef __cplusplus |
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
61 | extern "C" { |
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
62 | #endif |
1 | 63 | |
64 | /* | |
65 | * Only the mainline needs to set the malloc key. | |
66 | */ | |
67 | ||
68 | NSAPI_PUBLIC void InitThreadMallocKey(void); | |
69 | ||
70 | NSAPI_PUBLIC void system_set_temp_dir(const char *dir); | |
71 | ||
72 | NSAPI_PUBLIC const char *system_get_temp_dir(void); | |
73 | ||
74 | /* This probably belongs somewhere else, perhaps with a different name */ | |
75 | NSAPI_PUBLIC char *INTdns_guess_domain(char * hname); | |
76 | ||
77 | /* --- Begin public functions --- */ | |
78 | ||
79 | #ifdef INTNSAPI | |
80 | ||
81 | NSAPI_PUBLIC char *INTsystem_version(void); | |
82 | ||
83 | /* | |
84 | Depending on the system, memory allocated via these macros may come from | |
85 | an arena. If these functions are called from within an Init function, they | |
86 | will be allocated from permanent storage. Otherwise, they will be freed | |
87 | when the current request is finished. | |
88 | */ | |
89 | ||
82
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
90 | //define MALLOC(size) INTsystem_malloc(size) |
1 | 91 | NSAPI_PUBLIC void *INTsystem_malloc(int size); |
92 | ||
82
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
93 | //define CALLOC(size) INTsystem_calloc(size) |
1 | 94 | NSAPI_PUBLIC void *INTsystem_calloc(int size); |
95 | ||
82
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
96 | //define REALLOC(ptr, size) INTsystem_realloc(ptr, size) |
1 | 97 | NSAPI_PUBLIC void *INTsystem_realloc(void *ptr, int size); |
98 | ||
82
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
99 | //define FREE(ptr) INTsystem_free(ptr) |
1 | 100 | NSAPI_PUBLIC void INTsystem_free(void *ptr); |
101 | ||
102 | NSAPI_PUBLIC char *INTsystem_strdup(const char *ptr); | |
103 | ||
104 | /* | |
105 | These macros always provide permanent storage, for use in global variables | |
106 | and such. They are checked at runtime to prevent them from returning NULL. | |
107 | */ | |
108 | ||
109 | #define PERM_MALLOC(size) INTsystem_malloc_perm(size) | |
110 | NSAPI_PUBLIC void *INTsystem_malloc_perm(int size); | |
111 | ||
112 | #define PERM_CALLOC(size) INTsystem_calloc_perm(size) | |
113 | NSAPI_PUBLIC void *INTsystem_calloc_perm(int size); | |
114 | ||
115 | #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size) | |
116 | NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size); | |
117 | ||
118 | #define PERM_FREE(ptr) INTsystem_free_perm(ptr) | |
119 | NSAPI_PUBLIC void INTsystem_free_perm(void *ptr); | |
120 | ||
121 | #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr) | |
122 | NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr); | |
123 | ||
124 | /* Thread-Private data key index for accessing the thread-private memory pool. | |
125 | * Each thread creates its own pool for allocating data. The MALLOC/FREE/etc | |
126 | * macros have been defined to check the thread private data area with the | |
127 | * thread_malloc_key index to find the address for the pool currently in use. | |
128 | * | |
129 | * If a thread wants to use a different pool, it must change the thread-local- | |
130 | * storage[thread_malloc_key]. | |
131 | */ | |
132 | ||
133 | NSAPI_PUBLIC int INTgetThreadMallocKey(void); | |
134 | ||
135 | NSAPI_PUBLIC pool_handle_t *INTsystem_pool(void); | |
136 | ||
137 | /* Not sure where to put this. */ | |
138 | ||
139 | NSAPI_PUBLIC void INTsystem_setnewhandler(void); | |
140 | ||
141 | #endif /* INTNSAPI */ | |
142 | ||
143 | /* --- End public functions --- */ | |
144 | ||
171
af7e2d80dee6
adds wrapper for close syscall with error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
118
diff
changeset
|
145 | int system_close(int fd); |
af7e2d80dee6
adds wrapper for close syscall with error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
118
diff
changeset
|
146 | |
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
147 | #ifdef __cplusplus |
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
148 | } |
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
149 | #endif |
1 | 150 | |
151 | #ifdef INTNSAPI | |
152 | ||
153 | #define dns_guess_domain INTdns_guess_domain | |
154 | //define system_version INTsystem_version | |
155 | #define system_malloc INTsystem_malloc | |
156 | #define system_calloc INTsystem_calloc | |
157 | #define system_realloc INTsystem_realloc | |
158 | #define system_free INTsystem_free | |
159 | #define system_strdup INTsystem_strdup | |
160 | #define system_malloc_perm INTsystem_malloc_perm | |
161 | #define system_calloc_perm INTsystem_calloc_perm | |
162 | #define system_realloc_perm INTsystem_realloc_perm | |
163 | #define system_free_perm INTsystem_free_perm | |
164 | #define system_strdup_perm INTsystem_strdup_perm | |
165 | #define getThreadMallocKey INTgetThreadMallocKey | |
166 | #define system_pool INTsystem_pool | |
167 | #define system_setnewhandler INTsystem_setnewhandler | |
168 | ||
169 | #endif /* INTNSAPI */ | |
170 | ||
171 | #ifndef HTTPS_ADMSERV | |
172 | #define HTTPS_ADMSERV "https-admserv" | |
173 | #endif | |
174 | ||
175 | #endif /* NETSITE_H */ |