summaryrefslogtreecommitdiff
path: root/gisi/iter.h
diff options
context:
space:
mode:
authorPekka Pessi <Pekka.Pessi@nokia.com>2009-10-08 19:47:15 +0300
committerAki Niemi <aki.niemi@nokia.com>2009-10-09 12:54:04 +0300
commitd1d870ba7a037773ae731a21b9707df8dcb47992 (patch)
tree793bcae692a3e9aab6f1839b0a762a702cd04cf8 /gisi/iter.h
parent8778826638d3f563b7a26746f05e2d0c47a9e238 (diff)
Refactor subblock iterators.
Always initialize iterators. Try to avoid pointer arithmetics on NULL; in other words, move all pointer arithmetics inside g_isi_sb_iter_init(). There are 4 different ways for representing sub blocks in ISI message: - 8-bit sub_blocks count, 8-bit sub_block_id/sub_block_len - 16-bit sub_blocks count, 8-bit sub_block_id/sub_block_len - 8-bit sub_blocks count, 16-bit sub_block_id/sub_block_len - 16-bit sub_blocks count, 16-bit sub_block_id/sub_block_len The compact form g_isi_sb_iter_init() supports 8-bit sub_block count before start of the sub blocks themselves and 8-bit sub_block_id and sub_block_len. The full form g_isi_sb_iter_init_full() with explicit longhdr and sub_block count supports all other cases.
Diffstat (limited to 'gisi/iter.h')
-rw-r--r--gisi/iter.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/gisi/iter.h b/gisi/iter.h
index 7596af04..081d85c4 100644
--- a/gisi/iter.h
+++ b/gisi/iter.h
@@ -34,13 +34,22 @@ extern "C" {
struct _GIsiSubBlockIter {
uint8_t *start;
uint8_t *end;
- bool longhdr;
+ uint16_t longhdr;
+ uint16_t sub_blocks;
};
+
typedef struct _GIsiSubBlockIter GIsiSubBlockIter;
-bool g_isi_sb_iter_init(const void *restrict data, size_t len,
- GIsiSubBlockIter *iter, bool longhdr);
-bool g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);
+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,
+ bool longhdr,
+ uint16_t sub_blocks);
+bool g_isi_sb_iter_is_valid(GIsiSubBlockIter const *iter);
+
bool g_isi_sb_iter_next(GIsiSubBlockIter *iter);
int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter);