diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 2 | ||||
| -rw-r--r-- | src/block-parser.c | 2 | ||||
| -rw-r--r-- | src/cgg.c | 22 | ||||
| -rw-r--r-- | src/gallery-utils.c | 30 | ||||
| -rw-r--r-- | src/gallery-utils.h | 16 | ||||
| -rw-r--r-- | src/generators.c | 28 | ||||
| -rw-r--r-- | src/items.c | 5 | ||||
| -rw-r--r-- | src/job-manager.c | 26 | ||||
| -rw-r--r-- | src/jpeg-utils.cpp | 9 | ||||
| -rw-r--r-- | src/setup.c | 2 | ||||
| -rw-r--r-- | src/stats.c | 52 | ||||
| -rw-r--r-- | src/stats.h | 28 | ||||
| -rw-r--r-- | src/xml-parser.c | 13 |
13 files changed, 189 insertions, 46 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 9b7396c..492e863 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,8 @@ cgg_SOURCES = \ replace-table.h \ setup.c \ setup.h \ + stats.h \ + stats.c \ xml-parser.c \ xml-parser.h \ $(NULL) diff --git a/src/block-parser.c b/src/block-parser.c index d5f1f24..57eae8c 100644 --- a/src/block-parser.c +++ b/src/block-parser.c @@ -237,7 +237,7 @@ block_parser_read_and_parse (BlockParser *parser, FILE *stream) if (strcmp (s, token) == 0) { data = g_hash_table_lookup (parser->table, (char *) l->data); if (data == NULL || data != g_queue_peek_head (parser->active_tree)) { - fprintf (stderr, "block_parser_read_and_parse: something is wrong with the parser table: expected '%s'\n", (char *) l->data); + log_error ("block_parser_read_and_parse: something is wrong with the parser table: expected '%s'\n", (char *) l->data); } else { @@ -20,6 +20,7 @@ #include <stdlib.h> #include <stdint.h> #include <unistd.h> +#include <time.h> #include <glib.h> #include <glib/gthread.h> @@ -32,6 +33,7 @@ #include "setup.h" #include "job-manager.h" +#include "stats.h" @@ -106,6 +108,8 @@ main(int argc, char* argv[]) gboolean verbose; int jobs; TGallerySetup *setup; + time_t time_start = time (NULL); + time_t time_stop; /* * this initialize the library and check potential ABI mismatches @@ -151,10 +155,28 @@ main(int argc, char* argv[]) } + stats_errors = 0; + stats_dirs = 0; + stats_images = 0; + + /* Print banner */ + if (verbose) + printf ("cgg v%s [%s]\n\n", VERSION, APP_BUILD_DATE); + /* Start building the gallery tree */ setup->verbose = verbose; build_tree (setup, source_dir, dst_dir, NULL, -1, jobs); + if (verbose) { + time_stop = time (NULL); + printf ("\nProcessed %d images in %d albums, elapsed time = %dm %ds\n", stats_images, stats_dirs, (int) ((time_stop - time_start) / 60), (int) ((time_stop - time_start) % 60)); + if (stats_errors == 1) + printf ("%d error occured.\n", stats_errors); + if (stats_errors > 1) + printf ("%d errors occured.\n", stats_errors); + } + + MagickWandTerminus(); diff --git a/src/gallery-utils.c b/src/gallery-utils.c index 3e6c30a..8ec258a 100644 --- a/src/gallery-utils.c +++ b/src/gallery-utils.c @@ -23,6 +23,7 @@ #include <sys/stat.h> #include <unistd.h> #include <utime.h> +#include <stats.h> #include "gallery-utils.h" @@ -101,13 +102,13 @@ copy_file (const char *src, const char *dst) fin = fopen (src, "r"); if (fin == NULL) { - fprintf (stderr, "copy_file: error reading file \"%s\": %s\n", src, strerror (errno)); + log_error ("copy_file: error reading file \"%s\": %s\n", src, strerror (errno)); return FALSE; } fout = fopen (dst, "w"); if (fout == NULL) { - fprintf (stderr, "copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno)); fclose (fin); return FALSE; } @@ -120,7 +121,7 @@ copy_file (const char *src, const char *dst) size_r = fread (buffer, 1, BUFFER_SIZE, fin); written = fwrite (buffer, 1, size_r, fout); if (written < size_r) { - fprintf (stderr, "copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("copy_file: error writing to file \"%s\": %s\n", dst, strerror (errno)); break; } } @@ -132,7 +133,7 @@ copy_file (const char *src, const char *dst) /* copy timestamps */ memset (&st, 0, sizeof (st)); if (stat (src, &st) == -1) { - fprintf (stderr, "copy_file: cannot stat source file \"%s\": %s\n", src, strerror (errno)); + log_error ("copy_file: cannot stat source file \"%s\": %s\n", src, strerror (errno)); return TRUE; } @@ -140,7 +141,7 @@ copy_file (const char *src, const char *dst) ut.actime = st.st_atime; ut.modtime = st.st_mtime; if (utime (dst, &ut) == -1) - fprintf (stderr, "copy_file: cannot set timestamps on target file \"%s\": %s\n", dst, strerror (errno)); + log_error ("copy_file: cannot set timestamps on target file \"%s\": %s\n", dst, strerror (errno)); return TRUE; } @@ -268,7 +269,7 @@ remove_tags (char **str, const char *tag_begin, const char *tag_end) else { /* break in case of malformed tag structure, avoid endless loop */ - fprintf (stderr, "remove_tags: malformed tag structure detected, strange things may happen\n"); + log_error ("remove_tags: malformed tag structure detected, strange things may happen\n"); break; } } @@ -308,3 +309,20 @@ extract_file_ext (const char *filename) return strrchr (filename, '.') + 1; } + + +/* + * log_error: prints an error and increments stats + */ +/* this function can possibly store error in some list and print them all at the end again */ +void +log_error (const gchar *format, ...) +{ + va_list args; + + va_start (args, format); + vfprintf (stderr, format, args); + va_end (args); + + stats_errors_inc (); +} diff --git a/src/gallery-utils.h b/src/gallery-utils.h index 123879b..d9c1d8a 100644 --- a/src/gallery-utils.h +++ b/src/gallery-utils.h @@ -15,6 +15,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef __cplusplus + extern "C" { +#endif + #include <glib.h> #include <string.h> @@ -22,7 +27,6 @@ #define IS_EQUAL_SIGN(ch) ((ch) == '=') #define GET_EXT(s) strrchr (s, '.') - /* * str_replace: replace substring 'search' with a 'replace' string * - multiple occurences of the string are replaced @@ -63,3 +67,13 @@ int count_dir_levels (const char *path); * extract_file_ext: returns pointer to filename extension */ const char *extract_file_ext (const char *filename); + +/* + * log_error: prints an error and increments stats + */ +void log_error (const gchar *format, ...) G_GNUC_PRINTF (1, 2); + + +#ifdef __cplusplus + } +#endif diff --git a/src/generators.c b/src/generators.c index 8100196..8dd6a58 100644 --- a/src/generators.c +++ b/src/generators.c @@ -32,6 +32,7 @@ #include "gallery-utils.h" #include "replace-table.h" #include "block-parser.h" +#include "stats.h" /* @@ -86,6 +87,7 @@ generate_image (TGallerySetup *setup, get_image_sizes (img_src_full, &new_w, &new_h); if ((new_w > 0) && (new_h > 0)) { + stats_images_inc (); item->gen_portrait = (new_w / new_h) < 1; /* Generate thumbnail */ @@ -99,11 +101,11 @@ generate_image (TGallerySetup *setup, else calculate_sizes (setup->thumbnail_portrait_width, setup->thumbnail_portrait_height, &thumb_w, &thumb_h); if (! resize_image (thumb_src_full, thumb_dst, thumb_w, thumb_h, setup->thumbnail_quality, TRUE)) - fprintf (stderr, "generate_image: error resizing thumbnail %s\n", thumb_src_full); + log_error ("generate_image: error resizing thumbnail %s\n", thumb_src_full); else g_free (thumb_dst); } else - fprintf (stderr, "generate_image: thumbnail %s sizes are %lux%lu\n", thumb_src_full, thumb_w, thumb_h); + log_error ("generate_image: thumbnail %s sizes are %lux%lu\n", thumb_src_full, thumb_w, thumb_h); /* Generate/copy preview and original image */ @@ -139,14 +141,14 @@ generate_image (TGallerySetup *setup, g_assert (img_src_full != NULL); if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq, FALSE)) - fprintf (stderr, "generate_image: error resizing big image %s\n", img_src_full); + log_error ("generate_image: error resizing big image %s\n", img_src_full); } else { /* Copy the preview (big) image provided */ big_src = g_strconcat (items->base_dir, "/", item->preview, NULL); if (! copy_file (big_src, big_dst)) - fprintf (stderr, "generate_image: error copying preview image %s\n", big_src); + log_error ("generate_image: error copying preview image %s\n", big_src); g_free (big_src); } modify_exif (big_dst, setup->erase_exif_thumbnail, setup->add_copyright); @@ -157,7 +159,7 @@ generate_image (TGallerySetup *setup, { orig_dst = g_strconcat (dst_dir, "/", setup->img_orig_dir, "/", item->gen_img_src, NULL); if (! copy_file(img_src_full, orig_dst)) - fprintf (stderr, "generate_image: error copying original image %s\n", img_src_full); + log_error ("generate_image: error copying original image %s\n", img_src_full); modify_exif (orig_dst, setup->erase_exif_thumbnail, setup->add_copyright); g_free (orig_dst); } @@ -202,12 +204,12 @@ write_html_album (TGallerySetup *setup, fin = fopen (template_src, "r"); if (fin == NULL) { - fprintf (stderr, "write_html_index: error reading file \"%s\": %s\n", template_src, strerror (errno)); + log_error ("write_html_index: error reading file \"%s\": %s\n", template_src, strerror (errno)); return FALSE; } fout = fopen (dst, "w"); if (fout == NULL) { - fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); fclose (fin); return FALSE; } @@ -357,7 +359,7 @@ write_html_album (TGallerySetup *setup, { item = g_ptr_array_index (items->items, i); if (item == NULL) { - fprintf (stderr, "write_html_index: error getting item %d\n", i); + log_error ("write_html_index: error getting item %d\n", i); continue; } @@ -413,7 +415,7 @@ write_html_album (TGallerySetup *setup, bb = fputs (line, fout); g_free (line); if (! bb) { - fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); res = FALSE; break; } @@ -472,12 +474,12 @@ write_html_image (TGallerySetup *setup, fin = fopen (template_src, "r"); if (fin == NULL) { - fprintf (stderr, "write_html_image: error reading file \"%s\": %s\n", template_src, strerror (errno)); + log_error ("write_html_image: error reading file \"%s\": %s\n", template_src, strerror (errno)); return FALSE; } fout = fopen (dst, "w"); if (fout == NULL) { - fprintf (stderr, "write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); fclose (fin); return FALSE; } @@ -528,7 +530,7 @@ write_html_image (TGallerySetup *setup, /* 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); + log_error ("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); @@ -746,7 +748,7 @@ write_html_image (TGallerySetup *setup, bb = fputs (line, fout); g_free (line); if (! bb) { - fprintf (stderr, "write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); res = FALSE; break; } diff --git a/src/items.c b/src/items.c index 255ef5f..2b9a1ad 100644 --- a/src/items.c +++ b/src/items.c @@ -26,6 +26,7 @@ #include "items.h" #include "xml-parser.h" +#include "gallery-utils.h" @@ -65,7 +66,7 @@ parse_album_xml (const char *filename, TAlbum *index) if (strcmp (gallery_type, "album") == 0) index->type = GALLERY_TYPE_ALBUM; else { - printf ("Invalid gallery type (%s)\n", gallery_type); + log_error ("Invalid gallery type (%s)\n", gallery_type); free (index); return FALSE; } @@ -182,7 +183,7 @@ parse_album_xml (const char *filename, TAlbum *index) } else { - fprintf (stderr, "%s: No image src specified, skipping!\n", filename); + log_error ("%s: No image src specified, skipping!\n", filename); free (item); } } diff --git a/src/job-manager.c b/src/job-manager.c index bcbc0b8..8344e60 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -30,6 +30,7 @@ #include "items.h" #include "gallery-utils.h" #include "generators.h" +#include "stats.h" @@ -62,7 +63,7 @@ mirror_files (TGallerySetup *setup, char **files, const char *src_tree, const ch s3 = g_path_get_dirname (s2); g_free (s2); if (g_mkdir_with_parents (s3, DEFAULT_DATA_DIR_MODE)) { - fprintf (stderr, "error making target extra directory '%s': %s\n", s3, strerror (errno)); + log_error ("error making target extra directory '%s': %s\n", s3, strerror (errno)); g_free (s3); continue; } @@ -109,7 +110,7 @@ thread_func (gpointer data) for (i = 0; i < job->items->items->len; i++) { TIndexItem *item_tmp = g_ptr_array_index (job->items->items, i); if (item_tmp == NULL) { - fprintf (stderr, "run_job: error getting item %d\n", i); + log_error ("run_job: error getting item %d\n", i); continue; } if (item_tmp->type == INDEX_ITEM_TYPE_PICTURE) { @@ -188,18 +189,19 @@ build_tree (TGallerySetup *setup, GList *thread_list; printf ("Processing directory \"%s\"\n", src_tree); + stats_dirs_inc (); #ifdef __DEBUG_ALL__ printf ("setup->real_templates_dir = %s\n", setup->real_templates_dir); #endif /* Check access permissions */ if (access (src_tree, R_OK)) { - fprintf (stderr, "error accessing source directory: %s\n", strerror (errno)); + log_error ("error accessing source directory: %s\n", strerror (errno)); return FALSE; } if (access (dst_dir, R_OK | W_OK | X_OK)) { if (g_mkdir_with_parents (dst_dir, DEFAULT_DATA_DIR_MODE)) { - fprintf (stderr, "error creating destination directory: %s\n", strerror (errno)); + log_error ("error creating destination directory: %s\n", strerror (errno)); return FALSE; } } @@ -207,7 +209,7 @@ build_tree (TGallerySetup *setup, /* Check the index file */ idx_file = g_strconcat (src_tree, "/index.xml", NULL); if (access (idx_file, R_OK)) { - fprintf (stderr, "error accessing index file '%s': %s\n", idx_file, strerror (errno)); + log_error ("error accessing index file '%s': %s\n", idx_file, strerror (errno)); g_free (idx_file); return FALSE; } @@ -216,7 +218,7 @@ build_tree (TGallerySetup *setup, items = malloc (sizeof (TAlbum)); memset (items, 0, sizeof (TAlbum)); if (! parse_album_xml (idx_file, items)) { - fprintf (stderr, "error reading index file '%s'\n", idx_file); + log_error ("error reading index file '%s'\n", idx_file); g_free (idx_file); free_album_data (items); return FALSE; @@ -247,7 +249,7 @@ build_tree (TGallerySetup *setup, thumb_dir = g_strconcat (dst_dir, "/", setup->thumbnail_dir, NULL); if (access (thumb_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (thumb_dir, DEFAULT_DATA_DIR_MODE)) { - fprintf (stderr, "error making target thumbnail directory: %s\n", strerror (errno)); + log_error ("error making target thumbnail directory: %s\n", strerror (errno)); g_free (thumb_dir); free_album_data (items); return FALSE; @@ -262,12 +264,12 @@ build_tree (TGallerySetup *setup, img_orig_dir = g_strconcat (dst_dir, "/", setup->img_orig_dir, NULL); if (access (img_big_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (img_big_dir, DEFAULT_DATA_DIR_MODE)) { - fprintf (stderr, "error making target preview directory: %s\n", strerror (errno)); + log_error ("error making target preview directory: %s\n", strerror (errno)); res = FALSE; } if (access (img_orig_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (img_orig_dir, DEFAULT_DATA_DIR_MODE)) { - fprintf (stderr, "error making target full size directory: %s\n", strerror (errno)); + log_error ("error making target full size directory: %s\n", strerror (errno)); res = FALSE; } g_free (img_big_dir); @@ -294,7 +296,7 @@ build_tree (TGallerySetup *setup, if (thread) thread_list = g_list_append (thread_list, thread); if (error) { - fprintf (stderr, "build_tree: error starting new thread: %s\n", error->message); + log_error ("build_tree: error starting new thread: %s\n", error->message); g_clear_error (&error); } } @@ -331,7 +333,7 @@ build_tree (TGallerySetup *setup, g_free (s2); g_free (template); if (! res) { - fprintf (stderr, "error generating target index file\n"); + log_error ("error generating target index file\n"); free_album_data (items); return FALSE; } @@ -344,7 +346,7 @@ build_tree (TGallerySetup *setup, 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); + log_error ("build_tree: error getting item %d\n", i); continue; } if (item->type == INDEX_ITEM_TYPE_PICTURE) { diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp index 483bf4a..275e859 100644 --- a/src/jpeg-utils.cpp +++ b/src/jpeg-utils.cpp @@ -27,6 +27,7 @@ #include <config.h> #include "jpeg-utils.h" +#include "gallery-utils.h" @@ -184,7 +185,7 @@ get_exif (const char *filename, TExifData **exif_data) } catch (Exiv2::AnyError& e) { - fprintf (stderr, "get_exif: Caught Exiv2 exception: '%s'\n", e.what()); + log_error ("get_exif: Caught Exiv2 exception: '%s'\n", e.what()); return -1; } @@ -283,7 +284,7 @@ resize_image (const char *src, const char *dst, ExceptionType severity; \ \ description = MagickGetException (wand, &severity); \ - (void) fprintf (stderr, "Error converting image: %s %s %ld %s\n", GetMagickModule(), description); \ + log_error ("Error converting image: %s %s %ld %s\n", GetMagickModule(), description); \ description = (char*) MagickRelinquishMemory (description); \ return FALSE; \ } @@ -325,7 +326,7 @@ get_image_sizes (const char *img, ExceptionType severity; \ \ description = MagickGetException (wand, &severity); \ - (void) fprintf (stderr, "Error reading image info: %s %s %ld %s\n", GetMagickModule(), description); \ + log_error ("Error reading image info: %s %s %ld %s\n", GetMagickModule(), description); \ description = (char*) MagickRelinquishMemory(description); \ return; \ } @@ -422,6 +423,6 @@ modify_exif (const char *filename, gboolean strip_thumbnail, const char *add_cop } catch (Exiv2::AnyError& e) { - fprintf (stderr, "modify_exif: Caught Exiv2 exception: '%s'\n", e.what()); + log_error ("modify_exif: Caught Exiv2 exception: '%s'\n", e.what()); } } diff --git a/src/setup.c b/src/setup.c index d07e6ab..3ff9cb8 100644 --- a/src/setup.c +++ b/src/setup.c @@ -245,7 +245,7 @@ find_templates_directory (TGallerySetup *setup) return pth; } - fprintf (stderr, "Couldn't find proper templates directory (tried '%s')\n", setup->templates_path); + log_error ("Couldn't find proper templates directory (tried '%s')\n", setup->templates_path); return NULL; } diff --git a/src/stats.c b/src/stats.c new file mode 100644 index 0000000..8469225 --- /dev/null +++ b/src/stats.c @@ -0,0 +1,52 @@ +/* Cataract - Static web photo gallery generator + * Copyright (C) 2009 Tomas Bzatek <tbzatek@users.sourceforge.net> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * 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. + */ + +#include <glib.h> + +#include "stats.h" + + + +G_LOCK_DEFINE_STATIC (stats_errors); +G_LOCK_DEFINE_STATIC (stats_dirs); +G_LOCK_DEFINE_STATIC (stats_images); + + +void +stats_errors_inc () +{ + G_LOCK (stats_errors); + stats_errors++; + G_UNLOCK (stats_errors); +} + +void +stats_dirs_inc () +{ + G_LOCK (stats_dirs); + stats_dirs++; + G_UNLOCK (stats_dirs); +} + +void +stats_images_inc () +{ + G_LOCK (stats_images); + stats_images++; + G_UNLOCK (stats_images); +} diff --git a/src/stats.h b/src/stats.h new file mode 100644 index 0000000..10ac0a3 --- /dev/null +++ b/src/stats.h @@ -0,0 +1,28 @@ +/* Cataract - Static web photo gallery generator + * Copyright (C) 2009 Tomas Bzatek <tbzatek@users.sourceforge.net> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * 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. + */ + + +/* Thread safe statistics counting */ + +int stats_errors; +int stats_dirs; +int stats_images; + +void stats_errors_inc (); +void stats_dirs_inc (); +void stats_images_inc (); diff --git a/src/xml-parser.c b/src/xml-parser.c index eb6c86f..34c0ebd 100644 --- a/src/xml-parser.c +++ b/src/xml-parser.c @@ -29,6 +29,7 @@ #include <glib.h> #include "xml-parser.h" +#include "gallery-utils.h" @@ -46,7 +47,7 @@ xml_parser_load (const char *filename) /* Load XML document */ file->doc = xmlParseFile (filename); if (file->doc == NULL) { - fprintf (stderr, "Error: unable to parse file \"%s\"\n", filename); + log_error ("Error: unable to parse file \"%s\"\n", filename); free (file); return NULL; } @@ -54,7 +55,7 @@ xml_parser_load (const char *filename) /* Create xpath evaluation context */ file->xpathCtx = xmlXPathNewContext (file->doc); if (file->xpathCtx == NULL) { - fprintf (stderr, "Error: unable to create new XPath context\n"); + log_error ("Error: unable to create new XPath context\n"); xmlFreeDoc (file->doc); free (file); return FALSE; @@ -95,7 +96,7 @@ xml_file_get_node_name (TXMLFile *file, const char *x_path) /* Evaluate xpath expression */ xpathObj = xmlXPathEvalExpression ((const xmlChar *) x_path, file->xpathCtx); if (xpathObj == NULL) { - fprintf (stderr, "Error: unable to evaluate xpath expression \"%s\"\n", x_path); + log_error ("Error: unable to evaluate xpath expression \"%s\"\n", x_path); return NULL; } @@ -130,7 +131,7 @@ xml_file_get_node_value (TXMLFile *file, const char *x_path) /* Evaluate xpath expression */ xpathObj = xmlXPathEvalExpression ((const xmlChar *) x_path, file->xpathCtx); if (xpathObj == NULL) { - fprintf (stderr, "Error: unable to evaluate xpath expression \"%s\"\n", x_path); + log_error ("Error: unable to evaluate xpath expression \"%s\"\n", x_path); return NULL; } @@ -185,7 +186,7 @@ xml_file_get_node_attribute (TXMLFile *file, const char *x_path, const char *att /* Evaluate xpath expression */ xpathObj = xmlXPathEvalExpression ((const xmlChar *) x_path, file->xpathCtx); if (xpathObj == NULL) { - fprintf (stderr, "Error: unable to evaluate xpath expression \"%s\"\n", x_path); + log_error ("Error: unable to evaluate xpath expression \"%s\"\n", x_path); return NULL; } @@ -248,7 +249,7 @@ xml_file_node_get_children_count (TXMLFile *file, const char *x_path) /* Evaluate xpath expression */ xpathObj = xmlXPathEvalExpression ((const xmlChar *) x_path, file->xpathCtx); if (xpathObj == NULL) { - fprintf (stderr, "Error: unable to evaluate xpath expression \"%s\"\n", x_path); + log_error ("Error: unable to evaluate xpath expression \"%s\"\n", x_path); return 0; } |
