summaryrefslogtreecommitdiff
path: root/src/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup.c')
-rw-r--r--src/setup.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/setup.c b/src/setup.c
index daa1ff0..a639348 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -40,56 +40,56 @@
/*
* find_setup_xml: try to find setup.xml in standard paths
*/
-gboolean
-find_setup_xml (TGallerySetup *setup)
+TGallerySetup *
+find_setup_xml ()
{
gchar *pth;
gchar *cwd;
- gboolean b;
+ TGallerySetup *setup;
- b = FALSE;
+ setup = NULL;
cwd = g_get_current_dir ();
pth = g_strconcat (cwd, "/", SETUP_XML, NULL);
g_free (cwd);
if (g_access (pth, R_OK) == 0)
- b = parse_setup_xml (pth, setup);
+ setup = parse_setup_xml (pth);
g_free (pth);
- if (b)
- return TRUE;
- pth = g_strconcat (g_getenv ("HOME"), "/.cgg/", SETUP_XML, NULL);
- if (g_access (pth, R_OK) == 0)
- b = parse_setup_xml (pth, setup);
- g_free (pth);
- if (b)
- return TRUE;
+ if (! setup) {
+ pth = g_strconcat (g_getenv ("HOME"), "/.cgg/", SETUP_XML, NULL);
+ if (g_access (pth, R_OK) == 0)
+ setup = parse_setup_xml (pth);
+ g_free (pth);
+ }
- pth = g_strconcat (DATADIR, "/cgg/", SETUP_XML, NULL);
- if (g_access (pth, R_OK) == 0)
- b = parse_setup_xml (pth, setup);
- g_free (pth);
- return b;
+ if (! setup) {
+ pth = g_strconcat (DATADIR, "/cgg/", SETUP_XML, NULL);
+ if (g_access (pth, R_OK) == 0)
+ setup = parse_setup_xml (pth);
+ g_free (pth);
+ }
+
+ return setup;
}
/*
* parse_setup_xml: XML parser for setup.xml file
*/
-gboolean
-parse_setup_xml (const gchar *filename, TGallerySetup *setup)
+TGallerySetup *
+parse_setup_xml (const gchar *filename)
{
TXMLFile *xml;
gchar *s;
+ TGallerySetup *setup;
xml = xml_parser_load (filename);
if (xml == NULL)
- return FALSE;
+ return NULL;
/* initialize data struct */
- if (setup == NULL)
- return FALSE;
- memset (setup, 0, sizeof (TGallerySetup));
+ setup = g_malloc0 (sizeof (TGallerySetup));
setup->setup_xml_path = g_strdup (filename);
setup->templates_path = xml_file_get_node_value (xml, "/gallery_setup/templates/path/text()");
@@ -166,12 +166,12 @@ parse_setup_xml (const gchar *filename, TGallerySetup *setup)
g_free (s);
xml_parser_close (xml);
- return TRUE;
+ return setup;
}
-int
+static int
test_tmpl_access (const gchar *dir, const gchar *path)
{
gchar *s;
@@ -183,7 +183,7 @@ test_tmpl_access (const gchar *dir, const gchar *path)
return b;
}
-int
+static int
test_tmpl_files (const gchar *dir, TGallerySetup *setup)
{
return test_tmpl_access (dir, setup->template_album) |
@@ -251,6 +251,5 @@ free_setup_data (TGallerySetup *setup)
g_free (setup->feed_title);
g_free (setup->feed_base_url);
g_free (setup);
- setup = NULL;
}
}