diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-08-30 12:32:00 +0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-04 22:22:02 +0100 |
commit | 003421aed298c52eacd5e58c120f877df5462ea0 (patch) | |
tree | 16e9dafe2daaffb5fa7d2e0b10f276761df10c20 /gobex/gobex-packet.c | |
parent | e12802a76b6a26d7556be8392aa9af75b8e983c5 (diff) | |
download | bluez-003421aed298c52eacd5e58c120f877df5462ea0.tar.gz |
gobex: Add OBEX packet header addition convenience functions
Diffstat (limited to 'gobex/gobex-packet.c')
-rw-r--r-- | gobex/gobex-packet.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c index 8303456c3..5765c8b4f 100644 --- a/gobex/gobex-packet.c +++ b/gobex/gobex-packet.c @@ -121,6 +121,52 @@ gboolean g_obex_packet_add_body(GObexPacket *pkt, GObexDataProducer func, return TRUE; } +gboolean g_obex_packet_add_unicode(GObexPacket *pkt, guint8 id, + const char *str) +{ + GObexHeader *hdr; + + hdr = g_obex_header_new_unicode(id, str); + if (hdr == NULL) + return FALSE; + + return g_obex_packet_add_header(pkt, hdr); +} + +gboolean g_obex_packet_add_bytes(GObexPacket *pkt, guint8 id, + const void *data, gsize len) +{ + GObexHeader *hdr; + + hdr = g_obex_header_new_bytes(id, data, len); + if (hdr == NULL) + return FALSE; + + return g_obex_packet_add_header(pkt, hdr); +} + +gboolean g_obex_packet_add_uint8(GObexPacket *pkt, guint8 id, guint8 val) +{ + GObexHeader *hdr; + + hdr = g_obex_header_new_uint8(id, val); + if (hdr == NULL) + return FALSE; + + return g_obex_packet_add_header(pkt, hdr); +} + +gboolean g_obex_packet_add_uint32(GObexPacket *pkt, guint8 id, guint32 val) +{ + GObexHeader *hdr; + + hdr = g_obex_header_new_uint32(id, val); + if (hdr == NULL) + return FALSE; + + return g_obex_packet_add_header(pkt, hdr); +} + const void *g_obex_packet_get_data(GObexPacket *pkt, gsize *len) { if (pkt->data_len == 0) { |