File: ve-misc.h

package info (click to toggle)
genius 1.0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 27,952 kB
  • sloc: ansic: 105,597; xml: 67,672; sh: 4,537; makefile: 2,089; lex: 499; yacc: 298; perl: 54; python: 22
file content (94 lines) | stat: -rw-r--r-- 3,335 bytes parent folder | download | duplicates (4)
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
85
86
87
88
89
90
91
92
93
94
/* Misc routines
 *
 * (c) 2000 Eazel, Inc.
 * (c) 2001,2002 George Lebl
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#ifndef VE_MISC_H
#define VE_MISC_H

#include <glib.h>
#include <time.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <locale.h>

char **	ve_split (const char *s);
char *	ve_first_word (const char *s);
gboolean ve_first_word_executable (const char *s, gboolean only_existance);
char *  ve_rest (const char *s);
char **	ve_vector_merge (char * const *v1, char * const *v2);
int	ve_vector_len (char * const *v);

/* Gets the first existing command out of a list separated by semicolons */
char *	ve_get_first_working_command (const char *list,
				      gboolean only_existance);

gboolean ve_bool_equal (gboolean a, gboolean b);

gboolean ve_is_string_in_list (const GList *list,
			       const char *string);
gboolean ve_is_string_in_list_case_no_locale (const GList *list,
					      const char *string);

#define ve_string_empty(x) ((x)==NULL||(x)[0]=='\0')
#define ve_sure_string(x) ((x)!=NULL?(x):"")

/* Find a file using the specified list of directories, an absolute path is
 * just checked, whereas a relative path is search in the given directories,
 */
char *		ve_find_file_simple		(const char *filename,
						 const GList *directories);

/* Find a file using the specified list of directories, an absolute path is
 * just checked, whereas a relative path is search in the given directories,
 * gnome_datadir, g_get_prgname() subdirectory, in GNOME_PATH
 * under /share/ and /share/<g_get_prgname()> */
char *		ve_find_file			(const char *filename,
						 const GList *directories);

/* These two functions will ALWAYS return a non-NULL string,
 * if there is an error, they return the unconverted string */
char * ve_locale_to_utf8 (const char *str);
char * ve_locale_from_utf8 (const char *str);

/* These two functions will ALWAYS return a non-NULL string,
 * if there is an error, they return the unconverted string */
char * ve_filename_to_utf8 (const char *str);
char * ve_filename_from_utf8 (const char *str);

/* works with utf-8 strings and always returns something */
char * ve_strftime (struct tm *the_tm, const char *format);

/* function which doesn't stop on signals */
pid_t ve_waitpid_no_signal (pid_t pid, int *status, int options);

/* Testing for existance of a certain locale */
gboolean ve_locale_exists (const char *loc);

gboolean ve_is_prog_in_path (const char *prog);

char *ve_shell_quote_filename (const char *name);

#define VE_IGNORE_EINTR(expr) \
	do {		\
		errno = 0;	\
		expr;		\
	} while G_UNLIKELY (errno == EINTR);

#endif /* VE_MISC_H */