Strophe
0.9
XMPP client library
|
Functions | |
xmpp_stanza_t * | xmpp_stanza_new (xmpp_ctx_t *ctx) |
Create a stanza object. More... | |
xmpp_stanza_t * | xmpp_stanza_clone (xmpp_stanza_t *const stanza) |
Clone a stanza object. More... | |
xmpp_stanza_t * | xmpp_stanza_copy (const xmpp_stanza_t *const stanza) |
Copy a stanza and its children. More... | |
int | xmpp_stanza_release (xmpp_stanza_t *const stanza) |
Release a stanza object and all of its children. More... | |
int | xmpp_stanza_is_text (xmpp_stanza_t *const stanza) |
Determine if a stanza is a text node. More... | |
int | xmpp_stanza_is_tag (xmpp_stanza_t *const stanza) |
Determine if a stanza is a tag node. More... | |
int | xmpp_stanza_to_text (xmpp_stanza_t *stanza, char **const buf, size_t *const buflen) |
Render a stanza object to text. More... | |
int | xmpp_stanza_set_name (xmpp_stanza_t *stanza, const char *const name) |
Set the name of a stanza. More... | |
const char * | xmpp_stanza_get_name (xmpp_stanza_t *const stanza) |
Get the stanza name. More... | |
int | xmpp_stanza_get_attribute_count (xmpp_stanza_t *const stanza) |
Count the attributes in a stanza object. More... | |
int | xmpp_stanza_get_attributes (xmpp_stanza_t *const stanza, const char **attr, int attrlen) |
Get all attributes for a stanza object. More... | |
int | xmpp_stanza_set_attribute (xmpp_stanza_t *const stanza, const char *const key, const char *const value) |
Set an attribute for a stanza object. More... | |
int | xmpp_stanza_set_ns (xmpp_stanza_t *const stanza, const char *const ns) |
Set the stanza namespace. More... | |
int | xmpp_stanza_add_child (xmpp_stanza_t *stanza, xmpp_stanza_t *child) |
Add a child stanza to a stanza object. More... | |
int | xmpp_stanza_set_text (xmpp_stanza_t *stanza, const char *const text) |
Set the text data for a text stanza. More... | |
int | xmpp_stanza_set_text_with_size (xmpp_stanza_t *stanza, const char *const text, const size_t size) |
Set the text data for a text stanza. More... | |
const char * | xmpp_stanza_get_id (xmpp_stanza_t *const stanza) |
Get the 'id' attribute of the stanza object. More... | |
const char * | xmpp_stanza_get_ns (xmpp_stanza_t *const stanza) |
Get the namespace attribute of the stanza object. More... | |
const char * | xmpp_stanza_get_type (xmpp_stanza_t *const stanza) |
Get the 'type' attribute of the stanza object. More... | |
const char * | xmpp_stanza_get_to (xmpp_stanza_t *const stanza) |
Get the 'to' attribute of the stanza object. More... | |
const char * | xmpp_stanza_get_from (xmpp_stanza_t *const stanza) |
Get the 'from' attribute of the stanza object. More... | |
xmpp_stanza_t * | xmpp_stanza_get_child_by_name (xmpp_stanza_t *const stanza, const char *const name) |
Get the first child of stanza with name. More... | |
xmpp_stanza_t * | xmpp_stanza_get_child_by_ns (xmpp_stanza_t *const stanza, const char *const ns) |
Get the first child of a stanza with a given namespace. More... | |
xmpp_stanza_t * | xmpp_stanza_get_children (xmpp_stanza_t *const stanza) |
Get the list of children. More... | |
xmpp_stanza_t * | xmpp_stanza_get_next (xmpp_stanza_t *const stanza) |
Get the next sibling of a stanza. More... | |
char * | xmpp_stanza_get_text (xmpp_stanza_t *const stanza) |
Get the text data for a text stanza. More... | |
const char * | xmpp_stanza_get_text_ptr (xmpp_stanza_t *const stanza) |
Get the text data pointer for a text stanza. More... | |
int | xmpp_stanza_set_id (xmpp_stanza_t *const stanza, const char *const id) |
Set the 'id' attribute of a stanza. More... | |
int | xmpp_stanza_set_type (xmpp_stanza_t *const stanza, const char *const type) |
Set the 'type' attribute of a stanza. More... | |
int | xmpp_stanza_set_to (xmpp_stanza_t *const stanza, const char *const to) |
Set the 'to' attribute of a stanza. More... | |
int | xmpp_stanza_set_from (xmpp_stanza_t *const stanza, const char *const from) |
Set the 'from' attribute of a stanza. More... | |
const char * | xmpp_stanza_get_attribute (xmpp_stanza_t *const stanza, const char *const name) |
Get an attribute from a stanza. More... | |
int | xmpp_stanza_del_attribute (xmpp_stanza_t *const stanza, const char *const name) |
Delete an attribute from a stanza. More... | |
xmpp_stanza_t * | xmpp_stanza_reply (xmpp_stanza_t *const stanza) |
Create a stanza object in reply to another. More... | |
xmpp_stanza_t * | xmpp_message_new (xmpp_ctx_t *ctx, const char *const type, const char *const to, const char *const id) |
Create a <message> stanza object with given attributes. More... | |
char * | xmpp_message_get_body (xmpp_stanza_t *msg) |
Get text from <body> child element. More... | |
int | xmpp_message_set_body (xmpp_stanza_t *msg, const char *const text) |
Add <body> child element to a <message> stanza with the given text. More... | |
xmpp_stanza_t * | xmpp_iq_new (xmpp_ctx_t *ctx, const char *const type, const char *const id) |
Create an <iq> stanza object with given attributes. More... | |
xmpp_stanza_t * | xmpp_presence_new (xmpp_ctx_t *ctx) |
Create a <presence> stanza object. More... | |
xmpp_stanza_t * | xmpp_error_new (xmpp_ctx_t *ctx, xmpp_error_type_t const type, const char *const text) |
Create an <stream:error/> stanza object with given type and error text. More... | |
xmpp_stanza_t* xmpp_stanza_new | ( | xmpp_ctx_t * | ctx | ) |
Create a stanza object.
This function allocates and initializes a blank stanza object. The stanza will have a reference count of one, so the caller does not need to clone it.
ctx | a Strophe context object |
xmpp_stanza_t* xmpp_stanza_clone | ( | xmpp_stanza_t *const | stanza | ) |
Clone a stanza object.
This function increments the reference count of the stanza object.
stanza | a Strophe stanza object |
xmpp_stanza_t* xmpp_stanza_copy | ( | const xmpp_stanza_t *const | stanza | ) |
Copy a stanza and its children.
This function copies a stanza along with all its children and returns the new stanza and children with a reference count of 1. The returned stanza will have no parent and no siblings. This function is useful for extracting a child stanza for inclusion in another tree.
stanza | a Strophe stanza object |
int xmpp_stanza_release | ( | xmpp_stanza_t *const | stanza | ) |
Release a stanza object and all of its children.
This function releases a stanza object and potentially all of its children, which may cause the object(s) to be freed.
stanza | a Strophe stanza object |
int xmpp_stanza_is_text | ( | xmpp_stanza_t *const | stanza | ) |
Determine if a stanza is a text node.
stanza | a Strophe stanza object |
int xmpp_stanza_is_tag | ( | xmpp_stanza_t *const | stanza | ) |
Determine if a stanza is a tag node.
stanza | a Strophe stanza object |
int xmpp_stanza_to_text | ( | xmpp_stanza_t * | stanza, |
char **const | buf, | ||
size_t *const | buflen | ||
) |
Render a stanza object to text.
This function renders a given stanza object, along with its children, to text. The text is returned in an allocated, null-terminated buffer. It starts by allocating a 1024 byte buffer and reallocates more memory if that is not large enough.
stanza | a Strophe stanza object |
buf | a reference to a string pointer |
buflen | a reference to a size_t |
int xmpp_stanza_set_name | ( | xmpp_stanza_t * | stanza, |
const char *const | name | ||
) |
Set the name of a stanza.
stanza | a Strophe stanza object |
name | a string with the name of the stanza |
const char* xmpp_stanza_get_name | ( | xmpp_stanza_t *const | stanza | ) |
Get the stanza name.
This function returns a pointer to the stanza name. If the caller needs to store this data, it must make a copy.
stanza | a Strophe stanza object |
int xmpp_stanza_get_attribute_count | ( | xmpp_stanza_t *const | stanza | ) |
Count the attributes in a stanza object.
stanza | a Strophe stanza object |
int xmpp_stanza_get_attributes | ( | xmpp_stanza_t *const | stanza, |
const char ** | attr, | ||
int | attrlen | ||
) |
Get all attributes for a stanza object.
This function populates the array with attributes from the stanza. The attr array will be in the format: attr[i] = attribute name, attr[i+1] = attribute value.
stanza | a Strophe stanza object |
attr | the string array to populate |
attrlen | the size of the array |
int xmpp_stanza_set_attribute | ( | xmpp_stanza_t *const | stanza, |
const char *const | key, | ||
const char *const | value | ||
) |
Set an attribute for a stanza object.
stanza | a Strophe stanza object |
key | a string with the attribute name |
value | a string with the attribute value |
int xmpp_stanza_set_ns | ( | xmpp_stanza_t *const | stanza, |
const char *const | ns | ||
) |
Set the stanza namespace.
This is a convenience function equivalent to calling: xmpp_stanza_set_attribute(stanza, "xmlns", ns);
stanza | a Strophe stanza object |
ns | a string with the namespace |
int xmpp_stanza_add_child | ( | xmpp_stanza_t * | stanza, |
xmpp_stanza_t * | child | ||
) |
Add a child stanza to a stanza object.
This function clones the child and appends it to the stanza object's children.
stanza | a Strophe stanza object |
child | the child stanza object |
int xmpp_stanza_set_text | ( | xmpp_stanza_t * | stanza, |
const char *const | text | ||
) |
Set the text data for a text stanza.
This function copies the text given and sets the stanza object's text to it. Attempting to use this function on a stanza that has a name will fail with XMPP_EINVOP. This function takes the text as a null-terminated string.
stanza | a Strophe stanza object |
text | a string with the text |
int xmpp_stanza_set_text_with_size | ( | xmpp_stanza_t * | stanza, |
const char *const | text, | ||
const size_t | size | ||
) |
Set the text data for a text stanza.
This function copies the text given and sets the stanza object's text to it. Attempting to use this function on a stanza that has a name will fail with XMPP_EINVOP. This function takes the text as buffer and a length as opposed to a null-terminated string.
stanza | a Strophe stanza object |
text | a buffer with the text |
size | the length of the text |
const char* xmpp_stanza_get_id | ( | xmpp_stanza_t *const | stanza | ) |
Get the 'id' attribute of the stanza object.
This is a convenience function equivalent to: xmpp_stanza_get_attribute(stanza, "id");
stanza | a Strophe stanza object |
const char* xmpp_stanza_get_ns | ( | xmpp_stanza_t *const | stanza | ) |
Get the namespace attribute of the stanza object.
This is a convenience function equivalent to: xmpp_stanza_get_attribute(stanza, "xmlns");
stanza | a Strophe stanza object |
const char* xmpp_stanza_get_type | ( | xmpp_stanza_t *const | stanza | ) |
Get the 'type' attribute of the stanza object.
This is a convenience function equivalent to: xmpp_stanza_get_attribute(stanza, "type");
stanza | a Strophe stanza object |
const char* xmpp_stanza_get_to | ( | xmpp_stanza_t *const | stanza | ) |
Get the 'to' attribute of the stanza object.
This is a convenience function equivalent to: xmpp_stanza_get_attribute(stanza, "to");
stanza | a Strophe stanza object |
const char* xmpp_stanza_get_from | ( | xmpp_stanza_t *const | stanza | ) |
Get the 'from' attribute of the stanza object.
This is a convenience function equivalent to: xmpp_stanza_get_attribute(stanza, "from");
stanza | a Strophe stanza object |
xmpp_stanza_t* xmpp_stanza_get_child_by_name | ( | xmpp_stanza_t *const | stanza, |
const char *const | name | ||
) |
Get the first child of stanza with name.
This function searches all the immediate children of stanza for a child stanza that matches the name. The first matching child is returned.
stanza | a Strophe stanza object |
name | a string with the name to match |
xmpp_stanza_t* xmpp_stanza_get_child_by_ns | ( | xmpp_stanza_t *const | stanza, |
const char *const | ns | ||
) |
Get the first child of a stanza with a given namespace.
This function searches all the immediate children of a stanza for a child stanza that matches the namespace provided. The first matching child is returned.
stanza | a Strophe stanza object |
ns | a string with the namespace to match |
xmpp_stanza_t* xmpp_stanza_get_children | ( | xmpp_stanza_t *const | stanza | ) |
Get the list of children.
This function returns the first child of the stanza object. The rest of the children can be obtained by calling xmpp_stanza_get_next() to iterate over the siblings.
stanza | a Strophe stanza object |
xmpp_stanza_t* xmpp_stanza_get_next | ( | xmpp_stanza_t *const | stanza | ) |
Get the next sibling of a stanza.
stanza | a Strophe stanza object |
char* xmpp_stanza_get_text | ( | xmpp_stanza_t *const | stanza | ) |
Get the text data for a text stanza.
This function copies the text data from a stanza and returns the new allocated string. The caller is responsible for freeing this string with xmpp_free().
stanza | a Strophe stanza object |
const char* xmpp_stanza_get_text_ptr | ( | xmpp_stanza_t *const | stanza | ) |
Get the text data pointer for a text stanza.
This function copies returns the raw pointer to the text data in the stanza. This should only be used in very special cases where the caller needs to translate the datatype as this will save a double allocation. The caller should not hold onto this pointer, and is responsible for allocating a copy if it needs one.
stanza | a Strophe stanza object |
int xmpp_stanza_set_id | ( | xmpp_stanza_t *const | stanza, |
const char *const | id | ||
) |
Set the 'id' attribute of a stanza.
This is a convenience function for: xmpp_stanza_set_attribute(stanza, 'id', id);
stanza | a Strophe stanza object |
id | a string containing the 'id' value |
int xmpp_stanza_set_type | ( | xmpp_stanza_t *const | stanza, |
const char *const | type | ||
) |
Set the 'type' attribute of a stanza.
This is a convenience function for: xmpp_stanza_set_attribute(stanza, 'type', type);
stanza | a Strophe stanza object |
type | a string containing the 'type' value |
int xmpp_stanza_set_to | ( | xmpp_stanza_t *const | stanza, |
const char *const | to | ||
) |
Set the 'to' attribute of a stanza.
This is a convenience function for: xmpp_stanza_set_attribute(stanza, 'to', to);
stanza | a Strophe stanza object |
to | a string containing the 'to' value |
int xmpp_stanza_set_from | ( | xmpp_stanza_t *const | stanza, |
const char *const | from | ||
) |
Set the 'from' attribute of a stanza.
This is a convenience function for: xmpp_stanza_set_attribute(stanza, 'from', from);
stanza | a Strophe stanza object |
from | a string containing the 'from' value |
const char* xmpp_stanza_get_attribute | ( | xmpp_stanza_t *const | stanza, |
const char *const | name | ||
) |
Get an attribute from a stanza.
This function returns a pointer to the attribute value. If the caller wishes to save this value it must make its own copy.
stanza | a Strophe stanza object |
name | a string containing attribute name |
int xmpp_stanza_del_attribute | ( | xmpp_stanza_t *const | stanza, |
const char *const | name | ||
) |
Delete an attribute from a stanza.
stanza | a Strophe stanza object |
name | a string containing attribute name |
xmpp_stanza_t* xmpp_stanza_reply | ( | xmpp_stanza_t *const | stanza | ) |
Create a stanza object in reply to another.
This function makes a copy of a stanza object with the attribute “to” set its original “from”. The stanza will have a reference count of one, so the caller does not need to clone it.
stanza | a Strophe stanza object |
xmpp_stanza_t* xmpp_message_new | ( | xmpp_ctx_t * | ctx, |
const char *const | type, | ||
const char *const | to, | ||
const char *const | id | ||
) |
Create a <message> stanza object with given attributes.
Attributes are optional and may be NULL.
ctx | a Strophe context object |
type | attribute 'type' |
to | attribute 'to' |
id | attribute 'id' |
char* xmpp_message_get_body | ( | xmpp_stanza_t * | msg | ) |
Get text from <body> child element.
This function returns new allocated string. The caller is responsible for freeing this string with xmpp_free().
msg | well formed <message> stanza |
int xmpp_message_set_body | ( | xmpp_stanza_t * | msg, |
const char *const | text | ||
) |
Add <body> child element to a <message> stanza with the given text.
msg | a <message> stanza object without <body> child element. |
xmpp_stanza_t* xmpp_iq_new | ( | xmpp_ctx_t * | ctx, |
const char *const | type, | ||
const char *const | id | ||
) |
Create an <iq> stanza object with given attributes.
Attributes are optional and may be NULL.
ctx | a Strophe context object |
type | attribute 'type' |
id | attribute 'id' |
xmpp_stanza_t* xmpp_presence_new | ( | xmpp_ctx_t * | ctx | ) |
Create a <presence> stanza object.
ctx | a Strophe context object |
xmpp_stanza_t* xmpp_error_new | ( | xmpp_ctx_t * | ctx, |
xmpp_error_type_t const | type, | ||
const char *const | text | ||
) |
Create an <stream:error/> stanza object with given type and error text.
The error text is optional and may be NULL.
ctx | a Strophe context object |
type | enum of xmpp_error_type_t |
text | content of a 'text' |