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>
27 #include "common/util.h"
29 /* Print error and exit with EXIT_FAILURE code. */
31 _fatal(int line
, const char *fct
, const char *fmt
, ...) {
34 g_fprintf(stderr
, "E: luakit: %s:%d: ", fct
, line
);
35 g_vfprintf(stderr
, fmt
, ap
);
37 g_fprintf(stderr
, "\n");
41 /* Print error message on stderr. */
43 _warn(int line
, const char *fct
, const char *fmt
, ...) {
46 g_fprintf(stderr
, "W: luakit: %s:%d: ", fct
, line
);
47 g_vfprintf(stderr
, fmt
, ap
);
49 g_fprintf(stderr
, "\n");
52 /* Print debug message on stderr. */
54 _debug(int line
, const char *fct
, const char *fmt
, ...) {
57 g_fprintf(stderr
, "D: luakit: %s:%d: ", fct
, line
);
58 g_vfprintf(stderr
, fmt
, ap
);
60 g_fprintf(stderr
, "\n");
64 file_exists(const gchar
*filename
)
66 return (access(filename
, F_OK
) == 0);