summaryrefslogtreecommitdiff
path: root/src/gallery-utils.h
blob: 29c7d8fb602abfa6670253874e0008254d963c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*   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 __CGG__GALLERY_UTILS_H__
#define __CGG__GALLERY_UTILS_H__

#include <glib.h>
#include <string.h>

G_BEGIN_DECLS


#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '~')
#define IS_EQUAL_SIGN(ch) ((ch) == '=')

/*
 *   str_replace: replace substring 'search' with a 'replace' string
 *                - multiple occurences of the string are replaced
 *                - reallocates the original string
 */
void str_replace (gchar **dst, const gchar *search, const gchar *replace);

/*
 *   copy_file: copy file from src to dst
 */
gboolean copy_file (const gchar *src, const gchar *dst);

/*
 *   make_string: make string of 'substr' substrings
 *                - returns newly allocated string
 */
gchar * make_string (const gchar *substr, int count);

/*
 *   fix_entities: replace all invalid & entities with &amp;
 *                 - returns newly allocated string
 */
void fix_entities (gchar **str);

/*
 *   remove_tags: remove all occurences of tags beginning with tag_begin and ending with tag_end
 *                - e.g.  remove_tags (&x, "<!--", "-->") will remove all comments
 *                - returns newly allocated string
 */
void remove_tags (gchar **str, const gchar *tag_begin, const gchar *tag_end);

/*
 *   count_dir_levels: returns number of path elements
 */
int count_dir_levels (const gchar *path);

/*
 *   extract_file_ext: returns pointer to filename extension
 */
const gchar * extract_file_ext (const gchar *filename);

/*
 *   log_error: prints an error and increments stats
 */
void log_error (const gchar *format, ...) G_GNUC_PRINTF (1, 2);

/*
 *   needs_update: returns TRUE if the destionation file needs updating, also when missing
 */
gboolean needs_update (const gchar *source, const gchar *dest);


G_END_DECLS

#endif /* __CGG__GALLERY_UTILS_H__ */