diff options
author | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-03 17:21:46 -0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-28 10:33:07 -0300 |
commit | c36942e998cd6187181df3033e53f1d624a5fd1a (patch) | |
tree | 63d19027d4dc0e779ede82eca74b0bcf80ecd881 /hcid/device.c | |
parent | c7b89988961e6c197c07fb1ba1f94bf27e457a51 (diff) |
Remove dbus-sdp.c and dbus-sdp.h.
Diffstat (limited to 'hcid/device.c')
-rw-r--r-- | hcid/device.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/hcid/device.c b/hcid/device.c index a2b6ab9d..c9160d58 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -62,9 +62,9 @@ #include "error.h" #include "glib-helper.h" #include "agent.h" -#include "dbus-sdp.h" #include "sdp-xml.h" +#define DEFAULT_XML_BUF_SIZE 1024 #define MAX_DEVICES 16 #define DISCONNECT_TIMER 2 @@ -1316,6 +1316,41 @@ static void iter_append_record(DBusMessageIter *dict, uint32_t handle, dbus_message_iter_close_container(dict, &entry); } +void append_and_grow_string(void *data, const char *str) +{ + sdp_buf_t *buff = data; + int len; + + len = strlen(str); + + if (!buff->data) { + buff->data = malloc(DEFAULT_XML_BUF_SIZE); + if (!buff->data) + return; + buff->buf_size = DEFAULT_XML_BUF_SIZE; + } + + /* Grow string */ + while (buff->buf_size < (buff->data_size + len + 1)) { + void *tmp; + uint32_t new_size; + + /* Grow buffer by a factor of 2 */ + new_size = (buff->buf_size << 1); + + tmp = realloc(buff->data, new_size); + if (!tmp) + return; + + buff->data = tmp; + buff->buf_size = new_size; + } + + /* Include the NULL character */ + memcpy(buff->data + buff->data_size, str, len + 1); + buff->data_size += len; +} + static void discover_device_reply(struct browse_req *req, sdp_list_t *recs) { DBusMessage *reply; |