summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2011-03-31 23:23:24 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2011-03-31 23:23:24 +0200
commiteb3092f8bd30d065c4e6f4bf0159309e1a960156 (patch)
treeb17974a38900afde77e67c91c96523e2b2ef0d7e
parent6707d9314ceedb12bfd995b924af4de6b9110800 (diff)
downloadcataract-eb3092f8bd30d065c4e6f4bf0159309e1a960156.tar.xz
block-parser: Add function to mark block as used
Some blocks such as "IMG_LIST" are containers themselves and no data are retrieved from them. That way they don't ever get marked as used, resulting in constant hit in the generator loop.
-rw-r--r--src/block-parser.c17
-rw-r--r--src/block-parser.h7
2 files changed, 24 insertions, 0 deletions
diff --git a/src/block-parser.c b/src/block-parser.c
index d4a04c1..d4fcccb 100644
--- a/src/block-parser.c
+++ b/src/block-parser.c
@@ -147,6 +147,23 @@ block_parser_has_unused_data (BlockParser *parser, const gchar *key)
return FALSE;
}
+/*
+ * block_parser_set_as_used: manually set data as used - sometimes blocks can act as containers for other nested blocks and
+ * cannot be used itself
+ *
+ */
+void
+block_parser_set_as_used (BlockParser *parser, const gchar *key)
+{
+ BlockData *data = NULL;
+
+ g_assert (parser != NULL);
+
+ data = g_hash_table_lookup (parser->table, key);
+ if (data != NULL && data->finished == TRUE) {
+ data->used = TRUE;
+ }
+}
diff --git a/src/block-parser.h b/src/block-parser.h
index 666d27a..21d0cfb 100644
--- a/src/block-parser.h
+++ b/src/block-parser.h
@@ -56,6 +56,13 @@ gchar * block_parser_get_data (BlockParser *parser, const gchar *key);
gboolean block_parser_has_unused_data (BlockParser *parser, const gchar *key);
/*
+ * block_parser_set_as_used: manually set data as used - sometimes blocks can act as containers for other nested blocks and
+ * cannot be used itself
+ *
+ */
+void block_parser_set_as_used (BlockParser *parser, const gchar *key);
+
+/*
* block_parser_read_and_parse: reads input from the file and returns parsed line
* - if there's a multiline block, string before the opening placeholder and
* string after closing placeholder are returned on one line,