sfeed

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

commit 9d19f7f844be74359b054d3bf395d6fdff5c20f8
parent 99d1766681b543dc0e2e50138c473fbcabd1c809
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  2 Jan 2015 16:49:04 +0100

improve compat

Diffstat:
MMakefile | 43+++++++++++++++++--------------------------
Mconfig.mk | 21+++++++++++++--------
Mutil.h | 14+++++++-------
3 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/Makefile b/Makefile @@ -10,6 +10,7 @@ SRC = \ sfeed_plain.c\ sfeed_web.c\ sfeed_xmlenc.c\ + strlcpy.c\ util.c\ xml.c BIN = \ @@ -45,13 +46,7 @@ HDR = \ util.h\ xml.h -LIBCOMPAT = libcompat.a -LIBCOMPATSRC = \ - compat/strlcpy.c -LIBCOMPATOBJ = $(LIBCOMPATSRC:.c=.o) - -OBJ = ${SRC:.c=.o} \ - $(LIBCOMPATOBJ) +OBJ = ${SRC:.c=.o} all: $(BIN) @@ -88,33 +83,29 @@ doc-oldman: $(MAN1) ${OBJ}: config.mk -$(LIBCOMPAT): $(LIBCOMPATDOBJ) - $(AR) -r -c $@ $? - $(RANLIB) $@ - -sfeed: sfeed.o xml.o util.o - ${CC} -o $@ sfeed.o xml.o util.o ${LDFLAGS} +sfeed: sfeed.o xml.o util.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} -sfeed_opml_import: sfeed_opml_import.o xml.o util.o - ${CC} -o $@ sfeed_opml_import.o xml.o util.o ${LDFLAGS} +sfeed_opml_import: sfeed_opml_import.o xml.o util.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} -sfeed_plain: sfeed_plain.o util.o - ${CC} -o $@ sfeed_plain.o util.o ${LDFLAGS} +sfeed_plain: sfeed_plain.o util.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} -sfeed_html: sfeed_html.o util.o - ${CC} -o $@ sfeed_html.o util.o ${LDFLAGS} +sfeed_html: sfeed_html.o util.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} -sfeed_frames: sfeed_frames.o util.o - ${CC} -o $@ sfeed_frames.o util.o ${LDFLAGS} +sfeed_frames: sfeed_frames.o util.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} -sfeed_xmlenc: sfeed_xmlenc.o xml.o - ${CC} -o $@ sfeed_xmlenc.o xml.o ${LDFLAGS} +sfeed_xmlenc: sfeed_xmlenc.o xml.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} -sfeed_web: sfeed_web.o xml.o util.o - ${CC} -o $@ sfeed_web.o xml.o util.o ${LDFLAGS} +sfeed_web: sfeed_web.o xml.o util.o ${EXTRAOBJ} + ${CC} -o $@ $? ${LDFLAGS} clean: - rm -f ${BIN} ${OBJ} ${LIBCOMPAT} + rm -f ${BIN} ${OBJ} install: all # installing executable files and scripts. diff --git a/config.mk b/config.mk @@ -5,26 +5,31 @@ PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man # includes and libs -INCS = +INCS = -I. LIBS = -lc # debug CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -Wextra -pedantic \ - -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 + ${INCS} \ + -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE LDFLAGS = ${LIBS} # optimized -#CFLAGS = -O2 -std=c99 -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +#CFLAGS = -O2 -std=c99 \ +# ${INCS} \ +# -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE #LDFLAGS = -s ${LIBS} -# tcc -#CC = tcc -#CFLAGS = -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -#LDFLAGS = -s ${LIBS} +# optimized static +#CFLAGS = -static -O2 -std=c99 \ +# ${INCS} \ +# -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE +#LDFLAGS = -static -s ${LIBS} # uncomment for compat CFLAGS += -DCOMPAT -LDFLAGS += -L. -lcompat +# if your libc doesn't support strlcpy.c +EXTRAOBJ = strlcpy.o # compiler and linker #CC = cc diff --git a/util.h b/util.h @@ -2,6 +2,7 @@ #include "compat.h" #endif +#include <stdio.h> #include <time.h> #define ISUTF8(c) (((c) & 0xc0) != 0x80) @@ -20,10 +21,9 @@ enum { FieldUnixTimestamp = 0, FieldTimeFormatted, FieldTitle, FieldLink, FieldContent, FieldContentType, FieldId, FieldAuthor, FieldFeedType, FieldFeedName, FieldFeedUrl, FieldBaseSiteUrl, FieldLast }; -void feedsfree(struct feed *f); -unsigned int parseline(char **line, size_t *size, char **fields, - unsigned int maxfields, int separator, FILE *fp); -void printfeednameid(const char *s, FILE *fp); -void printhtmlencoded(const char *s, FILE *fp); -void printlink(const char *link, const char *baseurl, FILE *fp); -void printutf8pad(FILE *fp, const char *s, size_t len, int pad); +void feedsfree(struct feed *); +unsigned int parseline(char **, size_t *, char **, unsigned int, int, FILE *); +void printfeednameid(const char *, FILE *); +void printhtmlencoded(const char *, FILE *); +void printlink(const char *, const char *, FILE *); +void printutf8pad(FILE *, const char *, size_t, int);