[PATCH obexd v2 1/4] MAP: Implementation of MAP AP core functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds implementation for creation and destruction of map_ap_t and
the definitions of MAP supported application parameters.
---
 src/map_ap.c |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 106 insertions(+), 1 deletions(-)

diff --git a/src/map_ap.c b/src/map_ap.c
index 9d13adf..8040b6d 100644
--- a/src/map_ap.c
+++ b/src/map_ap.c
@@ -27,13 +27,118 @@
 
 #include "map_ap.h"
 
+enum ap_type {
+	APT_UINT8,
+	APT_UINT16,
+	APT_UINT32,
+	APT_STR
+};
+
+static const struct ap_def {
+	enum map_ap_tag tag;
+	const char *name;
+	enum ap_type type;
+} ap_defs[] = {
+	{ MAP_AP_MAXLISTCOUNT,		"MAXLISTCOUNT",
+		APT_UINT16					},
+	{ MAP_AP_STARTOFFSET,		"STARTOFFSET",
+		APT_UINT16					},
+	{ MAP_AP_FILTERMESSAGETYPE,	"FILTERMESSAGETYPE",
+		APT_UINT8					},
+	{ MAP_AP_FILTERPERIODBEGIN,	"FILTERPERIODBEGIN",
+		APT_STR						},
+	{ MAP_AP_FILTERPERIODEND,	"FILTERPERIODEND",
+		APT_STR						},
+	{ MAP_AP_FILTERREADSTATUS,	"FILTERREADSTATUS",
+		APT_UINT8					},
+	{ MAP_AP_FILTERRECIPIENT,	"FILTERRECIPIENT",
+		APT_STR						},
+	{ MAP_AP_FILTERORIGINATOR,	"FILTERORIGINATOR",
+		APT_STR						},
+	{ MAP_AP_FILTERPRIORITY,	"FILTERPRIORITY",
+		APT_UINT8					},
+	{ MAP_AP_ATTACHMENT,		"ATTACHMENT",
+		APT_UINT8					},
+	{ MAP_AP_TRANSPARENT,		"TRANSPARENT",
+		APT_UINT8					},
+	{ MAP_AP_RETRY,			"RETRY",
+		APT_UINT8					},
+	{ MAP_AP_NEWMESSAGE,		"NEWMESSAGE",
+		APT_UINT8					},
+	{ MAP_AP_NOTIFICATIONSTATUS,	"NOTIFICATIONSTATUS",
+		APT_UINT8					},
+	{ MAP_AP_MASINSTANCEID,		"MASINSTANCEID",
+		APT_UINT8					},
+	{ MAP_AP_PARAMETERMASK,		"PARAMETERMASK",
+		APT_UINT32					},
+	{ MAP_AP_FOLDERLISTINGSIZE,	"FOLDERLISTINGSIZE",
+		APT_UINT16					},
+	{ MAP_AP_MESSAGESLISTINGSIZE,	"MESSAGESLISTINGSIZE",
+		APT_UINT16					},
+	{ MAP_AP_SUBJECTLENGTH,		"SUBJECTLENGTH",
+		APT_UINT8					},
+	{ MAP_AP_CHARSET,		"CHARSET",
+		APT_UINT8					},
+	{ MAP_AP_FRACTIONREQUEST,	"FRACTIONREQUEST",
+		APT_UINT8					},
+	{ MAP_AP_FRACTIONDELIVER,	"FRACTIONDELIVER",
+		APT_UINT8					},
+	{ MAP_AP_STATUSINDICATOR,	"STATUSINDICATOR",
+		APT_UINT8					},
+	{ MAP_AP_STATUSVALUE,		"STATUSVALUE",
+		APT_UINT8					},
+	{ MAP_AP_MSETIME,		"MSETIME",
+		APT_STR						},
+	{ MAP_AP_INVALID,		NULL,
+		0						},
+};
+
+struct ap_entry {
+	enum map_ap_tag tag;
+	union {
+		uint32_t val32u;
+		uint16_t val16u;
+		uint8_t val8u;
+		char *valstr;
+	};
+};
+
+static int find_ap_def(uint8_t tag)
+{
+	int i;
+
+	for (i = 0; ap_defs[i].tag != MAP_AP_INVALID; ++i)
+		if (ap_defs[i].tag == tag)
+			return i;
+
+	return -1;
+}
+
+static void ap_entry_free(gpointer val)
+{
+	struct ap_entry *entry = val;
+	int tago;
+
+	tago = find_ap_def(entry->tag);
+
+	if (tago >= 0 && ap_defs[tago].type == APT_STR)
+		g_free(entry->valstr);
+
+	g_free(entry);
+}
+
 map_ap_t *map_ap_new(void)
 {
-	return NULL;
+	return g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
+								ap_entry_free);
 }
 
 void map_ap_free(map_ap_t *ap)
 {
+	if (!ap)
+		return;
+
+	g_hash_table_destroy(ap);
 }
 
 map_ap_t *map_ap_decode(const uint8_t *buffer, size_t length)
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux