diff --git a/gobex/gobex-header.c b/gobex/gobex-header.c
index bf7dc9d..d4351cb 100644
--- a/gobex/gobex-header.c
+++ b/gobex/gobex-header.c
#include "gobex-header.h"
/* Header types */
-#define G_OBEX_HDR_TYPE_UNICODE (0 << 6)
-#define G_OBEX_HDR_TYPE_BYTES (1 << 6)
-#define G_OBEX_HDR_TYPE_UINT8 (2 << 6)
-#define G_OBEX_HDR_TYPE_UINT32 (3 << 6)
+#define G_OBEX_HDR_ENC_UNICODE (0 << 6)
+#define G_OBEX_HDR_ENC_BYTES (1 << 6)
+#define G_OBEX_HDR_ENC_UINT8 (2 << 6)
+#define G_OBEX_HDR_ENC_UINT32 (3 << 6)
-#define G_OBEX_HDR_TYPE(id) ((id) & 0xc0)
+#define G_OBEX_HDR_ENC(id) ((id) & 0xc0)
struct _GObexHeader {
guint8 id;
ptr = put_bytes(ptr, &header->id, sizeof(header->id));
- switch (G_OBEX_HDR_TYPE(header->id)) {
- case G_OBEX_HDR_TYPE_UNICODE:
+ switch (G_OBEX_HDR_ENC(header->id)) {
+ case G_OBEX_HDR_ENC_UNICODE:
utf16_len = utf8_to_utf16(&utf16, header->v.string);
if (utf16_len < 0 || (guint16) utf16_len > buf_len)
return -1;
ptr = put_bytes(ptr, utf16, utf16_len);
g_free(utf16);
break;
- case G_OBEX_HDR_TYPE_BYTES:
+ case G_OBEX_HDR_ENC_BYTES:
u16 = g_htons(header->hlen);
ptr = put_bytes(ptr, &u16, sizeof(u16));
if (header->extdata)
else
ptr = put_bytes(ptr, header->v.data, header->vlen);
break;
- case G_OBEX_HDR_TYPE_UINT8:
+ case G_OBEX_HDR_ENC_UINT8:
*ptr = header->v.u8;
break;
- case G_OBEX_HDR_TYPE_UINT32:
+ case G_OBEX_HDR_ENC_UINT32:
u32 = g_htonl(header->v.u32);
ptr = put_bytes(ptr, &u32, sizeof(u32));
break;
ptr = get_bytes(&header->id, ptr, sizeof(header->id));
- switch (G_OBEX_HDR_TYPE(header->id)) {
- case G_OBEX_HDR_TYPE_UNICODE:
+ switch (G_OBEX_HDR_ENC(header->id)) {
+ case G_OBEX_HDR_ENC_UNICODE:
if (len < 3) {
g_set_error(err, G_OBEX_ERROR,
G_OBEX_ERROR_PARSE_ERROR,
*parsed = hdr_len;
break;
- case G_OBEX_HDR_TYPE_BYTES:
+ case G_OBEX_HDR_ENC_BYTES:
if (len < 3) {
g_set_error(err, G_OBEX_ERROR,
G_OBEX_ERROR_PARSE_ERROR,
*parsed = hdr_len;
break;
- case G_OBEX_HDR_TYPE_UINT8:
+ case G_OBEX_HDR_ENC_UINT8:
header->vlen = 1;
header->hlen = 2;
header->v.u8 = *ptr;
*parsed = 2;
break;
- case G_OBEX_HDR_TYPE_UINT32:
+ case G_OBEX_HDR_ENC_UINT32:
if (len < 5) {
g_set_error(err, G_OBEX_ERROR,
G_OBEX_ERROR_PARSE_ERROR,
void g_obex_header_free(GObexHeader *header)
{
- switch (G_OBEX_HDR_TYPE(header->id)) {
- case G_OBEX_HDR_TYPE_UNICODE:
+ switch (G_OBEX_HDR_ENC(header->id)) {
+ case G_OBEX_HDR_ENC_UNICODE:
g_free(header->v.string);
break;
- case G_OBEX_HDR_TYPE_BYTES:
+ case G_OBEX_HDR_ENC_BYTES:
if (!header->extdata)
g_free(header->v.data);
break;
- case G_OBEX_HDR_TYPE_UINT8:
- case G_OBEX_HDR_TYPE_UINT32:
+ case G_OBEX_HDR_ENC_UINT8:
+ case G_OBEX_HDR_ENC_UINT32:
break;
default:
g_assert_not_reached();
gboolean g_obex_header_get_unicode(GObexHeader *header, const char **str)
{
- if (G_OBEX_HDR_TYPE(header->id) != G_OBEX_HDR_TYPE_UNICODE)
+ if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_UNICODE)
return FALSE;
*str = header->v.string;
gboolean g_obex_header_get_bytes(GObexHeader *header, const guint8 **val,
gsize *len)
{
- if (G_OBEX_HDR_TYPE(header->id) != G_OBEX_HDR_TYPE_BYTES)
+ if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_BYTES)
return FALSE;
*len = header->vlen;
gboolean g_obex_header_get_uint8(GObexHeader *header, guint8 *val)
{
- if (G_OBEX_HDR_TYPE(header->id) != G_OBEX_HDR_TYPE_UINT8)
+ if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_UINT8)
return FALSE;
*val = header->v.u8;
gboolean g_obex_header_get_uint32(GObexHeader *header, guint32 *val)
{
- if (G_OBEX_HDR_TYPE(header->id) != G_OBEX_HDR_TYPE_UINT32)
+ if (G_OBEX_HDR_ENC(header->id) != G_OBEX_HDR_ENC_UINT32)
return FALSE;
*val = header->v.u32;
GObexHeader *header;
gsize len;
- if (G_OBEX_HDR_TYPE(id) != G_OBEX_HDR_TYPE_UNICODE)
+ if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_UNICODE)
return NULL;
header = g_new0(GObexHeader, 1);
{
GObexHeader *header;
- if (G_OBEX_HDR_TYPE(id) != G_OBEX_HDR_TYPE_BYTES)
+ if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_BYTES)
return NULL;
header = g_new0(GObexHeader, 1);
{
GObexHeader *header;
- if (G_OBEX_HDR_TYPE(id) != G_OBEX_HDR_TYPE_UINT8)
+ if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_UINT8)
return NULL;
header = g_new0(GObexHeader, 1);
{
GObexHeader *header;
- if (G_OBEX_HDR_TYPE(id) != G_OBEX_HDR_TYPE_UINT32)
+ if (G_OBEX_HDR_ENC(id) != G_OBEX_HDR_ENC_UINT32)
return NULL;
header = g_new0(GObexHeader, 1);
*total_len = 0;
- while (id != G_OBEX_HDR_ID_INVALID) {
+ while (id != G_OBEX_HDR_INVALID) {
GObexHeader *hdr;
const char *str;
const void *bytes;
unsigned int val;
gsize len;
- switch (G_OBEX_HDR_TYPE(id)) {
- case G_OBEX_HDR_TYPE_UNICODE:
+ switch (G_OBEX_HDR_ENC(id)) {
+ case G_OBEX_HDR_ENC_UNICODE:
str = va_arg(args, const char *);
hdr = g_obex_header_new_unicode(id, str);
break;
- case G_OBEX_HDR_TYPE_BYTES:
+ case G_OBEX_HDR_ENC_BYTES:
bytes = va_arg(args, void *);
len = va_arg(args, gsize);
hdr = g_obex_header_new_bytes(id, bytes, len);
break;
- case G_OBEX_HDR_TYPE_UINT8:
+ case G_OBEX_HDR_ENC_UINT8:
val = va_arg(args, unsigned int);
hdr = g_obex_header_new_uint8(id, val);
break;
- case G_OBEX_HDR_TYPE_UINT32:
+ case G_OBEX_HDR_ENC_UINT32:
val = va_arg(args, unsigned int);
hdr = g_obex_header_new_uint32(id, val);
break;
diff --git a/gobex/gobex-header.h b/gobex/gobex-header.h
index 0a8ff33..b7d23eb 100644
--- a/gobex/gobex-header.h
+++ b/gobex/gobex-header.h
#include <gobex/gobex-defs.h>
/* Header ID's */
-#define G_OBEX_HDR_ID_INVALID 0x00
+#define G_OBEX_HDR_INVALID 0x00
-#define G_OBEX_HDR_ID_COUNT 0xc0
-#define G_OBEX_HDR_ID_NAME 0x01
-#define G_OBEX_HDR_ID_TYPE 0x42
-#define G_OBEX_HDR_ID_LENGTH 0xc3
-#define G_OBEX_HDR_ID_TIME 0x44
-#define G_OBEX_HDR_ID_DESCRIPTION 0x05
-#define G_OBEX_HDR_ID_TARGET 0x46
-#define G_OBEX_HDR_ID_HTTP 0x47
-#define G_OBEX_HDR_ID_BODY 0x48
-#define G_OBEX_HDR_ID_BODY_END 0x49
-#define G_OBEX_HDR_ID_WHO 0x4a
-#define G_OBEX_HDR_ID_CONNECTION 0xcb
-#define G_OBEX_HDR_ID_APPARAM 0x4c
-#define G_OBEX_HDR_ID_AUTHCHAL 0x4d
-#define G_OBEX_HDR_ID_AUTHRESP 0x4e
-#define G_OBEX_HDR_ID_CREATOR 0xcf
-#define G_OBEX_HDR_ID_WANUUID 0x50
-#define G_OBEX_HDR_ID_OBJECTCLASS 0x51
-#define G_OBEX_HDR_ID_SESSIONPARAM 0x52
-#define G_OBEX_HDR_ID_SESSIONSEQ 0x93
-#define G_OBEX_HDR_ID_ACTION 0x94
-#define G_OBEX_HDR_ID_DESTNAME 0x15
-#define G_OBEX_HDR_ID_PERMISSIONS 0xd6
-#define G_OBEX_HDR_ID_SRM 0x97
-#define G_OBEX_HDR_ID_SRM_PARAMETERS 0x98
+#define G_OBEX_HDR_COUNT 0xc0
+#define G_OBEX_HDR_NAME 0x01
+#define G_OBEX_HDR_TYPE 0x42
+#define G_OBEX_HDR_LENGTH 0xc3
+#define G_OBEX_HDR_TIME 0x44
+#define G_OBEX_HDR_DESCRIPTION 0x05
+#define G_OBEX_HDR_TARGET 0x46
+#define G_OBEX_HDR_HTTP 0x47
+#define G_OBEX_HDR_BODY 0x48
+#define G_OBEX_HDR_BODY_END 0x49
+#define G_OBEX_HDR_WHO 0x4a
+#define G_OBEX_HDR_CONNECTION 0xcb
+#define G_OBEX_HDR_APPARAM 0x4c
+#define G_OBEX_HDR_AUTHCHAL 0x4d
+#define G_OBEX_HDR_AUTHRESP 0x4e
+#define G_OBEX_HDR_CREATOR 0xcf
+#define G_OBEX_HDR_WANUUID 0x50
+#define G_OBEX_HDR_OBJECTCLASS 0x51
+#define G_OBEX_HDR_SESSIONPARAM 0x52
+#define G_OBEX_HDR_SESSIONSEQ 0x93
+#define G_OBEX_HDR_ACTION 0x94
+#define G_OBEX_HDR_DESTNAME 0x15
+#define G_OBEX_HDR_PERMISSIONS 0xd6
+#define G_OBEX_HDR_SRM 0x97
+#define G_OBEX_HDR_SRM_PARAMETERS 0x98
typedef struct _GObexHeader GObexHeader;
diff --git a/gobex/gobex-packet.c b/gobex/gobex-packet.c
index 10c1cf7..679a2dd 100644
--- a/gobex/gobex-packet.c
+++ b/gobex/gobex-packet.c
final = (opcode & FINAL_BIT) ? TRUE : FALSE;
opcode &= ~FINAL_BIT;
- pkt = g_obex_packet_new(opcode, final, G_OBEX_HDR_ID_INVALID);
+ pkt = g_obex_packet_new(opcode, final, G_OBEX_HDR_INVALID);
if (header_offset == 0)
goto headers;
return ret;
if (ret > 0)
- buf[0] = G_OBEX_HDR_ID_BODY;
+ buf[0] = G_OBEX_HDR_BODY;
else
- buf[0] = G_OBEX_HDR_ID_BODY_END;
+ buf[0] = G_OBEX_HDR_BODY_END;
u16 = g_htons(ret + 3);
memcpy(&buf[1], &u16, sizeof(u16));
diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c
index 75fa50e..c664118 100644
--- a/gobex/gobex-transfer.c
+++ b/gobex/gobex-transfer.c
if (ret >= 0)
return ret;
- req = g_obex_packet_new(G_OBEX_OP_ABORT, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_ABORT, TRUE, G_OBEX_HDR_INVALID);
transfer->req_id = g_obex_send_req(transfer->obex, req, -1,
transfer_abort_response,
transfer, &err);
if (transfer->opcode == G_OBEX_OP_GET) {
GObexHeader *body;
- body = g_obex_packet_get_header(rsp, G_OBEX_HDR_ID_BODY);
+ body = g_obex_packet_get_header(rsp, G_OBEX_HDR_BODY);
if (body == NULL)
body = g_obex_packet_get_header(rsp,
- G_OBEX_HDR_ID_BODY_END);
+ G_OBEX_HDR_BODY_END);
if (body != NULL) {
const guint8 *buf;
gsize len;
return;
}
- req = g_obex_packet_new(transfer->opcode, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(transfer->opcode, TRUE, G_OBEX_HDR_INVALID);
if (transfer->opcode == G_OBEX_OP_PUT)
g_obex_packet_add_body(req, put_get_data, transfer);
transfer = transfer_new(obex, G_OBEX_OP_PUT, complete_func, user_data);
transfer->data_producer = data_func;
- req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
if (type) {
- hdr = g_obex_header_new_bytes(G_OBEX_HDR_ID_TYPE,
+ hdr = g_obex_header_new_bytes(G_OBEX_HDR_TYPE,
(char *) type, strlen(type) + 1);
g_obex_packet_add_header(req, hdr);
}
if (name) {
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, name);
+ hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, name);
g_obex_packet_add_header(req, hdr);
}
GObexPacket *rsp;
GObexHeader *body;
- body = g_obex_packet_get_header(req, G_OBEX_HDR_ID_BODY);
+ body = g_obex_packet_get_header(req, G_OBEX_HDR_BODY);
if (body == NULL) {
- body = g_obex_packet_get_header(req, G_OBEX_HDR_ID_BODY_END);
+ body = g_obex_packet_get_header(req, G_OBEX_HDR_BODY_END);
rspcode = G_OBEX_RSP_SUCCESS;
}
transfer->data_consumer(buf, len, transfer->user_data);
}
- rsp = g_obex_packet_new(rspcode, TRUE, G_OBEX_HDR_ID_INVALID);
+ rsp = g_obex_packet_new(rspcode, TRUE, G_OBEX_HDR_INVALID);
if (!g_obex_send(obex, rsp, &err)) {
transfer_complete(transfer, err);
g_error_free(err);
err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED,
"Request was aborted");
- rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID);
g_obex_send(obex, rsp, NULL);
transfer_complete(transfer, err);
transfer = transfer_new(obex, G_OBEX_OP_GET, complete_func, user_data);
transfer->data_consumer = data_func;
- req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
if (type) {
- hdr = g_obex_header_new_bytes(G_OBEX_HDR_ID_TYPE,
+ hdr = g_obex_header_new_bytes(G_OBEX_HDR_TYPE,
(char *) type, strlen(type) + 1);
g_obex_packet_add_header(req, hdr);
}
if (name) {
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, name);
+ hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, name);
g_obex_packet_add_header(req, hdr);
}
}
req = g_obex_packet_new(G_OBEX_RSP_INTERNAL_SERVER_ERROR, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ G_OBEX_HDR_INVALID);
g_obex_send(transfer->obex, req, NULL);
err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED,
GError *err = NULL;
GObexPacket *rsp;
- rsp = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ rsp = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID);
g_obex_packet_add_body(rsp, get_get_data, transfer);
if (!g_obex_send(obex, rsp, &err)) {
diff --git a/gobex/gobex.c b/gobex/gobex.c
index b0d21ea..f98551e 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
init_connect_data(obex, &data);
g_obex_packet_set_data(rsp, &data, sizeof(data), G_OBEX_DATA_COPY);
- connid = g_obex_packet_find_header(rsp, G_OBEX_HDR_ID_CONNECTION);
+ connid = g_obex_packet_find_header(rsp, G_OBEX_HDR_CONNECTION);
if (connid != NULL) {
g_obex_header_get_uint32(connid, &obex->conn_id);
return;
obex->conn_id = next_connid++;
- connid = g_obex_header_new_uint32(G_OBEX_HDR_ID_CONNECTION,
+ connid = g_obex_header_new_uint32(G_OBEX_HDR_CONNECTION,
obex->conn_id);
g_obex_packet_prepend_header(rsp, connid);
}
if (obex->conn_id == CONNID_INVALID)
goto create_pending;
- connid = g_obex_packet_find_header(req, G_OBEX_HDR_ID_CONNECTION);
+ connid = g_obex_packet_find_header(req, G_OBEX_HDR_CONNECTION);
if (connid != NULL)
goto create_pending;
- connid = g_obex_header_new_uint32(G_OBEX_HDR_ID_CONNECTION,
+ connid = g_obex_header_new_uint32(G_OBEX_HDR_CONNECTION,
obex->conn_id);
g_obex_packet_prepend_header(req, connid);
obex->pending_req->cancelled = TRUE;
- pkt = g_obex_packet_new(G_OBEX_OP_ABORT, TRUE, G_OBEX_HDR_ID_INVALID);
+ pkt = g_obex_packet_new(G_OBEX_OP_ABORT, TRUE, G_OBEX_HDR_INVALID);
return g_obex_send(obex, pkt, err);
}
obex->tx_mtu = obex->io_tx_mtu;
obex->tx_buf = g_realloc(obex->tx_buf, obex->tx_mtu);
- connid = g_obex_packet_find_header(pkt, G_OBEX_HDR_ID_CONNECTION);
+ connid = g_obex_packet_find_header(pkt, G_OBEX_HDR_CONNECTION);
if (connid != NULL)
g_obex_header_get_uint32(connid, &obex->conn_id);
}
}
rsp = g_obex_packet_new(G_OBEX_RSP_NOT_IMPLEMENTED, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ G_OBEX_HDR_INVALID);
g_obex_send(obex, rsp, NULL);
}
GObexPacket *req;
struct connect_data data;
- req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID);
init_connect_data(obex, &data);
g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY);
if (target != NULL) {
GObexHeader *hdr;
- hdr = g_obex_header_new_bytes(G_OBEX_HDR_ID_TARGET,
+ hdr = g_obex_header_new_bytes(G_OBEX_HDR_TARGET,
target, target_len);
g_obex_packet_add_header(req, hdr);
}
GObexPacket *req;
struct setpath_data data;
- req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE, G_OBEX_HDR_INVALID);
memset(&data, 0, sizeof(data));
else {
GObexHeader *hdr;
data.flags = 0x02;
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, path);
+ hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, path);
g_obex_packet_add_header(req, hdr);
}
GObexHeader *hdr;
struct setpath_data data;
- req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_SETPATH, TRUE, G_OBEX_HDR_INVALID);
memset(&data, 0, sizeof(data));
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, path);
+ hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, path);
g_obex_packet_add_header(req, hdr);
g_obex_packet_set_data(req, &data, sizeof(data), G_OBEX_DATA_COPY);
GObexPacket *req;
GObexHeader *hdr;
- req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
- hdr = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, name);
+ hdr = g_obex_header_new_unicode(G_OBEX_HDR_NAME, name);
g_obex_packet_add_header(req, hdr);
return g_obex_send_req(obex, req, -1, func, user_data, err);
diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
index bfb6877..6d2e75b 100644
--- a/tools/obex-server-tool.c
+++ b/tools/obex-server-tool.c
const char *type, *name;
gsize type_len;
- hdr = g_obex_packet_find_header(req, G_OBEX_HDR_ID_TYPE);
+ hdr = g_obex_packet_find_header(req, G_OBEX_HDR_TYPE);
if (hdr != NULL) {
g_obex_header_get_bytes(hdr, (const guint8 **) &type,
&type_len);
} else
type = NULL;
- hdr = g_obex_packet_find_header(req, G_OBEX_HDR_ID_NAME);
+ hdr = g_obex_packet_find_header(req, G_OBEX_HDR_NAME);
if (hdr != NULL)
g_obex_header_get_unicode(hdr, &name);
else
g_print("connect\n");
- rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID);
g_obex_send(obex, rsp, NULL);
}
diff --git a/unit/test-gobex-header.c b/unit/test-gobex-header.c
index 27a2ab5..f67b3a8 100644
--- a/unit/test-gobex-header.c
+++ b/unit/test-gobex-header.c
#include "util.h"
-static uint8_t hdr_connid[] = { G_OBEX_HDR_ID_CONNECTION, 1, 2, 3, 4 };
-static uint8_t hdr_name_ascii[] = { G_OBEX_HDR_ID_NAME, 0x00, 0x0b,
+static uint8_t hdr_connid[] = { G_OBEX_HDR_CONNECTION, 1, 2, 3, 4 };
+static uint8_t hdr_name_ascii[] = { G_OBEX_HDR_NAME, 0x00, 0x0b,
0x00, 'f', 0x00, 'o', 0x00, 'o',
0x00, 0x00 };
-static uint8_t hdr_name_umlaut[] = { G_OBEX_HDR_ID_NAME, 0x00, 0x0b,
+static uint8_t hdr_name_umlaut[] = { G_OBEX_HDR_NAME, 0x00, 0x0b,
0x00, 0xe5, 0x00, 0xe4, 0x00, 0xf6,
0x00, 0x00 };
-static uint8_t hdr_body[] = { G_OBEX_HDR_ID_BODY, 0x00, 0x07, 1, 2, 3, 4 };
-static uint8_t hdr_actionid[] = { G_OBEX_HDR_ID_ACTION, 0xab };
+static uint8_t hdr_body[] = { G_OBEX_HDR_BODY, 0x00, 0x07, 1, 2, 3, 4 };
+static uint8_t hdr_actionid[] = { G_OBEX_HDR_ACTION, 0xab };
-static uint8_t hdr_uint32_nval[] = { G_OBEX_HDR_ID_CONNECTION, 1, 2 };
-static uint8_t hdr_unicode_nval_short[] = { G_OBEX_HDR_ID_NAME, 0x12, 0x34,
+static uint8_t hdr_uint32_nval[] = { G_OBEX_HDR_CONNECTION, 1, 2 };
+static uint8_t hdr_unicode_nval_short[] = { G_OBEX_HDR_NAME, 0x12, 0x34,
0x00, 'a', 0x00, 'b',
0x00, 0x00 };
-static uint8_t hdr_unicode_nval_data[] = { G_OBEX_HDR_ID_NAME, 0x00, 0x01,
+static uint8_t hdr_unicode_nval_data[] = { G_OBEX_HDR_NAME, 0x00, 0x01,
0x00, 'a', 0x00, 'b' };
-static uint8_t hdr_bytes_nval_short[] = { G_OBEX_HDR_ID_BODY, 0xab, 0xcd,
+static uint8_t hdr_bytes_nval_short[] = { G_OBEX_HDR_BODY, 0xab, 0xcd,
0x01, 0x02, 0x03 };
-static uint8_t hdr_bytes_nval_data[] = { G_OBEX_HDR_ID_BODY, 0xab };
+static uint8_t hdr_bytes_nval_data[] = { G_OBEX_HDR_BODY, 0xab };
static void test_header_name_ascii(void)
{
uint8_t buf[1024];
size_t len;
- header = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, "foo");
+ header = g_obex_header_new_unicode(G_OBEX_HDR_NAME, "foo");
g_assert(header != NULL);
uint8_t buf[1024];
size_t len;
- header = g_obex_header_new_unicode(G_OBEX_HDR_ID_NAME, "åäö");
+ header = g_obex_header_new_unicode(G_OBEX_HDR_NAME, "åäö");
g_assert(header != NULL);
uint8_t buf[1024], data[] = { 1, 2, 3, 4 };
size_t len;
- header = g_obex_header_new_bytes(G_OBEX_HDR_ID_BODY, data,
- sizeof(data));
+ header = g_obex_header_new_bytes(G_OBEX_HDR_BODY, data, sizeof(data));
g_assert(header != NULL);
len = g_obex_header_encode(header, buf, sizeof(buf));
uint8_t buf[1024];
size_t len;
- header = g_obex_header_new_uint8(G_OBEX_HDR_ID_ACTION, 0xab);
+ header = g_obex_header_new_uint8(G_OBEX_HDR_ACTION, 0xab);
g_assert(header != NULL);
uint8_t buf[1024];
size_t len;
- header = g_obex_header_new_uint32(G_OBEX_HDR_ID_CONNECTION,
- 0x01020304);
-
+ header = g_obex_header_new_uint32(G_OBEX_HDR_CONNECTION, 0x01020304);
len = g_obex_header_encode(header, buf, sizeof(buf));
assert_memequal(hdr_connid, sizeof(hdr_connid), buf, len);
diff --git a/unit/test-gobex-packet.c b/unit/test-gobex-packet.c
index d3e4825..20d4804 100644
--- a/unit/test-gobex-packet.c
+++ b/unit/test-gobex-packet.c
static uint8_t pkt_connect[] = { G_OBEX_OP_CONNECT, 0x00, 0x0c,
0x10, 0x00, 0x10, 0x00,
- G_OBEX_HDR_ID_TARGET,
+ G_OBEX_HDR_TARGET,
0x00, 0x05, 0xab, 0xcd };
static uint8_t pkt_put_action[] = { G_OBEX_OP_PUT, 0x00, 0x05,
- G_OBEX_HDR_ID_ACTION, 0xab };
+ G_OBEX_HDR_ACTION, 0xab };
static uint8_t pkt_put_body[] = { G_OBEX_OP_PUT, 0x00, 0x0a,
- G_OBEX_HDR_ID_BODY, 0x00, 0x07,
+ G_OBEX_HDR_BODY, 0x00, 0x07,
1, 2, 3, 4 };
static uint8_t pkt_put[] = { G_OBEX_OP_PUT, 0x00, 0x03 };
static uint8_t pkt_nval_len[] = { G_OBEX_OP_PUT, 0xab, 0xcd, 0x12 };
static guint8 pkt_put_long[] = { G_OBEX_OP_PUT, 0x00, 0x32,
- G_OBEX_HDR_ID_CONNECTION, 0x01, 0x02, 0x03, 0x04,
- G_OBEX_HDR_ID_TYPE, 0x00, 0x0b,
+ G_OBEX_HDR_CONNECTION, 0x01, 0x02, 0x03, 0x04,
+ G_OBEX_HDR_TYPE, 0x00, 0x0b,
'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
- G_OBEX_HDR_ID_NAME, 0x00, 0x15,
+ G_OBEX_HDR_NAME, 0x00, 0x15,
0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
- G_OBEX_HDR_ID_ACTION, 0xab,
- G_OBEX_HDR_ID_BODY, 0x00, 0x08,
+ G_OBEX_HDR_ACTION, 0xab,
+ G_OBEX_HDR_BODY, 0x00, 0x08,
0, 1, 2, 3, 4 };
static void test_pkt(void)
{
GObexPacket *pkt;
- pkt = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_ID_INVALID);
+ pkt = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
g_assert(pkt != NULL);
0, G_OBEX_DATA_REF, &err);
g_assert_no_error(err);
- header = g_obex_packet_get_header(pkt, G_OBEX_HDR_ID_ACTION);
+ header = g_obex_packet_get_header(pkt, G_OBEX_HDR_ACTION);
g_assert(header != NULL);
ret = g_obex_header_get_uint8(header, &val);
g_assert_no_error(err);
g_assert(pkt != NULL);
- header = g_obex_packet_get_header(pkt, G_OBEX_HDR_ID_TARGET);
+ header = g_obex_packet_get_header(pkt, G_OBEX_HDR_TARGET);
g_assert(header != NULL);
ret = g_obex_header_get_bytes(header, &buf, &len);
uint8_t buf[255];
gssize len;
- pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_ID_INVALID);
+ pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID);
g_obex_packet_add_body(pkt, get_body_data, NULL);
len = g_obex_packet_encode(pkt, buf, sizeof(buf));
uint8_t buf[255];
gssize len;
- pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_ID_INVALID);
+ pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID);
g_obex_packet_add_body(pkt, get_body_data_fail, NULL);
len = g_obex_packet_encode(pkt, buf, sizeof(buf));
gssize len;
pkt = g_obex_packet_new(G_OBEX_OP_PUT, FALSE,
- G_OBEX_HDR_ID_CONNECTION, 0x01020304,
- G_OBEX_HDR_ID_TYPE, "foo/bar", strlen("foo/bar") + 1,
- G_OBEX_HDR_ID_NAME, "file.txt",
- G_OBEX_HDR_ID_ACTION, 0xab,
- G_OBEX_HDR_ID_BODY, body, sizeof(body),
- G_OBEX_HDR_ID_INVALID);
+ G_OBEX_HDR_CONNECTION, 0x01020304,
+ G_OBEX_HDR_TYPE, "foo/bar", strlen("foo/bar") + 1,
+ G_OBEX_HDR_NAME, "file.txt",
+ G_OBEX_HDR_ACTION, 0xab,
+ G_OBEX_HDR_BODY, body, sizeof(body),
+ G_OBEX_HDR_INVALID);
g_assert(pkt != NULL);
diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index cf391f0..595a49c 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
#define FINAL_BIT 0x80
static guint8 put_req_first[] = { G_OBEX_OP_PUT | FINAL_BIT, 0x00, 0x30,
- G_OBEX_HDR_ID_TYPE, 0x00, 0x0b,
+ G_OBEX_HDR_TYPE, 0x00, 0x0b,
'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
- G_OBEX_HDR_ID_NAME, 0x00, 0x15,
+ G_OBEX_HDR_NAME, 0x00, 0x15,
0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
- G_OBEX_HDR_ID_BODY, 0x00, 0x0d,
+ G_OBEX_HDR_BODY, 0x00, 0x0d,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
static guint8 put_req_last[] = { G_OBEX_OP_PUT | FINAL_BIT, 0x00, 0x06,
- G_OBEX_HDR_ID_BODY_END, 0x00, 0x03 };
+ G_OBEX_HDR_BODY_END, 0x00, 0x03 };
static guint8 put_rsp_first[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT,
0x00, 0x03 };
static guint8 put_rsp_last[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x03 };
static guint8 get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x23,
- G_OBEX_HDR_ID_TYPE, 0x00, 0x0b,
+ G_OBEX_HDR_TYPE, 0x00, 0x0b,
'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
- G_OBEX_HDR_ID_NAME, 0x00, 0x15,
+ G_OBEX_HDR_NAME, 0x00, 0x15,
0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
static guint8 get_req_last[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x03, };
static guint8 get_rsp_first[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x10,
- G_OBEX_HDR_ID_BODY, 0x00, 0x0d,
+ G_OBEX_HDR_BODY, 0x00, 0x0d,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
static guint8 get_rsp_last[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x06,
- G_OBEX_HDR_ID_BODY_END, 0x00, 0x03 };
+ G_OBEX_HDR_BODY_END, 0x00, 0x03 };
static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
id = g_obex_get_rsp(obex, provide_data, transfer_complete, d, &d->err,
- G_OBEX_HDR_ID_INVALID);
+ G_OBEX_HDR_INVALID);
if (id == 0)
g_main_loop_quit(d->mainloop);
}
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index ce40bf6..eda6246 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
static uint8_t pkt_setpath_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT, 0x00, 0x10,
0x02, 0x00,
- G_OBEX_HDR_ID_NAME, 0x00, 0x0b,
+ G_OBEX_HDR_NAME, 0x00, 0x0b,
0, 'd', 0, 'i', 0, 'r', 0, 0 };
static uint8_t pkt_setpath_up_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT,
0x00, 0x05, 0x03, 0x00 };
static uint8_t pkt_mkdir_req[] = { G_OBEX_OP_SETPATH | FINAL_BIT, 0x00, 0x10,
0x00, 0x00,
- G_OBEX_HDR_ID_NAME, 0x00, 0x0b,
+ G_OBEX_HDR_NAME, 0x00, 0x0b,
0, 'd', 0, 'i', 0, 'r', 0, 0 };
static uint8_t pkt_delete_req[] = { G_OBEX_OP_PUT | FINAL_BIT, 0x00, 0x16,
- G_OBEX_HDR_ID_NAME, 0x00, 0x13,
+ G_OBEX_HDR_NAME, 0x00, 0x13,
0, 'f', 0, 'o', 0, 'o', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
static uint8_t pkt_nval_connect_rsp[] = { 0x10 | FINAL_BIT, 0x00, 0x05,
static uint8_t pkt_abort_rsp[] = { 0x90, 0x00, 0x03 };
static uint8_t pkt_nval_short_rsp[] = { 0x10 | FINAL_BIT, 0x12 };
static uint8_t pkt_put_body[] = { G_OBEX_OP_PUT, 0x00, 0x0a,
- G_OBEX_HDR_ID_BODY, 0x00, 0x07,
+ G_OBEX_HDR_BODY, 0x00, 0x07,
1, 2, 3, 4 };
static gboolean timeout(gpointer user_data)
GObexPacket *req;
guint8 connect_data[] = { 0x10, 0x00, 0x10, 0x00 };
- req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID);
g_assert(req != NULL);
g_obex_packet_set_data(req, connect_data, sizeof(connect_data),
r.err = NULL;
- req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
r.id = g_obex_send_req(r.obex, req, -1, req_done, &r, &r.err);
g_assert_no_error(r.err);
g_assert(r.id != 0);
r.err = NULL;
- req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
r.id = g_obex_send_req(r.obex, req, -1, req_done, &r, &r.err);
g_assert_no_error(r.err);
g_assert(r.id != 0);
r.buf = pkt_connect_req;
r.len = sizeof(pkt_connect_req);
- req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID);
g_assert(req != NULL);
g_obex_packet_set_data(req, connect_data, sizeof(connect_data),
g_obex_set_disconnect_function(obex, unexpected_disconn, &err);
- req = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE,
- G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID);
len = g_obex_packet_encode(req, buf, sizeof(buf));
g_assert_cmpint(len, >=, 0);
r.buf = pkt_put_body;
r.len = sizeof(pkt_put_body);
- req = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_ID_INVALID);
+ req = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID);
g_obex_packet_add_body(req, func, &r);
g_obex_send(obex, req, &r.err);