From: Slawomir Bochenski <lkslawek@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Slawomir Bochenski <lkslawek@gmail.com>
Subject: [PATCH obexd 1/4] MAP: Implementation of MAP AP core functions
Date: Fri, 13 Jan 2012 11:48:29 +0100 [thread overview]
Message-ID: <1326451712-21784-1-git-send-email-lkslawek@gmail.com> (raw)
This adds implementation for creation and destruction of map_ap_t and
the definitions of MAP supported application parameters.
---
src/map_ap.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 105 insertions(+), 1 deletions(-)
diff --git a/src/map_ap.c b/src/map_ap.c
index 9d13adf..bec2cc5 100644
--- a/src/map_ap.c
+++ b/src/map_ap.c
@@ -27,13 +27,117 @@
#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(NULL, NULL, 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
next reply other threads:[~2012-01-13 10:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-13 10:48 Slawomir Bochenski [this message]
2012-01-13 10:48 ` [PATCH obexd 2/4] map_ap.c: Add implementation for map_ap_set_* Slawomir Bochenski
2012-01-13 10:48 ` [PATCH obexd 3/4] map_ap.c: Add implementation for map_ap_decode() Slawomir Bochenski
2012-01-13 12:09 ` Luiz Augusto von Dentz
2012-01-13 12:40 ` Slawomir Bochenski
2012-01-13 10:48 ` [PATCH obexd 4/4] map_ap.c: Add dumping of map_ap_t after decoding Slawomir Bochenski
2012-01-13 12:13 ` Luiz Augusto von Dentz
2012-01-13 12:24 ` Slawomir Bochenski
2012-01-13 12:02 ` [PATCH obexd 1/4] MAP: Implementation of MAP AP core functions Luiz Augusto von Dentz
2012-01-13 12:37 ` Slawomir Bochenski
2012-01-13 12:55 ` Slawomir Bochenski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326451712-21784-1-git-send-email-lkslawek@gmail.com \
--to=lkslawek@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).