sfeed

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

commit f6a0aabfa27e19ad57823e104db7eac1252e6f1f
parent 5acace38c73074fa08c8b44d1109cfc9c6b0d66e
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 27 Jun 2014 15:42:53 +0200

small fixes

reorder static -> public xml functions.

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

Diffstat:
Msfeed_plain.c | 3++-
Msfeed_stats.c | 1+
Msfeed_web.c | 2+-
Mutil.c | 6++++++
Mxml.c | 19+++++++++++--------
5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/sfeed_plain.c b/sfeed_plain.c @@ -10,7 +10,8 @@ printutf8padded(FILE *fp, const char *s, size_t len, int pad) { size_t n = 0, i; for(i = 0; s[i] && n < len; i++) { - if((s[i] & 0xc0) != 0x80) /* start of character */ + /* start of character */ + if((s[i] & 0xc0) != 0x80) n++; putc(s[i], fp); } diff --git a/sfeed_stats.c b/sfeed_stats.c @@ -12,6 +12,7 @@ static char *line = NULL; static void cleanup(void) { free(line); /* free line */ + line = NULL; feedsfree(feeds); /* free feeds linked-list */ } diff --git a/sfeed_web.c b/sfeed_web.c @@ -26,7 +26,7 @@ xmltagstartparsed(XMLParser *p, const char *tag, size_t taglen, int isshort) { if(isfeedlink) { if(*feedtype) { fputs(feedtype, stdout); - putchar(' ' ); + putchar(' '); } printlink(feedlink, basehref, stdout); putchar('\n'); diff --git a/util.c b/util.c @@ -76,6 +76,12 @@ printlink(const char *link, const char *baseurl, FILE *fp) { fputs(link, fp); } +/* read a field-separated line from 'fp', + * separated by a character 'separator', + * 'fields' is a list of pointer with a maximum size of 'maxfields'. + * 'line' buffer is allocated using malloc, 'size' will contain the + * allocated buffer size. + * returns: amount of fields read. */ unsigned int parseline(char **line, size_t *size, char **fields, unsigned int maxfields, int separator, FILE *fp) diff --git a/xml.c b/xml.c @@ -5,20 +5,17 @@ #include "xml.h" -void -xmlparser_init(XMLParser *x, FILE *fp) { - memset(x, 0, sizeof(XMLParser)); - x->fp = fp; -} - static __inline__ int /* like getc(), but do some smart buffering */ xmlparser_getnext(XMLParser *x) { + return fgetc(x->fp); +#if 0 if(x->readoffset >= x->readlastbytes) { x->readoffset = 0; if(!(x->readlastbytes = fread(x->readbuf, 1, sizeof(x->readbuf), x->fp))) return EOF; /* 0 bytes read, assume EOF */ } return (int)x->readbuf[x->readoffset++]; +#endif } static __inline__ void @@ -141,7 +138,7 @@ xmlparser_parsecomment(XMLParser *x) { i = 0; } /* || (c == '-' && d >= sizeof(x->data) - 4)) { */ - /* TODO: what if the end has --, and its cut on the boundary, test this. */ + /* TODO: what if the end has --, and it's cut on the boundary, test this. */ if(datalen < sizeof(x->data) - 1) x->data[datalen++] = c; else { @@ -185,7 +182,7 @@ xmlparser_parsecdata(XMLParser *x) { } i = 0; } - /* TODO: what if the end has ]>, and its cut on the boundary */ + /* TODO: what if the end has ]>, and it's cut on the boundary */ if(datalen < sizeof(x->data) - 1) { x->data[datalen++] = c; } else { @@ -199,6 +196,12 @@ xmlparser_parsecdata(XMLParser *x) { } void +xmlparser_init(XMLParser *x, FILE *fp) { + memset(x, 0, sizeof(XMLParser)); + x->fp = fp; +} + +void xmlparser_parse(XMLParser *x) { int c, ispi; size_t datalen, tagdatalen, taglen;