]>
Commit | Line | Data |
---|---|---|
7d02a0b0 GB |
1 | /* |
2 | * viking -- GPS Data and Topo Analyzer, Explorer, and Manager | |
3 | * | |
a482007a | 4 | * Copyright (C) 2007-2009, Guilhem Bonnefille <guilhem.bonnefille@gmail.com> |
6a280b85 | 5 | * Copyright (C) 2014, Rob Norris <rw_norris@hotmail.com> |
7d02a0b0 | 6 | * Based on: |
a482007a | 7 | * Copyright (C) 2003-2007, Leandro A. F. Pereira <leandro@linuxmag.com.br> |
7d02a0b0 GB |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | */ | |
24 | ||
25 | #ifndef _VIKING_UTIL_H | |
26 | #define _VIKING_UTIL_H | |
27 | ||
28 | #include <glib.h> | |
7d02a0b0 | 29 | |
722b5481 RN |
30 | G_BEGIN_DECLS |
31 | ||
6b6225cb RN |
32 | guint util_get_number_of_cpus (void); |
33 | ||
0da89d90 | 34 | gboolean split_string_from_file_on_equals ( const gchar *buf, gchar **key, gchar **val ); |
9106934d | 35 | |
44871dd1 RN |
36 | void util_add_to_deletion_list ( const gchar* filename ); |
37 | void util_remove_all_in_deletion_list ( void ); | |
38 | ||
6a280b85 RN |
39 | gchar *util_str_remove_chars(gchar *string, const gchar *chars); |
40 | ||
41 | /** Returns @c TRUE if @a ptr is @c NULL or @c *ptr is @c FALSE. */ | |
42 | #define EMPTY(ptr) \ | |
43 | (!(ptr) || !*(ptr)) | |
44 | ||
45 | /** Iterates all the nodes in @a list. | |
46 | * @param node should be a (@c GList*). | |
47 | * @param list @c GList to traverse. */ | |
48 | #define foreach_list(node, list) \ | |
49 | for (node = list; node != NULL; node = node->next) | |
50 | ||
51 | /** Iterates all the nodes in @a list. | |
52 | * @param node should be a (@c GSList*). | |
53 | * @param list @c GSList to traverse. */ | |
54 | #define foreach_slist(node, list) \ | |
55 | foreach_list(node, list) | |
56 | ||
57 | /** Iterates through each character in @a string. | |
58 | * @param char_ptr Pointer to character. | |
59 | * @param string String to traverse. | |
60 | * @warning Doesn't include null terminating character. */ | |
61 | #define foreach_str(char_ptr, string) \ | |
62 | for (char_ptr = string; *char_ptr; char_ptr++) | |
63 | ||
81bf47ee RN |
64 | int util_remove ( const gchar *filename ); |
65 | ||
73def8cb RN |
66 | gchar* util_write_tmp_file_from_bytes ( const void *buffer, gsize count ); |
67 | ||
872840c0 RN |
68 | gchar* util_make_absolute_filename ( const gchar *filename, const gchar *dirpath ); |
69 | ||
70 | void util_make_absolute_filenames ( GList *filenames, const gchar *dirpath ); | |
71 | ||
722b5481 RN |
72 | G_END_DECLS |
73 | ||
7d02a0b0 | 74 | #endif |