Mercurial > hg
annotate mcabber/libjabber/libxode.h @ 1573:ece4f26bf9ff
Add count parameter to roster up/down command
(Based on a patch from knyar in the issue tracker)
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 13 Apr 2009 00:26:56 +0200 |
parents | 9054697b1a06 |
children |
rev | line source |
---|---|
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
1 /* |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
2 * jabberd - Jabber Open Source Server |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
3 * Copyright (c) 2002 Jeremie Miller, Thomas Muldowney, |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
4 * Ryan Eatmon, Robert Norris |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
5 * |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
9 * (at your option) any later version. |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
10 * |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
14 * GNU General Public License for more details. |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
15 * |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
19 */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
20 |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
21 #ifdef HAVE_CONFIG_H |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
22 # include <config.h> |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
23 #endif |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
24 |
25 | 25 #include <string.h> |
26 #include <stdlib.h> | |
27 #include <sys/types.h> | |
28 #include <stdio.h> | |
29 #include <setjmp.h> | |
30 #include <sys/stat.h> | |
31 #include <fcntl.h> | |
32 #include <errno.h> | |
33 #include <signal.h> | |
34 #include <strings.h> | |
35 #include <unistd.h> | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
36 #include <sys/time.h> |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
37 #include <syslog.h> |
25 | 38 #include <netinet/in.h> |
39 #include <netdb.h> | |
40 #include <arpa/inet.h> | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
41 #include <sys/socket.h> |
25 | 42 |
43 #include "xmlparse.h" | |
44 | |
45 /* | |
46 ** Arrange to use either varargs or stdargs | |
47 */ | |
48 | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
49 #define MAXSHORTSTR 203 /* max short string length */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
50 #define QUAD_T unsigned long long |
25 | 51 |
52 #ifdef __STDC__ | |
53 | |
54 #include <stdarg.h> | |
55 | |
56 # define VA_LOCAL_DECL va_list ap; | |
57 # define VA_START(f) va_start(ap, f) | |
58 # define VA_END va_end(ap) | |
59 | |
60 #else /* __STDC__ */ | |
61 | |
62 # include <varargs.h> | |
63 | |
64 # define VA_LOCAL_DECL va_list ap; | |
65 # define VA_START(f) va_start(ap) | |
66 # define VA_END va_end(ap) | |
67 | |
68 #endif /* __STDC__ */ | |
69 | |
70 | |
71 #ifndef INCL_LIBXODE_H | |
72 #define INCL_LIBXODE_H | |
73 | |
74 #ifdef __cplusplus | |
75 extern "C" { | |
76 #endif | |
77 | |
78 | |
79 #ifndef HAVE_SNPRINTF | |
80 extern int ap_snprintf(char *, size_t, const char *, ...); | |
81 #define snprintf ap_snprintf | |
82 #endif | |
83 | |
84 #ifndef HAVE_VSNPRINTF | |
85 extern int ap_vsnprintf(char *, size_t, const char *, va_list ap); | |
86 #define vsnprintf ap_vsnprintf | |
87 #endif | |
88 | |
89 #define ZONE zonestr(__FILE__,__LINE__) | |
90 char *zonestr(char *file, int line); | |
91 | |
92 /* --------------------------------------------------------- */ | |
93 /* */ | |
94 /* Pool-based memory management routines */ | |
95 /* */ | |
96 /* --------------------------------------------------------- */ | |
97 | |
98 #undef POOL_DEBUG | |
99 /* | |
100 flip these, this should be a prime number for top # of pools debugging | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
101 #define POOL_DEBUG 40009 |
25 | 102 */ |
103 | |
104 /* pheap - singular allocation of memory */ | |
105 struct pheap | |
106 { | |
107 void *block; | |
108 int size, used; | |
109 }; | |
110 | |
111 /* pool_cleaner - callback type which is associated | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
112 with a pool entry; invoked when the pool entry is |
25 | 113 free'd */ |
114 typedef void (*pool_cleaner)(void *arg); | |
115 | |
116 /* pfree - a linked list node which stores an | |
117 allocation chunk, plus a callback */ | |
118 struct pfree | |
119 { | |
120 pool_cleaner f; | |
121 void *arg; | |
122 struct pheap *heap; | |
123 struct pfree *next; | |
124 }; | |
125 | |
126 /* pool - base node for a pool. Maintains a linked list | |
127 of pool entries (pfree) */ | |
128 typedef struct pool_struct | |
129 { | |
130 int size; | |
131 struct pfree *cleanup; | |
132 struct pheap *heap; | |
133 #ifdef POOL_DEBUG | |
134 char name[8], zone[32]; | |
135 int lsize; | |
136 } _pool, *pool; | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
137 #define pool_new() _pool_new(__FILE__,__LINE__) |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
138 #define pool_heap(i) _pool_new_heap(i,__FILE__,__LINE__) |
25 | 139 #else |
140 } _pool, *pool; | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
141 #define pool_heap(i) _pool_new_heap(i, NULL, 0) |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
142 #define pool_new() _pool_new(NULL, 0) |
25 | 143 #endif |
144 | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
145 pool _pool_new(char *zone, int line); /* new pool :) */ |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
146 pool _pool_new_heap(int size, char *zone, int line); /* creates a new memory pool with an initial heap size */ |
25 | 147 void *pmalloc(pool p, int size); /* wrapper around malloc, takes from the pool, cleaned up automatically */ |
148 void *pmalloc_x(pool p, int size, char c); /* Wrapper around pmalloc which prefils buffer with c */ | |
149 void *pmalloco(pool p, int size); /* YAPW for zeroing the block */ | |
150 char *pstrdup(pool p, const char *src); /* wrapper around strdup, gains mem from pool */ | |
151 void pool_stat(int full); /* print to stderr the changed pools and reset */ | |
152 char *pstrdupx(pool p, const char *src); /* temp stub */ | |
153 void pool_cleanup(pool p, pool_cleaner f, void *arg); /* calls f(arg) before the pool is freed during cleanup */ | |
154 void pool_free(pool p); /* calls the cleanup functions, frees all the data on the pool, and deletes the pool itself */ | |
155 int pool_size(pool p); /* returns total bytes allocated in this pool */ | |
156 | |
157 | |
158 | |
159 | |
160 /* --------------------------------------------------------- */ | |
161 /* */ | |
162 /* Socket helper stuff */ | |
163 /* */ | |
164 /* --------------------------------------------------------- */ | |
165 #ifndef MAXHOSTNAMELEN | |
166 #define MAXHOSTNAMELEN 64 | |
167 #endif | |
168 | |
169 #define NETSOCKET_SERVER 0 | |
170 #define NETSOCKET_CLIENT 1 | |
171 #define NETSOCKET_UDP 2 | |
172 | |
173 #ifndef WIN32 | |
174 int make_netsocket(u_short port, char *host, int type, int ssl); | |
175 int make_nb_netsocket(u_short port, char *host, int type, int ssl, int * state); | |
176 void change_socket_to_blocking(int socket); | |
177 struct in_addr *make_addr(char *host); | |
178 int set_fd_close_on_exec(int fd, int flag); | |
179 #endif | |
180 | |
181 | |
182 /* --------------------------------------------------------- */ | |
183 /* */ | |
184 /* String management routines */ | |
185 /* */ | |
186 /* --------------------------------------------------------- */ | |
187 char *j_strdup(const char *str); /* provides NULL safe strdup wrapper */ | |
188 char *j_strcat(char *dest, char *txt); /* strcpy() clone */ | |
189 int j_strcmp(const char *a, const char *b); /* provides NULL safe strcmp wrapper */ | |
190 int j_strcasecmp(const char *a, const char *b); /* provides NULL safe strcasecmp wrapper */ | |
191 int j_strncmp(const char *a, const char *b, int i); /* provides NULL safe strncmp wrapper */ | |
192 int j_strncasecmp(const char *a, const char *b, int i); /* provides NULL safe strncasecmp wrapper */ | |
193 int j_strlen(const char *a); /* provides NULL safe strlen wrapper */ | |
194 int j_atoi(const char *a, int def); /* checks for NULL and uses default instead, convienence */ | |
195 void str_b64decode(char *str); /* what it says */ | |
196 | |
197 | |
198 /* --------------------------------------------------------- */ | |
199 /* */ | |
200 /* SHA calculations */ | |
201 /* */ | |
202 /* --------------------------------------------------------- */ | |
203 #if (SIZEOF_INT == 4) | |
204 typedef unsigned int uint32; | |
205 #elif (SIZEOF_SHORT == 4) | |
206 typedef unsigned short uint32; | |
207 #else | |
208 typedef unsigned int uint32; | |
209 #endif /* HAVEUINT32 */ | |
210 | |
211 int sha_hash(int *data, int *hash); | |
212 int sha_init(int *hash); | |
213 char *shahash(char *str); /* NOT THREAD SAFE */ | |
214 void shahash_r(const char* str, char hashbuf[40]); /* USE ME */ | |
215 | |
216 int strprintsha(char *dest, int *hashval); | |
217 | |
218 | |
219 /* --------------------------------------------------------- */ | |
220 /* */ | |
221 /* Hashtable functions */ | |
222 /* */ | |
223 /* --------------------------------------------------------- */ | |
224 typedef int (*KEYHASHFUNC)(const void *key); | |
225 typedef int (*KEYCOMPAREFUNC)(const void *key1, const void *key2); | |
226 typedef int (*TABLEWALKFUNC)(void *user_data, const void *key, void *data); | |
227 | |
228 typedef void *HASHTABLE; | |
229 | |
230 HASHTABLE ghash_create(int buckets, KEYHASHFUNC hash, KEYCOMPAREFUNC cmp); | |
231 void ghash_destroy(HASHTABLE tbl); | |
232 void *ghash_get(HASHTABLE tbl, const void *key); | |
233 int ghash_put(HASHTABLE tbl, const void *key, void *value); | |
234 int ghash_remove(HASHTABLE tbl, const void *key); | |
235 int ghash_walk(HASHTABLE tbl, TABLEWALKFUNC func, void *user_data); | |
236 int str_hash_code(const char *s); | |
237 | |
238 | |
239 /* --------------------------------------------------------- */ | |
240 /* */ | |
241 /* XML escaping utils */ | |
242 /* */ | |
243 /* --------------------------------------------------------- */ | |
244 char *strescape(pool p, char *buf); /* Escape <>&'" chars */ | |
245 char *strunescape(pool p, char *buf); | |
246 | |
247 | |
248 /* --------------------------------------------------------- */ | |
249 /* */ | |
250 /* String pools (spool) functions */ | |
251 /* */ | |
252 /* --------------------------------------------------------- */ | |
253 struct spool_node | |
254 { | |
255 char *c; | |
256 struct spool_node *next; | |
257 }; | |
258 | |
259 typedef struct spool_struct | |
260 { | |
261 pool p; | |
262 int len; | |
263 struct spool_node *last; | |
264 struct spool_node *first; | |
265 } *spool; | |
266 | |
267 spool spool_new(pool p); /* create a string pool */ | |
268 void spooler(spool s, ...); /* append all the char * args to the pool, terminate args with s again */ | |
269 char *spool_print(spool s); /* return a big string */ | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
270 void spool_add(spool s, char *str); /* add a single string to the pool */ |
25 | 271 char *spools(pool p, ...); /* wrap all the spooler stuff in one function, the happy fun ball! */ |
272 | |
273 | |
274 /* --------------------------------------------------------- */ | |
275 /* */ | |
276 /* xmlnodes - Document Object Model */ | |
277 /* */ | |
278 /* --------------------------------------------------------- */ | |
279 #define NTYPE_TAG 0 | |
280 #define NTYPE_ATTRIB 1 | |
281 #define NTYPE_CDATA 2 | |
282 | |
283 #define NTYPE_LAST 2 | |
284 #define NTYPE_UNDEF -1 | |
285 | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
286 /* -------------------------------------------------------------------------- |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
287 Node structure. Do not use directly! Always use accessor macros |
25 | 288 and methods! |
289 -------------------------------------------------------------------------- */ | |
290 typedef struct xmlnode_t | |
291 { | |
292 char* name; | |
293 unsigned short type; | |
294 char* data; | |
295 int data_sz; | |
296 int complete; | |
297 pool p; | |
298 struct xmlnode_t* parent; | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
299 struct xmlnode_t* firstchild; |
25 | 300 struct xmlnode_t* lastchild; |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
301 struct xmlnode_t* prev; |
25 | 302 struct xmlnode_t* next; |
303 struct xmlnode_t* firstattrib; | |
304 struct xmlnode_t* lastattrib; | |
305 } _xmlnode, *xmlnode; | |
306 | |
307 /* Node creation routines */ | |
308 xmlnode xmlnode_wrap(xmlnode x,const char* wrapper); | |
309 xmlnode xmlnode_new_tag(const char* name); | |
310 xmlnode xmlnode_new_tag_pool(pool p, const char* name); | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
311 xmlnode xmlnode_insert_tag(xmlnode parent, const char* name); |
25 | 312 xmlnode xmlnode_insert_cdata(xmlnode parent, const char* CDATA, unsigned int size); |
313 xmlnode xmlnode_insert_tag_node(xmlnode parent, xmlnode node); | |
314 void xmlnode_insert_node(xmlnode parent, xmlnode node); | |
315 xmlnode xmlnode_str(char *str, int len); | |
316 xmlnode xmlnode_file(char *file); | |
317 xmlnode xmlnode_dup(xmlnode x); /* duplicate x */ | |
318 xmlnode xmlnode_dup_pool(pool p, xmlnode x); | |
319 | |
320 /* Node Memory Pool */ | |
321 pool xmlnode_pool(xmlnode node); | |
322 xmlnode _xmlnode_new(pool p, const char *name, unsigned int type); | |
323 | |
324 /* Node editing */ | |
325 void xmlnode_hide(xmlnode child); | |
326 void xmlnode_hide_attrib(xmlnode parent, const char *name); | |
327 | |
328 /* Node deletion routine, also frees the node pool! */ | |
329 void xmlnode_free(xmlnode node); | |
330 | |
331 /* Locates a child tag by name and returns it */ | |
332 xmlnode xmlnode_get_tag(xmlnode parent, const char* name); | |
333 char* xmlnode_get_tag_data(xmlnode parent, const char* name); | |
334 | |
335 /* Attribute accessors */ | |
336 void xmlnode_put_attrib(xmlnode owner, const char* name, const char* value); | |
337 char* xmlnode_get_attrib(xmlnode owner, const char* name); | |
338 void xmlnode_put_expat_attribs(xmlnode owner, const char** atts); | |
339 | |
340 /* Bastard am I, but these are fun for internal use ;-) */ | |
341 void xmlnode_put_vattrib(xmlnode owner, const char* name, void *value); | |
342 void* xmlnode_get_vattrib(xmlnode owner, const char* name); | |
343 | |
344 /* Node traversal routines */ | |
345 xmlnode xmlnode_get_firstattrib(xmlnode parent); | |
346 xmlnode xmlnode_get_firstchild(xmlnode parent); | |
347 xmlnode xmlnode_get_lastchild(xmlnode parent); | |
348 xmlnode xmlnode_get_nextsibling(xmlnode sibling); | |
349 xmlnode xmlnode_get_prevsibling(xmlnode sibling); | |
350 xmlnode xmlnode_get_parent(xmlnode node); | |
351 | |
352 /* Node information routines */ | |
353 char* xmlnode_get_name(xmlnode node); | |
354 char* xmlnode_get_data(xmlnode node); | |
355 int xmlnode_get_datasz(xmlnode node); | |
356 int xmlnode_get_type(xmlnode node); | |
357 | |
358 int xmlnode_has_children(xmlnode node); | |
359 int xmlnode_has_attribs(xmlnode node); | |
360 | |
361 /* Node-to-string translation */ | |
362 char* xmlnode2str(xmlnode node); | |
363 | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
364 /* Node-to-terminated-string translation |
25 | 365 -- useful for interfacing w/ scripting langs */ |
366 char* xmlnode2tstr(xmlnode node); | |
367 | |
368 int xmlnode_cmp(xmlnode a, xmlnode b); /* compares a and b for equality */ | |
369 | |
370 int xmlnode2file(char *file, xmlnode node); /* writes node to file */ | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
371 int xmlnode2file_limited(char *file, xmlnode node, size_t sizelimit); |
25 | 372 |
373 /* Expat callbacks */ | |
374 void expat_startElement(void* userdata, const char* name, const char** atts); | |
375 void expat_endElement(void* userdata, const char* name); | |
376 void expat_charData(void* userdata, const char* s, int len); | |
377 | |
378 /*********************** | |
379 * XSTREAM Section | |
380 ***********************/ | |
381 | |
382 #define XSTREAM_MAXNODE 1000000 | |
383 #define XSTREAM_MAXDEPTH 100 | |
384 | |
385 #define XSTREAM_ROOT 0 /* root element */ | |
386 #define XSTREAM_NODE 1 /* normal node */ | |
387 #define XSTREAM_CLOSE 2 /* closed </stream:stream> */ | |
388 #define XSTREAM_ERR 4 /* parser error */ | |
389 | |
390 typedef void (*xstream_onNode)(int type, xmlnode x, void *arg); /* xstream event handler */ | |
391 | |
392 typedef struct xstream_struct | |
393 { | |
394 XML_Parser parser; | |
395 xmlnode node; | |
396 char *cdata; | |
397 int cdata_len; | |
398 pool p; | |
399 xstream_onNode f; | |
400 void *arg; | |
401 int status; | |
402 int depth; | |
403 } *xstream, _xstream; | |
404 | |
405 xstream xstream_new(pool p, xstream_onNode f, void *arg); /* create a new xstream */ | |
406 int xstream_eat(xstream xs, char *buff, int len); /* parse new data for this xstream, returns last XSTREAM_* status */ | |
407 | |
408 /* convience functions */ | |
409 xmlnode xstream_header(char *nspace, char *to, char *from); | |
410 char *xstream_header_char(xmlnode x); | |
411 | |
412 /* SHA.H */ | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
413 /* |
25 | 414 * The contents of this file are subject to the Mozilla Public |
415 * License Version 1.1 (the "License"); you may not use this file | |
416 * except in compliance with the License. You may obtain a copy of | |
417 * the License at http://www.mozilla.org/MPL/ | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
418 * |
25 | 419 * Software distributed under the License is distributed on an "AS |
420 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
421 * implied. See the License for the specific language governing | |
422 * rights and limitations under the License. | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
423 * |
25 | 424 * The Original Code is SHA 180-1 Header File |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
425 * |
25 | 426 * The Initial Developer of the Original Code is Paul Kocher of |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
427 * Cryptography Research. Portions created by Paul Kocher are |
25 | 428 * Copyright (C) 1995-9 by Cryptography Research, Inc. All |
429 * Rights Reserved. | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
430 * |
25 | 431 * Contributor(s): |
432 * | |
433 * Paul Kocher | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
434 * |
25 | 435 * Alternatively, the contents of this file may be used under the |
436 * terms of the GNU General Public License Version 2 or later (the | |
417
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
437 * "GPL"), in which case the provisions of the GPL are applicable |
c3ae9251c197
Sync libjabber with upstream
Mikael Berthe <mikael@lilotux.net>
parents:
25
diff
changeset
|
438 * instead of those above. If you wish to allow use of your |
25 | 439 * version of this file only under the terms of the GPL and not to |
440 * allow others to use your version of this file under the MPL, | |
441 * indicate your decision by deleting the provisions above and | |
442 * replace them with the notice and other provisions required by | |
443 * the GPL. If you do not delete the provisions above, a recipient | |
444 * may use your version of this file under either the MPL or the | |
445 * GPL. | |
446 */ | |
447 | |
448 typedef struct { | |
722
9054697b1a06
Sync with upstream libjabber
Mikael Berthe <mikael@lilotux.net>
parents:
417
diff
changeset
|
449 uint32_t H[5]; |
9054697b1a06
Sync with upstream libjabber
Mikael Berthe <mikael@lilotux.net>
parents:
417
diff
changeset
|
450 uint32_t W[80]; |
25 | 451 int lenW; |
722
9054697b1a06
Sync with upstream libjabber
Mikael Berthe <mikael@lilotux.net>
parents:
417
diff
changeset
|
452 uint32_t sizeHi,sizeLo; |
25 | 453 } SHA_CTX; |
454 | |
455 | |
456 void shaInit(SHA_CTX *ctx); | |
457 void shaUpdate(SHA_CTX *ctx, unsigned char *dataIn, int len); | |
458 void shaFinal(SHA_CTX *ctx, unsigned char hashout[20]); | |
459 void shaBlock(unsigned char *dataIn, int len, unsigned char hashout[20]); | |
460 | |
461 | |
462 /* END SHA.H */ | |
463 | |
464 #ifdef __cplusplus | |
465 } | |
466 #endif | |
467 | |
468 #endif /* INCL_LIBXODE_H */ |