All windows are now added into the globalconf.windows pointer array.
[luakit.git] / common / util.c
blobe52d8ec4aa48ea2e7c6eb33cbaa2c7fed87f014e
1 /*
2 * util.c - useful functions
4 * Copyright (C) 2010 Mason Larobina <mason.larobina@gmail.com>
5 * Copyright (C) 2007-2008 Julien Danjou <julien@danjou.info>
6 * Copyright (C) 2006 Pierre Habouzit <madcoder@debian.org>
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include <glib/gprintf.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
27 #include "common/util.h"
29 /* Print error and exit with EXIT_FAILURE code. */
30 void
31 _fatal(int line, const char *fct, const char *fmt, ...) {
32 va_list ap;
33 va_start(ap, fmt);
34 g_fprintf(stderr, "E: luakit: %s:%d: ", fct, line);
35 g_vfprintf(stderr, fmt, ap);
36 va_end(ap);
37 g_fprintf(stderr, "\n");
38 exit(EXIT_FAILURE);
41 /* Print error message on stderr. */
42 void
43 _warn(int line, const char *fct, const char *fmt, ...) {
44 va_list ap;
45 va_start(ap, fmt);
46 g_fprintf(stderr, "W: luakit: %s:%d: ", fct, line);
47 g_vfprintf(stderr, fmt, ap);
48 va_end(ap);
49 g_fprintf(stderr, "\n");
52 /* Print debug message on stderr. */
53 void
54 _debug(int line, const char *fct, const char *fmt, ...) {
55 va_list ap;
56 va_start(ap, fmt);
57 g_fprintf(stderr, "D: luakit: %s:%d: ", fct, line);
58 g_vfprintf(stderr, fmt, ap);
59 va_end(ap);
60 g_fprintf(stderr, "\n");
63 gboolean
64 file_exists(const gchar *filename)
66 return (access(filename, F_OK) == 0);