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

4 5
#include "gnumeric.h"
#include "numbers.h"
6

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

Chyla Zbigniew's avatar
Chyla Zbigniew committed
10 11 12 13 14
GList   *gnumeric_config_get_string_list (const gchar *config_path,
                                          const gchar *item_name_prefix);
void     gnumeric_config_set_string_list (GList *items,
                                          const gchar *config_path,
                                          const gchar *item_name_prefix);
15

16 17
void	  g_ptr_array_insert (GPtrArray *array, gpointer value, int index);
GList    *g_create_list	     (gpointer item1, ...);
18
gint      g_list_index_custom (GList *list, gpointer data, GCompareFunc cmp_func);
19
void      g_list_free_custom (GList *list, GFreeFunc free_func);
Chyla Zbigniew's avatar
Chyla Zbigniew committed
20 21
GList    *g_string_list_copy (GList *list);
GList    *g_strsplit_to_list (const gchar *string, const gchar *delimiter);
22 23 24 25 26 27 28 29 30 31 32
#define   g_list_to_vector(vector,elem_type,list_expr) \
G_STMT_START { \
	GList *list, *l; \
	gint size, i; \
	list = (list_expr); \
	size = g_list_length (list); \
	(vector) = g_new (elem_type *, size + 1); \
	for (l = list, i = 0; l != NULL; l = l->next, i++) \
		(vector)[i] = (elem_type *) l->data; \
	(vector)[size] = NULL; \
} G_STMT_END
33 34 35 36 37 38 39 40 41 42 43
#define   g_list_to_vector_custom(vector,elem_type,list_expr,conv_func) \
G_STMT_START { \
	GList *list, *l; \
	gint size, i; \
	list = (list_expr); \
	size = g_list_length (list); \
	(vector) = g_new (elem_type *, size + 1); \
	for (l = list, i = 0; l != NULL; l = l->next, i++) \
		(vector)[i] = (elem_type *) conv_func (l->data); \
	(vector)[size] = NULL; \
} G_STMT_END
44 45
#define   g_vector_free_custom(vector_expr,elem_type,free_func_expr) \
G_STMT_START { \
Chyla Zbigniew's avatar
Chyla Zbigniew committed
46
	elem_type **vector, **v; \
47
	GFreeFunc free_func; \
Chyla Zbigniew's avatar
Chyla Zbigniew committed
48 49 50 51
	vector = (vector_expr); \
	free_func = (free_func_expr); \
	for (v = vector; *v != NULL; v++) \
		free_func (*v); \
52 53
	g_free (vector); \
} G_STMT_END
54

55 56
void      g_slist_free_custom (GSList *list, GFreeFunc free_func);

57 58 59
#define   g_lang_score_is_better(score_a, score_b) (score_a < score_b)
gint      g_lang_score_in_lang_list (gchar *lang, GList *lang_list);

60 61 62 63 64 65 66 67
guint     gnumeric_strcase_hash  (gconstpointer v);
gint      gnumeric_strcase_equal (gconstpointer v, gconstpointer v2);

/**
 * System and user paths
 */
char *    gnumeric_sys_lib_dir    (const char *subdir);
char *    gnumeric_sys_data_dir   (const char *subdir);
68 69
char *    gnumeric_sys_glade_dir  (void);
char *    gnumeric_sys_plugin_dir (void);
70 71

char *    gnumeric_usr_dir        (const char *subdir);
72
char *    gnumeric_usr_plugin_dir (void);
73

74 75 76 77 78 79 80 81 82 83
/*
 * Function to help with accessing non-aligned little-endian data.
 */
gint16    gnumeric_get_le_int16 (const void *p);
guint16   gnumeric_get_le_uint16 (const void *p);
gint32    gnumeric_get_le_int32 (const void *p);
guint32   gnumeric_get_le_uint32 (const void *p);
double    gnumeric_get_le_double (const void *p);
void      gnumeric_set_le_double (void *p, double d);

84 85
char *    gnumeric_strescape (const char *string);

86
#endif /* GNUMERIC_UTILS_H */