diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-07-10 21:36:47 +0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-04 22:22:01 +0100 |
commit | cdcde596874e3a698b674c4ef0c47f13232bbe8c (patch) | |
tree | 1dee711fee65a9e46c0c06d0f22ab4d08d3c2bd6 /gobex/gobex-packet.c | |
parent | f8e95ce529bd2e65473d9dcd0c8540f664a76393 (diff) | |
download | bluez-cdcde596874e3a698b674c4ef0c47f13232bbe8c.tar.gz |
gobex: Add va-args based packet creation support
Diffstat (limited to 'gobex/gobex-packet.c')
-rw-r--r-- | gobex/gobex-packet.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c index 0e6528edf..10c1cf70a 100644 --- a/gobex/gobex-packet.c +++ b/gobex/gobex-packet.c @@ -154,7 +154,8 @@ gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len, return TRUE; } -GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final, GSList *headers) +GObexPacket *g_obex_packet_new_valist(guint8 opcode, gboolean final, + guint8 first_hdr_id, va_list args) { GObexPacket *pkt; @@ -162,13 +163,26 @@ GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final, GSList *headers) pkt->opcode = opcode; pkt->final = final; - pkt->headers = headers; - + pkt->headers = g_obex_header_create_list(first_hdr_id, args, + &pkt->hlen); pkt->data_policy = G_OBEX_DATA_COPY; return pkt; } +GObexPacket *g_obex_packet_new(guint8 opcode, gboolean final, + guint8 first_hdr_id, ...) +{ + GObexPacket *pkt; + va_list args; + + va_start(args, first_hdr_id); + pkt = g_obex_packet_new_valist(opcode, final, first_hdr_id, args); + va_end(args); + + return pkt; +} + void g_obex_packet_free(GObexPacket *pkt) { switch (pkt->data_policy) { @@ -253,7 +267,7 @@ GObexPacket *g_obex_packet_decode(const void *data, gsize len, final = (opcode & FINAL_BIT) ? TRUE : FALSE; opcode &= ~FINAL_BIT; - pkt = g_obex_packet_new(opcode, final, NULL); + pkt = g_obex_packet_new(opcode, final, G_OBEX_HDR_ID_INVALID); if (header_offset == 0) goto headers; |