summaryrefslogtreecommitdiff
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
parentee8d3aa3f337cef3faae8d45c6e23ab05f380db8 (diff)
downloadcataract-3462576fd6bc883c41042fb7ae93ebabb12718d8.tar.xz
Support for different preview image borders
Strip trailing whitespaces
-rw-r--r--cgg.c54
-rw-r--r--config.h6
-rw-r--r--gallery-utils.c94
-rw-r--r--gallery-utils.h24
-rw-r--r--generators.c378
-rw-r--r--generators.h40
-rw-r--r--items.c77
-rw-r--r--items.h22
-rw-r--r--jpeg-utils.cpp198
-rw-r--r--jpeg-utils.h44
l---------sample/src/CIAF_1/img_6802e.jpg1
l---------sample/src/CIAF_1/img_6802f.jpg1
-rw-r--r--sample/src/CIAF_1/index.xml14
l---------sample/src/CIAF_1/preview/img_6802d.jpg1
l---------sample/src/CIAF_1/preview/img_6802e.jpg1
l---------sample/src/CIAF_1/preview/img_6802f.jpg1
-rw-r--r--sample/src/setup.xml4
-rw-r--r--setup.c112
-rw-r--r--setup.h28
-rw-r--r--templates/styles.css50
-rw-r--r--templates/template-view_photo.tmpl2
-rw-r--r--xml-parser.c76
-rw-r--r--xml-parser.h20
23 files changed, 659 insertions, 589 deletions
diff --git a/cgg.c b/cgg.c
index 690c919..086f003 100644
--- a/cgg.c
+++ b/cgg.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.
@@ -38,16 +38,16 @@
/*
- * parse_cmd: parse commandline and fill global variable parameters
- */
-gboolean
+ * parse_cmd: parse commandline and fill global variable parameters
+ */
+gboolean
parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *verbose)
{
static gboolean _verbose = FALSE;
static gchar *_source_dir = NULL;
static gchar *_dst_dir = NULL;
- static GOptionEntry entries[] =
+ static GOptionEntry entries[] =
{
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &_verbose, "Be verbose", NULL },
{ "source", 's', 0, G_OPTION_ARG_STRING, &_source_dir, "Specifies path to source structure", NULL },
@@ -58,11 +58,11 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *
GError *error = NULL;
GOptionContext *context;
char *s1;
-
+
g_set_prgname ("cgg");
-
+
context = g_option_context_new ("- web gallery generator");
- s1 = g_strdup_printf ("cgg v%s [%s] Copyright (c) 2008 Tomas Bzatek", APP_VERSION, APP_BUILD_DATE);
+ s1 = g_strdup_printf ("cgg v%s [%s] Copyright (c) 2008 Tomas Bzatek", APP_VERSION, APP_BUILD_DATE);
g_option_context_set_summary (context, s1);
g_free (s1);
g_option_context_add_main_entries (context, entries, NULL);
@@ -84,7 +84,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *
return FALSE;
}
g_option_context_free (context);
-
+
*source_dir = _source_dir;
*dst_dir = _dst_dir;
*verbose = _verbose;
@@ -94,63 +94,63 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *
-int
+int
main(int argc, char* argv[])
{
char *source_dir;
char *dst_dir;
gboolean verbose;
TGallerySetup *setup;
-
+
/*
* this initialize the library and check potential ABI mismatches
* between the version it was compiled for and the actual shared
* library used.
*/
- LIBXML_TEST_VERSION;
+ LIBXML_TEST_VERSION;
source_dir = NULL;
dst_dir = NULL;
setup = malloc(sizeof(TGallerySetup));
-
+
/* Parse commandline */
if (! parse_cmd (argc, argv, &source_dir, &dst_dir, &verbose))
return -1;
-
+
if ((! source_dir) || (access (source_dir, R_OK))) {
fprintf (stderr, "error: source directory must be specified and pointing to valid structure\n");
return -4;
- }
+ }
if (! dst_dir) {
fprintf (stderr, "error: target directory must be specified\n");
return -5;
}
-
+
/* Read gallery settings */
if (! find_setup_xml (setup)) {
fprintf (stderr, "error: could not parse gallery settings file\n");
- return -2;
- }
+ return -2;
+ }
setup->real_templates_dir = find_templates_directory (setup);
if (setup->real_templates_dir == NULL) {
fprintf (stderr, "error: could not determine templates directory\n");
- return -3;
- }
-
-
+ return -3;
+ }
+
+
/* Start building the gallery tree */
setup->verbose = verbose;
build_tree (setup, source_dir, dst_dir, NULL);
-
+
/* Cleanup function for the XML library. */
xmlCleanupParser();
-
+
free (source_dir);
free (dst_dir);
free_setup_data (setup);
-
+
return (0);
}
diff --git a/config.h b/config.h
index 21ac1cd..3ce3d89 100644
--- a/config.h
+++ b/config.h
@@ -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.
diff --git a/gallery-utils.c b/gallery-utils.c
index ce80a4f..9253f51 100644
--- a/gallery-utils.c
+++ b/gallery-utils.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.
@@ -31,7 +31,7 @@ strstr_exclude (const char *haystack, const char *needle, const char *exclude_wh
char *found;
src = haystack;
-
+
while (src && strstr (src, needle)) {
found = strstr (src, needle);
@@ -49,42 +49,42 @@ strstr_exclude (const char *haystack, const char *needle, const char *exclude_wh
/*
* str_replace: replace substring 'search' with a 'replace' string
- * - multiple occurences of the string are replaced
+ * - multiple occurrences of the string are replaced
* - specify 'exclude_when' if you want to skip replace when a string found at the place of 'search'
- * - reallocates the original string
- */
-void
+ * - reallocates the original string
+ */
+void
str_replace (char **dst, const char *search, const char *replace, const char *exclude_when)
{
- #define REPLACE_MAX_LENGTH 32768
+ #define REPLACE_MAX_LENGTH 32768
static char d[REPLACE_MAX_LENGTH];
char *src;
char *found;
int i;
-
+
/* TODO: add range checking */
-
- if (strstr (*dst, search) == NULL || strlen (*dst) == 0 ||
+
+ if (strstr (*dst, search) == NULL || strlen (*dst) == 0 ||
strlen (search) == 0 || strlen (replace) == 0)
return;
-
+
i = 0;
src = *dst;
while (strstr_exclude (src, search, exclude_when)) {
found = strstr_exclude (src, search, exclude_when);
-
+
/* copy the data between search string */
if (found > src) {
memcpy (&d[i], src, found - src);
i += found - src;
}
-
+
/* copy replace string instead */
memcpy (&d[i], replace, strlen (replace));
i += strlen (replace);
src = found + strlen (search);
}
-
+
/* copy the rest */
if (src) {
memcpy (&d[i], src, strlen (src));
@@ -92,7 +92,7 @@ str_replace (char **dst, const char *search, const char *replace, const char *ex
}
d[i] = 0x0;
-
+
#ifdef __DEBUG_ALL__
printf ("str_replace('%s', '%s') = '%s' --> '%s'\n", search, replace, *dst, &d[0]);
#endif
@@ -104,71 +104,71 @@ str_replace (char **dst, const char *search, const char *replace, const char *ex
/*
- * copy_file: copy file from src to dst
- */
-gboolean
+ * copy_file: copy file from src to dst
+ */
+gboolean
copy_file (const char *src, const char *dst)
{
#define BUFFER_SIZE 65536
-
+
FILE *fin;
FILE *fout;
void *buffer;
int size_r;
-
+
fin = fopen (src, "r");
if (fin == NULL) {
fprintf (stderr, "copy_file: error reading file \"%s\": %s\n", src, strerror (errno));
- return FALSE;
+ return FALSE;
}
-
+
fout = fopen (dst, "w");
if (fout == NULL) {
fprintf (stderr, "copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno));
fclose (fin);
- return FALSE;
+ return FALSE;
}
-
+
buffer = malloc (BUFFER_SIZE);
memset (buffer, 0, BUFFER_SIZE);
size_r = BUFFER_SIZE;
-
+
while ((! feof (fin)) && (size_r == BUFFER_SIZE)) {
size_r = fread (buffer, 1, BUFFER_SIZE, fin);
fwrite (buffer, 1, size_r, fout);
}
-
- fclose (fout);
+
+ fclose (fout);
fclose (fin);
free (buffer);
-
- return TRUE;
+
+ return TRUE;
}
/*
* make_string: make string of 'substr' substrings
- * - returns newly allocated string
- */
+ * - returns newly allocated string
+ */
char *
make_string (const char* substr, const int count)
{
int i;
char *s;
-
+
s = malloc (strlen (substr) * count + 1);
for (i = 0; i < count; i++)
memcpy (s + (strlen (substr) * i), substr, strlen (substr));
- s[strlen (substr) * count] = 0;
- return s;
+ s[strlen (substr) * count] = 0;
+ return s;
}
/*
* fix_entities: replace all invalid & entities with &amp;
- * - returns newly allocated string
+ * - returns newly allocated string
*/
-void
+void
fix_entities (char **str)
{
static char d[REPLACE_MAX_LENGTH];
@@ -176,12 +176,12 @@ fix_entities (char **str)
char *found;
char *scan;
int i;
-
+
/* TODO: add range checking */
-
+
if (! *str || strstr (*str, "&") == NULL)
return;
-
+
i = 0;
src = *str;
while (strstr (src, "&")) {
@@ -190,17 +190,17 @@ fix_entities (char **str)
/* copy the data between search string */
memcpy (&d[i], src, found - src + 1);
i += found - src + 1;
-
+
/* scroll to next whitespace */
scan = found + 1;
while (scan && (
- (*scan >= 0x41 && *scan <= 0x5a) || (*scan >= 0x61 && *scan <= 0x7a) || /* A-Z, a-z */
+ (*scan >= 0x41 && *scan <= 0x5a) || (*scan >= 0x61 && *scan <= 0x7a) || /* A-Z, a-z */
(*scan >= 0x30 && *scan <= 0x39) || (*scan == 0x23) /* 0-9, # */
))
scan++;
-
+
if (scan && (*scan == 0x3b)) {
- /* this is semi-colon, correctly closed entity */
+ /* this is semicolon, correctly closed entity */
/* -- ignore */
}
else {
@@ -210,7 +210,7 @@ fix_entities (char **str)
}
src = found + 1;
}
-
+
/* copy the rest */
if (src) {
memcpy (&d[i], src, strlen (src));
@@ -218,7 +218,7 @@ fix_entities (char **str)
}
d[i] = 0x0;
-
+
#ifdef __DEBUG_ALL__
printf ("fix_entities: '%s' --> '%s'\n", *str, &d[0]);
#endif
diff --git a/gallery-utils.h b/gallery-utils.h
index 95dbcff..dd97663 100644
--- a/gallery-utils.h
+++ b/gallery-utils.h
@@ -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.
@@ -25,23 +25,23 @@
* str_replace: replace substring 'search' with a 'replace' string
* - multiple occurences of the string are replaced
* - specify 'exclude_when' if you want to skip replace when a string found at the place of 'search'
- * - reallocates the original string
- */
+ * - reallocates the original string
+ */
void str_replace (char **dst, const char *search, const char *replace, const char *exclude_when);
/*
- * copy_file: copy file from src to dst
- */
+ * copy_file: copy file from src to dst
+ */
gboolean copy_file (const char *src, const char *dst);
/*
- * make_string: make string of 'substr' substrings
- * - returns newly allocated string
- */
+ * make_string: make string of 'substr' substrings
+ * - returns newly allocated string
+ */
char *make_string (const char* substr, const int count);
/*
* fix_entities: replace all invalid & entities with &amp;
- * - returns newly allocated string
+ * - returns newly allocated string
*/
-void fix_entities (char **str); \ No newline at end of file
+void fix_entities (char **str);
diff --git a/generators.c b/generators.c
index 18fa25f..210bdb0 100644
--- a/generators.c
+++ b/generators.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.
@@ -46,27 +46,27 @@ generate_image (TGallerySetup *setup,
char *thumb_dst;
char *big_dst;
char *big_src;
- char *orig_dst;
+ char *orig_dst;
char *img_src_full;
char *s1, *s2;
int bigq;
-
- *img_src = item->thumbnail;
- if (items->type == GALLERY_TYPE_INDEX)
+
+ *img_src = item->thumbnail;
+ if (items->type == GALLERY_TYPE_INDEX)
*img_src = item->thumbnail;
- else
+ else
if (items->type == GALLERY_TYPE_ALBUM)
*img_src = (item->path == NULL && item->preview) ? item->preview : item->path;
-
+
img_src_full = g_strconcat (items->base_dir, "/", *img_src, NULL);
get_image_sizes (img_src_full, img_w, img_h);
if ((img_w > 0) && (img_h > 0)) {
new_w = *img_w;
new_h = *img_h;
-
-
+
+
/* Generate thumbnail */
s1 = g_path_get_dirname (dst);
s2 = g_path_get_basename (*img_src);
@@ -75,19 +75,19 @@ generate_image (TGallerySetup *setup,
g_free (s2);
if (setup->verbose) printf (" Generating thumbnail of '%s' ...", *img_src);
- if ((*img_w / *img_h) >= 1)
+ if ((*img_w / *img_h) >= 1)
calculate_sizes (setup->thumbnail_landscape_width, setup->thumbnail_landscape_height, &new_w, &new_h);
- else
+ else
calculate_sizes (setup->thumbnail_portrait_width, setup->thumbnail_portrait_height, &new_w, &new_h);
if (! resize_image (img_src_full, thumb_dst, new_w, new_h, setup->thumbnail_quality))
fprintf (stderr, "write_html_index: error resizing thumbnail %s\n", img_src_full);
- else
+ else
if (setup->verbose) printf (" done.\n");
g_free (thumb_dst);
-
+
/* Generate/copy preview and original image */
- if (items->type == GALLERY_TYPE_ALBUM)
+ if (items->type == GALLERY_TYPE_ALBUM)
{
s1 = g_path_get_dirname (dst);
s2 = g_path_get_basename (*img_src);
@@ -96,11 +96,11 @@ generate_image (TGallerySetup *setup,
g_free (s2);
if (item->preview == NULL) {
- /* No preview image supplied, generate it from original */
+ /* No preview image supplied, generate it from original */
bigq = setup->preview_quality;
- if ((items->quality > 0) && (items->quality <= 100))
+ if ((items->quality > 0) && (items->quality <= 100))
bigq = items->quality;
- if ((item->quality > 0) && (item->quality <= 100))
+ if ((item->quality > 0) && (item->quality <= 100))
bigq = item->quality;
new_w = *img_w;
new_h = *img_h;
@@ -108,7 +108,7 @@ generate_image (TGallerySetup *setup,
if (setup->verbose) printf (" Generating preview of '%s' ...", *img_src);
if ((item->width > 0) && (item->height > 0)) {
calculate_sizes (item->width, item->height, &new_w, &new_h);
- } else {
+ } else {
if ((*img_w / *img_h) >= 1)
{
if ((items->landscape_width > 0) && (items->landscape_height > 0))
@@ -124,10 +124,10 @@ generate_image (TGallerySetup *setup,
calculate_sizes (setup->preview_portrait_width, setup->preview_portrait_height, &new_w, &new_h);
}
}
-
+
if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq))
fprintf (stderr, "write_html_index: error resizing big image %s\n", img_src_full);
- else
+ else
if (setup->verbose) printf (" done.\n");
}
else
@@ -137,13 +137,13 @@ generate_image (TGallerySetup *setup,
if (setup->verbose) printf (" Copying preview image '%s' ...", *img_src);
if (! copy_file (big_src, big_dst))
fprintf (stderr, "write_html_index: error copying preview image %s\n", big_src);
- else
+ else
if (setup->verbose) printf (" done.\n");
g_free (big_src);
}
g_free (big_dst);
- if (! item->nofullsize)
+ if (! item->nofullsize)
{
s1 = g_path_get_dirname(dst);
orig_dst = g_strconcat (s1, "/", IMG_ORIG_DIR, "/", *img_src, NULL);
@@ -155,22 +155,22 @@ generate_image (TGallerySetup *setup,
if (setup->verbose) printf(" done.\n");
g_free (orig_dst);
}
- }
+ }
}
- g_free (img_src_full);
+ g_free (img_src_full);
}
/*
* write_html_album: process album and index template files
- *
+ *
* template_src = template file of the album/index
* dst = save generated file as
* items = array of items in the album/index
*
- */
-gboolean
+ */
+gboolean
write_html_album (TGallerySetup *setup,
const char *template_src,
const char *dst,
@@ -180,12 +180,12 @@ write_html_album (TGallerySetup *setup,
FILE *fin;
FILE *fout;
char *buffer;
- char *buf_img_list_landscape;
+ char *buf_img_list_landscape;
char *buf_img_list_portrait;
char *buf_go_up_string;
- gboolean in_img_list;
- gboolean in_img_list_landscape;
- gboolean in_img_list_portrait;
+ gboolean in_img_list;
+ gboolean in_img_list_landscape;
+ gboolean in_img_list_portrait;
gboolean in_go_up_string;
char *b;
char *s1, *s2, *s3, *s4;
@@ -196,32 +196,32 @@ write_html_album (TGallerySetup *setup,
int i;
unsigned long img_w, img_h;
const char *img_src;
-
-
+
+
fin = fopen (template_src, "r");
if (fin == NULL) {
fprintf (stderr, "write_html_index: error reading file \"%s\": %s\n", template_src, strerror (errno));
- return FALSE;
+ return FALSE;
}
fout = fopen (dst, "w");
if (fout == NULL) {
fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno));
fclose (fin);
- return FALSE;
+ return FALSE;
}
-
+
buffer = malloc (BUFFER_SIZE);
- buf_img_list_landscape = malloc (BUFFER_SIZE);
+ buf_img_list_landscape = malloc (BUFFER_SIZE);
buf_img_list_portrait = malloc (BUFFER_SIZE);
buf_go_up_string = malloc (BUFFER_SIZE);
- in_img_list = FALSE;
- in_img_list_landscape = FALSE;
- in_img_list_portrait = FALSE;
+ in_img_list = FALSE;
+ in_img_list_landscape = FALSE;
+ in_img_list_portrait = FALSE;
in_go_up_string = FALSE;
res = TRUE;
-
+
/* Read through the template and replace placeholders with real data */
- while (! feof (fin))
+ while (! feof (fin))
{
memset (buffer, 0, BUFFER_SIZE);
if (! fgets (buffer, BUFFER_SIZE, fin))
@@ -229,28 +229,28 @@ write_html_album (TGallerySetup *setup,
if (buffer == NULL)
continue;
b = strdup (buffer);
-
-
+
+
/* Block placeholders */
if (in_img_list && (strstr (buffer, "<!-- $(BEGIN_IMG_LIST_LANDSCAPE) -->"))) {
in_img_list_landscape = TRUE;
free (b);
- continue;
+ continue;
}
if (in_img_list && (strstr (buffer, "<!-- $(END_IMG_LIST_LANDSCAPE) -->"))) {
in_img_list_landscape = FALSE;
free (b);
- continue;
+ continue;
}
if (in_img_list && (strstr (buffer, "<!-- $(BEGIN_IMG_LIST_PORTRAIT) -->"))) {
in_img_list_portrait = TRUE;
free (b);
- continue;
+ continue;
}
if (in_img_list && (strstr (buffer, "<!-- $(END_IMG_LIST_PORTRAIT) -->"))) {
in_img_list_portrait = FALSE;
free (b);
- continue;
+ continue;
}
if (in_img_list && in_img_list_landscape) {
buf_img_list_landscape = strncat (buf_img_list_landscape, b, BUFFER_SIZE - strlen (buf_img_list_landscape) - 2);
@@ -272,7 +272,7 @@ write_html_album (TGallerySetup *setup,
if (in_go_up_string && (strstr (buffer, "<!-- $(END_GO_UP) -->"))) {
in_go_up_string = FALSE;
free (b);
- /* print the "Go Up" string if not toplevel */
+ /* print the "Go Up" string if not toplevel */
if (items->parent_index)
b = strdup (buf_go_up_string);
else continue;
@@ -283,8 +283,8 @@ write_html_album (TGallerySetup *setup,
continue;
}
-
- /* Simple placeholders */
+
+ /* Simple placeholders */
if (strstr (b, "<!-- $(ID) -->") && items->ID) {
s1 = g_strdup (items->ID);
fix_entities (&s1);
@@ -310,10 +310,10 @@ write_html_album (TGallerySetup *setup,
g_free (s1);
}
if (strstr (b, "<!-- $(TOTAL_ITEMS) -->")) {
- s1 = g_strdup_printf ("%d", items->items->len);
+ s1 = g_strdup_printf ("%d", items->items->len);
str_replace (&b, "<!-- $(TOTAL_ITEMS) -->", s1, NULL);
g_free (s1);
- }
+ }
if (strstr (b, "<!-- $(NAV_BAR) -->")) {
s1 = g_strdup (items->ID);
fix_entities (&s1);
@@ -329,11 +329,11 @@ write_html_album (TGallerySetup *setup,
g_free (s4);
s1 = s2;
parent = parent->parent_index;
- level++;
+ level++;
}
str_replace (&b, "<!-- $(NAV_BAR) -->", s1, NULL);
g_free (s1);
- }
+ }
/* Image list, nested placeholders */
if (strstr (buffer, "<!-- $(BEGIN_IMG_LIST) -->")) {
@@ -350,15 +350,15 @@ write_html_album (TGallerySetup *setup,
in_img_list = FALSE;
in_img_list_landscape = FALSE;
in_img_list_portrait = FALSE;
-
+
/* Now we have all block placeholders read, generate the items: */
- for (i = 0; i < items->items->len; i++)
+ for (i = 0; i < items->items->len; i++)
{
item = g_ptr_array_index (items->items, i);
if (item == NULL) {
- fprintf (stderr, "write_html_index: error getting item %d\n", i);
+ fprintf (stderr, "write_html_index: error getting item %d\n", i);
free (b);
- continue;
+ continue;
}
/* Generate the images (preview, original, thumbnail) */
@@ -368,11 +368,11 @@ write_html_album (TGallerySetup *setup,
generate_image (setup, items, item, dst, &img_w, &img_h, &img_src);
/* Process HTML box code */
- if ((img_w / img_h) >= 1)
+ if ((img_w / img_h) >= 1)
s1 = strdup (buf_img_list_landscape);
- else
+ else
s1 = strdup (buf_img_list_portrait);
-
+
if (strstr (s1, "<!-- $(ALBUM_SUBPATH) -->")) {
s2 = g_strconcat (item->path, "/index.html", NULL);
str_replace (&s1, "<!-- $(ALBUM_SUBPATH) -->", s2, NULL);
@@ -401,10 +401,10 @@ write_html_album (TGallerySetup *setup,
str_replace (&s1, "<!-- $(ALBUM_NUM_ITEMS) -->", s2, NULL);
g_free (s2);
g_free (s3);
- }
+ }
if (strstr (s1, "<!-- $(IMG_THUMBNAIL) -->")) {
s3 = g_path_get_basename (img_src);
- s2 = g_strconcat (THUMBNAIL_DIR, "/", s3, NULL);
+ s2 = g_strconcat (THUMBNAIL_DIR, "/", s3, NULL);
str_replace (&s1, "<!-- $(IMG_THUMBNAIL) -->", s2, NULL);
g_free (s2);
g_free (s3);
@@ -412,10 +412,10 @@ write_html_album (TGallerySetup *setup,
if (strstr (s1, "<!-- $(IMG_FILENAME) -->"))
str_replace (&s1, "<!-- $(IMG_FILENAME) -->", img_src, NULL);
-
+
#ifdef __DEBUG_ALL__
printf("***** %s ******\n", s1);
- #endif
+ #endif
if (! fputs (s1, fout)) {
fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno));
res = FALSE;
@@ -437,34 +437,34 @@ write_html_album (TGallerySetup *setup,
}
free (b);
}
-
+
fclose (fout);
fclose (fin);
free (buffer);
- free (buf_img_list_landscape);
+ free (buf_img_list_landscape);
free (buf_img_list_portrait);
free (buf_go_up_string);
- return res;
+ return res;
}
/*
* write_html_image: process single image template file
- *
+ *
* template_src = template file of the album/index
* original_img = source image file (original full-size) to get EXIF data from
* dst = save generated file as
* item = data for the current item
* parent_items = array of items in the album, to determine our position and make links to previous/next image
- *
- */
-gboolean
-write_html_image (TGallerySetup *setup,
- const char *template_src,
- const char *original_img,
- const char *dst,
- TIndexItem *item,
+ *
+ */
+gboolean
+write_html_image (TGallerySetup *setup,
+ const char *template_src,
+ const char *original_img,
+ const char *dst,
+ TIndexItem *item,
TAlbum *parent_items)
{
#define BUFFER_SIZE 65536
@@ -487,41 +487,41 @@ write_html_image (TGallerySetup *setup,
char *b;
gboolean res;
int level;
-
-
+
+
fin = fopen (template_src, "r");
if (fin == NULL) {
fprintf (stderr, "write_html_image: error reading file \"%s\": %s\n", template_src, strerror (errno));
- return FALSE;
+ return FALSE;
}
fout = fopen (dst, "w");
if (fout == NULL) {
fprintf (stderr, "write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno));
fclose (fin);
- return FALSE;
+ return FALSE;
}
-
+
buffer = malloc (BUFFER_SIZE);
s1 = g_path_get_dirname (dst);
imgname = (item->path == NULL && item->preview) ? g_path_get_basename (item->preview) : g_strdup (item->path);
big_dst = g_strconcat (s1, "/", IMG_BIG_DIR, "/", imgname, NULL);
orig_dst = g_strconcat (s1, "/", IMG_ORIG_DIR, "/", imgname, NULL);
g_free (s1);
- buf_img_fullsize_link = malloc (BUFFER_SIZE);
+ buf_img_fullsize_link = malloc (BUFFER_SIZE);
memset (buf_img_fullsize_link, 0, BUFFER_SIZE);
in_img_fullsize_link = FALSE;
res = TRUE;
-
+
/* Get EXIF data from the original image */
if (get_exif (original_img, &exif))
fprintf (stderr, "write_html_image: error getting exif data from file \"%s\"\n", orig_dst);
/* Retrieve image sizes of preview and original image */
get_image_sizes (big_dst, &img_big_w, &img_big_h);
- if (! item->nofullsize)
+ if (! item->nofullsize)
get_image_sizes (orig_dst, &img_orig_w, &img_orig_h);
-
+
/* Get our index in the album */
item_index = 0;
for (i = 0; i < parent_items->items->len; i++)
@@ -529,45 +529,45 @@ write_html_image (TGallerySetup *setup,
item_index = i + 1;
break;
}
-
+
/* Get previous and next items */
previous_item = NULL;
next_item = NULL;
- if (item_index > 1)
- previous_item = g_ptr_array_index (parent_items->items, item_index - 2);
- if (item_index < parent_items->items->len)
+ if (item_index > 1)
+ previous_item = g_ptr_array_index (parent_items->items, item_index - 2);
+ if (item_index < parent_items->items->len)
next_item = g_ptr_array_index (parent_items->items, item_index);
-
+
/* Read through the template and replace placeholders with real data */
while (! feof (fin)) {
- memset (buffer, 0, BUFFER_SIZE);
- if (! fgets (buffer, BUFFER_SIZE, fin))
+ memset (buffer, 0, BUFFER_SIZE);
+ if (! fgets (buffer, BUFFER_SIZE, fin))
break;
b = strdup (buffer);
-
+
/* Block placeholders */
if (strstr (buffer, "<!-- $(BEGIN_IMG_FULLSIZE_LINK) -->")) {
in_img_fullsize_link = TRUE;
free (b);
- continue;
+ continue;
}
if (strstr (buffer, "<!-- $(END_IMG_FULLSIZE_LINK) -->")) {
in_img_fullsize_link = FALSE;
free (b);
if (! item->nofullsize)
b = strdup (buf_img_fullsize_link);
- else continue;
+ else continue;
}
if (in_img_fullsize_link) {
buf_img_fullsize_link = strncat (buf_img_fullsize_link, b, BUFFER_SIZE - strlen (buf_img_fullsize_link) - 2);
free (b);
- continue;
+ continue;
}
-
- /* Simple placeholders */
+
+ /* Simple placeholders */
if (strstr (b, "<!-- $(FILE_NAME) -->"))
str_replace (&b, "<!-- $(FILE_NAME) -->", imgname, NULL);
if (strstr (b, "<!-- $(TITLE) -->") && item->title) {
@@ -583,15 +583,15 @@ write_html_image (TGallerySetup *setup,
g_free (s1);
}
if (strstr (b, "<!-- $(TOTAL_ITEMS) -->")) {
- s1 = g_strdup_printf ("%d", parent_items->items->len);
+ s1 = g_strdup_printf ("%d", parent_items->items->len);
str_replace (&b, "<!-- $(TOTAL_ITEMS) -->", s1, NULL);
g_free (s1);
- }
+ }
if (strstr (b, "<!-- $(FILE_NO) -->")) {
- s1 = g_strdup_printf ("%d", item_index);
+ s1 = g_strdup_printf ("%d", item_index);
str_replace(&b, "<!-- $(FILE_NO) -->", s1, NULL);
g_free (s1);
- }
+ }
if (strstr (b, "<!-- $(NAV_BAR) -->")) {
// s1 = g_strconcat (item->title, " (", imgname, ")", NULL);
s1 = g_strdup (imgname);
@@ -607,82 +607,92 @@ write_html_image (TGallerySetup *setup,
g_free (s4);
s1 = s2;
parent = parent->parent_index;
- level++;
+ level++;
}
str_replace (&b, "<!-- $(NAV_BAR) -->", s1, NULL);
g_free (s1);
- }
+ }
if (strstr (b, "<!-- $(IMG_SRC_BIG) -->")) {
s1 = g_strconcat (IMG_BIG_DIR, "/", imgname, NULL);
str_replace (&b, "<!-- $(IMG_SRC_BIG) -->", s1, NULL);
g_free (s1);
}
- if (strstr(b, "<!-- $(IMG_SRC_FULL) -->")) {
+ if (strstr (b, "<!-- $(IMG_SRC_FULL) -->")) {
s1 = g_strconcat (IMG_ORIG_DIR, "/", imgname, NULL);
str_replace (&b, "<!-- $(IMG_SRC_FULL) -->", s1, NULL);
g_free (s1);
}
- if (strstr(b, "<!-- $(IMG_SIZE_BIG_W) -->")) {
- s1 = g_strdup_printf ("%lu", img_big_w);
+ if (strstr (b, "<!-- $(IMG_SIZE_BIG_W) -->")) {
+ s1 = g_strdup_printf ("%lu", img_big_w);
str_replace (&b, "<!-- $(IMG_SIZE_BIG_W) -->", s1, NULL);
g_free (s1);
}
- if (strstr(b, "<!-- $(IMG_SIZE_BIG_H) -->")) {
- s1 = g_strdup_printf ("%lu", img_big_h);
+ if (strstr (b, "<!-- $(IMG_SIZE_BIG_H) -->")) {
+ s1 = g_strdup_printf ("%lu", img_big_h);
str_replace (&b, "<!-- $(IMG_SIZE_BIG_H) -->", s1, NULL);
g_free (s1);
}
- if (strstr(b, "<!-- $(IMG_SIZE_ORIG_W) -->")) {
- s1 = g_strdup_printf ("%lu", img_orig_w);
+ if (strstr (b, "<!-- $(IMG_SIZE_ORIG_W) -->")) {
+ s1 = g_strdup_printf ("%lu", img_orig_w);
str_replace (&b, "<!-- $(IMG_SIZE_ORIG_W) -->", s1, NULL);
g_free (s1);
}
- if (strstr(b, "<!-- $(IMG_SIZE_ORIG_H) -->")) {
- s1 = g_strdup_printf ("%lu", img_orig_h);
+ if (strstr (b, "<!-- $(IMG_SIZE_ORIG_H) -->")) {
+ s1 = g_strdup_printf ("%lu", img_orig_h);
str_replace (&b, "<!-- $(IMG_SIZE_ORIG_H) -->", s1, NULL);
g_free (s1);
}
+ if (strstr (b, "<!-- $(IMG_BORDER_STYLE) -->")) {
+ s1 = item->border_style;
+ if (s1 == NULL)
+ s1 = parent_items->border_style;
+ if (s1 == NULL)
+ s1 = setup->border_style;
+ if (s1 == NULL)
+ s1 = "border_single";
+ str_replace (&b, "<!-- $(IMG_BORDER_STYLE) -->", s1, NULL);
+ }
if (strstr (b, "<!-- $(EXIF_ISO) -->")) {
- if (exif->iso)
+ if (exif->iso)
str_replace (&b, "<!-- $(EXIF_ISO) -->", exif->iso, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_ISO) -->", "??", NULL);
- }
+ }
if (strstr (b, "<!-- $(EXIF_TIME) -->")) {
- if (exif->exposure)
+ if (exif->exposure)
str_replace (&b, "<!-- $(EXIF_TIME) -->", exif->exposure, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_TIME) -->", "??", NULL);
}
if (strstr (b, "<!-- $(EXIF_APERTURE) -->")) {
- if (exif->aperture)
+ if (exif->aperture)
str_replace (&b, "<!-- $(EXIF_APERTURE) -->", exif->aperture, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_APERTURE) -->", "??", NULL);
}
if (strstr (b, "<!-- $(EXIF_FOCAL_LENGTH) -->")) {
- if (exif->focal_length)
+ if (exif->focal_length)
str_replace (&b, "<!-- $(EXIF_FOCAL_LENGTH) -->", exif->focal_length, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_FOCAL_LENGTH) -->", "??", NULL);
}
if (strstr (b, "<!-- $(EXIF_FLASH) -->")) {
- if (exif->flash)
+ if (exif->flash)
str_replace (&b, "<!-- $(EXIF_FLASH) -->", exif->flash, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_FLASH) -->", "??", NULL);
}
if (strstr (b, "<!-- $(EXIF_DATE) -->")) {
- if (exif->datetime)
+ if (exif->datetime)
str_replace (&b, "<!-- $(EXIF_DATE) -->", exif->datetime, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_DATE) -->", "??", NULL);
}
if (strstr (b, "<!-- $(EXIF_CAMERA_MODEL) -->")) {
- if (exif->camera_model)
+ if (exif->camera_model)
str_replace (&b, "<!-- $(EXIF_CAMERA_MODEL) -->", exif->camera_model, NULL);
- else
+ else
str_replace (&b, "<!-- $(EXIF_CAMERA_MODEL) -->", "??", NULL);
}
if (strstr (b, "<!-- $(EXIF_FOCAL_35) -->")) {
@@ -691,7 +701,7 @@ write_html_image (TGallerySetup *setup,
str_replace (&b, "<!-- $(EXIF_FOCAL_35) -->", s1, NULL);
g_free (s1);
}
- else
+ else
str_replace (&b, "<!-- $(EXIF_FOCAL_35) -->", "", NULL);
}
@@ -703,9 +713,9 @@ write_html_image (TGallerySetup *setup,
g_free (s1);
g_free (s2);
}
- else
+ else
str_replace (&b, "<!-- $(LINK_NEXT) -->", "index.html", NULL);
- }
+ }
if (strstr(b, "<!-- $(LINK_PREV) -->")) {
if (previous_item) {
s2 = (previous_item->path == NULL && previous_item->preview) ? g_path_get_basename (previous_item->preview) : g_strdup (previous_item->path);
@@ -714,9 +724,9 @@ write_html_image (TGallerySetup *setup,
g_free (s1);
g_free (s2);
}
- else
+ else
str_replace (&b, "<!-- $(LINK_PREV) -->", "index.html", NULL);
- }
+ }
if (strstr (b, "<!-- $(FOOTER) -->")) {
s1 = g_strdup (setup->footer);
@@ -733,8 +743,8 @@ write_html_image (TGallerySetup *setup,
}
free (b);
}
-
- fclose (fout);
+
+ fclose (fout);
fclose (fin);
free (buffer);
free (big_dst);
@@ -748,16 +758,16 @@ write_html_image (TGallerySetup *setup,
/*
* build_tree: generate complete gallery tree based on source xml files
- *
+ *
* src_tree = source directory of the items
* dst_dir = destination of the generated items
- * parent_index = parent album to determine our descent in the tree
- *
- */
-gboolean
-build_tree (TGallerySetup *setup,
- const char *src_tree,
- const char *dst_dir,
+ * parent_index = parent album to determine our descent in the tree
+ *
+ */
+gboolean
+build_tree (TGallerySetup *setup,
+ const char *src_tree,
+ const char *dst_dir,
TAlbum *parent_index)
{
char *idx_file;
@@ -771,13 +781,13 @@ build_tree (TGallerySetup *setup,
char *imgname;
gboolean res;
int i;
-
- printf ("*** Entering directory '%s'\n", src_tree);
+
+ printf ("*** Entering directory '%s'\n", src_tree);
#ifdef __DEBUG_ALL__
printf ("setup->real_templates_dir = %s\n", setup->real_templates_dir);
#endif
- /* Check access permissions */
+ /* Check access permissions */
if (access (src_tree, R_OK | X_OK)) {
fprintf (stderr, "error accessing source directory: %s\n", strerror (errno));
return FALSE;
@@ -787,7 +797,7 @@ build_tree (TGallerySetup *setup,
fprintf (stderr, "error creating destination directory: %s\n", strerror (errno));
return FALSE;
}
- }
+ }
/* Check the index file */
idx_file = g_strconcat (src_tree, "/index.xml", NULL);
@@ -796,7 +806,7 @@ build_tree (TGallerySetup *setup,
g_free (idx_file);
return FALSE;
}
-
+
/* Read the index file and fill items array */
items = malloc (sizeof (TAlbum));
if (! parse_album_xml (idx_file, items)) {
@@ -808,7 +818,7 @@ build_tree (TGallerySetup *setup,
g_free (idx_file);
items->parent_index = parent_index;
-
+
/* Copy support files */
if (setup->verbose) printf ("Writing '%s' ...", setup->styles);
s1 = g_strconcat (setup->real_templates_dir, "/", setup->styles, NULL);
@@ -817,33 +827,33 @@ build_tree (TGallerySetup *setup,
g_free (s1);
g_free (s2);
if (setup->verbose) printf (" done.\n");
-
+
if (setup->verbose) printf ("Writing '%s' ...", setup->scripts);
s1 = g_strconcat (setup->real_templates_dir, "/", setup->scripts, NULL);
- s2 = g_strconcat (dst_dir, "/", setup->scripts, NULL);
+ s2 = g_strconcat (dst_dir, "/", setup->scripts, NULL);
copy_file (s1, s2);
g_free (s1);
g_free (s2);
- if (setup->verbose) printf (" done.\n");
+ if (setup->verbose) printf (" done.\n");
+
-
/* Prepare target thumbnail directory */
- thumb_dir = g_strconcat (dst_dir, "/", THUMBNAIL_DIR, NULL);
+ thumb_dir = g_strconcat (dst_dir, "/", THUMBNAIL_DIR, NULL);
if (access (thumb_dir, R_OK | W_OK | X_OK))
if (mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
fprintf (stderr, "error making target thumbnail directory: %s\n", strerror (errno));
g_free (thumb_dir);
free_album_data (items);
- return FALSE;
+ return FALSE;
}
g_free (thumb_dir);
-
+
/* Prepare target preview and orig directories */
- if (items->type == GALLERY_TYPE_ALBUM)
+ if (items->type == GALLERY_TYPE_ALBUM)
{
- res = TRUE;
- img_big_dir = g_strconcat (dst_dir, "/", IMG_BIG_DIR, NULL);
- img_orig_dir = g_strconcat (dst_dir, "/", IMG_ORIG_DIR, NULL);
+ res = TRUE;
+ img_big_dir = g_strconcat (dst_dir, "/", IMG_BIG_DIR, NULL);
+ img_orig_dir = g_strconcat (dst_dir, "/", IMG_ORIG_DIR, NULL);
if (access (img_big_dir, R_OK | W_OK | X_OK))
if (mkdir (img_big_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
fprintf (stderr, "error making target preview directory: %s\n", strerror (errno));
@@ -862,18 +872,18 @@ build_tree (TGallerySetup *setup,
}
}
-
+
/* Start generating items */
- if (items->type == GALLERY_TYPE_INDEX)
+ if (items->type == GALLERY_TYPE_INDEX)
template = g_strconcat ("/", setup->template_index, NULL);
- else
- if (items->type == GALLERY_TYPE_ALBUM)
+ else
+ if (items->type == GALLERY_TYPE_ALBUM)
template = g_strconcat ("/", setup->template_album, NULL);
if (setup->verbose) printf ("Writing 'index.html' ...\n");
s1 = g_strconcat (setup->real_templates_dir, template, NULL);
s2 = g_strconcat (dst_dir, "/index.html", NULL);
- res = write_html_album (setup, s1, s2, items);
+ res = write_html_album (setup, s1, s2, items);
g_free (s1);
g_free (s2);
g_free (template);
@@ -884,16 +894,16 @@ build_tree (TGallerySetup *setup,
}
if (setup->verbose) printf (" done.\n");
-
+
/* Recurse to sub-albums (in case of album index) */
- if (items->type == GALLERY_TYPE_INDEX)
+ if (items->type == GALLERY_TYPE_INDEX)
{
if (items->items->len > 0) {
for (i = 0; i < items->items->len; i++) {
item = g_ptr_array_index (items->items, i);
if (item == NULL) {
- fprintf (stderr, "build_tree: error getting item %d\n", i);
- continue;
+ fprintf (stderr, "build_tree: error getting item %d\n", i);
+ continue;
}
s1 = g_strconcat (src_tree, "/", item->path, "/", NULL);
s2 = g_strconcat (dst_dir, "/", item->path, "/", NULL);
@@ -901,20 +911,20 @@ build_tree (TGallerySetup *setup,
g_free (s1);
g_free (s2);
}
- }
+ }
}
-
+
/* Generate separate image pages (in case of album) */
- if (items->type == GALLERY_TYPE_ALBUM)
+ if (items->type == GALLERY_TYPE_ALBUM)
{
if (items->items->len > 0) {
- for (i = 0; i < items->items->len; i++) {
+ for (i = 0; i < items->items->len; i++) {
item = g_ptr_array_index (items->items, i);
if (item == NULL) {
- fprintf (stderr, "build_tree: error getting item %d\n", i);
- continue;
+ fprintf (stderr, "build_tree: error getting item %d\n", i);
+ continue;
}
- imgname = (item->path == NULL && item->preview) ? g_path_get_basename (item->preview) : g_strdup (item->path);
+ imgname = (item->path == NULL && item->preview) ? g_path_get_basename (item->preview) : g_strdup (item->path);
if (setup->verbose) printf ("Writing '%s.html' ...", imgname);
s1 = g_strconcat (setup->real_templates_dir, "/", setup->template_photo, NULL);
s2 = g_strconcat (items->base_dir, "/", (item->path == NULL && item->preview) ? item->preview : item->path, NULL);
@@ -924,14 +934,14 @@ build_tree (TGallerySetup *setup,
g_free (s2);
g_free (s3);
g_free (imgname);
- if (! res ) continue;
- if (setup->verbose) printf (" done.\n");
- }
+ if (! res ) continue;
+ if (setup->verbose) printf (" done.\n");
+ }
}
}
printf ("*** Leaving directory '%s'\n", src_tree);
free_album_data (items);
- return TRUE;
+ return TRUE;
}
diff --git a/generators.h b/generators.h
index 9dc9446..c87e8a3 100644
--- a/generators.h
+++ b/generators.h
@@ -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.
@@ -21,12 +21,12 @@
/*
* write_html_album: process album and index template files
- *
+ *
* template_src = template file of the album/index
* dst = save generated file as
* items = array of items in the album/index
*
- */
+ */
gboolean write_html_album (TGallerySetup *setup,
const char *template_src,
const char *dst,
@@ -34,31 +34,31 @@ gboolean write_html_album (TGallerySetup *setup,
/*
* write_html_image: process single image template file
- *
+ *
* template_src = template file of the album/index
* original_img = source image file (original full-size) to get EXIF data from
* dst = save generated file as
* item = data for the current item
* parent_items = array of items in the album, to determine our position and make links to previous/next image
- *
- */
-gboolean write_html_image (TGallerySetup *setup,
- const char *template_src,
- const char *original_img,
- const char *dst,
- TIndexItem *item,
+ *
+ */
+gboolean write_html_image (TGallerySetup *setup,
+ const char *template_src,
+ const char *original_img,
+ const char *dst,
+ TIndexItem *item,
TAlbum *parent_items);
/*
* build_tree: generate complete gallery tree based on source xml files
- *
+ *
* src_tree = source directory of the items
* dst_dir = destination of the generated items
- * parent_index = parent album to determine our descent in the tree
- *
- */
-gboolean build_tree (TGallerySetup *setup,
- const char *src_tree,
- const char *dst_dir,
+ * parent_index = parent album to determine our descent in the tree
+ *
+ */
+gboolean build_tree (TGallerySetup *setup,
+ const char *src_tree,
+ const char *dst_dir,
TAlbum *parent_index);
diff --git a/items.c b/items.c
index 2c7b094..91eee63 100644
--- a/items.c
+++ b/items.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.
@@ -30,9 +30,9 @@
/*
- * parse_album_xml: XML parser for gallery index.xml files
- */
-gboolean
+ * parse_album_xml: XML parser for gallery index.xml files
+ */
+gboolean
parse_album_xml (const char *filename, TAlbum *index)
{
TXMLFile *xml;
@@ -41,13 +41,13 @@ parse_album_xml (const char *filename, TAlbum *index)
int i;
char *s;
TIndexItem *item;
-
+
xml = xml_parser_load (filename);
if (xml == NULL)
return FALSE;
-
+
/* Initialize data struct */
- if (index == NULL)
+ if (index == NULL)
index = malloc (sizeof (TAlbum));
memset (index, 0, sizeof (TAlbum));
@@ -60,7 +60,7 @@ parse_album_xml (const char *filename, TAlbum *index)
#endif
if (strcmp (gallery_type, "index") == 0)
index->type = GALLERY_TYPE_INDEX;
- else
+ else
if (strcmp (gallery_type, "album") == 0)
index->type = GALLERY_TYPE_ALBUM;
else {
@@ -68,67 +68,70 @@ parse_album_xml (const char *filename, TAlbum *index)
free (index);
return FALSE;
}
-
+
/* Section General */
index->ID = xml_file_get_node_value (xml, "/gallery/general/ID/text()");
index->title = xml_file_get_node_value (xml, "/gallery/general/title/text()");
index->desc = xml_file_get_node_value (xml, "/gallery/general/description/text()");
-
+
index->quality = xml_file_get_node_attribute_long (xml, "/gallery/general/images", "quality", -1);
index->landscape_width = xml_file_get_node_attribute_long (xml, "/gallery/general/images", "landscape_w", 0);
index->landscape_height = xml_file_get_node_attribute_long (xml, "/gallery/general/images", "landscape_h", 0);
index->portrait_width = xml_file_get_node_attribute_long (xml, "/gallery/general/images", "portrait_w", 0);
index->portrait_height = xml_file_get_node_attribute_long (xml, "/gallery/general/images", "portrait_h", 0);
+ index->border_style = xml_file_get_node_attribute (xml, "/gallery/general/border", "style");
+
/* Section Items */
count = xml_file_node_get_children_count (xml, "/gallery/items/item");
index->items = g_ptr_array_new();
-
+
for (i = 0; i < count; i++)
{
item = malloc (sizeof (TIndexItem));
memset (item, 0, sizeof (TIndexItem));
s = g_strdup_printf ("/gallery/items/item[%d]", i + 1);
- if (index->type == GALLERY_TYPE_INDEX)
+ if (index->type == GALLERY_TYPE_INDEX)
item->path = xml_file_get_node_attribute (xml, s, "path");
- else
+ else
item->path = xml_file_get_node_attribute (xml, s, "src");
item->preview = xml_file_get_node_attribute (xml, s, "preview");
item->quality = xml_file_get_node_attribute_long (xml, s, "quality", -1);
item->width = xml_file_get_node_attribute_long (xml, s, "width", 0);
item->height = xml_file_get_node_attribute_long (xml, s, "height", 0);
+ item->border_style = xml_file_get_node_attribute (xml, s, "border");
g_free (s);
s = g_strdup_printf ("/gallery/items/item[%d]/title/text()", i + 1);
item->title = xml_file_get_node_value (xml, s);
g_free (s);
-
+
s = g_strdup_printf ("/gallery/items/item[%d]/title_description/text()", i + 1);
item->title_description = xml_file_get_node_value (xml, s);
g_free (s);
-
+
s = g_strdup_printf ("/gallery/items/item[%d]/thumbnail", i + 1);
item->thumbnail = xml_file_get_node_attribute (xml, s, "src");
g_free (s);
-
+
s = g_strdup_printf ("/gallery/items/item[%d]/nofullsize", i + 1);
item->nofullsize = (xml_file_get_node_present (xml, s) || item->path == NULL);
g_free (s);
- if (item->path || item->preview)
+ if (item->path || item->preview)
{
- g_ptr_array_add (index->items, item);
- }
+ g_ptr_array_add (index->items, item);
+ }
else
{
fprintf (stderr, "%s: No image src specified, skipping!\n", filename);
free (item);
}
}
-
+
xml_parser_close (xml);
-
+
/* Print the items */
#ifdef __DEBUG_ALL__
printf ("ID = '%s'\ntitle = '%s'\ndescription = '%s'\n", index->ID, index->title, index->desc);
@@ -138,18 +141,18 @@ parse_album_xml (const char *filename, TAlbum *index)
i, item->path, item->title, item->title_description, item->thumbnail);
}
#endif
- return TRUE;
+ return TRUE;
}
/*
* free_album_data: free allocated album data
*/
-void
+void
free_album_data (TAlbum *album)
{
if (album) {
- if (album->ID)
+ if (album->ID)
free (album->ID);
if (album->title)
free (album->title);
@@ -157,12 +160,14 @@ free_album_data (TAlbum *album)
free (album->desc);
if (album->base_dir)
free (album->base_dir);
-
+ if (album->border_style)
+ free (album->border_style);
+
if (album->items) {
if (album->items->len > 0) {
TIndexItem *item;
int i;
-
+
for (i = 0; i < album->items->len; i++) {
item = g_ptr_array_index (album->items, i);
if (item != NULL) {
@@ -176,31 +181,33 @@ free_album_data (TAlbum *album)
free (item->thumbnail);
if (item->preview)
free (item->preview);
+ if (item->border_style)
+ free (item->border_style);
free (item);
}
}
}
- g_ptr_array_free (album->items, TRUE);
+ g_ptr_array_free (album->items, TRUE);
}
free (album);
- album = NULL;
+ album = NULL;
}
}
/*
- * get_gallery_objects_count: retrieve number of items in specified album
- */
-int
+ * get_gallery_objects_count: retrieve number of items in specified album
+ */
+int
get_album_objects_count (const char *filename)
{
TXMLFile *xml;
int count;
-
+
xml = xml_parser_load (filename);
if (xml == NULL)
return 0;
-
+
count = xml_file_node_get_children_count (xml, "/gallery/items/item");
xml_parser_close (xml);
diff --git a/items.h b/items.h
index b89728c..c6143ca 100644
--- a/items.h
+++ b/items.h
@@ -1,22 +1,22 @@
/* 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.
*/
-#ifndef __ITEMS_H__
-#define __ITEMS_H__
+#ifndef __ITEMS_H__
+#define __ITEMS_H__
#include <glib.h>
@@ -25,7 +25,7 @@
typedef enum {
GALLERY_TYPE_INDEX = 1 << 0,
GALLERY_TYPE_ALBUM = 1 << 1
-} TGalleryType;
+} TGalleryType;
typedef struct {
TGalleryType type;
@@ -40,6 +40,7 @@ typedef struct {
unsigned long landscape_height;
unsigned long portrait_width;
unsigned long portrait_height;
+ char *border_style;
} TAlbum;
typedef struct {
@@ -52,13 +53,14 @@ typedef struct {
unsigned long width;
unsigned long height;
gboolean nofullsize;
+ char *border_style;
} TIndexItem;
/*
- * parse_album_xml: XML parser for gallery index.xml files
- */
+ * parse_album_xml: XML parser for gallery index.xml files
+ */
gboolean parse_album_xml (const char *filename, TAlbum *index);
/*
@@ -67,8 +69,8 @@ gboolean parse_album_xml (const char *filename, TAlbum *index);
void free_album_data (TAlbum *index);
/*
- * get_album_objects_count: retrieve number of items in specified album
- */
+ * get_album_objects_count: retrieve number of items in specified album
+ */
int get_album_objects_count (const char *filename);
diff --git a/jpeg-utils.cpp b/jpeg-utils.cpp
index 973b448..5c50914 100644
--- a/jpeg-utils.cpp
+++ b/jpeg-utils.cpp
@@ -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.
@@ -29,17 +29,17 @@
/*
- * get_exif: retrieve EXIF informations from a JPEG image
- */
-int
+ * get_exif: retrieve EXIF informations from a JPEG image
+ */
+int
get_exif (const char *filename, TExifData **exif_data)
{
TExifData *data;
-
+
data = (TExifData*) malloc (sizeof (TExifData));
memset (data, 0, sizeof (TExifData));
*exif_data = data;
-
+
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
@@ -56,7 +56,7 @@ get_exif (const char *filename, TExifData **exif_data)
} catch (...) { }
/* EXIF::Camera model */
- try {
+ try {
const char *val = exifData["Exif.Image.Model"].toString().c_str();
if (val && strlen(val) > 0)
data->camera_model = strdup (val);
@@ -72,12 +72,12 @@ get_exif (const char *filename, TExifData **exif_data)
try {
val = exifData["Exif.Image.DateTime"].toString().c_str();
} catch (...) { }
-
+
if (val && strlen(val) > 0) {
static struct tm tt;
static char conv[1024];
-
- if (sscanf (val, "%d:%d:%d %d:%d:%d", &tt.tm_year, &tt.tm_mon, &tt.tm_mday, &tt.tm_hour, &tt.tm_min, &tt.tm_sec) == 6)
+
+ if (sscanf (val, "%d:%d:%d %d:%d:%d", &tt.tm_year, &tt.tm_mon, &tt.tm_mday, &tt.tm_hour, &tt.tm_min, &tt.tm_sec) == 6)
{
tt.tm_year -= 1900;
tt.tm_mon--;
@@ -95,15 +95,15 @@ get_exif (const char *filename, TExifData **exif_data)
data->exposure = g_strdup_printf ("1/%.0f s", 1/val);
else
data->exposure = g_strdup_printf ("%.1f s", val);
- }
+ }
} catch (...) { }
/* EXIF::Flash */
try {
- long int val = exifData["Exif.Photo.Flash"].toLong();
+ long int val = exifData["Exif.Photo.Flash"].toLong();
if ((val > 0) && ((val & 1) == 1))
data->flash = strdup ((char *) "Flash fired");
- else
+ else
data->flash = strdup ((char *) "--");
} catch (...) { }
@@ -122,27 +122,27 @@ get_exif (const char *filename, TExifData **exif_data)
} catch (...) { }
/* EXIF::Software */
- try {
+ try {
data->exif_software = strdup (exifData["Exif.Image.Software"].toString().c_str());
} catch (...) { }
-
+
/* EXIF::Image description */
- try {
+ try {
data->exif_imgdesc = strdup (exifData["Exif.Image.ImageDescription"].toString().c_str());
} catch (...) { }
-
+
/* EXIF::Artist */
- try {
+ try {
data->exif_artist = strdup (exifData["Exif.Image.Artist"].toString().c_str());
} catch (...) { }
-
+
/* EXIF::Copyright */
- try {
+ try {
data->exif_copyright = strdup (exifData["Exif.Image.Copyright"].toString().c_str());
} catch (...) { }
-
+
/* EXIF::User comment */
- try {
+ try {
data->exif_usercomment = strdup (exifData["Exif.Photo.UserComment"].toString().c_str());
} catch (...) { }
}
@@ -150,45 +150,45 @@ get_exif (const char *filename, TExifData **exif_data)
Exiv2::IptcData &iptcData = image->iptcData();
if (! iptcData.empty()) {
/* IPTC::Object name */
- try {
+ try {
data->iptc_objectname = strdup (iptcData["Iptc.Application2.ObjectName"].toString().c_str());
} catch (...) { }
/* IPTC::Copyright */
- try {
+ try {
data->iptc_copyright = strdup (iptcData["Iptc.Application2.Copyright"].toString().c_str());
} catch (...) { }
/* IPTC::Credit */
- try {
+ try {
data->iptc_credit = strdup (iptcData["Iptc.Application2.Credit"].toString().c_str());
} catch (...) { }
/* IPTC::Caption */
- try {
+ try {
data->iptc_caption = strdup (iptcData["Iptc.Application2.Caption"].toString().c_str());
} catch (...) { }
/* IPTC::Author */
- try {
+ try {
data->iptc_author = strdup (iptcData["Iptc.Application2.Byline"].toString().c_str());
} catch (...) { }
}
-
+
}
- catch (Exiv2::AnyError& e)
+ catch (Exiv2::AnyError& e)
{
fprintf (stderr, "get_exif: Caught Exiv2 exception: '%s'\n", e.what());
return -1;
}
-
+
/* Read the JPEG comment */
MagickBooleanType status;
MagickWand *magick_wand;
char *comment;
MagickWandGenesis();
- magick_wand = NewMagickWand();
+ magick_wand = NewMagickWand();
status = MagickPingImage (magick_wand, filename);
if (status == MagickTrue) {
comment = MagickGetImageProperty(magick_wand, "comment");
@@ -198,8 +198,8 @@ get_exif (const char *filename, TExifData **exif_data)
}
magick_wand = DestroyMagickWand (magick_wand);
MagickWandTerminus();
-
-
+
+
#ifdef __DEBUG_ALL__
printf("EXIF_TAG_DATE_TIME = '%s'\n", data->datetime);
printf("EXIF_TAG_MODEL = '%s'\n", data->camera_model);
@@ -220,72 +220,72 @@ get_exif (const char *filename, TExifData **exif_data)
printf("Iptc.Application2.Caption = '%s'\n", data->iptc_caption);
printf("Iptc.Application2.Byline = '%s'\n", data->iptc_author);
printf("JPEG comment = '%s'\n", data->jpeg_comment);
-#endif
+#endif
- return 0;
+ return 0;
}
/*
- * free_exif_struct: free allocated structure
- */
-void
+ * free_exif_struct: free allocated structure
+ */
+void
free_exif_data (TExifData *data)
{
if (data) {
- if (data->aperture)
- free (data->aperture);
- if (data->camera_model)
- free (data->camera_model);
- if (data->datetime)
- free (data->datetime);
- if (data->exposure)
- free (data->exposure);
- if (data->flash)
- free (data->flash);
- if (data->focal_length)
- free (data->focal_length);
- if (data->focal_length_35mm)
- free (data->focal_length_35mm);
- if (data->iso)
+ if (data->aperture)
+ free (data->aperture);
+ if (data->camera_model)
+ free (data->camera_model);
+ if (data->datetime)
+ free (data->datetime);
+ if (data->exposure)
+ free (data->exposure);
+ if (data->flash)
+ free (data->flash);
+ if (data->focal_length)
+ free (data->focal_length);
+ if (data->focal_length_35mm)
+ free (data->focal_length_35mm);
+ if (data->iso)
free (data->iso);
- if (data->exif_software)
+ if (data->exif_software)
free (data->exif_software);
- if (data->exif_imgdesc)
+ if (data->exif_imgdesc)
free (data->exif_imgdesc);
- if (data->exif_artist)
+ if (data->exif_artist)
free (data->exif_artist);
- if (data->exif_copyright)
+ if (data->exif_copyright)
free (data->exif_copyright);
- if (data->exif_usercomment)
+ if (data->exif_usercomment)
free (data->exif_usercomment);
-
- if (data->iptc_objectname)
+
+ if (data->iptc_objectname)
free (data->iptc_objectname);
- if (data->iptc_copyright)
+ if (data->iptc_copyright)
free (data->iptc_copyright);
- if (data->iptc_credit)
+ if (data->iptc_credit)
free (data->iptc_credit);
- if (data->iptc_caption)
+ if (data->iptc_caption)
free (data->iptc_caption);
- if (data->iptc_author)
+ if (data->iptc_author)
free (data->iptc_author);
-
- if (data->jpeg_comment)
+
+ if (data->jpeg_comment)
free (data->jpeg_comment);
-
+
free (data);
data = NULL;
- }
+ }
}
/*
- * resize_image: resize image pointed by src and save result to dst
- */
-gboolean
-resize_image (const char *src, const char *dst,
- int size_x, int size_y,
+ * resize_image: resize image pointed by src and save result to dst
+ */
+gboolean
+resize_image (const char *src, const char *dst,
+ int size_x, int size_y,
int quality)
{
#define ThrowWandException(wand) \
@@ -298,19 +298,19 @@ resize_image (const char *src, const char *dst,
description = (char*) MagickRelinquishMemory (description); \
return FALSE; \
}
-
+
MagickBooleanType status;
MagickWand *magick_wand;
-
+
/* Read an image. */
MagickWandGenesis();
- magick_wand = NewMagickWand();
+ magick_wand = NewMagickWand();
status = MagickReadImage (magick_wand, src);
if (status == MagickFalse)
ThrowWandException (magick_wand);
MagickResizeImage (magick_wand, size_x, size_y, LanczosFilter, 1.0);
MagickSetImageCompressionQuality (magick_wand, quality);
-
+
/* Write the image and destroy it. */
status = MagickWriteImage (magick_wand, dst);
if (status == MagickFalse)
@@ -323,10 +323,10 @@ resize_image (const char *src, const char *dst,
/*
- * get_image_sizes: retrieve image dimensions
- */
-void
-get_image_sizes (const char *img,
+ * get_image_sizes: retrieve image dimensions
+ */
+void
+get_image_sizes (const char *img,
unsigned long *width, unsigned long *height)
{
#define xThrowWandException(wand) \
@@ -339,49 +339,49 @@ get_image_sizes (const char *img,
description = (char*) MagickRelinquishMemory(description); \
return; \
}
-
+
MagickBooleanType status;
MagickWand *magick_wand;
*width = -1;
- *height = -1;
+ *height = -1;
/* Read an image. */
MagickWandGenesis();
- magick_wand = NewMagickWand();
+ magick_wand = NewMagickWand();
status = MagickPingImage (magick_wand, img);
- if (status == MagickFalse)
+ if (status == MagickFalse)
xThrowWandException (magick_wand);
*width = MagickGetImageWidth (magick_wand);
*height = MagickGetImageHeight (magick_wand);
-
+
magick_wand = DestroyMagickWand (magick_wand);
MagickWandTerminus();
}
/*
- * calculate_sizes: calculate maximal image sizes within specified limits keeping aspect ratio
- */
-void
-calculate_sizes (const unsigned long max_width, const unsigned long max_height,
+ * calculate_sizes: calculate maximal image sizes within specified limits keeping aspect ratio
+ */
+void
+calculate_sizes (const unsigned long max_width, const unsigned long max_height,
unsigned long *width, unsigned long *height)
{
- if ((max_width > *width) && (max_height > *height))
+ if ((max_width > *width) && (max_height > *height))
return;
-
+
double max_ratio = (double) max_width / (double) max_height;
double real_ratio = (double) *width / (double) *height;
-
+
if ((*width > *height) && (max_ratio <= real_ratio))
{
- *height = max_width / real_ratio;
+ *height = max_width / real_ratio;
*width = max_width;
}
else
- {
+ {
*width = max_height * real_ratio;
- *height = max_height;
+ *height = max_height;
}
-}
+}
diff --git a/jpeg-utils.h b/jpeg-utils.h
index 4c47d3c..e5e39de 100644
--- a/jpeg-utils.h
+++ b/jpeg-utils.h
@@ -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.
@@ -23,7 +23,7 @@
#include <glib.h>
-/* TODO: we want to have numerical values here at some point in the future */
+/* TODO: we want to have numerical values here at some point in the future */
typedef struct {
char *datetime;
char *camera_model;
@@ -33,55 +33,55 @@ typedef struct {
char *aperture;
char *exposure;
char *flash;
-
+
char *exif_software;
char *exif_imgdesc;
char *exif_artist;
char *exif_copyright;
char *exif_usercomment;
-
+
char *iptc_objectname;
char *iptc_copyright;
char *iptc_credit;
char *iptc_caption;
char *iptc_author;
-
+
char *jpeg_comment;
} TExifData;
/*
- * get_exif: retrieve EXIF info from a JPEG image
- */
+ * get_exif: retrieve EXIF info from a JPEG image
+ */
int get_exif (const char *filename, TExifData **exif_data);
/*
- * free_exif_struct: free allocated structure
- */
+ * free_exif_struct: free allocated structure
+ */
void free_exif_data (TExifData *data);
/*
- * resize_image: resize image pointed by src and save result to dst
- */
-gboolean resize_image (const char *src, const char *dst,
- int size_x, int size_y,
+ * resize_image: resize image pointed by src and save result to dst
+ */
+gboolean resize_image (const char *src, const char *dst,
+ int size_x, int size_y,
int quality);
/*
- * get_image_sizes: retrieve image dimensions
- */
-void get_image_sizes (const char *img,
+ * get_image_sizes: retrieve image dimensions
+ */
+void get_image_sizes (const char *img,
unsigned long *width, unsigned long *height);
/*
- * calculate_sizes: calculate maximal image sizes within specified limits keeping aspect ratio
- */
-void calculate_sizes (const unsigned long max_width, const unsigned long max_height,
+ * calculate_sizes: calculate maximal image sizes within specified limits keeping aspect ratio
+ */
+void calculate_sizes (const unsigned long max_width, const unsigned long max_height,
unsigned long *width, unsigned long *height);
#ifdef __cplusplus
}
-#endif \ No newline at end of file
+#endif
diff --git a/sample/src/CIAF_1/img_6802e.jpg b/sample/src/CIAF_1/img_6802e.jpg
new file mode 120000
index 0000000..d6b7d1d
--- /dev/null
+++ b/sample/src/CIAF_1/img_6802e.jpg
@@ -0,0 +1 @@
+img_6802.jpg \ No newline at end of file
diff --git a/sample/src/CIAF_1/img_6802f.jpg b/sample/src/CIAF_1/img_6802f.jpg
new file mode 120000
index 0000000..d6b7d1d
--- /dev/null
+++ b/sample/src/CIAF_1/img_6802f.jpg
@@ -0,0 +1 @@
+img_6802.jpg \ No newline at end of file
diff --git a/sample/src/CIAF_1/index.xml b/sample/src/CIAF_1/index.xml
index 788fc95..fe98cc2 100644
--- a/sample/src/CIAF_1/index.xml
+++ b/sample/src/CIAF_1/index.xml
@@ -6,10 +6,14 @@
<description><![CDATA[8. - 9. září 2007<br/>
mezinárodní letiště Brno - Tuřany<br/>
<a href="http://www.airshow.cz/18-CZ-CIAF-07-Home.html">http://www.airshow.cz/18-CZ-CIAF-07-Home.html</a><br/>
+ <br/><br/>
+ This album sets border style "border_none" for preview images.
]]></description>
<!-- you can override global settings in each album: -->
<images quality="60" landscape_w="640" landscape_h="480" portrait_w="480" portrait_h="640" />
+ <!-- override global preview image border style -->
+ <border style="border_none" />
</general>
<items>
@@ -54,5 +58,15 @@
<title_description><![CDATA[Can contain <a href="http://cgg.bzatek.net/" title="Cataract Gallery Generator" class="footermail">links</a> etc...]]></title_description>
</item>
+ <item src="img_6802e.jpg" border="frame_white">
+ <title>White frame</title>
+ <title_description>This particular image overrides both global and album border styles.</title_description>
+ </item>
+
+ <item src="img_6802f.jpg" border="frame_black">
+ <title>Black frame</title>
+ <title_description>This particular image overrides both global and album border styles.</title_description>
+ </item>
+
</items>
</gallery>
diff --git a/sample/src/CIAF_1/preview/img_6802d.jpg b/sample/src/CIAF_1/preview/img_6802d.jpg
new file mode 120000
index 0000000..d6b7d1d
--- /dev/null
+++ b/sample/src/CIAF_1/preview/img_6802d.jpg
@@ -0,0 +1 @@
+img_6802.jpg \ No newline at end of file
diff --git a/sample/src/CIAF_1/preview/img_6802e.jpg b/sample/src/CIAF_1/preview/img_6802e.jpg
new file mode 120000
index 0000000..d6b7d1d
--- /dev/null
+++ b/sample/src/CIAF_1/preview/img_6802e.jpg
@@ -0,0 +1 @@
+img_6802.jpg \ No newline at end of file
diff --git a/sample/src/CIAF_1/preview/img_6802f.jpg b/sample/src/CIAF_1/preview/img_6802f.jpg
new file mode 120000
index 0000000..d6b7d1d
--- /dev/null
+++ b/sample/src/CIAF_1/preview/img_6802f.jpg
@@ -0,0 +1 @@
+img_6802.jpg \ No newline at end of file
diff --git a/sample/src/setup.xml b/sample/src/setup.xml
index ae92918..8f4b632 100644
--- a/sample/src/setup.xml
+++ b/sample/src/setup.xml
@@ -20,10 +20,12 @@
<!-- default sizes of thumbnail and preview images -->
<thumbnail landscape_w="180" landscape_h="120"
portrait_w="120" portrait_h="180"
- quality="95" />
+ quality="80" />
<preview landscape_w="900" landscape_h="600"
portrait_w="500" portrait_h="750"
quality="95" />
+ <!-- preview image border style - use your custom CSS style to display frame around image -->
+ <border style="border_single" />
</images>
<footer><![CDATA[
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;
}
}
diff --git a/setup.h b/setup.h
index 0cde34c..c1f72bf 100644
--- a/setup.h
+++ b/setup.h
@@ -1,22 +1,22 @@
/* 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.
*/
-#ifndef __SETUP_H__
-#define __SETUP_H__
+#ifndef __SETUP_H__
+#define __SETUP_H__
#include <glib.h>
@@ -27,14 +27,14 @@ typedef struct {
char *real_templates_dir;
char *setup_xml_path;
-
+
char *templates_path;
char *template_index;
char *template_album;
char *template_photo;
char *styles;
char *scripts;
-
+
char *footer;
int thumbnail_quality;
@@ -48,18 +48,20 @@ typedef struct {
unsigned long preview_landscape_height;
unsigned long preview_portrait_width;
unsigned long preview_portrait_height;
+
+ char *border_style;
} TGallerySetup;
/*
- * find_setup_xml: try to find setup.xml in standard paths
- */
+ * find_setup_xml: try to find setup.xml in standard paths
+ */
gboolean 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);
/*
@@ -69,8 +71,8 @@ void free_setup_data (TGallerySetup *setup);
/*
* find_templates_directory: absolute/relative path checks, trying to find templates directory
- * - returned string should be freed
- */
+ * - returned string should be freed
+ */
char *find_templates_directory (TGallerySetup *setup);
diff --git a/templates/styles.css b/templates/styles.css
index e0ae25e..10fc110 100644
--- a/templates/styles.css
+++ b/templates/styles.css
@@ -7,7 +7,8 @@ body {
font-family: "DejaVu Sans", "Bitstream Vera Sans", "Verdana", sans-serif;
font-size: 12px;
color: #EEEEEC;
- background: #343D42;
+/* background: #343D42; */
+ background: #43484A;
}
img {
@@ -35,7 +36,7 @@ div.navigation {
padding-top: 5px;
padding-bottom: 5px;
font-size: 13px;
- border-top: 10px solid #343D42;
+ border-top: 10px solid #43484A;
border-bottom: 1px dotted #80878A;
}
@@ -87,17 +88,6 @@ a.footermail:hover {
text-decoration: underline;
}
-img#preview {
-/* border: 6px solid #384347; */
- background-color: #6b6c69;
- padding: 1px;
-/* -moz-border-radius: 5px; */
-}
-
-img#preview:hover {
-/* border: 6px solid #A3BED4; */
-}
-
div#img_preview {
text-align: center;
}
@@ -355,3 +345,37 @@ div.contentx {
padding: 8px;
}
+
+
+/*
+ * Image border styles
+ */
+
+img#border_single {
+/* border: 6px solid #384347; */
+ background-color: #6b6c69;
+ padding: 1px;
+/* -moz-border-radius: 5px; */
+}
+
+img#border_single:hover {
+/* border: 6px solid #A3BED4; */
+}
+
+img#border_none {
+ padding: 0px;
+ margin: 0px;
+}
+
+img#frame_black {
+ background-color: #909090;
+ padding: 1px;
+ border: 20px solid black;
+}
+
+img#frame_white {
+ background-color: #444444;
+ padding: 1px;
+ border: 20px solid white;
+}
+
diff --git a/templates/template-view_photo.tmpl b/templates/template-view_photo.tmpl
index 2cd9b5c..2cc78a5 100644
--- a/templates/template-view_photo.tmpl
+++ b/templates/template-view_photo.tmpl
@@ -37,7 +37,7 @@
<!-- ## Image -->
<div id="img_preview">
- <a href="<!-- $(LINK_NEXT) -->" id="img_preview_a"><img src="<!-- $(IMG_SRC_BIG) -->" width="<!-- $(IMG_SIZE_BIG_W) -->" height="<!-- $(IMG_SIZE_BIG_H) -->" alt="" id="preview" /></a>
+ <a href="<!-- $(LINK_NEXT) -->" id="img_preview_a"><img src="<!-- $(IMG_SRC_BIG) -->" width="<!-- $(IMG_SIZE_BIG_W) -->" height="<!-- $(IMG_SIZE_BIG_H) -->" alt="" id="<!-- $(IMG_BORDER_STYLE) -->" /></a>
<br /><br />
<!-- $(BEGIN_IMG_FULLSIZE_LINK) -->
<a href="<!-- $(IMG_SRC_FULL) -->">See original size (<!-- $(IMG_SIZE_ORIG_W) -->x<!-- $(IMG_SIZE_ORIG_H) -->)</a>
diff --git a/xml-parser.c b/xml-parser.c
index 444ea58..2b3005a 100644
--- a/xml-parser.c
+++ b/xml-parser.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.
@@ -33,13 +33,13 @@
/*
- * xml_parser_load: initialize and load the XML document
- */
+ * xml_parser_load: initialize and load the XML document
+ */
TXMLFile *
xml_parser_load (const char *filename)
{
TXMLFile *file;
-
+
file = malloc (sizeof (TXMLFile));
memset (file, 0, sizeof (TXMLFile));
@@ -55,24 +55,24 @@ xml_parser_load (const char *filename)
file->xpathCtx = xmlXPathNewContext (file->doc);
if (file->xpathCtx == NULL) {
fprintf (stderr, "Error: unable to create new XPath context\n");
- xmlFreeDoc (file->doc);
+ xmlFreeDoc (file->doc);
free (file);
return FALSE;
}
- return file;
+ return file;
}
/*
- * xml_parser_close: close the XML document parser
- */
-void
+ * xml_parser_close: close the XML document parser
+ */
+void
xml_parser_close (TXMLFile *file)
{
if (file)
{
- xmlXPathFreeContext (file->xpathCtx);
+ xmlXPathFreeContext (file->xpathCtx);
xmlFreeDoc (file->doc);
free (file);
file = NULL;
@@ -82,13 +82,13 @@ xml_parser_close (TXMLFile *file)
/*
* xml_file_get_node_value: retrieve string value from XPath node
- * - multiple matched nodes will be concatenated into one string
- * - otherwise please use [0], [1] etc. quantificators
+ * - multiple matched nodes will be concatenated into one string
+ * - otherwise please use [0], [1] etc. quantificators
*/
-char *
+char *
xml_file_get_node_value (TXMLFile *file, const char *x_path)
{
- xmlXPathObjectPtr xpathObj;
+ xmlXPathObjectPtr xpathObj;
xmlNodePtr cur;
char *val, *valx;
int i;
@@ -108,13 +108,13 @@ xml_file_get_node_value (TXMLFile *file, const char *x_path)
#ifdef __DEBUG_ALL__
printf("Result (%d nodes):\n", xpathObj->nodesetval->nodeNr);
#endif
-
+
for (i = 0; i < xpathObj->nodesetval->nodeNr; i++)
{
cur = xpathObj->nodesetval->nodeTab[i];
#ifdef __DEBUG_ALL__
printf(" XPATH matched: element node \"%s[%d]\", value = '%s'\n", cur->name, i, cur->content);
- #endif
+ #endif
if (cur->content)
{
@@ -131,19 +131,19 @@ xml_file_get_node_value (TXMLFile *file, const char *x_path)
}
}
}
-
+
xmlXPathFreeObject (xpathObj);
- return val;
+ return val;
}
/*
* xml_file_get_node_attribute: retrieve attribute value from XPath node
*/
-char *
+char *
xml_file_get_node_attribute (TXMLFile *file, const char *x_path, const char *attr)
{
- xmlXPathObjectPtr xpathObj;
+ xmlXPathObjectPtr xpathObj;
xmlNodePtr cur;
xmlChar *attrvx;
char *attrv;
@@ -157,7 +157,7 @@ xml_file_get_node_attribute (TXMLFile *file, const char *x_path, const char *att
fprintf (stderr, "Error: unable to evaluate xpath expression \"%s\"\n", x_path);
return NULL;
}
-
+
attrv = NULL;
if ((xpathObj->nodesetval) && (xpathObj->nodesetval->nodeNr > 0)) {
cur = xpathObj->nodesetval->nodeTab[0];
@@ -165,28 +165,28 @@ xml_file_get_node_attribute (TXMLFile *file, const char *x_path, const char *att
if (attrvx) {
attrv = strdup ((char*) attrvx);
xmlFree (attrvx);
- }
+ }
#ifdef __DEBUG_ALL__
printf("Result (%d nodes):\n", xpathObj->nodesetval->nodeNr);
printf(" XPATH matched: element node \"%s\", value = '%s', property value = '%s'\n", cur->name, cur->content, attrv);
- #endif
+ #endif
}
-
+
xmlXPathFreeObject (xpathObj);
- return attrv;
+ return attrv;
}
-long
+long
xml_file_get_node_attribute_long (TXMLFile *file, const char *x_path, const char *attr, const int _default)
{
char *s;
long int i;
-
+
s = xml_file_get_node_attribute (file, x_path, attr);
if (s == NULL)
return _default;
-
+
i = atol (s);
free (s);
return i;
@@ -195,25 +195,25 @@ xml_file_get_node_attribute_long (TXMLFile *file, const char *x_path, const char
/*
* xml_file_get_node_present: existency test of the XPath node
*/
-gboolean
+gboolean
xml_file_get_node_present (TXMLFile *file, const char *x_path)
{
- return xml_file_node_get_children_count (file, x_path) > 0;
+ return xml_file_node_get_children_count (file, x_path) > 0;
}
/*
* xml_file_node_get_children_count: retrieve number of children items of the specified XPath node
*/
-int
+int
xml_file_node_get_children_count (TXMLFile *file, const char *x_path)
{
- xmlXPathObjectPtr xpathObj;
+ xmlXPathObjectPtr xpathObj;
int count;
-
+
if ((! file) || (! x_path))
return 0;
-
+
/* Evaluate xpath expression */
xpathObj = xmlXPathEvalExpression ((const xmlChar *) x_path, file->xpathCtx);
if (xpathObj == NULL) {
@@ -224,7 +224,7 @@ xml_file_node_get_children_count (TXMLFile *file, const char *x_path)
count = 0;
if (xpathObj->nodesetval)
count = xpathObj->nodesetval->nodeNr;
-
+
xmlXPathFreeObject (xpathObj);
- return count;
+ return count;
}
diff --git a/xml-parser.h b/xml-parser.h
index e130e5b..031bf6b 100644
--- a/xml-parser.h
+++ b/xml-parser.h
@@ -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.
@@ -23,25 +23,25 @@
typedef struct {
xmlDocPtr doc;
- xmlXPathContextPtr xpathCtx;
+ xmlXPathContextPtr xpathCtx;
} TXMLFile;
/*
- * xml_parser_load: initialize and load the XML document
- */
+ * xml_parser_load: initialize and load the XML document
+ */
TXMLFile * xml_parser_load (const char *filename);
/*
- * xml_parser_close: close the XML document parser
- */
+ * xml_parser_close: close the XML document parser
+ */
void xml_parser_close (TXMLFile *file);
/*
* xml_file_get_node_value: retrieve string value from XPath node
- * - multiple matched nodes will be concatenated into one string
- * - otherwise please use [0], [1] etc. quantificators
+ * - multiple matched nodes will be concatenated into one string
+ * - otherwise please use [0], [1] etc. quantificators
*/
char * xml_file_get_node_value (TXMLFile *file, const char *x_path);