summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-08-10 14:30:23 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-08-10 14:30:23 +0200
commit3462576fd6bc883c41042fb7ae93ebabb12718d8 (patch)
tree3a6e85717d93b375c5b46674894f4b44d2c961b3 /setup.c
parentee8d3aa3f337cef3faae8d45c6e23ab05f380db8 (diff)
downloadcataract-3462576fd6bc883c41042fb7ae93ebabb12718d8.tar.xz
Support for different preview image borders
Strip trailing whitespaces
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c112
1 files changed, 58 insertions, 54 deletions
diff --git a/setup.c b/setup.c
index 5f31a41..b3db734 100644
--- a/setup.c
+++ b/setup.c
@@ -1,16 +1,16 @@
/* Cataract - Static web photo gallery generator
* Copyright (C) 2008 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
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -36,9 +36,9 @@
/*
- * find_setup_xml: try to find setup.xml in standard paths
- */
-gboolean
+ * find_setup_xml: try to find setup.xml in standard paths
+ */
+gboolean
find_setup_xml (TGallerySetup *setup)
{
#define BUFFER_SIZE 65536
@@ -46,21 +46,21 @@ find_setup_xml (TGallerySetup *setup)
char *pth;
char *cwd;
gboolean b;
-
+
cwd = malloc (BUFFER_SIZE);
- cwd = getcwd (cwd, BUFFER_SIZE);
+ cwd = getcwd (cwd, BUFFER_SIZE);
pth = g_strconcat (cwd, "/", SETUP_XML, NULL);
free (cwd);
-
+
b = parse_setup_xml (pth, setup);
g_free (pth);
if (b) return TRUE;
-
+
pth = g_strconcat (getenv ("HOME"), "/.cgg/", SETUP_XML, NULL);
b = parse_setup_xml (pth, setup);
g_free (pth);
if (b) return TRUE;
-
+
pth = g_strconcat("/usr/share/cgg/", SETUP_XML, NULL);
b = parse_setup_xml (pth, setup);
g_free (pth);
@@ -74,17 +74,17 @@ find_setup_xml (TGallerySetup *setup)
/*
- * parse_setup_xml: XML parser for setup.xml file
- */
+ * parse_setup_xml: XML parser for setup.xml file
+ */
gboolean
parse_setup_xml (const char *filename, TGallerySetup *setup)
{
TXMLFile *xml;
-
+
xml = xml_parser_load (filename);
if (xml == NULL)
return FALSE;
-
+
/* initialize data struct */
if (setup == NULL)
return FALSE;
@@ -108,35 +108,37 @@ parse_setup_xml (const char *filename, TGallerySetup *setup)
setup->preview_portrait_height = xml_file_get_node_attribute_long (xml, "/gallery_setup/images/preview", "portrait_h", 0);
setup->preview_quality = xml_file_get_node_attribute_long (xml, "/gallery_setup/images/preview", "quality", -1);
setup->footer = xml_file_get_node_value (xml, "/gallery_setup/footer/text()");
-
+ setup->border_style = xml_file_get_node_attribute (xml, "/gallery_setup/images/border", "style");
+
xml_parser_close (xml);
-
+
#ifdef __DEBUG_ALL__
- printf("setup: templates_path = '%s'\n", setup->templates_path);
- printf("setup: template_index = '%s'\n", setup->template_index);
- printf("setup: template_album = '%s'\n", setup->template_album);
- printf("setup: template_photo = '%s'\n", setup->template_photo);
- printf("setup: styles = '%s'\n", setup->styles);
- printf("setup: scripts = '%s'\n", setup->scripts);
- printf("setup: thumbnail_quality = %d\n", setup->thumbnail_quality);
- printf("setup: thumbnail_landscape_width = %ld\n", setup->thumbnail_landscape_width);
- printf("setup: thumbnail_landscape_height = %ld\n", setup->thumbnail_landscape_height);
- printf("setup: thumbnail_portrait_width = %ld\n", setup->thumbnail_portrait_width);
- printf("setup: thumbnail_portrait_height = %ld\n", setup->thumbnail_portrait_height);
- printf("setup: preview_quality = %d\n", setup->preview_quality);
- printf("setup: preview_landscape_width = %ld\n", setup->preview_landscape_width);
- printf("setup: preview_landscape_height = %ld\n", setup->preview_landscape_height);
- printf("setup: preview_portrait_width = %ld\n", setup->preview_portrait_width);
- printf("setup: preview_portrait_height = %ld\n", setup->preview_portrait_height);
- printf("setup: footer = '%s'\n", setup->footer);
+ printf("setup: templates_path = '%s'\n", setup->templates_path);
+ printf("setup: template_index = '%s'\n", setup->template_index);
+ printf("setup: template_album = '%s'\n", setup->template_album);
+ printf("setup: template_photo = '%s'\n", setup->template_photo);
+ printf("setup: styles = '%s'\n", setup->styles);
+ printf("setup: scripts = '%s'\n", setup->scripts);
+ printf("setup: thumbnail_quality = %d\n", setup->thumbnail_quality);
+ printf("setup: thumbnail_landscape_width = %ld\n", setup->thumbnail_landscape_width);
+ printf("setup: thumbnail_landscape_height = %ld\n", setup->thumbnail_landscape_height);
+ printf("setup: thumbnail_portrait_width = %ld\n", setup->thumbnail_portrait_width);
+ printf("setup: thumbnail_portrait_height = %ld\n", setup->thumbnail_portrait_height);
+ printf("setup: preview_quality = %d\n", setup->preview_quality);
+ printf("setup: preview_landscape_width = %ld\n", setup->preview_landscape_width);
+ printf("setup: preview_landscape_height = %ld\n", setup->preview_landscape_height);
+ printf("setup: preview_portrait_width = %ld\n", setup->preview_portrait_width);
+ printf("setup: preview_portrait_height = %ld\n", setup->preview_portrait_height);
+ printf("setup: footer = '%s'\n", setup->footer);
+ printf("setup: border_style = '%s'\n", setup->border_style);
#endif
- return TRUE;
+ return TRUE;
}
-int
+int
test_tmpl_access (const char *dir, const char *path)
{
char *s;
@@ -148,46 +150,46 @@ test_tmpl_access (const char *dir, const char *path)
return b;
}
-int
+int
test_tmpl_files (const char *dir, TGallerySetup *setup)
{
return test_tmpl_access (dir, setup->template_album) | test_tmpl_access (dir, setup->template_photo) |
- test_tmpl_access (dir, setup->template_index) | test_tmpl_access (dir, setup->styles) |
+ test_tmpl_access (dir, setup->template_index) | test_tmpl_access (dir, setup->styles) |
test_tmpl_access (dir, setup->scripts);
}
/*
- * find_templates_directory: absolute/relative path checks, trying to find templates directory
- * - returned string should be freed
- */
+ * find_templates_directory: absolute/relative path checks, trying to find templates directory
+ * - returned string should be freed
+ */
char *
find_templates_directory (TGallerySetup *setup)
{
char *base_dir;
- char *pth;
-
- if (IS_DIR_SEP (*setup->templates_path))
+ char *pth;
+
+ if (IS_DIR_SEP (*setup->templates_path))
{
#ifdef __DEBUG_ALL__
printf("Warning: using absolute paths to templates\n");
#endif
-
+
if (! test_tmpl_files (setup->templates_path, setup))
return strdup (setup->templates_path);
- }
- else
+ }
+ else
{
base_dir = g_path_get_dirname (setup->setup_xml_path);
pth = g_strconcat (base_dir, "/", setup->templates_path, NULL);
g_free (base_dir);
-
+
#ifdef __DEBUG_ALL__
printf("Warning: using relative paths to templates\n");
#endif
-
- if (! test_tmpl_files (pth, setup))
+
+ if (! test_tmpl_files (pth, setup))
return pth;
- }
+ }
fprintf (stderr, "Couldn't find proper templates directory (tried '%s')\n", setup->templates_path);
return NULL;
@@ -197,11 +199,11 @@ find_templates_directory (TGallerySetup *setup)
/*
* free_setup_data: free allocated setup data
*/
-void
+void
free_setup_data (TGallerySetup *setup)
{
if (setup) {
- if (setup->real_templates_dir)
+ if (setup->real_templates_dir)
free (setup->real_templates_dir);
if (setup->setup_xml_path)
free (setup->setup_xml_path);
@@ -219,7 +221,9 @@ free_setup_data (TGallerySetup *setup)
free (setup->scripts);
if (setup->footer)
free (setup->footer);
+ if (setup->border_style)
+ free (setup->border_style);
free (setup);
- setup = NULL;
+ setup = NULL;
}
}