summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAki Niemi <aki.niemi@nokia.com>2010-11-14 18:20:08 +0200
committerAki Niemi <aki.niemi@nokia.com>2010-12-22 17:13:46 +0200
commit4f14a6c1799930492b33bfe5581c53fb95fc3406 (patch)
tree8cd53383f32714841c79ecd79ef5e74e6ddd112f
parent785771f0beb2baeb4962c60df027d63c269f4a95 (diff)
downloadofono-4f14a6c1799930492b33bfe5581c53fb95fc3406.tar.bz2
gisi: Make subblock iterator use new message API
-rw-r--r--gisi/iter.c16
-rw-r--r--gisi/iter.h16
2 files changed, 19 insertions, 13 deletions
diff --git a/gisi/iter.c b/gisi/iter.c
index 3eef8dde..a0a9b3a1 100644
--- a/gisi/iter.c
+++ b/gisi/iter.c
@@ -45,10 +45,13 @@ static inline void bcd_to_mccmnc(const uint8_t *restrict bcd,
mnc[3] = '\0';
}
-void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const void *restrict data,
- size_t len, size_t used, gboolean longhdr,
+void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const GIsiMessage *msg,
+ size_t used, gboolean longhdr,
uint16_t sub_blocks)
{
+ const uint8_t *data = g_isi_msg_data(msg);
+ size_t len = g_isi_msg_data_len(msg);
+
if (!data)
len = used = 0;
@@ -58,9 +61,12 @@ void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const void *restrict data,
iter->sub_blocks = len > used ? sub_blocks : 0;
}
-void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const void *restrict data,
- size_t len, size_t used)
+void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const GIsiMessage *msg,
+ size_t used)
{
+ const uint8_t *data = g_isi_msg_data(msg);
+ size_t len = g_isi_msg_data_len(msg);
+
if (!data)
len = used = 0;
@@ -107,6 +113,7 @@ gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|| iter->start + pos > iter->end)
return FALSE;
+
*data = (void *)iter->start + pos;
return TRUE;
}
@@ -117,6 +124,7 @@ gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
if ((size_t)pos > g_isi_sb_iter_get_len(iter)
|| iter->start + pos > iter->end)
return FALSE;
+
*byte = iter->start[pos];
return TRUE;
}
diff --git a/gisi/iter.h b/gisi/iter.h
index 6be31d5c..74ec5932 100644
--- a/gisi/iter.h
+++ b/gisi/iter.h
@@ -28,22 +28,20 @@ extern "C" {
#include <stdint.h>
+#include "message.h"
+
struct _GIsiSubBlockIter {
uint8_t *start;
uint8_t *end;
- uint16_t longhdr;
+ gboolean longhdr;
uint16_t sub_blocks;
};
-
typedef struct _GIsiSubBlockIter GIsiSubBlockIter;
-void g_isi_sb_iter_init(GIsiSubBlockIter *iter,
- const void *restrict data,
- size_t len, size_t used);
-void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter,
- const void *restrict data,
- size_t len, size_t used,
- gboolean longhdr,
+void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const GIsiMessage *msg,
+ size_t used);
+void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const GIsiMessage *msg,
+ size_t used, gboolean longhdr,
uint16_t sub_blocks);
gboolean g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);