sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit 3003c3ab6912570f3ee01a99971bd82f31180627
parent ed133b0000e8b8cdabf038bf40e457fac2cc428c
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 20 May 2013 19:30:04 +0200

add compat files to make compile with older compilers, mostly for mingw and dos, ugly

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
Acompat.c | 41+++++++++++++++++++++++++++++++++++++++++
Acompat.h | 17+++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/compat.c b/compat.c @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <sys/stat.h> +#include <sys/types.h> + +int +xstrcasecmp(const char *_l, const char *_r) { + const unsigned char *l = (void *)_l, *r = (void *)_r; + for(; *l && *r && (*l == *r || tolower(*l) == tolower(*r)); l++, r++); + return tolower(*l) - tolower(*r); +} + +int +xstrncasecmp(const char *_l, const char *_r, size_t n) { + const unsigned char *l=(void *)_l, *r=(void *)_r; + if(!n--) + return 0; + for(; *l && *r && n && (*l == *r || tolower(*l) == tolower(*r)); l++, r++, n--); + return tolower(*l) - tolower(*r); +} + +void * +xstrdup(const char *s) { + size_t len = strlen(s) + 1; + void *p = malloc(len); + if(p) + memcpy(p, s, len); + return p; +} + +int +xmkdir(const char *path, mode_t mode) { +/* TODO: fix for mingw */ +#if MINGW + return mkdir(path); +#else + return mkdir(path, mode); +#endif +} diff --git a/compat.h b/compat.h @@ -0,0 +1,17 @@ +#if 1 +#include <strings.h> +#include <string.h> +#define xstrcasecmp strcasecmp +#define xstrncasecmp strncasecmp +#else +int xstrcasecmp(const char *s1, const char *s2); +int xstrncasecmp(const char *s1, const char *s2, size_t len); +#endif + +/* non-ansi */ +void * xstrdup(const char *s); + +/* for mingw */ +#include <sys/stat.h> +#include <sys/types.h> +int xmkdir(const char *path, mode_t mode);