sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 8b4664f694eee80e78903605e21fee770ba7cedf
parent dd0baa3e7b32fb66f2f8c1fa8cb41cae3f4feca4
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  2 Jan 2015 14:35:53 +0100

compat: separate compat stuff, strlcpy atm

Diffstat:
Mutil.c | 30------------------------------
Mutil.h | 7++++---
2 files changed, 4 insertions(+), 33 deletions(-)

diff --git a/util.c b/util.c @@ -8,36 +8,6 @@ #include "util.h" -/* - * Taken from OpenBSD. - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - /* copy as many bytes as will fit */ - if (n != 0) { - while (--n != 0) { - if ((*d++ = *s++) == '\0') - break; - } - } - /* not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - return(s - src - 1); /* count does not include NUL */ -} - /* print link; if link is relative use baseurl to make it absolute */ void printlink(const char *link, const char *baseurl, FILE *fp) diff --git a/util.h b/util.h @@ -1,3 +1,7 @@ +#ifdef COMPAT +#include "compat.h" +#endif + #include <time.h> #define ISUTF8(c) (((c) & 0xc0) != 0x80) @@ -16,9 +20,6 @@ enum { FieldUnixTimestamp = 0, FieldTimeFormatted, FieldTitle, FieldLink, FieldContent, FieldContentType, FieldId, FieldAuthor, FieldFeedType, FieldFeedName, FieldFeedUrl, FieldBaseSiteUrl, FieldLast }; -#undef strlcpy -size_t strlcpy(char *, const char *, size_t); - void feedsfree(struct feed *f); unsigned int parseline(char **line, size_t *size, char **fields, unsigned int maxfields, int separator, FILE *fp);