From 0eb816b94d09b05136c8c6e83058a5a0bc01d990 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 16 Oct 2006 14:43:31 +0200 Subject: [PATCH] eprint fix --- util.c | 39 --------------------------------------- wm.c | 14 +++++++------- 2 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 util.c diff --git a/util.c b/util.c deleted file mode 100644 index 283d8b0a..00000000 --- a/util.c +++ /dev/null @@ -1,39 +0,0 @@ -/* (C)opyright MMVI Anselm R. Garbe - * See LICENSE file for license details. - */ -#include "wm.h" -#include -#include -#include -#include -#include - -/* extern */ - -void * -emallocz(unsigned int size) { - void *res = calloc(1, size); - - if(!res) - eprint("fatal: could not malloc() %u bytes\n", size); - return res; -} - -void -eprint(const char *errstr, ...) { - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - -void * -erealloc(void *ptr, unsigned int size) { - void *res = realloc(ptr, size); - - if(!res) - eprint("fatal: could not malloc() %u bytes\n", size); - return res; -} diff --git a/wm.c b/wm.c index c894046d..bd54a2e0 100644 --- a/wm.c +++ b/wm.c @@ -210,7 +210,7 @@ main(int argc, char *argv[]) { starting = True; blz.dpy = XOpenDisplay(0); if(!blz.dpy) - error("wmiiwm: cannot open dpy\n"); + ixp_eprint("wmiiwm: cannot open dpy\n"); blz.screen = DefaultScreen(blz.dpy); blz.root = RootWindow(blz.dpy, blz.screen); /* check if another WM is already running */ @@ -220,7 +220,7 @@ main(int argc, char *argv[]) { XSelectInput(blz.dpy, blz.root, SubstructureRedirectMask | EnterWindowMask); XSync(blz.dpy, False); if(other_wm_running) - error("wmiiwm: another window manager is already running\n"); + ixp_eprint("wmiiwm: another window manager is already running\n"); if(!address) usage(); /* Check namespace permissions */ @@ -231,10 +231,10 @@ main(int argc, char *argv[]) { if(namespace[i] == '/') break; namespace[i+1] = '\0'; if(stat(namespace, &st)) - error("wmiiwm: can't stat namespace directory \"%s\": %s\n", + ixp_eprint("wmiiwm: can't stat namespace directory \"%s\": %s\n", namespace, strerror(errno)); if(getuid() != st.st_uid) - error("wmiiwm: namespace directory \"%s\" exists, but is not owned by you", + ixp_eprint("wmiiwm: namespace directory \"%s\" exists, but is not owned by you", namespace); if(st.st_mode & 077) error("wmiiwm: namespace directory \"%s\" exists, " @@ -247,7 +247,7 @@ main(int argc, char *argv[]) { errstr = NULL; i = ixp_create_sock(address, &errstr); if(i < 0) - error("wmiiwm: fatal: %s\n", errstr); + ixp_eprint("wmiiwm: fatal: %s\n", errstr); /* start wmiirc */ if(wmiirc) { @@ -256,12 +256,12 @@ main(int argc, char *argv[]) { switch(fork()) { case 0: if(setsid() == -1) - error("wmiim: can't setsid: %s\n", strerror(errno)); + ixp_eprint("wmiim: can't setsid: %s\n", strerror(errno)); close(i); close(ConnectionNumber(blz.dpy)); snprintf(execstr, name_len, "exec %s", wmiirc); execl("/bin/sh", "sh", "-c", execstr, NULL); - error("wmiiwm: can't exec \"%s\": %s\n", wmiirc, strerror(errno)); + ixp_eprint("wmiiwm: can't exec \"%s\": %s\n", wmiirc, strerror(errno)); case -1: perror("wmiiwm: cannot fork wmiirc"); default: