stropheruby 0.1.5 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -0
- data/README.txt +8 -3
- data/ext/auth.c +23 -22
- data/ext/common.h +8 -20
- data/ext/conn.c +167 -18
- data/ext/ctx.c +5 -5
- data/ext/event.c +28 -32
- data/ext/handler.c +6 -2
- data/ext/hash.c +2 -2
- data/ext/hash.h +2 -2
- data/ext/jid.c +1 -1
- data/ext/md5.h +1 -1
- data/ext/ostypes.h +2 -2
- data/ext/parser.h +43 -0
- data/ext/parser_expat.c +202 -0
- data/ext/sasl.h +3 -3
- data/ext/sock.c +1 -1
- data/ext/sock.h +2 -2
- data/ext/stanza.c +8 -47
- data/ext/strophe.h +8 -5
- data/ext/thread.c +2 -2
- data/ext/thread.h +2 -2
- data/ext/tls.h +1 -1
- data/ext/tls_dummy.c +2 -2
- data/ext/util.c +2 -2
- data/ext/util.h +2 -2
- metadata +8 -4
- data/ext/parser.c +0 -208
data/ext/event.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* event.c
|
2
2
|
** strophe XMPP client library -- event loop and management
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -31,7 +31,7 @@
|
|
31
31
|
* example, a GUI program will already include an event loop to
|
32
32
|
* process UI events from users, and xmpp_run_once() would be called
|
33
33
|
* from an idle function.
|
34
|
-
*/
|
34
|
+
*/
|
35
35
|
|
36
36
|
#include <stdio.h>
|
37
37
|
#include <stdlib.h>
|
@@ -49,6 +49,7 @@
|
|
49
49
|
|
50
50
|
#include "strophe.h"
|
51
51
|
#include "common.h"
|
52
|
+
#include "parser.h"
|
52
53
|
|
53
54
|
#ifndef DEFAULT_TIMEOUT
|
54
55
|
/** @def DEFAULT_TIMEOUT
|
@@ -83,6 +84,7 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
83
84
|
int towrite;
|
84
85
|
char buf[4096];
|
85
86
|
uint64_t next;
|
87
|
+
long usec;
|
86
88
|
|
87
89
|
if (ctx->loop_status == XMPP_LOOP_QUIT) return -2;
|
88
90
|
ctx->loop_status = XMPP_LOOP_RUNNING;
|
@@ -128,16 +130,16 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
128
130
|
}
|
129
131
|
|
130
132
|
} else {
|
131
|
-
|
133
|
+
ret = sock_write(conn->sock, &sq->data[sq->written], towrite);
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
135
|
+
if (ret < 0 && !sock_is_recoverable(sock_error())) {
|
136
|
+
/* an error occured */
|
137
|
+
conn->error = sock_error();
|
138
|
+
break;
|
139
|
+
} else if (ret < towrite) {
|
140
|
+
/* not all data could be sent now */
|
141
|
+
if (ret >= 0) sq->written += ret;
|
142
|
+
break;
|
141
143
|
}
|
142
144
|
}
|
143
145
|
|
@@ -168,7 +170,7 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
168
170
|
/* reset parsers if needed */
|
169
171
|
for (connitem = ctx->connlist; connitem; connitem = connitem->next) {
|
170
172
|
if (connitem->conn->reset_parser)
|
171
|
-
|
173
|
+
conn_parser_reset(connitem->conn);
|
172
174
|
}
|
173
175
|
|
174
176
|
|
@@ -177,7 +179,7 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
177
179
|
to be called */
|
178
180
|
next = handler_fire_timed(ctx);
|
179
181
|
|
180
|
-
|
182
|
+
usec = ((next < timeout) ? next : timeout) * 1000;
|
181
183
|
tv.tv_sec = usec / 1000000;
|
182
184
|
tv.tv_usec = usec % 1000000;
|
183
185
|
|
@@ -223,19 +225,15 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
223
225
|
|
224
226
|
/* select errored */
|
225
227
|
if (ret < 0) {
|
226
|
-
if (!sock_is_recoverable(sock_error()))
|
227
|
-
|
228
|
-
|
229
|
-
conn->error = sock_error();
|
228
|
+
if (!sock_is_recoverable(sock_error()))
|
229
|
+
xmpp_error(ctx, "xmpp", "event watcher internal error %d",
|
230
|
+
sock_error());
|
230
231
|
return -1;
|
231
232
|
}
|
232
|
-
}
|
233
233
|
|
234
234
|
/* no events happened */
|
235
|
-
if (ret == 0)
|
236
|
-
|
237
|
-
}
|
238
|
-
|
235
|
+
if (ret == 0) return 1;
|
236
|
+
|
239
237
|
/* process events */
|
240
238
|
connitem = ctx->connlist;
|
241
239
|
while (connitem) {
|
@@ -247,8 +245,7 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
247
245
|
/* connection complete */
|
248
246
|
|
249
247
|
/* check for error */
|
250
|
-
|
251
|
-
if (conn->error != 0) {
|
248
|
+
if (sock_connect_error(conn->sock) != 0) {
|
252
249
|
/* connection failed */
|
253
250
|
xmpp_debug(ctx, "xmpp", "connection failed");
|
254
251
|
conn_disconnect(conn);
|
@@ -269,16 +266,15 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
269
266
|
if (conn->tls) {
|
270
267
|
ret = tls_read(conn->tls, buf, 4096);
|
271
268
|
} else {
|
272
|
-
|
269
|
+
ret = sock_read(conn->sock, buf, 4096);
|
273
270
|
}
|
274
271
|
|
275
272
|
if (ret > 0) {
|
276
|
-
ret =
|
273
|
+
ret = parser_feed(conn->parser, buf, ret);
|
277
274
|
if (!ret) {
|
278
275
|
/* parse error, we need to shut down */
|
279
276
|
/* FIXME */
|
280
277
|
xmpp_debug(ctx, "xmpp", "parse error, disconnecting");
|
281
|
-
conn -> error = -1;
|
282
278
|
conn_disconnect(conn);
|
283
279
|
}
|
284
280
|
} else {
|
@@ -290,13 +286,13 @@ int xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout)
|
|
290
286
|
conn_disconnect(conn);
|
291
287
|
}
|
292
288
|
} else {
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
289
|
+
/* return of 0 means socket closed by server */
|
290
|
+
xmpp_debug(ctx, "xmpp", "Socket closed by remote host.");
|
291
|
+
conn->error = ECONNRESET;
|
292
|
+
conn_disconnect(conn);
|
293
|
+
}
|
297
294
|
}
|
298
295
|
}
|
299
|
-
}
|
300
296
|
|
301
297
|
break;
|
302
298
|
case XMPP_STATE_DISCONNECTED:
|
data/ext/handler.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* handler.c
|
2
2
|
** strophe XMPP client library -- event handler management
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -66,6 +66,7 @@ void handler_fire_stanza(xmpp_conn_t * const conn,
|
|
66
66
|
hash_drop(conn->id_handlers, id);
|
67
67
|
hash_add(conn->id_handlers, id, next);
|
68
68
|
}
|
69
|
+
xmpp_free(conn->ctx, item->id);
|
69
70
|
xmpp_free(conn->ctx, item);
|
70
71
|
item = NULL;
|
71
72
|
}
|
@@ -89,7 +90,7 @@ void handler_fire_stanza(xmpp_conn_t * const conn,
|
|
89
90
|
while (item) {
|
90
91
|
/* skip newly added handlers */
|
91
92
|
if (!item->enabled) {
|
92
|
-
|
93
|
+
prev = item;
|
93
94
|
item = item->next;
|
94
95
|
continue;
|
95
96
|
}
|
@@ -111,6 +112,9 @@ void handler_fire_stanza(xmpp_conn_t * const conn,
|
|
111
112
|
prev->next = item->next;
|
112
113
|
else
|
113
114
|
conn->handlers = item->next;
|
115
|
+
if (item->ns) xmpp_free(conn->ctx, item->ns);
|
116
|
+
if (item->name) xmpp_free(conn->ctx, item->name);
|
117
|
+
if (item->type) xmpp_free(conn->ctx, item->type);
|
114
118
|
xmpp_free(conn->ctx, item);
|
115
119
|
item = NULL;
|
116
120
|
}
|
data/ext/hash.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* hash.c
|
2
2
|
** strophe XMPP client library -- hash table implementation
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/** @file
|
16
16
|
* Hash tables.
|
17
|
-
*/
|
17
|
+
*/
|
18
18
|
|
19
19
|
#include <stdlib.h>
|
20
20
|
#include <string.h>
|
data/ext/hash.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* hash.h
|
2
2
|
** strophe XMPP client library -- hash table interface
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/** @file
|
16
16
|
* Hash table API.
|
17
|
-
*/
|
17
|
+
*/
|
18
18
|
|
19
19
|
#ifndef __LIBSTROPHE_HASH_H__
|
20
20
|
#define __LIBSTROPHE_HASH_H__
|
data/ext/jid.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* jid.c
|
2
2
|
** strophe XMPP client library -- helper functions for parsing JIDs
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
data/ext/md5.h
CHANGED
data/ext/ostypes.h
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
** strophe XMPP client library -- type definitions for platforms
|
3
3
|
** without stdint.h
|
4
4
|
**
|
5
|
-
** Copyright (C) 2005-
|
5
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
6
6
|
**
|
7
7
|
** This software is provided AS-IS with no warranty, either express
|
8
8
|
** or implied.
|
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
/** @file
|
17
17
|
* Type definitions for platforms without stdint.h.
|
18
|
-
*/
|
18
|
+
*/
|
19
19
|
|
20
20
|
#ifndef __LIBSTROPHE_OSTYPES_H__
|
21
21
|
#define __LIBSTROPHE_OSTYPES_H__
|
data/ext/parser.h
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
/* parser.h
|
2
|
+
** strophe XMPP client library -- parser structures and functions
|
3
|
+
**
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
|
+
**
|
6
|
+
** This software is provided AS-IS with no warranty, either express or
|
7
|
+
** implied.
|
8
|
+
**
|
9
|
+
** This software is distributed under license and may not be copied,
|
10
|
+
** modified or distributed except as expressly authorized under the
|
11
|
+
** terms of the license contained in the file LICENSE.txt in this
|
12
|
+
** distribution.
|
13
|
+
*/
|
14
|
+
|
15
|
+
/** @file
|
16
|
+
* Internally used functions and structures.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef __LIBSTROPHE_PARSER_H__
|
20
|
+
#define __LIBSTROPHE_PARSER_H__
|
21
|
+
|
22
|
+
#include "strophe.h"
|
23
|
+
|
24
|
+
typedef struct _parser_t parser_t;
|
25
|
+
|
26
|
+
typedef void (*parser_start_callback)(char *name,
|
27
|
+
char **attrs,
|
28
|
+
void * const userdata);
|
29
|
+
typedef void (*parser_end_callback)(char *name, void * const userdata);
|
30
|
+
typedef void (*parser_stanza_callback)(xmpp_stanza_t *stanza,
|
31
|
+
void * const userdata);
|
32
|
+
|
33
|
+
|
34
|
+
parser_t *parser_new(xmpp_ctx_t *ctx,
|
35
|
+
parser_start_callback startcb,
|
36
|
+
parser_end_callback endcb,
|
37
|
+
parser_stanza_callback stanzacb,
|
38
|
+
void *userdata);
|
39
|
+
void parser_free(parser_t * const parser);
|
40
|
+
int parser_reset(parser_t *parser);
|
41
|
+
int parser_feed(parser_t *parser, char *chunk, int len);
|
42
|
+
|
43
|
+
#endif /* __LIBSTROPHE_PARSER_H__ */
|
data/ext/parser_expat.c
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
/* parser.c
|
2
|
+
** strophe XMPP client library -- xml parser handlers and utility functions
|
3
|
+
**
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
|
+
**
|
6
|
+
** This software is provided AS-IS with no warranty, either express
|
7
|
+
** or implied.
|
8
|
+
**
|
9
|
+
** This software is distributed under license and may not be copied,
|
10
|
+
** modified or distributed except as expressly authorized under the
|
11
|
+
** terms of the license contained in the file LICENSE.txt in this
|
12
|
+
** distribution.
|
13
|
+
*/
|
14
|
+
|
15
|
+
/** @file
|
16
|
+
* XML parser handlers.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <stdio.h>
|
20
|
+
#include <stdlib.h>
|
21
|
+
#include <string.h>
|
22
|
+
|
23
|
+
#include <expat.h>
|
24
|
+
|
25
|
+
#include <strophe.h>
|
26
|
+
#include "common.h"
|
27
|
+
#include "parser.h"
|
28
|
+
|
29
|
+
struct _parser_t {
|
30
|
+
xmpp_ctx_t *ctx;
|
31
|
+
XML_Parser expat;
|
32
|
+
parser_start_callback startcb;
|
33
|
+
parser_end_callback endcb;
|
34
|
+
parser_stanza_callback stanzacb;
|
35
|
+
void *userdata;
|
36
|
+
int depth;
|
37
|
+
xmpp_stanza_t *stanza;
|
38
|
+
};
|
39
|
+
|
40
|
+
static void _set_attributes(xmpp_stanza_t *stanza, const XML_Char **attrs)
|
41
|
+
{
|
42
|
+
int i;
|
43
|
+
|
44
|
+
if (!attrs) return;
|
45
|
+
|
46
|
+
for (i = 0; attrs[i]; i += 2) {
|
47
|
+
xmpp_stanza_set_attribute(stanza, attrs[i], attrs[i+1]);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
static void _start_element(void *userdata,
|
52
|
+
const XML_Char *name,
|
53
|
+
const XML_Char **attrs)
|
54
|
+
{
|
55
|
+
parser_t *parser = (parser_t *)userdata;
|
56
|
+
xmpp_stanza_t *child;
|
57
|
+
|
58
|
+
if (parser->depth == 0) {
|
59
|
+
/* notify the owner */
|
60
|
+
if (parser->startcb)
|
61
|
+
parser->startcb((char *)name, (char **)attrs,
|
62
|
+
parser->userdata);
|
63
|
+
} else {
|
64
|
+
/* build stanzas at depth 1 */
|
65
|
+
if (!parser->stanza && parser->depth != 1) {
|
66
|
+
/* something terrible happened */
|
67
|
+
/* FIXME: shutdown disconnect */
|
68
|
+
xmpp_error(parser->ctx, "parser", "oops, where did our stanza go?");
|
69
|
+
} else if (!parser->stanza) {
|
70
|
+
/* starting a new toplevel stanza */
|
71
|
+
parser->stanza = xmpp_stanza_new(parser->ctx);
|
72
|
+
if (!parser->stanza) {
|
73
|
+
/* FIXME: can't allocate, disconnect */
|
74
|
+
}
|
75
|
+
xmpp_stanza_set_name(parser->stanza, name);
|
76
|
+
_set_attributes(parser->stanza, attrs);
|
77
|
+
} else {
|
78
|
+
/* starting a child of parser->stanza */
|
79
|
+
child = xmpp_stanza_new(parser->ctx);
|
80
|
+
if (!child) {
|
81
|
+
/* FIXME: can't allocate, disconnect */
|
82
|
+
}
|
83
|
+
xmpp_stanza_set_name(child, name);
|
84
|
+
_set_attributes(child, attrs);
|
85
|
+
|
86
|
+
/* add child to parent */
|
87
|
+
xmpp_stanza_add_child(parser->stanza, child);
|
88
|
+
|
89
|
+
/* the child is owned by the toplevel stanza now */
|
90
|
+
xmpp_stanza_release(child);
|
91
|
+
|
92
|
+
/* make child the current stanza */
|
93
|
+
parser->stanza = child;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
parser->depth++;
|
98
|
+
}
|
99
|
+
|
100
|
+
static void _end_element(void *userdata, const XML_Char *name)
|
101
|
+
{
|
102
|
+
parser_t *parser = (parser_t *)userdata;
|
103
|
+
|
104
|
+
parser->depth--;
|
105
|
+
|
106
|
+
if (parser->depth == 0) {
|
107
|
+
/* notify the owner */
|
108
|
+
if (parser->endcb)
|
109
|
+
parser->endcb((char *)name, parser->userdata);
|
110
|
+
} else {
|
111
|
+
if (parser->stanza->parent) {
|
112
|
+
/* we're finishing a child stanza, so set current to the parent */
|
113
|
+
parser->stanza = parser->stanza->parent;
|
114
|
+
} else {
|
115
|
+
if (parser->stanzacb)
|
116
|
+
parser->stanzacb(parser->stanza,
|
117
|
+
parser->userdata);
|
118
|
+
xmpp_stanza_release(parser->stanza);
|
119
|
+
parser->stanza = NULL;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
static void _characters(void *userdata, const XML_Char *s, int len)
|
125
|
+
{
|
126
|
+
parser_t *parser = (parser_t *)userdata;
|
127
|
+
xmpp_stanza_t *stanza;
|
128
|
+
|
129
|
+
if (parser->depth < 2) return;
|
130
|
+
|
131
|
+
/* create and populate stanza */
|
132
|
+
stanza = xmpp_stanza_new(parser->ctx);
|
133
|
+
if (!stanza) {
|
134
|
+
/* FIXME: allocation error, disconnect */
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
xmpp_stanza_set_text_with_size(stanza, s, len);
|
138
|
+
|
139
|
+
xmpp_stanza_add_child(parser->stanza, stanza);
|
140
|
+
xmpp_stanza_release(stanza);
|
141
|
+
}
|
142
|
+
|
143
|
+
parser_t *parser_new(xmpp_ctx_t *ctx,
|
144
|
+
parser_start_callback startcb,
|
145
|
+
parser_end_callback endcb,
|
146
|
+
parser_stanza_callback stanzacb,
|
147
|
+
void *userdata)
|
148
|
+
{
|
149
|
+
parser_t *parser;
|
150
|
+
|
151
|
+
parser = xmpp_alloc(ctx, sizeof(parser_t));
|
152
|
+
if (parser != NULL) {
|
153
|
+
parser->ctx = ctx;
|
154
|
+
parser->expat = NULL;
|
155
|
+
parser->startcb = startcb;
|
156
|
+
parser->endcb = endcb;
|
157
|
+
parser->stanzacb = stanzacb;
|
158
|
+
parser->userdata = userdata;
|
159
|
+
parser->depth = 0;
|
160
|
+
parser->stanza = NULL;
|
161
|
+
|
162
|
+
parser_reset(parser);
|
163
|
+
}
|
164
|
+
|
165
|
+
return parser;
|
166
|
+
}
|
167
|
+
|
168
|
+
/* free a parser */
|
169
|
+
void parser_free(parser_t *parser)
|
170
|
+
{
|
171
|
+
if (parser->expat)
|
172
|
+
XML_ParserFree(parser->expat);
|
173
|
+
|
174
|
+
xmpp_free(parser->ctx, parser);
|
175
|
+
}
|
176
|
+
|
177
|
+
/* shuts down and restarts XML parser. true on success */
|
178
|
+
int parser_reset(parser_t *parser)
|
179
|
+
{
|
180
|
+
if (parser->expat)
|
181
|
+
XML_ParserFree(parser->expat);
|
182
|
+
|
183
|
+
if (parser->stanza)
|
184
|
+
xmpp_stanza_release(parser->stanza);
|
185
|
+
|
186
|
+
parser->expat = XML_ParserCreate(NULL);
|
187
|
+
if (!parser->expat) return 0;
|
188
|
+
|
189
|
+
parser->depth = 0;
|
190
|
+
parser->stanza = NULL;
|
191
|
+
|
192
|
+
XML_SetUserData(parser->expat, parser);
|
193
|
+
XML_SetElementHandler(parser->expat, _start_element, _end_element);
|
194
|
+
XML_SetCharacterDataHandler(parser->expat, _characters);
|
195
|
+
|
196
|
+
return 1;
|
197
|
+
}
|
198
|
+
|
199
|
+
int parser_feed(parser_t *parser, char *chunk, int len)
|
200
|
+
{
|
201
|
+
return XML_Parse(parser->expat, chunk, len, 0);
|
202
|
+
}
|
data/ext/sasl.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* sasl.h
|
2
2
|
** strophe XMPP client library -- SASL authentication helpers
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/** @file
|
16
16
|
* SASL authentication helpers.
|
17
|
-
*/
|
17
|
+
*/
|
18
18
|
|
19
19
|
#ifndef __LIBSTROPHE_SASL_H__
|
20
20
|
#define __LIBSTROPHE_SASL_H__
|
@@ -39,6 +39,6 @@ int base64_decoded_len(xmpp_ctx_t *ctx,
|
|
39
39
|
const char * const buffer, const unsigned len);
|
40
40
|
|
41
41
|
unsigned char *base64_decode(xmpp_ctx_t *ctx,
|
42
|
-
const char * const buffer, const unsigned
|
42
|
+
const char * const buffer, const unsigned len);
|
43
43
|
|
44
44
|
#endif /* _LIBXMPP_SASL_H__ */
|
data/ext/sock.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* sock.c
|
2
2
|
** strophe XMPP client library -- socket abstraction implementation
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
data/ext/sock.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* sock.h
|
2
2
|
** strophe XMPP client library -- socket abstraction header
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/** @file
|
16
16
|
* Socket abstraction API.
|
17
|
-
*/
|
17
|
+
*/
|
18
18
|
|
19
19
|
#ifndef __LIBSTROPHE_SOCK_H__
|
20
20
|
#define __LIBSTROPHE_SOCK_H__
|
data/ext/stanza.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* stanza.c
|
2
2
|
** strophe XMPP client library -- XMPP stanza object and utilities
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -165,13 +165,13 @@ int xmpp_stanza_release(xmpp_stanza_t * const stanza)
|
|
165
165
|
if (stanza->ref > 1)
|
166
166
|
stanza->ref--;
|
167
167
|
else {
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
168
|
+
/* release all children */
|
169
|
+
child = stanza->children;
|
170
|
+
while (child) {
|
171
|
+
tchild = child;
|
172
|
+
child = child->next;
|
173
|
+
xmpp_stanza_release(tchild);
|
174
|
+
}
|
175
175
|
|
176
176
|
if (stanza->attributes) hash_release(stanza->attributes);
|
177
177
|
if (stanza->data) xmpp_free(stanza->ctx, stanza->data);
|
@@ -400,45 +400,6 @@ char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza)
|
|
400
400
|
return stanza->data;
|
401
401
|
}
|
402
402
|
|
403
|
-
/** Set or replace attributes on a stanza.
|
404
|
-
* This function replaces all previous attributes (if any) with the
|
405
|
-
* attributes given. It is used primarily by the XML parser during
|
406
|
-
* stanza creation. All strings in the array are copied before placing them
|
407
|
-
* inside the stanza object.
|
408
|
-
*
|
409
|
-
* @param stanza a Strophe stanza object
|
410
|
-
* @param attr an array of strings with the attributes in the following
|
411
|
-
* format: attr[i] = attribute name, attr[i+1] = attribute value
|
412
|
-
*
|
413
|
-
* @return XMPP_EOK on success, a number less than 0 on failure (XMPP_EMEM,
|
414
|
-
* XMPP_EINVOP)
|
415
|
-
*
|
416
|
-
* @ingroup Stanza
|
417
|
-
*/
|
418
|
-
int xmpp_stanza_set_attributes(xmpp_stanza_t * const stanza,
|
419
|
-
const char * const * const attr)
|
420
|
-
{
|
421
|
-
int i;
|
422
|
-
char *value;
|
423
|
-
|
424
|
-
if (stanza->attributes != NULL)
|
425
|
-
hash_release(stanza->attributes);
|
426
|
-
|
427
|
-
stanza->attributes = hash_new(stanza->ctx, 8, xmpp_free);
|
428
|
-
if (!stanza->attributes) return XMPP_EMEM;
|
429
|
-
|
430
|
-
for (i = 0; attr[i]; i += 2) {
|
431
|
-
value = xmpp_strdup(stanza->ctx, attr[i + 1]);
|
432
|
-
if (!value) {
|
433
|
-
/* FIXME: memory allocation error */
|
434
|
-
continue;
|
435
|
-
}
|
436
|
-
hash_add(stanza->attributes, attr[i], value);
|
437
|
-
}
|
438
|
-
|
439
|
-
return XMPP_EOK;
|
440
|
-
}
|
441
|
-
|
442
403
|
/** Count the attributes in a stanza object.
|
443
404
|
*
|
444
405
|
* @param stanza a Strophe stanza object
|
data/ext/strophe.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* strophe.h
|
2
2
|
** strophe XMPP client library C API
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express or
|
7
7
|
** implied.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/** @file
|
16
16
|
* Strophe public C API definitions.
|
17
|
-
*/
|
17
|
+
*/
|
18
18
|
|
19
19
|
#ifndef __LIBSTROPHE_STROPHE_H__
|
20
20
|
#define __LIBSTROPHE_STROPHE_H__
|
@@ -212,16 +212,19 @@ xmpp_conn_t * xmpp_conn_clone(xmpp_conn_t * const conn);
|
|
212
212
|
int xmpp_conn_release(xmpp_conn_t * const conn);
|
213
213
|
|
214
214
|
const char *xmpp_conn_get_jid(const xmpp_conn_t * const conn);
|
215
|
+
const char *xmpp_conn_get_bound_jid(const xmpp_conn_t * const conn);
|
215
216
|
void xmpp_conn_set_jid(xmpp_conn_t * const conn, const char * const jid);
|
216
217
|
const char *xmpp_conn_get_pass(const xmpp_conn_t * const conn);
|
217
218
|
void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass);
|
219
|
+
unsigned int xmpp_conn_get_connect_timeout(const xmpp_conn_t * const conn);
|
220
|
+
void xmpp_conn_set_connect_timeout(xmpp_conn_t * const conn, const unsigned int timeout);
|
218
221
|
xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn);
|
219
222
|
|
220
|
-
int xmpp_connect_client(xmpp_conn_t * const conn,
|
223
|
+
int xmpp_connect_client(xmpp_conn_t * const conn,
|
221
224
|
const char * const altdomain,
|
222
225
|
unsigned short altport,
|
223
|
-
|
224
|
-
|
226
|
+
xmpp_conn_handler callback,
|
227
|
+
void * const userdata);
|
225
228
|
|
226
229
|
/*
|
227
230
|
int xmpp_connect_component(conn, name)
|
data/ext/thread.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* thread.c
|
2
2
|
** strophe XMPP client library -- thread abstraction
|
3
3
|
**
|
4
|
-
** Copyright (C) 2005-
|
4
|
+
** Copyright (C) 2005-2009 Collecta, Inc.
|
5
5
|
**
|
6
6
|
** This software is provided AS-IS with no warranty, either express
|
7
7
|
** or implied.
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/** @file
|
16
16
|
* Thread absraction.
|
17
|
-
*/
|
17
|
+
*/
|
18
18
|
|
19
19
|
#include <stdio.h>
|
20
20
|
#include <stdlib.h>
|