/*
- * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2012,2013 Andy Spencer <andy753421@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _XOPEN_SOURCE
+#define _XOPEN_SOURCE_EXTENDED
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
*cur = repl;
}
+char *strcopy(const char *str)
+{
+ if (str == NULL)
+ return NULL;
+ return strdup(str);
+}
+
+int match(const char *a, const char *b)
+{
+ if (a == b)
+ return 1;
+ if (!a || !b)
+ return 0;
+ return !strcmp(a, b);
+}
+
/* Memory functions */
void *alloc0(int size)
{
/*
- * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2012,2013 Andy Spencer <andy753421@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* Stirng functions */
void strsub(char *str, char find, char repl);
+char *strcopy(const char *str);
+int match(const char *a, const char *b);
/* Memory functions */
void *alloc0(int size);
static int get_color(const char *cat)
{
return cat == NULL ? 0 :
- !strcmp(cat, "class") ? COLOR_CLASS :
- !strcmp(cat, "ec") ? COLOR_EC :
- !strcmp(cat, "work") ? COLOR_WORK : COLOR_OTHER ;
+ match(cat, "class") ? COLOR_CLASS :
+ match(cat, "ec") ? COLOR_EC :
+ match(cat, "work") ? COLOR_WORK : COLOR_OTHER ;
}
/* Helper functions */
#define _XOPEN_SOURCE_EXTENDED
-#include <string.h>
#include <ncurses.h>
#include "util.h"