Debian Codegraph @

include/netsite.h

raw
1 /** BEGIN COPYRIGHT BLOCK
2 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3 * Copyright (C) 2005 Red Hat, Inc.
4 * All rights reserved.
5 *
6 * License: GPL (version 3 or any later version).
7 * See LICENSE for details.
8 * END COPYRIGHT BLOCK **/
9
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14 #ifndef NETSITE_H
15 #define NETSITE_H
16
17 #ifndef NOINTNSAPI
18 #define INTNSAPI
19 #endif /* !NOINTNSAPI */
20
21 /*
22 * Standard defs for NetSite servers.
23 */
24
25 /*
26 ** Macro shorthands for conditional C++ extern block delimiters.
27 ** Don't redefine for compatability with NSPR.
28 */
29 #ifndef NSPR_BEGIN_EXTERN_C
30 #ifdef __cplusplus
31 #define NSPR_BEGIN_EXTERN_C extern "C" {
32 #define NSPR_END_EXTERN_C }
33 #else
34 #define NSPR_BEGIN_EXTERN_C
35 #define NSPR_END_EXTERN_C
36 #endif
37 #endif /* NSPR_BEGIN_EXTERN_C */
38 #ifdef __cplusplus
39 #define EXTERNC extern "C"
40 #else
41 #define EXTERNC
42 #endif
43
44 #ifndef BASE_SYSTEMS_H
45 #include "base/systems.h"
46 #endif /* !BASE_SYSTEMS_H */
47
48 #ifndef VOID
49 #define VOID void
50 #endif
51
52 #if !defined(boolean) && !defined(__GNUC__)
53 typedef int boolean;
54 #endif
55
56 #define NS_TRUE 1
57 #define NS_FALSE 0
58
59 NSPR_BEGIN_EXTERN_C
60
61 #ifndef APSTUDIO_READONLY_SYMBOLS
62
63 /* Include the public netsite.h definitions */
64 #ifndef PUBLIC_NETSITE_H
65 #ifdef MALLOC_DEBUG
66 #define NS_MALLOC_DEBUG
67 #endif /* MALLOC_DEBUG */
68 #include "public/netsite.h"
69 #endif /* PUBLIC_NETSITE_H */
70
71 #endif /* !APSTUDIO_READONLY_SYMBOLS */
72
73 /*
74 * If NS_MALLOC_DEBUG is defined, declare the debug version of the memory
75 * allocation API.
76 */
77 #ifdef NS_MALLOC_DEBUG
78 #define PERM_MALLOC(size) INTsystem_malloc_perm(size, __LINE__, __FILE__)
79 NSAPI_PUBLIC void *INTsystem_malloc_perm(int size, int line, char *file);
80
81 #define PERM_CALLOC(size) INTsystem_calloc_perm(size, __LINE__, __FILE__)
82 NSAPI_PUBLIC void *INTsystem_calloc_perm(int size, int line, char *file);
83
84 #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size, __LINE__, __FILE__)
85 NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size, int line, char *file);
86
87 #define PERM_FREE(ptr) INTsystem_free_perm((void *)ptr, __LINE__, __FILE__)
88 NSAPI_PUBLIC void INTsystem_free_perm(void *ptr, int line, char *file);
89
90 #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr, __LINE__, __FILE__)
91 NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr, int line, char *file);
92 #endif /* NS_MALLOC_DEBUG */
93
94 /*
95 * Only the mainline needs to set the malloc key.
96 */
97
98 void setThreadMallocKey(int key);
99
100 /* This probably belongs somewhere else, perhaps with a different name */
101 NSAPI_PUBLIC char *INTdns_guess_domain(char *hname);
102
103 /* --- Begin public functions --- */
104
105 #ifdef INTNSAPI
106
107 NSAPI_PUBLIC char *INTsystem_version(void);
108
109 /*
110 Depending on the system, memory allocated via these macros may come from
111 an arena. If these functions are called from within an Init function, they
112 will be allocated from permanent storage. Otherwise, they will be freed
113 when the current request is finished.
114 */
115
116 #define MALLOC(size) INTsystem_malloc(size)
117 NSAPI_PUBLIC void *INTsystem_malloc(int size);
118
119 #define CALLOC(size) INTsystem_calloc(size)
120 NSAPI_PUBLIC void *INTsystem_calloc(int size);
121
122 #define REALLOC(ptr, size) INTsystem_realloc(ptr, size)
123 NSAPI_PUBLIC void *INTsystem_realloc(void *ptr, int size);
124
125 #define FREE(ptr) INTsystem_free((void *)ptr)
126 NSAPI_PUBLIC void INTsystem_free(void *ptr);
127
128 #define STRDUP(ptr) INTsystem_strdup(ptr)
129 NSAPI_PUBLIC char *INTsystem_strdup(const char *ptr);
130
131 /*
132 These macros always provide permanent storage, for use in global variables
133 and such. They are checked at runtime to prevent them from returning NULL.
134 */
135
136 #ifndef NS_MALLOC_DEBUG
137
138 #define PERM_MALLOC(size) INTsystem_malloc_perm(size)
139 NSAPI_PUBLIC void *INTsystem_malloc_perm(int size);
140
141 #define PERM_CALLOC(size) INTsystem_calloc_perm(size)
142 NSAPI_PUBLIC void *INTsystem_calloc_perm(int size);
143
144 #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size)
145 NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size);
146
147 #define PERM_FREE(ptr) INTsystem_free_perm((void *)ptr)
148 NSAPI_PUBLIC void INTsystem_free_perm(void *ptr);
149
150 #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr)
151 NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr);
152
153 #endif /* !NS_MALLOC_DEBUG */
154
155 /* Thread-Private data key index for accessing the thread-private memory pool.
156 * Each thread creates its own pool for allocating data. The MALLOC/FREE/etc
157 * macros have been defined to check the thread private data area with the
158 * thread_malloc_key index to find the address for the pool currently in use.
159 *
160 * If a thread wants to use a different pool, it must change the thread-local-
161 * storage[thread_malloc_key].
162 */
163
164 NSAPI_PUBLIC int INTgetThreadMallocKey(void);
165
166 /* Not sure where to put this. */
167 NSAPI_PUBLIC void INTmagnus_atrestart(void (*fn)(void *), void *data);
168
169 #endif /* INTNSAPI */
170
171 /* --- End public functions --- */
172
173 NSPR_END_EXTERN_C
174
175 #define system_version_set INTsystem_version_set
176 #define dns_guess_domain INTdns_guess_domain
177
178 #ifdef INTNSAPI
179
180 #define system_version INTsystem_version
181 #define system_malloc INTsystem_malloc
182 #define system_calloc INTsystem_calloc
183 #define system_realloc INTsystem_realloc
184 #define system_free INTsystem_free
185 #define system_strdup INTsystem_strdup
186 #define system_malloc_perm INTsystem_malloc_perm
187 #define system_calloc_perm INTsystem_calloc_perm
188 #define system_realloc_perm INTsystem_realloc_perm
189 #define system_free_perm INTsystem_free_perm
190 #define system_strdup_perm INTsystem_strdup_perm
191 #define getThreadMallocKey INTgetThreadMallocKey
192 #define magnus_atrestart INTmagnus_atrestart
193
194 #endif /* INTNSAPI */
195
196 #endif /* NETSITE_H */