netsite.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. #ifndef NETSITE_H
  39. #define NETSITE_H
  40. #ifndef NOINTNSAPI
  41. #define INTNSAPI
  42. #endif /* !NOINTNSAPI */
  43. /*
  44. * Standard defs for NetSite servers.
  45. */
  46. /*
  47. ** Macro shorthands for conditional C++ extern block delimiters.
  48. ** Don't redefine for compatability with NSPR.
  49. */
  50. #ifndef NSPR_BEGIN_EXTERN_C
  51. #ifdef __cplusplus
  52. #define NSPR_BEGIN_EXTERN_C extern "C" {
  53. #define NSPR_END_EXTERN_C }
  54. #else
  55. #define NSPR_BEGIN_EXTERN_C
  56. #define NSPR_END_EXTERN_C
  57. #endif
  58. #endif /* NSPR_BEGIN_EXTERN_C */
  59. #ifdef __cplusplus
  60. #define EXTERNC extern "C"
  61. #else
  62. #define EXTERNC
  63. #endif
  64. #ifndef VERSION_H
  65. #include "version.h"
  66. #endif /* !VERSION_H */
  67. #ifndef BASE_SYSTEMS_H
  68. #include "base/systems.h"
  69. #endif /* !BASE_SYSTEMS_H */
  70. #ifndef VOID
  71. #define VOID void
  72. #endif
  73. #ifdef XP_UNIX
  74. /*
  75. * Provide some typedefs that are commonly used on windows
  76. *
  77. * DO NOT USE THESE! They will be deleted later!
  78. *
  79. */
  80. #define CONST const
  81. typedef unsigned long DWORD;
  82. typedef int BOOL;
  83. typedef unsigned char BYTE;
  84. typedef unsigned short WORD;
  85. typedef float FLOAT;
  86. typedef FLOAT *PFLOAT;
  87. typedef BOOL *PBOOL;
  88. typedef BOOL *LPBOOL;
  89. typedef BYTE *PBYTE;
  90. typedef BYTE *LPBYTE;
  91. typedef int *PINT;
  92. typedef int *LPINT;
  93. typedef WORD *PWORD;
  94. typedef WORD *LPWORD;
  95. typedef long *LPLONG;
  96. typedef DWORD *PDWORD;
  97. typedef DWORD *LPDWORD;
  98. typedef void *LPVOID;
  99. #ifndef SNI
  100. #if !defined (boolean) && !defined (__GNUC__)
  101. typedef int boolean;
  102. #endif
  103. #endif
  104. #endif
  105. #define NS_TRUE 1
  106. #define NS_FALSE 0
  107. NSPR_BEGIN_EXTERN_C
  108. #ifndef APSTUDIO_READONLY_SYMBOLS
  109. /* Include the public netsite.h definitions */
  110. #ifndef PUBLIC_NETSITE_H
  111. #ifdef MALLOC_DEBUG
  112. #define NS_MALLOC_DEBUG
  113. #endif /* MALLOC_DEBUG */
  114. #include "public/netsite.h"
  115. #endif /* PUBLIC_NETSITE_H */
  116. #endif /* !APSTUDIO_READONLY_SYMBOLS */
  117. /*
  118. * If NS_MALLOC_DEBUG is defined, declare the debug version of the memory
  119. * allocation API.
  120. */
  121. #ifdef NS_MALLOC_DEBUG
  122. #define PERM_MALLOC(size) INTsystem_malloc_perm(size, __LINE__, __FILE__)
  123. NSAPI_PUBLIC void *INTsystem_malloc_perm(int size, int line, char *file);
  124. #define PERM_CALLOC(size) INTsystem_calloc_perm(size, __LINE__, __FILE__)
  125. NSAPI_PUBLIC void *INTsystem_calloc_perm(int size, int line, char *file);
  126. #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size, __LINE__, __FILE__)
  127. NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size, int line, char *file);
  128. #define PERM_FREE(ptr) INTsystem_free_perm((void *) ptr, __LINE__, __FILE__)
  129. NSAPI_PUBLIC void INTsystem_free_perm(void *ptr, int line, char *file);
  130. #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr, __LINE__, __FILE__)
  131. NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr, int line, char *file);
  132. #endif /* NS_MALLOC_DEBUG */
  133. /*
  134. * Only the mainline needs to set the malloc key.
  135. */
  136. void setThreadMallocKey(int key);
  137. /* This probably belongs somewhere else, perhaps with a different name */
  138. NSAPI_PUBLIC char *INTdns_guess_domain(char * hname);
  139. /* --- Begin public functions --- */
  140. #ifdef INTNSAPI
  141. NSAPI_PUBLIC char *INTsystem_version();
  142. /*
  143. Depending on the system, memory allocated via these macros may come from
  144. an arena. If these functions are called from within an Init function, they
  145. will be allocated from permanent storage. Otherwise, they will be freed
  146. when the current request is finished.
  147. */
  148. #define MALLOC(size) INTsystem_malloc(size)
  149. NSAPI_PUBLIC void *INTsystem_malloc(int size);
  150. #define CALLOC(size) INTsystem_calloc(size)
  151. NSAPI_PUBLIC void *INTsystem_calloc(int size);
  152. #define REALLOC(ptr, size) INTsystem_realloc(ptr, size)
  153. NSAPI_PUBLIC void *INTsystem_realloc(void *ptr, int size);
  154. #define FREE(ptr) INTsystem_free((void *) ptr)
  155. NSAPI_PUBLIC void INTsystem_free(void *ptr);
  156. #define STRDUP(ptr) INTsystem_strdup(ptr)
  157. NSAPI_PUBLIC char *INTsystem_strdup(const char *ptr);
  158. /*
  159. These macros always provide permanent storage, for use in global variables
  160. and such. They are checked at runtime to prevent them from returning NULL.
  161. */
  162. #ifndef NS_MALLOC_DEBUG
  163. #define PERM_MALLOC(size) INTsystem_malloc_perm(size)
  164. NSAPI_PUBLIC void *INTsystem_malloc_perm(int size);
  165. #define PERM_CALLOC(size) INTsystem_calloc_perm(size)
  166. NSAPI_PUBLIC void *INTsystem_calloc_perm(int size);
  167. #define PERM_REALLOC(ptr, size) INTsystem_realloc_perm(ptr, size)
  168. NSAPI_PUBLIC void *INTsystem_realloc_perm(void *ptr, int size);
  169. #define PERM_FREE(ptr) INTsystem_free_perm((void *) ptr)
  170. NSAPI_PUBLIC void INTsystem_free_perm(void *ptr);
  171. #define PERM_STRDUP(ptr) INTsystem_strdup_perm(ptr)
  172. NSAPI_PUBLIC char *INTsystem_strdup_perm(const char *ptr);
  173. #endif /* !NS_MALLOC_DEBUG */
  174. /* Thread-Private data key index for accessing the thread-private memory pool.
  175. * Each thread creates its own pool for allocating data. The MALLOC/FREE/etc
  176. * macros have been defined to check the thread private data area with the
  177. * thread_malloc_key index to find the address for the pool currently in use.
  178. *
  179. * If a thread wants to use a different pool, it must change the thread-local-
  180. * storage[thread_malloc_key].
  181. */
  182. NSAPI_PUBLIC int INTgetThreadMallocKey(void);
  183. /* Not sure where to put this. */
  184. NSAPI_PUBLIC void INTmagnus_atrestart(void (*fn)(void *), void *data);
  185. #endif /* INTNSAPI */
  186. /* --- End public functions --- */
  187. NSPR_END_EXTERN_C
  188. #define system_version_set INTsystem_version_set
  189. #define dns_guess_domain INTdns_guess_domain
  190. #ifdef INTNSAPI
  191. #define system_version INTsystem_version
  192. #define system_malloc INTsystem_malloc
  193. #define system_calloc INTsystem_calloc
  194. #define system_realloc INTsystem_realloc
  195. #define system_free INTsystem_free
  196. #define system_strdup INTsystem_strdup
  197. #define system_malloc_perm INTsystem_malloc_perm
  198. #define system_calloc_perm INTsystem_calloc_perm
  199. #define system_realloc_perm INTsystem_realloc_perm
  200. #define system_free_perm INTsystem_free_perm
  201. #define system_strdup_perm INTsystem_strdup_perm
  202. #define getThreadMallocKey INTgetThreadMallocKey
  203. #define magnus_atrestart INTmagnus_atrestart
  204. #endif /* INTNSAPI */
  205. #endif /* NETSITE_H */