25 int tflag = 0, fflag = 0, vflag = 0, iflag = 0, i;
33 if(strlen(name) < i || strncmp(name,
uri_STREAMS "|stream", i) != 0 || (name[i] !=
'\0' && name[i] !=
'|')) {
44 while(attr[0] != NULL) {
45 if(!tflag && strcmp(attr[0],
"to") == 0) {
46 s->
res_to = strdup(attr[1]);
50 if(!fflag && strcmp(attr[0],
"from") == 0) {
55 if(!vflag && strcmp(attr[0],
"version") == 0) {
60 if(!iflag && strcmp(attr[0],
"id") == 0) {
61 s->
id = strdup(attr[1]);
111 void sx_client_init(
sx_t s,
unsigned int flags,
const char *ns,
const char *to,
const char *from,
const char *version) {
116 assert((
int) (s != NULL));
127 if(ns != NULL) s->
ns = strdup(ns);
128 if(to != NULL) s->
req_to = strdup(to);
129 if(from != NULL) s->
req_from = strdup(from);
130 if(version != NULL) s->
req_version = strdup(version);
138 _sx_debug(
ZONE,
"stream request: ns %s to %s from %s version %s", ns, to, from, version);
143 if(ns != NULL) len += 9 + strlen(ns);
144 if(to != NULL) len += 6 + strlen(to);
145 if(from != NULL) len += 8 + strlen(from);
146 if(version != NULL) len += 11 + strlen(version);
150 strcpy(c,
"<?xml version='1.0'?><stream:stream xmlns:stream='" uri_STREAMS "'");
152 if(ns != NULL) { c = strchr(c,
'\0'); sprintf(c,
" xmlns='%s'", ns); }
153 if(to != NULL) { c = strchr(c,
'\0'); sprintf(c,
" to='%s'", to); }
154 if(from != NULL) { c = strchr(c,
'\0'); sprintf(c,
" from='%s'", from); }
155 if(version != NULL) { c = strchr(c,
'\0'); sprintf(c,
" version='%s'", version); }
157 c = strchr(c,
'\0'); sprintf(c,
">");
159 assert(buf->
len == strlen(buf->
data)+1);
void(* header)(sx_t s, sx_plugin_t p, sx_buf_t buf)
#define _sx_event(s, e, data)
error info for event_ERROR
holds the state for a single stream
void _sx_element_end(void *arg, const char *name)
void sx_client_init(sx_t s, unsigned int flags, const char *ns, const char *to, const char *from, const char *version)
void jqueue_push(jqueue_t q, void *data, int priority)
static void _sx_client_element_start(void *arg, const char *name, const char **atts)
sx_buf_t _sx_buffer_new(const char *data, int len, _sx_notify_t notify, void *notify_arg)
utility: make a new buffer if len>0 but data is NULL, the buffer will contain that many bytes of garb...
void _sx_namespace_start(void *arg, const char *prefix, const char *uri)
void _sx_cdata(void *arg, const char *str, int len)
void(* stream)(sx_t s, sx_plugin_t p)
static void _sx_client_notify_header(sx_t s, void *arg)
static void _sx_client_element_end(void *arg, const char *name)
void _sx_error(sx_t s, int err, const char *text)
send an error
void _sx_element_start(void *arg, const char *name, const char **atts)
primary expat callbacks
#define stream_err_BAD_FORMAT
#define _sx_gen_error(e, c, g, s)
helper macro to populate this struct
void(* client)(sx_t s, sx_plugin_t p)