4 /* `str' should be type char[MAX_INT_STRLEN] */
5 #define ltoa(str, num) \
6 g_snprintf(str, sizeof(str), "%d", num)
8 typedef void* (*FOREACH_FIND_FUNC) (void *item, void *data);
9 typedef int (*COLUMN_LEN_FUNC)(void *data);
11 static inline int nearest_power(int num)
15 while (n < num) n <<= 1;
19 /* Returns 1 if tv1 > tv2, -1 if tv2 > tv1 or 0 if they're equal. */
20 int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2);
21 /* Returns "tv1 - tv2", returns the result in milliseconds. Note that
22 if the difference is too large, the result might be invalid. */
23 long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2);
25 /* find `item' from a space separated `list' */
26 int find_substr(const char *list, const char *item);
27 /* return how many items `array' has */
28 int strarray_length(char **array);
29 /* return index of `item' in `array' or -1 if not found */
30 int strarray_find(char **array, const char *item);
32 int execute(const char *cmd); /* returns pid or -1 = error */
34 GSList *gslist_find_string(GSList *list, const char *key);
35 GSList *gslist_find_icase_string(GSList *list, const char *key);
36 GList *glist_find_string(GList *list, const char *key);
37 GList *glist_find_icase_string(GList *list, const char *key);
39 void *gslist_foreach_find(GSList *list, FOREACH_FIND_FUNC func, const void *data);
41 /* `list' contains pointer to structure with a char* to string. */
42 char *gslistptr_to_string(GSList *list, int offset, const char *delimiter);
43 /* `list' contains char* */
44 char *gslist_to_string(GSList *list, const char *delimiter);
46 /* save all keys in hash table to linked list - you shouldn't remove any
47 items while using this list, use g_slist_free() after you're done with it */
48 GSList *hashtable_get_keys(GHashTable *hash);
50 /* strstr() with case-ignoring */
51 char *stristr(const char *data, const char *key);
53 /* like strstr(), but matches only for full words.
54 `icase' specifies if match is case sensitive */
55 char *strstr_full_case(const char *data, const char *key, int icase);
56 char *strstr_full(const char *data, const char *key);
57 char *stristr_full(const char *data, const char *key);
59 /* easy way to check if regexp matches */
60 int regexp_match(const char *str, const char *regexp);
62 /* Create the directory and all it's parent directories */
63 int mkpath(const char *path, int mode);
65 /* Get home directory */
66 const char *get_home_dir(void);
68 /* convert ~/ to $HOME */
69 char *convert_home(const char *path);
71 /* Case-insensitive string hash functions */
72 int g_istr_equal(gconstpointer v, gconstpointer v2);
73 unsigned int g_istr_hash(gconstpointer v);
75 /* Case-insensitive GCompareFunc func */
76 int g_istr_cmp(gconstpointer v, gconstpointer v2);
78 /* Find `mask' from `data', you can use * and ? wildcards. */
79 int match_wildcards(const char *mask, const char *data);
81 /* Return TRUE if all characters in `str' are numbers.
82 Stop when `end_char' is found from string. */
83 int is_numeric(const char *str, char end_char);
85 /* replace all `from' chars in string to `to' chars. returns `str' */
86 char *replace_chars(char *str, char from, char to);
88 /* octal <-> decimal conversions */
89 int octal2dec(int octal);
90 int dec2octal(int decimal);
92 /* convert all low-ascii (<32) to ^<A..> combinations */
93 char *show_lowascii(const char *channel);
95 /* Get time in human readable form with localtime() + asctime() */
96 char *my_asctime(time_t t);
98 /* Returns number of columns needed to print items.
99 save_column_widths is filled with length of each column. */
100 int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
101 int max_width, int max_columns,
102 int item_extra, int item_min_size,
103 int **save_column_widths, int *rows);
105 /* Return a column sorted copy of a list. */
106 GSList *columns_sort_list(GSList *list, int rows);
108 /* Expand escape string, the first character in data should be the
109 one after '\'. Returns the expanded character or -1 if error. */
110 int expand_escape(const char **data);