]> Pileus Git - wmpus/blobdiff - util.c
X11 updates
[wmpus] / util.c
diff --git a/util.c b/util.c
index 98c40c68a13e89d317992678da38c8361a617ea9..c5f3b9af021c3351488198be26a5ccbbee8bde20 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "util.h"
 
@@ -14,6 +15,18 @@ list_t *list_insert(list_t *next, void *data)
        return node;
 }
 
+list_t *list_append(list_t *head, void *data)
+{
+       list_t *last = head;
+       while (last->next)
+               last = last->next;
+       list_t *node = new0(list_t);
+       node->data = data;
+       node->prev = last;
+       if (last) last->next = node;
+       return last ? head : node;
+}
+
 list_t *list_remove(list_t *head, list_t *node)
 {
        list_t *next = node->next;
@@ -35,3 +48,16 @@ int list_length(list_t *node)
 void list_move(list_t *node, int offset)
 {
 }
+
+/* Misc */
+int error(char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap, fmt);
+       fprintf(stderr, "Error: ");
+       vfprintf(stderr, fmt, ap);
+       fprintf(stderr, "\n");
+       va_end(ap);
+       exit(1);
+       return 0;
+}