Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/util/secport.h @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 | |
5 /* | |
6 * secport.h - portability interfaces for security libraries | |
7 */ | |
8 | |
9 #ifndef _SECPORT_H_ | |
10 #define _SECPORT_H_ | |
11 | |
12 #include "utilrename.h" | |
13 #include "prlink.h" | |
14 | |
15 /* | |
16 * define XP_WIN, XP_BEOS, or XP_UNIX, in case they are not defined | |
17 * by anyone else | |
18 */ | |
19 #ifdef _WINDOWS | |
20 # ifndef XP_WIN | |
21 # define XP_WIN | |
22 # endif | |
23 #if defined(_WIN32) || defined(WIN32) | |
24 # ifndef XP_WIN32 | |
25 # define XP_WIN32 | |
26 # endif | |
27 #endif | |
28 #endif | |
29 | |
30 #ifdef __BEOS__ | |
31 # ifndef XP_BEOS | |
32 # define XP_BEOS | |
33 # endif | |
34 #endif | |
35 | |
36 #ifdef unix | |
37 # ifndef XP_UNIX | |
38 # define XP_UNIX | |
39 # endif | |
40 #endif | |
41 | |
42 #include <sys/types.h> | |
43 | |
44 #include <ctype.h> | |
45 #include <string.h> | |
46 #include <stddef.h> | |
47 #include <stdlib.h> | |
48 #include "prtypes.h" | |
49 #include "prlog.h" /* for PR_ASSERT */ | |
50 #include "plarena.h" | |
51 #include "plstr.h" | |
52 | |
53 /* | |
54 * HACK for NSS 2.8 to allow Admin to compile without source changes. | |
55 */ | |
56 #ifndef SEC_BEGIN_PROTOS | |
57 #include "seccomon.h" | |
58 #endif | |
59 | |
60 SEC_BEGIN_PROTOS | |
61 | |
62 extern void *PORT_Alloc(size_t len); | |
63 extern void *PORT_Realloc(void *old, size_t len); | |
64 extern void *PORT_AllocBlock(size_t len); | |
65 extern void *PORT_ReallocBlock(void *old, size_t len); | |
66 extern void PORT_FreeBlock(void *ptr); | |
67 extern void *PORT_ZAlloc(size_t len); | |
68 extern void PORT_Free(void *ptr); | |
69 extern void PORT_ZFree(void *ptr, size_t len); | |
70 extern char *PORT_Strdup(const char *s); | |
71 extern time_t PORT_Time(void); | |
72 extern void PORT_SetError(int value); | |
73 extern int PORT_GetError(void); | |
74 | |
75 extern PLArenaPool *PORT_NewArena(unsigned long chunksize); | |
76 extern void *PORT_ArenaAlloc(PLArenaPool *arena, size_t size); | |
77 extern void *PORT_ArenaZAlloc(PLArenaPool *arena, size_t size); | |
78 extern void PORT_FreeArena(PLArenaPool *arena, PRBool zero); | |
79 extern void *PORT_ArenaGrow(PLArenaPool *arena, void *ptr, | |
80 size_t oldsize, size_t newsize); | |
81 extern void *PORT_ArenaMark(PLArenaPool *arena); | |
82 extern void PORT_ArenaRelease(PLArenaPool *arena, void *mark); | |
83 extern void PORT_ArenaZRelease(PLArenaPool *arena, void *mark); | |
84 extern void PORT_ArenaUnmark(PLArenaPool *arena, void *mark); | |
85 extern char *PORT_ArenaStrdup(PLArenaPool *arena, const char *str); | |
86 | |
87 SEC_END_PROTOS | |
88 | |
89 #define PORT_Assert PR_ASSERT | |
90 #define PORT_ZNew(type) (type*)PORT_ZAlloc(sizeof(type)) | |
91 #define PORT_New(type) (type*)PORT_Alloc(sizeof(type)) | |
92 #define PORT_ArenaNew(poolp, type) \ | |
93 (type*) PORT_ArenaAlloc(poolp, sizeof(type)) | |
94 #define PORT_ArenaZNew(poolp, type) \ | |
95 (type*) PORT_ArenaZAlloc(poolp, sizeof(type)) | |
96 #define PORT_NewArray(type, num) \ | |
97 (type*) PORT_Alloc (sizeof(type)*(num)) | |
98 #define PORT_ZNewArray(type, num) \ | |
99 (type*) PORT_ZAlloc (sizeof(type)*(num)) | |
100 #define PORT_ArenaNewArray(poolp, type, num) \ | |
101 (type*) PORT_ArenaAlloc (poolp, sizeof(type)*(num)) | |
102 #define PORT_ArenaZNewArray(poolp, type, num) \ | |
103 (type*) PORT_ArenaZAlloc (poolp, sizeof(type)*(num)) | |
104 | |
105 /* Please, keep these defines sorted alphabetically. Thanks! */ | |
106 | |
107 #define PORT_Atoi(buff) (int)strtol(buff, NULL, 10) | |
108 | |
109 /* Returns a UTF-8 encoded constant error string for err. | |
110 * Returns NULL if initialization of the error tables fails | |
111 * due to insufficient memory. | |
112 * | |
113 * This string must not be modified by the application. | |
114 */ | |
115 #define PORT_ErrorToString(err) PR_ErrorToString((err), PR_LANGUAGE_I_DEFAULT) | |
116 | |
117 #define PORT_ErrorToName PR_ErrorToName | |
118 | |
119 #define PORT_Memcmp memcmp | |
120 #define PORT_Memcpy memcpy | |
121 #ifndef SUNOS4 | |
122 #define PORT_Memmove memmove | |
123 #else /*SUNOS4*/ | |
124 #define PORT_Memmove(s,ct,n) bcopy ((ct), (s), (n)) | |
125 #endif/*SUNOS4*/ | |
126 #define PORT_Memset memset | |
127 | |
128 #define PORT_Strcasecmp PL_strcasecmp | |
129 #define PORT_Strcat strcat | |
130 #define PORT_Strchr strchr | |
131 #define PORT_Strrchr strrchr | |
132 #define PORT_Strcmp strcmp | |
133 #define PORT_Strcpy strcpy | |
134 #define PORT_Strlen(s) strlen(s) | |
135 #define PORT_Strncasecmp PL_strncasecmp | |
136 #define PORT_Strncat strncat | |
137 #define PORT_Strncmp strncmp | |
138 #define PORT_Strncpy strncpy | |
139 #define PORT_Strpbrk strpbrk | |
140 #define PORT_Strstr strstr | |
141 #define PORT_Strtok strtok | |
142 | |
143 #define PORT_Tolower tolower | |
144 | |
145 typedef PRBool (PR_CALLBACK * PORTCharConversionWSwapFunc) (PRBool toUnicode, | |
146 unsigned char *inBuf, unsigned int inBufLen, | |
147 unsigned char *outBuf, unsigned int maxOutBufLen, | |
148 unsigned int *outBufLen, PRBool swapBytes); | |
149 | |
150 typedef PRBool (PR_CALLBACK * PORTCharConversionFunc) (PRBool toUnicode, | |
151 unsigned char *inBuf, unsigned int inBufLen, | |
152 unsigned char *outBuf, unsigned int maxOutBufLen, | |
153 unsigned int *outBufLen); | |
154 | |
155 SEC_BEGIN_PROTOS | |
156 | |
157 void PORT_SetUCS4_UTF8ConversionFunction(PORTCharConversionFunc convFunc); | |
158 void PORT_SetUCS2_ASCIIConversionFunction(PORTCharConversionWSwapFunc convFunc); | |
159 PRBool PORT_UCS4_UTF8Conversion(PRBool toUnicode, unsigned char *inBuf, | |
160 unsigned int inBufLen, unsigned char *outBuf, | |
161 unsigned int maxOutBufLen, unsigned int *outBufLen); | |
162 PRBool PORT_UCS2_ASCIIConversion(PRBool toUnicode, unsigned char *inBuf, | |
163 unsigned int inBufLen, unsigned char *outBuf, | |
164 unsigned int maxOutBufLen, unsigned int *outBufLen, | |
165 PRBool swapBytes); | |
166 void PORT_SetUCS2_UTF8ConversionFunction(PORTCharConversionFunc convFunc); | |
167 PRBool PORT_UCS2_UTF8Conversion(PRBool toUnicode, unsigned char *inBuf, | |
168 unsigned int inBufLen, unsigned char *outBuf, | |
169 unsigned int maxOutBufLen, unsigned int *outBufLen); | |
170 | |
171 /* One-way conversion from ISO-8859-1 to UTF-8 */ | |
172 PRBool PORT_ISO88591_UTF8Conversion(const unsigned char *inBuf, | |
173 unsigned int inBufLen, unsigned char *outBuf, | |
174 unsigned int maxOutBufLen, unsigned int *outBufLen); | |
175 | |
176 extern PRBool | |
177 sec_port_ucs4_utf8_conversion_function | |
178 ( | |
179 PRBool toUnicode, | |
180 unsigned char *inBuf, | |
181 unsigned int inBufLen, | |
182 unsigned char *outBuf, | |
183 unsigned int maxOutBufLen, | |
184 unsigned int *outBufLen | |
185 ); | |
186 | |
187 extern PRBool | |
188 sec_port_ucs2_utf8_conversion_function | |
189 ( | |
190 PRBool toUnicode, | |
191 unsigned char *inBuf, | |
192 unsigned int inBufLen, | |
193 unsigned char *outBuf, | |
194 unsigned int maxOutBufLen, | |
195 unsigned int *outBufLen | |
196 ); | |
197 | |
198 /* One-way conversion from ISO-8859-1 to UTF-8 */ | |
199 extern PRBool | |
200 sec_port_iso88591_utf8_conversion_function | |
201 ( | |
202 const unsigned char *inBuf, | |
203 unsigned int inBufLen, | |
204 unsigned char *outBuf, | |
205 unsigned int maxOutBufLen, | |
206 unsigned int *outBufLen | |
207 ); | |
208 | |
209 extern int NSS_PutEnv(const char * envVarName, const char * envValue); | |
210 | |
211 extern int NSS_SecureMemcmp(const void *a, const void *b, size_t n); | |
212 | |
213 #ifndef NSS_STATIC | |
214 /* | |
215 * Load a shared library called "newShLibName" in the same directory as | |
216 * a shared library that is already loaded, called existingShLibName. | |
217 * A pointer to a static function in that shared library, | |
218 * staticShLibFunc, is required. | |
219 * | |
220 * existingShLibName: | |
221 * The file name of the shared library that shall be used as the | |
222 * "reference library". The loader will attempt to load the requested | |
223 * library from the same directory as the reference library. | |
224 * | |
225 * staticShLibFunc: | |
226 * Pointer to a static function in the "reference library". | |
227 * | |
228 * newShLibName: | |
229 * The simple file name of the new shared library to be loaded. | |
230 * | |
231 * We use PR_GetLibraryFilePathname to get the pathname of the loaded | |
232 * shared lib that contains this function, and then do a | |
233 * PR_LoadLibraryWithFlags with an absolute pathname for the shared | |
234 * library to be loaded. | |
235 * | |
236 * On Windows, the "alternate search path" strategy is employed, if available. | |
237 * On Unix, if existingShLibName is a symbolic link, and no link exists for the | |
238 * new library, the original link will be resolved, and the new library loaded | |
239 * from the resolved location. | |
240 * | |
241 * If the new shared library is not found in the same location as the reference | |
242 * library, it will then be loaded from the normal system library path. | |
243 */ | |
244 PRLibrary * | |
245 PORT_LoadLibraryFromOrigin(const char* existingShLibName, | |
246 PRFuncPtr staticShLibFunc, | |
247 const char *newShLibName); | |
248 #endif /* NSS_STATIC */ | |
249 | |
250 SEC_END_PROTOS | |
251 | |
252 #endif /* _SECPORT_H_ */ |