sfeed

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

commit c3b5da658eeef51b1444060aa107fc413ea0f436
parent 79eb0f67b83fca3d8917845fe0c913cd0e10e2f2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 13 May 2014 10:06:27 +0000

util: use standard getline() function to get lines

this is standard since POSIX 200809L

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

Diffstat:
Mutil.c | 38+-------------------------------------
1 file changed, 1 insertion(+), 37 deletions(-)

diff --git a/util.c b/util.c @@ -33,43 +33,7 @@ strlcpy(char *dst, const char *src, size_t siz) { while (*s++) ; } - return(s - src - 1); /* count does not include NUL */ -} - -char * -afgets(char **p, size_t *size, FILE *fp) { - char buf[BUFSIZ], *alloc = NULL; - size_t n, len = 0, allocsiz; - int end = 0; - - while(!end && !feof(fp) && fgets(buf, sizeof(buf), fp)) { - n = strlen(buf); - if(buf[n - 1] == '\n') { /* dont store newlines. */ - buf[n - 1] = '\0'; - n--; - end = 1; /* newline found, end */ - } - len += n; - allocsiz = len + 1; - if(allocsiz > *size) { - if((alloc = realloc(*p, allocsiz))) { - *p = alloc; - *size = allocsiz; - } else { - free(*p); - *p = NULL; - fputs("error: could not realloc\n", stderr); - exit(EXIT_FAILURE); - return NULL; - } - } - strlcpy((*p + (len - n)), buf, n + 1); - } - if(*p && len > 0) { - (*p)[len] = '\0'; - return *p; - } - return NULL; + return(s - src - 1); /* count does not include NUL */ } /* print link; if link is relative use baseurl to make it absolute */