netsite.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef NETSITE_H
  42. #define NETSITE_H
  43. #ifndef NOINTNSAPI
  44. #define INTNSAPI
  45. #endif /* !NOINTNSAPI */
  46. /*
  47. * Standard defs for NetSite servers.
  48. */
  49. /*
  50. ** Macro shorthands for conditional C++ extern block delimiters.
  51. ** Don't redefine for compatability with NSPR.
  52. */
  53. #ifndef NSPR_BEGIN_EXTERN_C
  54. #ifdef __cplusplus
  55. #define NSPR_BEGIN_EXTERN_C extern "C" {
  56. #define NSPR_END_EXTERN_C }
  57. #else
  58. #define NSPR_BEGIN_EXTERN_C
  59. #define NSPR_END_EXTERN_C
  60. #endif
  61. #endif /* NSPR_BEGIN_EXTERN_C */
  62. #ifdef __cplusplus
  63. #define EXTERNC extern "C"
  64. #else
  65. #define EXTERNC
  66. #endif
  67. #ifndef VERSION_H
  68. #include "version.h"
  69. #endif /* !VERSION_H */
  70. #ifndef BASE_SYSTEMS_H
  71. #include "base/systems.h"
  72. #endif /* !BASE_SYSTEMS_H */
  73. #ifndef VOID
  74. #define VOID void
  75. #endif
  76. #ifdef XP_UNIX
  77. /*
  78. * Provide some typedefs that are commonly used on windows
  79. *
  80. * DO NOT USE THESE! They will be deleted later!
  81. *
  82. */
  83. #define CONST const
  84. typedef unsigned long DWORD;
  85. typedef int BOOL;
  86. typedef unsigned char BYTE;
  87. typedef unsigned short WORD;
  88. typedef float FLOAT;
  89. typedef FLOAT *PFLOAT;
  90. typedef BOOL *PBOOL;
  91. typedef BOOL *LPBOOL;
  92. typedef BYTE *PBYTE;
  93. typedef BYTE *LPBYTE;
  94. typedef int *PINT;
  95. typedef int *LPINT;
  96. typedef WORD *PWORD;
  97. typedef WORD *LPWORD;
  98. typedef long *LPLONG;
  99. typedef DWORD *PDWORD;
  100. typedef DWORD *LPDWORD;
  101. typedef void *LPVOID;
  102. #ifndef SNI
  103. #if !defined (boolean) && !defined (__GNUC__)
  104. typedef int boolean;
  105. #endif
  106. #endif
  107. #endif
  108. #define NS_TRUE 1
  109. #define NS_FALSE 0
  110. NSPR_BEGIN_EXTERN_C
  111. #ifndef APSTUDIO_READONLY_SYMBOLS
  112. /* Include the public netsite.h definitions */
  113. #ifndef PUBLIC_NETSITE_H
  114. #ifdef MALLOC_DEBUG
  115. #define NS_MALLOC_DEBUG
  116. #endif /* MALLOC_DEBUG */
  117. #include "public/netsite.h"
  118. #endif /* PUBLIC_NETSITE_H */
  119. #endif /* !APSTUDIO_READONLY_SYMBOLS */
  120. /*
  121. * If NS_MALLOC_DEBUG is defined, declare the debug version of the memory
  122. * allocation API.
  123. */
  124. #ifdef NS_MALLOC_DEBUG
  125. #define PERM_MALLOC(size) INTsystem_malloc_perm(size, __LINE__, __FILE__)
  126. NSAPI_PUBLIC void *INTsystem_malloc_perm(int size, int line, char *file);
  127. #define PERM_CALLOC(size) INTsystem_calloc_perm(size, __LINE__, __FILE__)
  128. NSAPI_PUBLIC void *INTsystem_calloc_perm(int size, int line, char *file);
  129. #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size, __LINE__, __FILE__)
  130. NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size, int line, char *file);
  131. #define PERM_FREE(ptr) INTsystem_free_perm((void *) ptr, __LINE__, __FILE__)
  132. NSAPI_PUBLIC void INTsystem_free_perm(void *ptr, int line, char *file);
  133. #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr, __LINE__, __FILE__)
  134. NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr, int line, char *file);
  135. #endif /* NS_MALLOC_DEBUG */
  136. /*
  137. * Only the mainline needs to set the malloc key.
  138. */
  139. void setThreadMallocKey(int key);
  140. /* This probably belongs somewhere else, perhaps with a different name */
  141. NSAPI_PUBLIC char *INTdns_guess_domain(char * hname);
  142. /* --- Begin public functions --- */
  143. #ifdef INTNSAPI
  144. NSAPI_PUBLIC char *INTsystem_version();
  145. /*
  146. Depending on the system, memory allocated via these macros may come from
  147. an arena. If these functions are called from within an Init function, they
  148. will be allocated from permanent storage. Otherwise, they will be freed
  149. when the current request is finished.
  150. */
  151. #define MALLOC(size) INTsystem_malloc(size)
  152. NSAPI_PUBLIC void *INTsystem_malloc(int size);
  153. #define CALLOC(size) INTsystem_calloc(size)
  154. NSAPI_PUBLIC void *INTsystem_calloc(int size);
  155. #define REALLOC(ptr, size) INTsystem_realloc(ptr, size)
  156. NSAPI_PUBLIC void *INTsystem_realloc(void *ptr, int size);
  157. #define FREE(ptr) INTsystem_free((void *) ptr)
  158. NSAPI_PUBLIC void INTsystem_free(void *ptr);
  159. #define STRDUP(ptr) INTsystem_strdup(ptr)
  160. NSAPI_PUBLIC char *INTsystem_strdup(const char *ptr);
  161. /*
  162. These macros always provide permanent storage, for use in global variables
  163. and such. They are checked at runtime to prevent them from returning NULL.
  164. */
  165. #ifndef NS_MALLOC_DEBUG
  166. #define PERM_MALLOC(size) INTsystem_malloc_perm(size)
  167. NSAPI_PUBLIC void *INTsystem_malloc_perm(int size);
  168. #define PERM_CALLOC(size) INTsystem_calloc_perm(size)
  169. NSAPI_PUBLIC void *INTsystem_calloc_perm(int size);
  170. #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size)
  171. NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size);
  172. #define PERM_FREE(ptr) INTsystem_free_perm((void *) ptr)
  173. NSAPI_PUBLIC void INTsystem_free_perm(void *ptr);
  174. #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr)
  175. NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr);
  176. #endif /* !NS_MALLOC_DEBUG */
  177. /* Thread-Private data key index for accessing the thread-private memory pool.
  178. * Each thread creates its own pool for allocating data. The MALLOC/FREE/etc
  179. * macros have been defined to check the thread private data area with the
  180. * thread_malloc_key index to find the address for the pool currently in use.
  181. *
  182. * If a thread wants to use a different pool, it must change the thread-local-
  183. * storage[thread_malloc_key].
  184. */
  185. NSAPI_PUBLIC int INTgetThreadMallocKey(void);
  186. /* Not sure where to put this. */
  187. NSAPI_PUBLIC void INTmagnus_atrestart(void (*fn)(void *), void *data);
  188. #endif /* INTNSAPI */
  189. /* --- End public functions --- */
  190. NSPR_END_EXTERN_C
  191. #define system_version_set INTsystem_version_set
  192. #define dns_guess_domain INTdns_guess_domain
  193. #ifdef INTNSAPI
  194. #define system_version INTsystem_version
  195. #define system_malloc INTsystem_malloc
  196. #define system_calloc INTsystem_calloc
  197. #define system_realloc INTsystem_realloc
  198. #define system_free INTsystem_free
  199. #define system_strdup INTsystem_strdup
  200. #define system_malloc_perm INTsystem_malloc_perm
  201. #define system_calloc_perm INTsystem_calloc_perm
  202. #define system_realloc_perm INTsystem_realloc_perm
  203. #define system_free_perm INTsystem_free_perm
  204. #define system_strdup_perm INTsystem_strdup_perm
  205. #define getThreadMallocKey INTgetThreadMallocKey
  206. #define magnus_atrestart INTmagnus_atrestart
  207. #endif /* INTNSAPI */
  208. #endif /* NETSITE_H */