stanza: avoid copy-paste in 'get' functions
This commit is contained in:
40
src/stanza.c
40
src/stanza.c
@@ -712,13 +712,7 @@ int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
|
|||||||
*/
|
*/
|
||||||
char *xmpp_stanza_get_id(xmpp_stanza_t * const stanza)
|
char *xmpp_stanza_get_id(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
if (stanza->type != XMPP_STANZA_TAG)
|
return xmpp_stanza_get_attribute(stanza, "id");
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!stanza->attributes)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char *)hash_get(stanza->attributes, "id");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the namespace attribute of the stanza object.
|
/** Get the namespace attribute of the stanza object.
|
||||||
@@ -733,13 +727,7 @@ char *xmpp_stanza_get_id(xmpp_stanza_t * const stanza)
|
|||||||
*/
|
*/
|
||||||
char *xmpp_stanza_get_ns(xmpp_stanza_t * const stanza)
|
char *xmpp_stanza_get_ns(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
if (stanza->type != XMPP_STANZA_TAG)
|
return xmpp_stanza_get_attribute(stanza, "xmlns");
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!stanza->attributes)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char *)hash_get(stanza->attributes, "xmlns");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the 'type' attribute of the stanza object.
|
/** Get the 'type' attribute of the stanza object.
|
||||||
@@ -754,13 +742,7 @@ char *xmpp_stanza_get_ns(xmpp_stanza_t * const stanza)
|
|||||||
*/
|
*/
|
||||||
char *xmpp_stanza_get_type(xmpp_stanza_t * const stanza)
|
char *xmpp_stanza_get_type(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
if (stanza->type != XMPP_STANZA_TAG)
|
return xmpp_stanza_get_attribute(stanza, "type");
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!stanza->attributes)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char *)hash_get(stanza->attributes, "type");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the 'to' attribute of the stanza object.
|
/** Get the 'to' attribute of the stanza object.
|
||||||
@@ -775,13 +757,7 @@ char *xmpp_stanza_get_type(xmpp_stanza_t * const stanza)
|
|||||||
*/
|
*/
|
||||||
char *xmpp_stanza_get_to(xmpp_stanza_t * const stanza)
|
char *xmpp_stanza_get_to(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
if (stanza->type != XMPP_STANZA_TAG)
|
return xmpp_stanza_get_attribute(stanza, "to");
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!stanza->attributes)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char *)hash_get(stanza->attributes, "to");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the 'from' attribute of the stanza object.
|
/** Get the 'from' attribute of the stanza object.
|
||||||
@@ -796,13 +772,7 @@ char *xmpp_stanza_get_to(xmpp_stanza_t * const stanza)
|
|||||||
*/
|
*/
|
||||||
char *xmpp_stanza_get_from(xmpp_stanza_t * const stanza)
|
char *xmpp_stanza_get_from(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
if (stanza->type != XMPP_STANZA_TAG)
|
return xmpp_stanza_get_attribute(stanza, "from");
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!stanza->attributes)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (char *)hash_get(stanza->attributes, "from");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the first child of stanza with name.
|
/** Get the first child of stanza with name.
|
||||||
|
|||||||
Reference in New Issue
Block a user