From c5e75352f27a02501b3a1a9189f10a581c12e7fb Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 24 Dec 2012 20:10:27 +0100 Subject: block-parser: Add support for custom block functions Similar to replace-table custom functions, this brings an ability to register custom block functions that can be called from templates with variable arguments. The syntax is as follows: ... An optional exclamation mark before the function name reverts the result (negates) the predicate. This allows template flexibility with respect to the currently processed image. --- src/block-parser.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/block-parser.h') diff --git a/src/block-parser.h b/src/block-parser.h index 96c7fb8..edf6dd2 100644 --- a/src/block-parser.h +++ b/src/block-parser.h @@ -26,6 +26,11 @@ G_BEGIN_DECLS typedef struct BlockParser BlockParser; +/* + * conditional function callback, arguments passed as strings. Returning TRUE means not to ignore the block. + */ +typedef gboolean (*BlockParserConditionalFunction) (gchar **args, gpointer user_data); + BlockParser * block_parser_new (); @@ -46,6 +51,12 @@ void block_parser_set_conditionals (BlockParser *parser, GHashTable *conditional */ void block_parser_register_key (BlockParser *parser, const gchar *key, const gchar *replace_key); +/* + * block_parser_register_function: function called to determine whether a block should be ignored or not + * + */ +void block_parser_register_function (BlockParser *parser, const gchar *conditional_name, BlockParserConditionalFunction callback, gpointer user_data); + /* * block_parser_get_data: return retrieved data or NULL if none read yet * returns newly allocated string, caller is responsible for freeing -- cgit v1.2.3