summaryrefslogtreecommitdiff
path: root/src/replace-table.h
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2012-04-15 21:37:44 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2012-04-15 21:37:44 +0200
commitc5f23c17a14bbe07042f46be90fe2b2e465436c7 (patch)
tree2b5190d0ff7dc10fae37d16d8fc8dcc587765366 /src/replace-table.h
parent4d45fb66b44ba67d698b2052184fa9cadb48ea5e (diff)
downloadcataract-c5f23c17a14bbe07042f46be90fe2b2e465436c7.tar.xz
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: <!-- $(function_name(arg1, "arg2", 'arg3')) --> 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.
Diffstat (limited to 'src/replace-table.h')
-rw-r--r--src/replace-table.h11
1 files changed, 11 insertions, 0 deletions
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 ();
@@ -48,6 +53,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
*
* - reallocates source buffer