From c5f23c17a14bbe07042f46be90fe2b2e465436c7 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 15 Apr 2012 21:37:44 +0200 Subject: replace-table: Add support for custom functions This adds a support for custom (registered) functions that can be called from templates with specified arguments. The syntax is as follows: Arguments are separated by a comma and can be quoted (recommended). Quoted arguments are allowed to contain a comma as well as another quote when escaped with a backslash. To call a function with no arguments just do "function_name()". Functions are supposed to be registered before actual data are parsed and are called back from within the parser cycle. --- src/replace-table.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/replace-table.h') diff --git a/src/replace-table.h b/src/replace-table.h index 7d6b70e..0d81c92 100644 --- a/src/replace-table.h +++ b/src/replace-table.h @@ -25,6 +25,11 @@ G_BEGIN_DECLS typedef struct ReplaceTable ReplaceTable; +/* + * registered function callback, arguments passed as strings + */ +typedef char * (*ReplaceTableFunction) (gchar **args, gpointer user_data); + ReplaceTable * replace_table_new (); @@ -47,6 +52,12 @@ void replace_table_add_key_printf (ReplaceTable *table, const gchar *tag, const */ void replace_table_set_defines (ReplaceTable *table, GHashTable *defines); +/* + * replace_table_register_function: register a method callback for specified function name + * + */ +void replace_table_register_function (ReplaceTable *table, const gchar *function_name, ReplaceTableFunction callback, gpointer user_data); + /* * replace_table_process: process buffer and replace all tags filled in the replace table * -- cgit v1.2.3