stanza: removed tabs and trailing spaces

This commit is contained in:
Dmitry Podgorny
2017-09-12 17:36:28 +03:00
parent 032e8ec89d
commit f12d43989f

View File

@@ -40,15 +40,15 @@ xmpp_stanza_t *xmpp_stanza_new(xmpp_ctx_t *ctx)
stanza = xmpp_alloc(ctx, sizeof(xmpp_stanza_t)); stanza = xmpp_alloc(ctx, sizeof(xmpp_stanza_t));
if (stanza != NULL) { if (stanza != NULL) {
stanza->ref = 1; stanza->ref = 1;
stanza->ctx = ctx; stanza->ctx = ctx;
stanza->type = XMPP_STANZA_UNKNOWN; stanza->type = XMPP_STANZA_UNKNOWN;
stanza->prev = NULL; stanza->prev = NULL;
stanza->next = NULL; stanza->next = NULL;
stanza->children = NULL; stanza->children = NULL;
stanza->parent = NULL; stanza->parent = NULL;
stanza->data = NULL; stanza->data = NULL;
stanza->attributes = NULL; stanza->attributes = NULL;
} }
return stanza; return stanza;
@@ -121,27 +121,27 @@ xmpp_stanza_t *xmpp_stanza_copy(const xmpp_stanza_t * const stanza)
copy->type = stanza->type; copy->type = stanza->type;
if (stanza->data) { if (stanza->data) {
copy->data = xmpp_strdup(stanza->ctx, stanza->data); copy->data = xmpp_strdup(stanza->ctx, stanza->data);
if (!copy->data) goto copy_error; if (!copy->data) goto copy_error;
} }
if (stanza->attributes) { if (stanza->attributes) {
if (_stanza_copy_attributes(copy, stanza) == -1) if (_stanza_copy_attributes(copy, stanza) == -1)
goto copy_error; goto copy_error;
} }
tail = copy->children; tail = copy->children;
for (child = stanza->children; child; child = child->next) { for (child = stanza->children; child; child = child->next) {
copychild = xmpp_stanza_copy(child); copychild = xmpp_stanza_copy(child);
if (!copychild) goto copy_error; if (!copychild) goto copy_error;
copychild->parent = copy; copychild->parent = copy;
if (tail) { if (tail) {
copychild->prev = tail; copychild->prev = tail;
tail->next = copychild; tail->next = copychild;
} else } else
copy->children = copychild; copy->children = copychild;
tail = copychild; tail = copychild;
} }
return copy; return copy;
@@ -169,20 +169,20 @@ int xmpp_stanza_release(xmpp_stanza_t * const stanza)
/* release stanza */ /* release stanza */
if (stanza->ref > 1) if (stanza->ref > 1)
stanza->ref--; stanza->ref--;
else { else {
/* release all children */ /* release all children */
child = stanza->children; child = stanza->children;
while (child) { while (child) {
tchild = child; tchild = child;
child = child->next; child = child->next;
xmpp_stanza_release(tchild); xmpp_stanza_release(tchild);
} }
if (stanza->attributes) hash_release(stanza->attributes); if (stanza->attributes) hash_release(stanza->attributes);
if (stanza->data) xmpp_free(stanza->ctx, stanza->data); if (stanza->data) xmpp_free(stanza->ctx, stanza->data);
xmpp_free(stanza->ctx, stanza); xmpp_free(stanza->ctx, stanza);
released = 1; released = 1;
} }
return released; return released;
@@ -274,17 +274,17 @@ static char *_escape_xml(xmpp_ctx_t * const ctx, char *text)
/* small helper function */ /* small helper function */
static void _render_update(int *written, const int length, static void _render_update(int *written, const int length,
const int lastwrite, const int lastwrite,
size_t *left, char **ptr) size_t *left, char **ptr)
{ {
*written += lastwrite; *written += lastwrite;
if (*written >= length) { if (*written >= length) {
*left = 0; *left = 0;
*ptr = NULL; *ptr = NULL;
} else { } else {
*left -= lastwrite; *left -= lastwrite;
*ptr = &(*ptr)[lastwrite]; *ptr = &(*ptr)[lastwrite];
} }
} }
@@ -294,7 +294,7 @@ static void _render_update(int *written, const int length,
* and return values > buflen indicate buffer was not large enough * and return values > buflen indicate buffer was not large enough
*/ */
static int _render_stanza_recursive(xmpp_stanza_t *stanza, static int _render_stanza_recursive(xmpp_stanza_t *stanza,
char * const buf, size_t const buflen) char * const buf, size_t const buflen)
{ {
char *ptr = buf; char *ptr = buf;
size_t left = buflen; size_t left = buflen;
@@ -309,80 +309,80 @@ static int _render_stanza_recursive(xmpp_stanza_t *stanza,
if (stanza->type == XMPP_STANZA_UNKNOWN) return XMPP_EINVOP; if (stanza->type == XMPP_STANZA_UNKNOWN) return XMPP_EINVOP;
if (stanza->type == XMPP_STANZA_TEXT) { if (stanza->type == XMPP_STANZA_TEXT) {
if (!stanza->data) return XMPP_EINVOP; if (!stanza->data) return XMPP_EINVOP;
tmp = _escape_xml(stanza->ctx, stanza->data); tmp = _escape_xml(stanza->ctx, stanza->data);
if (tmp == NULL) return XMPP_EMEM; if (tmp == NULL) return XMPP_EMEM;
ret = xmpp_snprintf(ptr, left, "%s", tmp); ret = xmpp_snprintf(ptr, left, "%s", tmp);
xmpp_free(stanza->ctx, tmp); xmpp_free(stanza->ctx, tmp);
if (ret < 0) return XMPP_EMEM; if (ret < 0) return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
} else { /* stanza->type == XMPP_STANZA_TAG */ } else { /* stanza->type == XMPP_STANZA_TAG */
if (!stanza->data) return XMPP_EINVOP; if (!stanza->data) return XMPP_EINVOP;
/* write beginning of tag and attributes */ /* write beginning of tag and attributes */
ret = xmpp_snprintf(ptr, left, "<%s", stanza->data); ret = xmpp_snprintf(ptr, left, "<%s", stanza->data);
if (ret < 0) return XMPP_EMEM; if (ret < 0) return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
if (stanza->attributes && hash_num_keys(stanza->attributes) > 0) { if (stanza->attributes && hash_num_keys(stanza->attributes) > 0) {
iter = hash_iter_new(stanza->attributes); iter = hash_iter_new(stanza->attributes);
while ((key = hash_iter_next(iter))) { while ((key = hash_iter_next(iter))) {
if (!strcmp(key, "xmlns")) { if (!strcmp(key, "xmlns")) {
/* don't output namespace if parent stanza is the same */ /* don't output namespace if parent stanza is the same */
if (stanza->parent && if (stanza->parent &&
stanza->parent->attributes && stanza->parent->attributes &&
hash_get(stanza->parent->attributes, key) && hash_get(stanza->parent->attributes, key) &&
!strcmp((char*)hash_get(stanza->attributes, key), !strcmp((char*)hash_get(stanza->attributes, key),
(char*)hash_get(stanza->parent->attributes, key))) (char*)hash_get(stanza->parent->attributes, key)))
continue; continue;
/* or if this is the stream namespace */ /* or if this is the stream namespace */
if (!stanza->parent && if (!stanza->parent &&
!strcmp((char*)hash_get(stanza->attributes, key), !strcmp((char*)hash_get(stanza->attributes, key),
XMPP_NS_CLIENT)) XMPP_NS_CLIENT))
continue; continue;
} }
tmp = _escape_xml(stanza->ctx, tmp = _escape_xml(stanza->ctx,
(char *)hash_get(stanza->attributes, key)); (char *)hash_get(stanza->attributes, key));
if (tmp == NULL) return XMPP_EMEM; if (tmp == NULL) return XMPP_EMEM;
ret = xmpp_snprintf(ptr, left, " %s=\"%s\"", key, tmp); ret = xmpp_snprintf(ptr, left, " %s=\"%s\"", key, tmp);
xmpp_free(stanza->ctx, tmp); xmpp_free(stanza->ctx, tmp);
if (ret < 0) return XMPP_EMEM; if (ret < 0) return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
} }
hash_iter_release(iter); hash_iter_release(iter);
} }
if (!stanza->children) { if (!stanza->children) {
/* write end if singleton tag */ /* write end if singleton tag */
ret = xmpp_snprintf(ptr, left, "/>"); ret = xmpp_snprintf(ptr, left, "/>");
if (ret < 0) return XMPP_EMEM; if (ret < 0) return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
} else { } else {
/* this stanza has child stanzas */ /* this stanza has child stanzas */
/* write end of start tag */ /* write end of start tag */
ret = xmpp_snprintf(ptr, left, ">"); ret = xmpp_snprintf(ptr, left, ">");
if (ret < 0) return XMPP_EMEM; if (ret < 0) return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
/* iterate and recurse over child stanzas */ /* iterate and recurse over child stanzas */
child = stanza->children; child = stanza->children;
while (child) { while (child) {
ret = _render_stanza_recursive(child, ptr, left); ret = _render_stanza_recursive(child, ptr, left);
if (ret < 0) return ret; if (ret < 0) return ret;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
child = child->next; child = child->next;
} }
/* write end tag */ /* write end tag */
ret = xmpp_snprintf(ptr, left, "</%s>", stanza->data); ret = xmpp_snprintf(ptr, left, "</%s>", stanza->data);
if (ret < 0) return XMPP_EMEM; if (ret < 0) return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr); _render_update(&written, buflen, ret, &left, &ptr);
} }
} }
return written; return written;
@@ -415,27 +415,27 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
length = 1024; length = 1024;
buffer = xmpp_alloc(stanza->ctx, length); buffer = xmpp_alloc(stanza->ctx, length);
if (!buffer) { if (!buffer) {
*buf = NULL; *buf = NULL;
*buflen = 0; *buflen = 0;
return XMPP_EMEM; return XMPP_EMEM;
} }
ret = _render_stanza_recursive(stanza, buffer, length); ret = _render_stanza_recursive(stanza, buffer, length);
if (ret < 0) return ret; if (ret < 0) return ret;
if ((size_t)ret > length - 1) { if ((size_t)ret > length - 1) {
tmp = xmpp_realloc(stanza->ctx, buffer, ret + 1); tmp = xmpp_realloc(stanza->ctx, buffer, ret + 1);
if (!tmp) { if (!tmp) {
xmpp_free(stanza->ctx, buffer); xmpp_free(stanza->ctx, buffer);
*buf = NULL; *buf = NULL;
*buflen = 0; *buflen = 0;
return XMPP_EMEM; return XMPP_EMEM;
} }
length = ret + 1; length = ret + 1;
buffer = tmp; buffer = tmp;
ret = _render_stanza_recursive(stanza, buffer, length); ret = _render_stanza_recursive(stanza, buffer, length);
if ((size_t)ret > length - 1) return XMPP_EMEM; if ((size_t)ret > length - 1) return XMPP_EMEM;
} }
buffer[length - 1] = 0; buffer[length - 1] = 0;
@@ -457,7 +457,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza,
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_name(xmpp_stanza_t *stanza, int xmpp_stanza_set_name(xmpp_stanza_t *stanza,
const char * const name) const char * const name)
{ {
if (stanza->type == XMPP_STANZA_TEXT) return XMPP_EINVOP; if (stanza->type == XMPP_STANZA_TEXT) return XMPP_EINVOP;
@@ -496,7 +496,7 @@ const char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza)
int xmpp_stanza_get_attribute_count(xmpp_stanza_t * const stanza) int xmpp_stanza_get_attribute_count(xmpp_stanza_t * const stanza)
{ {
if (stanza->attributes == NULL) { if (stanza->attributes == NULL) {
return 0; return 0;
} }
return hash_num_keys(stanza->attributes); return hash_num_keys(stanza->attributes);
@@ -517,30 +517,30 @@ int xmpp_stanza_get_attribute_count(xmpp_stanza_t * const stanza)
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_get_attributes(xmpp_stanza_t * const stanza, int xmpp_stanza_get_attributes(xmpp_stanza_t * const stanza,
const char **attr, int attrlen) const char **attr, int attrlen)
{ {
hash_iterator_t *iter; hash_iterator_t *iter;
const char *key; const char *key;
int num = 0; int num = 0;
if (stanza->attributes == NULL) { if (stanza->attributes == NULL) {
return 0; return 0;
} }
iter = hash_iter_new(stanza->attributes); iter = hash_iter_new(stanza->attributes);
while ((key = hash_iter_next(iter)) != NULL && attrlen) { while ((key = hash_iter_next(iter)) != NULL && attrlen) {
attr[num++] = key; attr[num++] = key;
attrlen--; attrlen--;
if (attrlen == 0) { if (attrlen == 0) {
hash_iter_release(iter); hash_iter_release(iter);
return num; return num;
} }
attr[num++] = hash_get(stanza->attributes, key); attr[num++] = hash_get(stanza->attributes, key);
attrlen--; attrlen--;
if (attrlen == 0) { if (attrlen == 0) {
hash_iter_release(iter); hash_iter_release(iter);
return num; return num;
} }
} }
hash_iter_release(iter); hash_iter_release(iter);
@@ -558,8 +558,8 @@ int xmpp_stanza_get_attributes(xmpp_stanza_t * const stanza,
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza, int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza,
const char * const key, const char * const key,
const char * const value) const char * const value)
{ {
char *val; char *val;
int rc; int rc;
@@ -567,8 +567,8 @@ int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza,
if (stanza->type != XMPP_STANZA_TAG) return XMPP_EINVOP; if (stanza->type != XMPP_STANZA_TAG) return XMPP_EINVOP;
if (!stanza->attributes) { if (!stanza->attributes) {
stanza->attributes = hash_new(stanza->ctx, 8, xmpp_free); stanza->attributes = hash_new(stanza->ctx, 8, xmpp_free);
if (!stanza->attributes) return XMPP_EMEM; if (!stanza->attributes) return XMPP_EMEM;
} }
val = xmpp_strdup(stanza->ctx, value); val = xmpp_strdup(stanza->ctx, value);
@@ -598,7 +598,7 @@ int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza,
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_ns(xmpp_stanza_t * const stanza, int xmpp_stanza_set_ns(xmpp_stanza_t * const stanza,
const char * const ns) const char * const ns)
{ {
return xmpp_stanza_set_attribute(stanza, "xmlns", ns); return xmpp_stanza_set_attribute(stanza, "xmlns", ns);
} }
@@ -624,12 +624,12 @@ int xmpp_stanza_add_child(xmpp_stanza_t *stanza, xmpp_stanza_t *child)
child->parent = stanza; child->parent = stanza;
if (!stanza->children) if (!stanza->children)
stanza->children = child; stanza->children = child;
else { else {
s = stanza->children; s = stanza->children;
while (s->next) s = s->next; while (s->next) s = s->next;
s->next = child; s->next = child;
child->prev = s; child->prev = s;
} }
return XMPP_EOK; return XMPP_EOK;
@@ -649,7 +649,7 @@ int xmpp_stanza_add_child(xmpp_stanza_t *stanza, xmpp_stanza_t *child)
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_text(xmpp_stanza_t *stanza, int xmpp_stanza_set_text(xmpp_stanza_t *stanza,
const char * const text) const char * const text)
{ {
if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP; if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP;
@@ -676,8 +676,8 @@ int xmpp_stanza_set_text(xmpp_stanza_t *stanza,
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza, int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
const char * const text, const char * const text,
const size_t size) const size_t size)
{ {
if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP; if (stanza->type == XMPP_STANZA_TAG) return XMPP_EINVOP;
@@ -780,14 +780,14 @@ const char *xmpp_stanza_get_from(xmpp_stanza_t * const stanza)
* @ingroup Stanza * @ingroup Stanza
*/ */
xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza, xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
const char * const name) const char * const name)
{ {
xmpp_stanza_t *child; xmpp_stanza_t *child;
for (child = stanza->children; child; child = child->next) { for (child = stanza->children; child; child = child->next) {
if (child->type == XMPP_STANZA_TAG && if (child->type == XMPP_STANZA_TAG &&
(strcmp(name, xmpp_stanza_get_name(child)) == 0)) (strcmp(name, xmpp_stanza_get_name(child)) == 0))
break; break;
} }
return child; return child;
@@ -806,14 +806,14 @@ xmpp_stanza_t *xmpp_stanza_get_child_by_name(xmpp_stanza_t * const stanza,
* @ingroup Stanza * @ingroup Stanza
*/ */
xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza, xmpp_stanza_t *xmpp_stanza_get_child_by_ns(xmpp_stanza_t * const stanza,
const char * const ns) const char * const ns)
{ {
xmpp_stanza_t *child; xmpp_stanza_t *child;
for (child = stanza->children; child; child = child->next) { for (child = stanza->children; child; child = child->next) {
if (xmpp_stanza_get_ns(child) && if (xmpp_stanza_get_ns(child) &&
strcmp(ns, xmpp_stanza_get_ns(child)) == 0) strcmp(ns, xmpp_stanza_get_ns(child)) == 0)
break; break;
} }
return child; return child;
@@ -866,16 +866,16 @@ char *xmpp_stanza_get_text(xmpp_stanza_t * const stanza)
char *text; char *text;
if (stanza->type == XMPP_STANZA_TEXT) { if (stanza->type == XMPP_STANZA_TEXT) {
if (stanza->data) if (stanza->data)
return xmpp_strdup(stanza->ctx, stanza->data); return xmpp_strdup(stanza->ctx, stanza->data);
else else
return NULL; return NULL;
} }
len = 0; len = 0;
for (child = stanza->children; child; child = child->next) for (child = stanza->children; child; child = child->next)
if (child->type == XMPP_STANZA_TEXT) if (child->type == XMPP_STANZA_TEXT)
len += strlen(child->data); len += strlen(child->data);
if (len == 0) return NULL; if (len == 0) return NULL;
@@ -884,11 +884,11 @@ char *xmpp_stanza_get_text(xmpp_stanza_t * const stanza)
len = 0; len = 0;
for (child = stanza->children; child; child = child->next) for (child = stanza->children; child; child = child->next)
if (child->type == XMPP_STANZA_TEXT) { if (child->type == XMPP_STANZA_TEXT) {
clen = strlen(child->data); clen = strlen(child->data);
memcpy(&text[len], child->data, clen); memcpy(&text[len], child->data, clen);
len += clen; len += clen;
} }
text[len] = 0; text[len] = 0;
@@ -911,7 +911,7 @@ char *xmpp_stanza_get_text(xmpp_stanza_t * const stanza)
const char *xmpp_stanza_get_text_ptr(xmpp_stanza_t * const stanza) const char *xmpp_stanza_get_text_ptr(xmpp_stanza_t * const stanza)
{ {
if (stanza->type == XMPP_STANZA_TEXT) if (stanza->type == XMPP_STANZA_TEXT)
return stanza->data; return stanza->data;
return NULL; return NULL;
} }
@@ -928,7 +928,7 @@ const char *xmpp_stanza_get_text_ptr(xmpp_stanza_t * const stanza)
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_id(xmpp_stanza_t * const stanza, int xmpp_stanza_set_id(xmpp_stanza_t * const stanza,
const char * const id) const char * const id)
{ {
return xmpp_stanza_set_attribute(stanza, "id", id); return xmpp_stanza_set_attribute(stanza, "id", id);
} }
@@ -945,7 +945,7 @@ int xmpp_stanza_set_id(xmpp_stanza_t * const stanza,
* @ingroup Stanza * @ingroup Stanza
*/ */
int xmpp_stanza_set_type(xmpp_stanza_t * const stanza, int xmpp_stanza_set_type(xmpp_stanza_t * const stanza,
const char * const type) const char * const type)
{ {
return xmpp_stanza_set_attribute(stanza, "type", type); return xmpp_stanza_set_attribute(stanza, "type", type);
} }
@@ -1001,10 +1001,10 @@ const char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza,
const char * const name) const char * const name)
{ {
if (stanza->type != XMPP_STANZA_TAG) if (stanza->type != XMPP_STANZA_TAG)
return NULL; return NULL;
if (!stanza->attributes) if (!stanza->attributes)
return NULL; return NULL;
return hash_get(stanza->attributes, name); return hash_get(stanza->attributes, name);
} }
@@ -1232,102 +1232,100 @@ xmpp_stanza_t *xmpp_presence_new(xmpp_ctx_t *ctx)
*/ */
xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, char * const text) xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, char * const text)
{ {
xmpp_stanza_t *error = _stanza_new_with_attrs(ctx, "stream:error", NULL, NULL, NULL); xmpp_stanza_t *error = _stanza_new_with_attrs(ctx, "stream:error", NULL, NULL, NULL);
xmpp_stanza_t *error_type = xmpp_stanza_new(ctx);
xmpp_stanza_t *error_type = xmpp_stanza_new(ctx); switch(type) {
switch(type) case XMPP_SE_BAD_FORMAT:
{ xmpp_stanza_set_name(error_type, "bad-format");
case XMPP_SE_BAD_FORMAT: break;
xmpp_stanza_set_name(error_type, "bad-format"); case XMPP_SE_BAD_NS_PREFIX:
break; xmpp_stanza_set_name(error_type, "bad-namespace-prefix");
case XMPP_SE_BAD_NS_PREFIX: break;
xmpp_stanza_set_name(error_type, "bad-namespace-prefix"); case XMPP_SE_CONFLICT:
break; xmpp_stanza_set_name(error_type, "conflict");
case XMPP_SE_CONFLICT: break;
xmpp_stanza_set_name(error_type, "conflict"); case XMPP_SE_CONN_TIMEOUT:
break; xmpp_stanza_set_name(error_type, "connection-timeout");
case XMPP_SE_CONN_TIMEOUT: break;
xmpp_stanza_set_name(error_type, "connection-timeout"); case XMPP_SE_HOST_GONE:
break; xmpp_stanza_set_name(error_type, "host-gone");
case XMPP_SE_HOST_GONE: break;
xmpp_stanza_set_name(error_type, "host-gone"); case XMPP_SE_HOST_UNKNOWN:
break; xmpp_stanza_set_name(error_type, "host-unknown");
case XMPP_SE_HOST_UNKNOWN: break;
xmpp_stanza_set_name(error_type, "host-unknown"); case XMPP_SE_IMPROPER_ADDR:
break; xmpp_stanza_set_name(error_type, "improper-addressing");
case XMPP_SE_IMPROPER_ADDR: break;
xmpp_stanza_set_name(error_type, "improper-addressing"); case XMPP_SE_INTERNAL_SERVER_ERROR:
break; xmpp_stanza_set_name(error_type, "internal-server-error");
case XMPP_SE_INTERNAL_SERVER_ERROR: break;
xmpp_stanza_set_name(error_type, "internal-server-error"); case XMPP_SE_INVALID_FROM:
break; xmpp_stanza_set_name(error_type, "invalid-from");
case XMPP_SE_INVALID_FROM: break;
xmpp_stanza_set_name(error_type, "invalid-from"); case XMPP_SE_INVALID_ID:
break; xmpp_stanza_set_name(error_type, "invalid-id");
case XMPP_SE_INVALID_ID: break;
xmpp_stanza_set_name(error_type, "invalid-id"); case XMPP_SE_INVALID_NS:
break; xmpp_stanza_set_name(error_type, "invalid-namespace");
case XMPP_SE_INVALID_NS: break;
xmpp_stanza_set_name(error_type, "invalid-namespace"); case XMPP_SE_INVALID_XML:
break; xmpp_stanza_set_name(error_type, "invalid-xml");
case XMPP_SE_INVALID_XML: break;
xmpp_stanza_set_name(error_type, "invalid-xml"); case XMPP_SE_NOT_AUTHORIZED:
break; xmpp_stanza_set_name(error_type, "not-authorized");
case XMPP_SE_NOT_AUTHORIZED: break;
xmpp_stanza_set_name(error_type, "not-authorized"); case XMPP_SE_POLICY_VIOLATION:
break; xmpp_stanza_set_name(error_type, "policy-violation");
case XMPP_SE_POLICY_VIOLATION: break;
xmpp_stanza_set_name(error_type, "policy-violation"); case XMPP_SE_REMOTE_CONN_FAILED:
break; xmpp_stanza_set_name(error_type, "remote-connection-failed");
case XMPP_SE_REMOTE_CONN_FAILED: break;
xmpp_stanza_set_name(error_type, "remote-connection-failed"); case XMPP_SE_RESOURCE_CONSTRAINT:
break; xmpp_stanza_set_name(error_type, "resource-constraint");
case XMPP_SE_RESOURCE_CONSTRAINT: break;
xmpp_stanza_set_name(error_type, "resource-constraint"); case XMPP_SE_RESTRICTED_XML:
break; xmpp_stanza_set_name(error_type, "restricted-xml");
case XMPP_SE_RESTRICTED_XML: break;
xmpp_stanza_set_name(error_type, "restricted-xml"); case XMPP_SE_SEE_OTHER_HOST:
break; xmpp_stanza_set_name(error_type, "see-other-host");
case XMPP_SE_SEE_OTHER_HOST: break;
xmpp_stanza_set_name(error_type, "see-other-host"); case XMPP_SE_SYSTEM_SHUTDOWN:
break; xmpp_stanza_set_name(error_type, "system-shutdown");
case XMPP_SE_SYSTEM_SHUTDOWN: break;
xmpp_stanza_set_name(error_type, "system-shutdown"); case XMPP_SE_UNDEFINED_CONDITION:
break; xmpp_stanza_set_name(error_type, "undefined-condition");
case XMPP_SE_UNDEFINED_CONDITION: break;
xmpp_stanza_set_name(error_type, "undefined-condition"); case XMPP_SE_UNSUPPORTED_ENCODING:
break; xmpp_stanza_set_name(error_type, "unsupported-encoding");
case XMPP_SE_UNSUPPORTED_ENCODING: break;
xmpp_stanza_set_name(error_type, "unsupported-encoding"); case XMPP_SE_UNSUPPORTED_STANZA_TYPE:
break; xmpp_stanza_set_name(error_type, "unsupported-stanza-type");
case XMPP_SE_UNSUPPORTED_STANZA_TYPE: break;
xmpp_stanza_set_name(error_type, "unsupported-stanza-type"); case XMPP_SE_UNSUPPORTED_VERSION:
break; xmpp_stanza_set_name(error_type, "unsupported-version");
case XMPP_SE_UNSUPPORTED_VERSION: break;
xmpp_stanza_set_name(error_type, "unsupported-version"); case XMPP_SE_XML_NOT_WELL_FORMED:
break; xmpp_stanza_set_name(error_type, "xml-not-well-formed");
case XMPP_SE_XML_NOT_WELL_FORMED: break;
xmpp_stanza_set_name(error_type, "xml-not-well-formed"); default:
break; xmpp_stanza_set_name(error_type, "internal-server-error");
default: break;
xmpp_stanza_set_name(error_type, "internal-server-error"); }
break;
}
xmpp_stanza_set_ns(error_type, XMPP_NS_STREAMS_IETF); xmpp_stanza_set_ns(error_type, XMPP_NS_STREAMS_IETF);
xmpp_stanza_add_child(error, error_type); xmpp_stanza_add_child(error, error_type);
xmpp_stanza_release(error_type); xmpp_stanza_release(error_type);
if(text) if (text) {
{ xmpp_stanza_t *error_text = xmpp_stanza_new(ctx);
xmpp_stanza_t *error_text = xmpp_stanza_new(ctx); xmpp_stanza_set_name(error_text, "text");
xmpp_stanza_set_name(error_text, "text"); xmpp_stanza_set_ns(error_text, XMPP_NS_STREAMS_IETF);
xmpp_stanza_set_ns(error_text, XMPP_NS_STREAMS_IETF); xmpp_stanza_set_text(error_text, text);
xmpp_stanza_set_text(error_text, text); xmpp_stanza_add_child(error, error_text);
xmpp_stanza_add_child(error, error_text); xmpp_stanza_release(error_text);
xmpp_stanza_release(error_text);
xmpp_stanza_t *content = xmpp_stanza_new(ctx); xmpp_stanza_t *content = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(content, text); xmpp_stanza_set_text(content, text);
xmpp_stanza_add_child(error_text, content); xmpp_stanza_add_child(error_text, content);
xmpp_stanza_release(content); xmpp_stanza_release(content);