sfeed

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

commit 6fb7a2d6189335be489424d9aebc73cd53d151ec
parent 34e4c3f859af9c68d26decc55251b2e940702cef
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 24 Oct 2021 20:59:04 +0200

sfeed_mbox: use 64-bit for the checksum number

This makes the checksum number atleast 64-bit and makes the Message-ID header
consistent across mixed 32-bit and 64-bit systems.

Tested on amd64 and MIPS32BE.

Diffstat:
Msfeed_mbox.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sfeed_mbox.c b/sfeed_mbox.c @@ -11,8 +11,8 @@ static size_t linesize; static char host[256], *user, dtimebuf[32], mtimebuf[32]; static int usecontent = 0; /* env variable: $SFEED_MBOX_CONTENT */ -static unsigned long -djb2(unsigned char *s, unsigned long hash) +static unsigned long long +djb2(unsigned char *s, unsigned long long hash) { int c; @@ -59,14 +59,14 @@ printfeed(FILE *fp, const char *feedname) char *fields[FieldLast], timebuf[32]; struct tm parsedtm, *tm; time_t parsedtime; - unsigned long hash; + unsigned long long hash; ssize_t linelen; int ishtml; while ((linelen = getline(&line, &linesize, fp)) > 0) { if (line[linelen - 1] == '\n') line[--linelen] = '\0'; - hash = djb2((unsigned char *)line, 5381UL); + hash = djb2((unsigned char *)line, 5381ULL); parseline(line, fields); /* mbox + mail header */ @@ -84,7 +84,7 @@ printfeed(FILE *fp, const char *feedname) printf("From: %s <sfeed@>\n", fields[FieldAuthor][0] ? fields[FieldAuthor] : feedname); printf("To: %s <%s@%s>\n", user, user, host); printf("Subject: %s\n", fields[FieldTitle]); - printf("Message-ID: <%s%s%lu@%s>\n", + printf("Message-ID: <%s%s%llu@%s>\n", fields[FieldUnixTimestamp], fields[FieldUnixTimestamp][0] ? "." : "", hash, feedname);