src/server/daemon/netsite.h

changeset 14
b8bf95b39952
parent 9
30e51941a673
child 24
1a7853a4257e
equal deleted inserted replaced
13:1fdbf4170ef4 14:b8bf95b39952
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
45 #include <mps/nspr.h>
46
47 #ifndef BASE_SYSTEMS_H
48 #include "../util/systems.h"
49 #endif /* !BASE_SYSTEMS_H */
50
51
52
53 #define MAGNUS_VERSION_STRING INTsystem_version()
54 #define MAGNUS_VERSION PRODUCT_VERSION_ID
55
56 /* Include the public nsapi.h definitions */
57 #ifndef PUBLIC_NETSITE_H
58 #include "../public/nsapi.h"
59 #endif /* PUBLIC_NETSITE_H */
60
61 NSPR_BEGIN_EXTERN_C
62
63 /*
64 * Only the mainline needs to set the malloc key.
65 */
66
67 NSAPI_PUBLIC void InitThreadMallocKey(void);
68
69 NSAPI_PUBLIC void system_set_temp_dir(const char *dir);
70
71 NSAPI_PUBLIC const char *system_get_temp_dir(void);
72
73 /* This probably belongs somewhere else, perhaps with a different name */
74 NSAPI_PUBLIC char *INTdns_guess_domain(char * hname);
75
76 /* --- Begin public functions --- */
77
78 #ifdef INTNSAPI
79
80 NSAPI_PUBLIC char *INTsystem_version(void);
81
82 /*
83 Depending on the system, memory allocated via these macros may come from
84 an arena. If these functions are called from within an Init function, they
85 will be allocated from permanent storage. Otherwise, they will be freed
86 when the current request is finished.
87 */
88
89 #define MALLOC(size) INTsystem_malloc(size)
90 NSAPI_PUBLIC void *INTsystem_malloc(int size);
91
92 #define CALLOC(size) INTsystem_calloc(size)
93 NSAPI_PUBLIC void *INTsystem_calloc(int size);
94
95 #define REALLOC(ptr, size) INTsystem_realloc(ptr, size)
96 NSAPI_PUBLIC void *INTsystem_realloc(void *ptr, int size);
97
98 #define FREE(ptr) INTsystem_free(ptr)
99 NSAPI_PUBLIC void INTsystem_free(void *ptr);
100
101 #define STRDUP(ptr) INTsystem_strdup(ptr)
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
145 NSPR_END_EXTERN_C
146
147 #ifdef INTNSAPI
148
149 #define dns_guess_domain INTdns_guess_domain
150 //define system_version INTsystem_version
151 #define system_malloc INTsystem_malloc
152 #define system_calloc INTsystem_calloc
153 #define system_realloc INTsystem_realloc
154 #define system_free INTsystem_free
155 #define system_strdup INTsystem_strdup
156 #define system_malloc_perm INTsystem_malloc_perm
157 #define system_calloc_perm INTsystem_calloc_perm
158 #define system_realloc_perm INTsystem_realloc_perm
159 #define system_free_perm INTsystem_free_perm
160 #define system_strdup_perm INTsystem_strdup_perm
161 #define getThreadMallocKey INTgetThreadMallocKey
162 #define system_pool INTsystem_pool
163 #define system_setnewhandler INTsystem_setnewhandler
164
165 #endif /* INTNSAPI */
166
167 #ifndef HTTPS_ADMSERV
168 #define HTTPS_ADMSERV "https-admserv"
169 #endif
170
171 #endif /* NETSITE_H */

mercurial