gutils.h 3.37 KB
Newer Older
1 2
#ifndef GNUMERIC_UTILS_H
#define GNUMERIC_UTILS_H
3

4 5
#include "gnumeric.h"
#include "numbers.h"
6
#include <sys/types.h>
7

8 9 10
void     gnumeric_time_counter_push (void);
gdouble  gnumeric_time_counter_pop (void);

11 12
typedef gpointer (*GnmMapFunc) (gpointer value);

13
void	  g_ptr_array_insert (GPtrArray *array, gpointer value, int index);
Jody Goldberg's avatar
Jody Goldberg committed
14
int	  g_str_compare	     (void const *x, void const *y);
15
GList    *g_create_list	     (gpointer item1, ...);
16
gint      g_list_index_custom (GList *list, gpointer data, GCompareFunc cmp_func);
17
void      g_list_free_custom (GList *list, GFreeFunc free_func);
18 19 20 21 22 23 24 25 26 27 28
#define GNM_LIST_FOREACH(list,valtype,val,stmnt) \
G_STMT_START { \
	GList *gnm_l; \
	for (gnm_l = (list); gnm_l != NULL; gnm_l = gnm_l->next) { \
		valtype *val = gnm_l->data; \
		stmnt \
		; \
	} \
} G_STMT_END
#define GNM_LIST_PREPEND(list,item) \
	(list = g_list_prepend (list, item))
Zbigniew Chyla's avatar
Zbigniew Chyla committed
29 30
#define GNM_LIST_APPEND(list,item) \
	(list = g_list_append (list, item))
31 32 33 34 35 36
#define GNM_LIST_REMOVE(list,item) \
	(list = g_list_remove (list, item))
#define GNM_LIST_CONCAT(list_a,list_b) \
	(list_a = g_list_concat (list_a, list_b))
#define GNM_LIST_REVERSE(list) \
	(list = g_list_reverse (list))
37 38
#define GNM_LIST_SORT(list,cmp_func) \
	(list = g_list_sort (list, cmp_func))
39

40
GSList   *g_slist_map        (GSList const *list, GnmMapFunc map_func);
41
GSList    *g_create_slist	     (gpointer item1, ...);
42
void      g_slist_free_custom (GSList *list, GFreeFunc free_func);
Zbigniew Chyla's avatar
Zbigniew Chyla committed
43
#define   g_string_slist_copy(list) g_slist_map (list, (GnmMapFunc) g_strdup)
44
GSList    *g_strsplit_to_slist (const gchar *string, const gchar *delimiter);
45 46
#define GNM_SLIST_FOREACH(list,valtype,val,stmnt) \
G_STMT_START { \
47
	GSList const *gnm_l; \
48 49 50 51 52 53 54 55
	for (gnm_l = (list); gnm_l != NULL; gnm_l = gnm_l->next) { \
		valtype *val = gnm_l->data; \
		stmnt \
		; \
	} \
} G_STMT_END
#define GNM_SLIST_PREPEND(list,item) \
	(list = g_slist_prepend (list, item))
Zbigniew Chyla's avatar
Zbigniew Chyla committed
56 57
#define GNM_SLIST_APPEND(list,item) \
	(list = g_slist_append (list, item))
58 59 60 61 62 63
#define GNM_SLIST_REMOVE(list,item) \
	(list = g_slist_remove (list, item))
#define GNM_SLIST_CONCAT(list_a,list_b) \
	(list_a = g_slist_concat (list_a, list_b))
#define GNM_SLIST_REVERSE(list) \
	(list = g_slist_reverse (list))
64 65 66
#define GNM_SLIST_SORT(list,cmp_func) \
	(list = g_slist_sort (list, cmp_func))

67 68
guint     gnumeric_ascii_strcase_hash  (gconstpointer v);
gint      gnumeric_ascii_strcase_equal (gconstpointer v, gconstpointer v2);
69
gint      gnumeric_utf8_collate_casefold (const char *a, const char *b);
70 71 72 73 74 75

/**
 * System and user paths
 */
char *    gnumeric_sys_lib_dir    (const char *subdir);
char *    gnumeric_sys_data_dir   (const char *subdir);
76 77
char *    gnumeric_sys_glade_dir  (void);
char *    gnumeric_sys_plugin_dir (void);
78 79

char *    gnumeric_usr_dir        (const char *subdir);
80
char *    gnumeric_usr_plugin_dir (void);
81

82
void      gnm_strescape (GString *target, const char *string);
Morten Welinder's avatar
Morten Welinder committed
83
const char *gnm_strunescape (GString *target, const char *string);
84

85 86
char *    gnumeric_utf8_strcapital (const char *p, ssize_t len);

Morten Welinder's avatar
Morten Welinder committed
87 88
gboolean  gnumeric_valid_filename (const char *filename);

89
gnm_mem_chunk *gnm_mem_chunk_new (const char *, size_t, size_t);
90
void gnm_mem_chunk_destroy (gnm_mem_chunk *, gboolean);
91 92 93
gpointer gnm_mem_chunk_alloc (gnm_mem_chunk *);
gpointer gnm_mem_chunk_alloc0 (gnm_mem_chunk *);
void gnm_mem_chunk_free (gnm_mem_chunk *, gpointer);
Morten Welinder's avatar
Morten Welinder committed
94
void gnm_mem_chunk_foreach_leak (gnm_mem_chunk *, GFunc, gpointer);
95

96
#endif /* GNUMERIC_UTILS_H */