~ubuntu-branches/ubuntu/oneiric/evince/oneiric-updates

« back to all changes in this revision

Viewing changes to backend/impress/iksemel.h

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya, Josselin Mouette, Rodrigo Moya
  • Date: 2011-05-19 12:12:42 UTC
  • mfrom: (1.1.65 upstream) (1.3.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110519121242-967hbn2nh2hunp4y
Tags: 3.0.0-4ubuntu1
[ Josselin Mouette ]
* bug-presubj: please document where to report rendering bugs.
* evince.mime: dropped. We have desktop files to handle MIME 
  associations, no need to maintain an alternate system by hand.
  Closes: #619564, #627027, #551734, #581441.

[ Rodrigo Moya ]
* Rebase from Debian and GNOME3 PPA (thanks to Rico Tzschichholz).
  Remaining Ubuntu changes:
* debian/apparmor-profile:
* debian/apparmor-profile.abstraction:
* debian/evince.apport:
* debian/evince-common.dirs:
* debian/evince-common.postinst:
* debian/evince-common.postrm:
  - Add apparmor profile
* debian/control:
  - Build-Depend on debhelper (>= 7.4.20ubuntu5), gnome-common,
    hardening-includes and liblaunchpad-integration-3.0-dev
  - Standards-Version is 3.9.1
  - Depend on apparmor
* debian/rules:
  - Include hardening.make
  - Add rule to install apparmor files
* debian/watch:
  - Watch unstable series
* debian/patches/01_lpi.patch:
  - Launchpad integration patch
* debian/patches/04_gold.patch:
  - Link against libz
* debian/patches/05_library-path.patch:
  - Fix library path for g-ir-scanner

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* iksemel (XML parser for Jabber)
2
 
** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
3
 
** This code is free software; you can redistribute it and/or
4
 
** modify it under the terms of GNU Lesser General Public License.
5
 
*/
6
 
 
7
 
#ifndef IKSEMEL_H
8
 
#define IKSEMEL_H 1
9
 
 
10
 
#ifdef __cplusplus
11
 
#include <cstddef>      /* size_t for C++ */
12
 
extern "C" {
13
 
#else
14
 
#include <stddef.h>     /* size_t for C */
15
 
#endif
16
 
 
17
 
/*****  object stack  *****/
18
 
 
19
 
struct ikstack_struct;
20
 
typedef struct ikstack_struct ikstack;
21
 
 
22
 
ikstack *iks_stack_new (size_t meta_chunk, size_t data_chunk);
23
 
void *iks_stack_alloc (ikstack *s, size_t size);
24
 
char *iks_stack_strdup (ikstack *s, const char *src, size_t len);
25
 
char *iks_stack_strcat (ikstack *s, char *old, size_t old_len, const char *src, size_t src_len);
26
 
void iks_stack_stat (ikstack *s, size_t *allocated, size_t *used);
27
 
void iks_stack_delete (ikstack *s);
28
 
 
29
 
/*****  utilities  *****/
30
 
 
31
 
void *iks_malloc (size_t size);
32
 
void iks_free (void *ptr);
33
 
void iks_set_mem_funcs (void *(*malloc_func)(size_t size), void (*free_func)(void *ptr));
34
 
 
35
 
char *iks_strdup (const char *src);
36
 
char *iks_strcat (char *dest, const char *src);
37
 
int iks_strcmp (const char *a, const char *b);
38
 
int iks_strcasecmp (const char *a, const char *b);
39
 
int iks_strncmp (const char *a, const char *b, size_t n);
40
 
int iks_strncasecmp (const char *a, const char *b, size_t n);
41
 
size_t iks_strlen (const char *src);
42
 
char *iks_escape (ikstack *s, char *src, size_t len);
43
 
char *iks_unescape (ikstack *s, char *src, size_t len);
44
 
 
45
 
/*****  dom tree  *****/
46
 
 
47
 
enum ikstype {
48
 
        IKS_NONE = 0,
49
 
        IKS_TAG,
50
 
        IKS_ATTRIBUTE,
51
 
        IKS_CDATA
52
 
};
53
 
 
54
 
struct iks_struct;
55
 
typedef struct iks_struct iks;
56
 
 
57
 
iks *iks_new (const char *name);
58
 
iks *iks_new_within (const char *name, ikstack *s);
59
 
iks *iks_insert (iks *x, const char *name);
60
 
iks *iks_insert_cdata (iks *x, const char *data, size_t len);
61
 
iks *iks_insert_attrib (iks *x, const char *name, const char *value);
62
 
iks *iks_insert_node (iks *x, iks *y);
63
 
void iks_hide (iks *x);
64
 
void iks_delete (iks *x);
65
 
iks *iks_next (iks *x);
66
 
iks *iks_next_tag (iks *x);
67
 
iks *iks_prev (iks *x);
68
 
iks *iks_prev_tag (iks *x);
69
 
iks *iks_parent (iks *x);
70
 
iks *iks_root (iks *x);
71
 
iks *iks_child (iks *x);
72
 
iks *iks_first_tag (iks *x);
73
 
iks *iks_attrib (iks *x);
74
 
iks *iks_find (iks *x, const char *name);
75
 
char *iks_find_cdata (iks *x, const char *name);
76
 
char *iks_find_attrib (iks *x, const char *name);
77
 
iks *iks_find_with_attrib (iks *x, const char *tagname, const char *attrname, const char *value);
78
 
ikstack *iks_stack (iks *x);
79
 
enum ikstype iks_type (iks *x);
80
 
char *iks_name (iks *x);
81
 
char *iks_cdata (iks *x);
82
 
size_t iks_cdata_size (iks *x);
83
 
int iks_has_children (iks *x);
84
 
int iks_has_attribs (iks *x);
85
 
char *iks_string (ikstack *s, iks *x);
86
 
iks *iks_copy (iks *x);
87
 
iks *iks_copy_within (iks *x, ikstack *s);
88
 
 
89
 
/*****  sax parser  *****/
90
 
 
91
 
enum ikserror {
92
 
        IKS_OK = 0,
93
 
        IKS_NOMEM,
94
 
        IKS_BADXML,
95
 
        IKS_HOOK
96
 
};
97
 
 
98
 
enum ikstagtype {
99
 
        IKS_OPEN,
100
 
        IKS_CLOSE,
101
 
        IKS_SINGLE
102
 
};
103
 
 
104
 
typedef int (iksTagHook)(void *user_data, char *name, char **atts, int type);
105
 
typedef int (iksCDataHook)(void *user_data, char *data, size_t len);
106
 
typedef void (iksDeleteHook)(void *user_data);
107
 
 
108
 
struct iksparser_struct;
109
 
typedef struct iksparser_struct  iksparser;
110
 
 
111
 
iksparser *iks_sax_new (void *user_data, iksTagHook *tagHook, iksCDataHook *cdataHook);
112
 
iksparser *iks_sax_extend (ikstack *s, void *user_data, iksTagHook *tagHook, iksCDataHook *cdataHook, iksDeleteHook *deleteHook);
113
 
ikstack *iks_parser_stack (iksparser *prs);
114
 
void *iks_user_data (iksparser *prs);
115
 
unsigned long iks_nr_bytes (iksparser *prs);
116
 
unsigned long iks_nr_lines (iksparser *prs);
117
 
int iks_parse (iksparser *prs, const char *data, size_t len, int finish);
118
 
void iks_parser_reset (iksparser *prs);
119
 
void iks_parser_delete (iksparser *prs);
120
 
 
121
 
/*****  dom parser  *****/
122
 
 
123
 
enum iksfileerror {
124
 
        IKS_FILE_NOFILE = 4,
125
 
        IKS_FILE_NOACCESS,
126
 
        IKS_FILE_RWERR
127
 
};
128
 
 
129
 
iksparser *iks_dom_new (iks **iksptr);
130
 
void iks_set_size_hint (iksparser *prs, size_t approx_size);
131
 
iks *iks_tree (const char *xml_str, size_t len, int *err);
132
 
int iks_load (const char *fname, iks **xptr);
133
 
int iks_save (const char *fname, iks *x);
134
 
 
135
 
/*****  transport layer  *****/
136
 
 
137
 
typedef void (iksTClose)(void *socket);
138
 
typedef int (iksTConnect)(iksparser *prs, void **socketptr, const char *server, int port);
139
 
typedef int (iksTSend)(void *socket, const char *data, size_t len);
140
 
typedef int (iksTRecv)(void *socket, char *buffer, size_t buf_len, int timeout);
141
 
typedef int (iksTConnectFD)(iksparser *prs, void **socketptr, void *fd);
142
 
typedef void *(iksTGetFD)(void *socket);
143
 
 
144
 
enum iksasyncevents {
145
 
        IKS_ASYNC_RESOLVED,
146
 
        IKS_ASYNC_CONNECTED,
147
 
        IKS_ASYNC_WRITE,
148
 
        IKS_ASYNC_WRITTEN,
149
 
        IKS_ASYNC_READ,
150
 
        IKS_ASYNC_CLOSED,
151
 
        IKS_ASYNC_ERROR
152
 
};
153
 
 
154
 
typedef int (iksAsyncNotify)(void *user_data, int event, void *event_data);
155
 
typedef int (iksTConnectAsync)(iksparser *prs, void **socketptr, const char *server, int port, void *notify_data, iksAsyncNotify *notify_func);
156
 
 
157
 
typedef struct ikstransport_struct {
158
 
        /* basic api, connect can be NULL if one of the other connect funcs are used */
159
 
        iksTConnect *connect;
160
 
        iksTSend *send;
161
 
        iksTRecv *recv;
162
 
        iksTClose *close;
163
 
        /* optional fd api */
164
 
        iksTConnectFD *connect_fd;
165
 
        iksTGetFD *get_fd;
166
 
        /* optional async api */
167
 
        iksTConnectAsync *connect_async;
168
 
} ikstransport;
169
 
 
170
 
extern ikstransport iks_default_transport;
171
 
 
172
 
/*****  stream parser  *****/
173
 
 
174
 
enum iksneterror {
175
 
        IKS_NET_NODNS = 4,
176
 
        IKS_NET_NOSOCK,
177
 
        IKS_NET_NOCONN,
178
 
        IKS_NET_RWERR,
179
 
        IKS_NET_NOTSUPP,
180
 
        IKS_NET_TLSFAIL
181
 
};
182
 
 
183
 
enum iksnodetype {
184
 
        IKS_NODE_START,
185
 
        IKS_NODE_NORMAL,
186
 
        IKS_NODE_ERROR,
187
 
        IKS_NODE_STOP
188
 
};
189
 
 
190
 
enum ikssasltype {
191
 
        IKS_SASL_PLAIN,
192
 
        IKS_SASL_DIGEST_MD5
193
 
};
194
 
 
195
 
#define IKS_JABBER_PORT 5222
196
 
 
197
 
typedef int (iksStreamHook)(void *user_data, int type, iks *node);
198
 
typedef void (iksLogHook)(void *user_data, const char *data, size_t size, int is_incoming);
199
 
 
200
 
iksparser *iks_stream_new (char *name_space, void *user_data, iksStreamHook *streamHook);
201
 
void *iks_stream_user_data (iksparser *prs);
202
 
void iks_set_log_hook (iksparser *prs, iksLogHook *logHook);
203
 
int iks_connect_tcp (iksparser *prs, const char *server, int port);
204
 
int iks_connect_fd (iksparser *prs, int fd);
205
 
int iks_connect_via (iksparser *prs, const char *server, int port, const char *server_name);
206
 
int iks_connect_with (iksparser *prs, const char *server, int port, const char *server_name, ikstransport *trans);
207
 
int iks_connect_async (iksparser *prs, const char *server, int port, void *notify_data, iksAsyncNotify *notify_func);
208
 
int iks_connect_async_with (iksparser *prs, const char *server, int port, const char *server_name, ikstransport *trans, void *notify_data, iksAsyncNotify *notify_func);
209
 
int iks_fd (iksparser *prs);
210
 
int iks_recv (iksparser *prs, int timeout);
211
 
int iks_send_header (iksparser *prs, const char *to);
212
 
int iks_send (iksparser *prs, iks *x);
213
 
int iks_send_raw (iksparser *prs, const char *xmlstr);
214
 
void iks_disconnect (iksparser *prs);
215
 
int iks_has_tls (void);
216
 
int iks_is_secure (iksparser *prs);
217
 
int iks_start_tls (iksparser *prs);
218
 
int iks_start_sasl (iksparser *prs, enum ikssasltype type, char *username, char *pass);
219
 
 
220
 
/*****  jabber  *****/
221
 
 
222
 
#define IKS_NS_CLIENT     "jabber:client"
223
 
#define IKS_NS_SERVER     "jabber:server"
224
 
#define IKS_NS_AUTH       "jabber:iq:auth"
225
 
#define IKS_NS_AUTH_0K    "jabber:iq:auth:0k"
226
 
#define IKS_NS_REGISTER   "jabber:iq:register"
227
 
#define IKS_NS_ROSTER     "jabber:iq:roster"
228
 
#define IKS_NS_XROSTER  "jabber:x:roster"
229
 
#define IKS_NS_OFFLINE    "jabber:x:offline"
230
 
#define IKS_NS_AGENT      "jabber:iq:agent"
231
 
#define IKS_NS_AGENTS     "jabber:iq:agents"
232
 
#define IKS_NS_BROWSE     "jabber:iq:browse"
233
 
#define IKS_NS_CONFERENCE "jabber:iq:conference"
234
 
#define IKS_NS_DELAY      "jabber:x:delay"
235
 
#define IKS_NS_VERSION    "jabber:iq:version"
236
 
#define IKS_NS_TIME       "jabber:iq:time"
237
 
#define IKS_NS_VCARD      "vcard-temp"
238
 
#define IKS_NS_PRIVATE    "jabber:iq:private"
239
 
#define IKS_NS_SEARCH     "jabber:iq:search"
240
 
#define IKS_NS_OOB        "jabber:iq:oob"
241
 
#define IKS_NS_XOOB       "jabber:x:oob"
242
 
#define IKS_NS_ADMIN      "jabber:iq:admin"
243
 
#define IKS_NS_FILTER     "jabber:iq:filter"
244
 
#define IKS_NS_GATEWAY    "jabber:iq:gateway"
245
 
#define IKS_NS_LAST       "jabber:iq:last"
246
 
#define IKS_NS_SIGNED     "jabber:x:signed"
247
 
#define IKS_NS_ENCRYPTED  "jabber:x:encrypted"
248
 
#define IKS_NS_ENVELOPE   "jabber:x:envelope"
249
 
#define IKS_NS_EVENT      "jabber:x:event"
250
 
#define IKS_NS_EXPIRE     "jabber:x:expire"
251
 
#define IKS_NS_XHTML      "http://www.w3.org/1999/xhtml"
252
 
#define IKS_NS_XMPP_SASL  "urn:ietf:params:xml:ns:xmpp-sasl"
253
 
#define IKS_NS_XMPP_BIND  "urn:ietf:params:xml:ns:xmpp-bind"
254
 
#define IKS_NS_XMPP_SESSION  "urn:ietf:params:xml:ns:xmpp-session"
255
 
 
256
 
#define IKS_ID_USER 1
257
 
#define IKS_ID_SERVER 2
258
 
#define IKS_ID_RESOURCE 4
259
 
#define IKS_ID_PARTIAL IKS_ID_USER | IKS_ID_SERVER
260
 
#define IKS_ID_FULL IKS_ID_USER | IKS_ID_SERVER | IKS_ID_RESOURCE
261
 
 
262
 
#define IKS_STREAM_STARTTLS                   1
263
 
#define IKS_STREAM_SESSION                    2
264
 
#define IKS_STREAM_BIND                       4
265
 
#define IKS_STREAM_SASL_PLAIN                 8
266
 
#define IKS_STREAM_SASL_MD5                  16
267
 
 
268
 
typedef struct iksid_struct {
269
 
        char *user;
270
 
        char *server;
271
 
        char *resource;
272
 
        char *partial;
273
 
        char *full;
274
 
} iksid;
275
 
 
276
 
iksid *iks_id_new (ikstack *s, const char *jid);
277
 
int iks_id_cmp (iksid *a, iksid *b, int parts);
278
 
 
279
 
enum ikspaktype {
280
 
        IKS_PAK_NONE = 0,
281
 
        IKS_PAK_MESSAGE,
282
 
        IKS_PAK_PRESENCE,
283
 
        IKS_PAK_IQ,
284
 
        IKS_PAK_S10N
285
 
};
286
 
 
287
 
enum iksubtype {
288
 
        IKS_TYPE_NONE = 0,
289
 
        IKS_TYPE_ERROR,
290
 
 
291
 
        IKS_TYPE_CHAT,
292
 
        IKS_TYPE_GROUPCHAT,
293
 
        IKS_TYPE_HEADLINE,
294
 
 
295
 
        IKS_TYPE_GET,
296
 
        IKS_TYPE_SET,
297
 
        IKS_TYPE_RESULT,
298
 
 
299
 
        IKS_TYPE_SUBSCRIBE,
300
 
        IKS_TYPE_SUBSCRIBED,
301
 
        IKS_TYPE_UNSUBSCRIBE,
302
 
        IKS_TYPE_UNSUBSCRIBED,
303
 
        IKS_TYPE_PROBE,
304
 
        IKS_TYPE_AVAILABLE,
305
 
        IKS_TYPE_UNAVAILABLE
306
 
};
307
 
 
308
 
enum ikshowtype {
309
 
        IKS_SHOW_UNAVAILABLE = 0,
310
 
        IKS_SHOW_AVAILABLE,
311
 
        IKS_SHOW_CHAT,
312
 
        IKS_SHOW_AWAY,
313
 
        IKS_SHOW_XA,
314
 
        IKS_SHOW_DND
315
 
};
316
 
 
317
 
typedef struct ikspak_struct {
318
 
        iks *x;
319
 
        iksid *from;
320
 
        iks *query;
321
 
        char *ns;
322
 
        char *id;
323
 
        enum ikspaktype type;
324
 
        enum iksubtype subtype;
325
 
        enum ikshowtype show;
326
 
} ikspak;
327
 
 
328
 
ikspak *iks_packet (iks *x);
329
 
 
330
 
iks *iks_make_auth (iksid *id, const char *pass, const char *sid);
331
 
iks *iks_make_msg (enum iksubtype type, const char *to, const char *body);
332
 
iks *iks_make_s10n (enum iksubtype type, const char *to, const char *msg);
333
 
iks *iks_make_pres (enum ikshowtype show, const char *status);
334
 
iks *iks_make_iq (enum iksubtype type, const char *xmlns);
335
 
iks *iks_make_resource_bind(iksid *id);
336
 
iks *iks_make_session(void);
337
 
int iks_stream_features(iks *x);
338
 
 
339
 
/*****  jabber packet filter  *****/
340
 
 
341
 
#define IKS_RULE_DONE 0
342
 
#define IKS_RULE_ID 1
343
 
#define IKS_RULE_TYPE 2
344
 
#define IKS_RULE_SUBTYPE 4
345
 
#define IKS_RULE_FROM 8
346
 
#define IKS_RULE_FROM_PARTIAL 16
347
 
#define IKS_RULE_NS 32
348
 
 
349
 
enum iksfilterret {
350
 
        IKS_FILTER_PASS,
351
 
        IKS_FILTER_EAT
352
 
};
353
 
 
354
 
typedef int (iksFilterHook)(void *user_data, ikspak *pak);
355
 
 
356
 
struct iksfilter_struct;
357
 
typedef struct iksfilter_struct iksfilter;
358
 
struct iksrule_struct;
359
 
typedef struct iksrule_struct iksrule;
360
 
 
361
 
iksfilter *iks_filter_new (void);
362
 
iksrule *iks_filter_add_rule (iksfilter *f, iksFilterHook *filterHook, void *user_data, ...);
363
 
void iks_filter_remove_rule (iksfilter *f, iksrule *rule);
364
 
void iks_filter_remove_hook (iksfilter *f, iksFilterHook *filterHook);
365
 
void iks_filter_packet (iksfilter *f, ikspak *pak);
366
 
void iks_filter_delete (iksfilter *f);
367
 
 
368
 
/*****  sha1  *****/
369
 
 
370
 
struct iksha_struct;
371
 
typedef struct iksha_struct iksha;
372
 
 
373
 
iksha *iks_sha_new (void);
374
 
void iks_sha_reset (iksha *sha);
375
 
void iks_sha_hash (iksha *sha, const unsigned char *data, size_t len, int finish);
376
 
void iks_sha_print (iksha *sha, char *hash);
377
 
void iks_sha_delete (iksha *sha);
378
 
void iks_sha (const char *data, char *hash);
379
 
 
380
 
/*****  md5  *****/
381
 
 
382
 
struct ikmd5_struct;
383
 
typedef struct iksmd5_struct iksmd5;
384
 
 
385
 
iksmd5 *iks_md5_new(void);
386
 
void iks_md5_reset(iksmd5 *md5);
387
 
void iks_md5_hash(iksmd5 *md5, const unsigned char *data, size_t slen, int finish);
388
 
void iks_md5_delete(iksmd5 *md5);
389
 
void iks_md5_print(iksmd5 *md5, char *buf);
390
 
void iks_md5_digest(iksmd5 *md5, unsigned char *digest);
391
 
void iks_md5(const char *data, char *buf);
392
 
 
393
 
/*****  base64  *****/
394
 
 
395
 
char *iks_base64_decode(const char *buf);
396
 
char *iks_base64_encode(const char *buf, int len);
397
 
 
398
 
#ifdef __cplusplus
399
 
}
400
 
#endif
401
 
 
402
 
#endif  /* IKSEMEL_H */