X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Futil.c;h=197f3d8ea17ca09f95b485701357d296feb1190c;hb=cfe3c8f203bd937ca4cadf7ef6c1bd9b2c603e13;hp=420dbd56dd99b7279bcd0f21639859d2981c30e4;hpb=335d816efb8dd7c003e285a19e9434c4119ec13f;p=lackey diff --git a/src/util.c b/src/util.c index 420dbd5..197f3d8 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Andy Spencer + * Copyright (C) 2012,2013 Andy Spencer * * 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 @@ -15,6 +15,9 @@ * along with this program. If not, see . */ +#define _XOPEN_SOURCE +#define _XOPEN_SOURCE_EXTENDED + #include #include #include @@ -81,6 +84,22 @@ void strsub(char *str, char find, char repl) *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) {