summaryrefslogtreecommitdiff
path: root/generators-replace-table.c
diff options
context:
space:
mode:
Diffstat (limited to 'generators-replace-table.c')
-rw-r--r--generators-replace-table.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/generators-replace-table.c b/generators-replace-table.c
index 562f9af..6a84c17 100644
--- a/generators-replace-table.c
+++ b/generators-replace-table.c
@@ -1,5 +1,5 @@
/* Cataract - Static web photo gallery generator
- * Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net>
+ * Copyright (C) 2009 Tomas Bzatek <tbzatek@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <glib.h>
+#include <glib/gprintf.h>
#include "generators-replace-table.h"
#include "gallery-utils.h"
@@ -30,7 +31,7 @@
-
+#if 0
static void
replace_table_destroy_notify (gpointer data)
{
@@ -39,11 +40,12 @@ replace_table_destroy_notify (gpointer data)
if ((gchar *) data)
g_free ((gchar *) data);
}
+#endif
ReplaceTable *
replace_table_new ()
{
- return (ReplaceTable *) g_hash_table_new_full (g_str_hash, g_str_equal, replace_table_destroy_notify, replace_table_destroy_notify);
+ return (ReplaceTable *) g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
}
void
@@ -51,7 +53,7 @@ replace_table_free (ReplaceTable *table)
{
g_return_if_fail (table != NULL);
- g_hash_table_destroy (table);
+ g_hash_table_destroy (table);
}
@@ -79,6 +81,22 @@ replace_table_add_key_int (ReplaceTable *table, const gchar *tag, gint value)
g_hash_table_replace (table, g_strdup (tag), g_strdup_printf ("%d", value));
}
+void
+replace_table_add_key_printf (ReplaceTable *table, const gchar *tag, const gchar *format, ...)
+{
+ va_list args;
+ gchar *s = NULL;
+
+ g_return_if_fail (table != NULL);
+
+ if (tag != NULL && format != NULL) {
+ va_start (args, format);
+ g_vasprintf (&s, format, args);
+ g_hash_table_replace (table, g_strdup (tag), s);
+ va_end (args);
+ }
+}
+
static void
@@ -112,6 +130,7 @@ replace_table_process_value (gpointer key, gpointer value, gpointer user_data)
/* TODO: do something with tag_value? */
/* fix_entities (&s1); */
/* s1 = g_markup_escape_text (s4, -1); */
+/* line endings */
/* remove all tags as we're tag value */
while (strstr (*buffer, tag)) {
str_replace (buffer, tag, tag_value, NULL);