sfeed

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

commit f6ad2583a768bfb1ddbc85a5a74e39d4167240ff
parent 853a6fdd6a689ab0e96fd11362ad55fff887f0ab
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  7 Aug 2015 20:46:22 +0200

sfeed_mbox: use simple hash for Message-Id

Diffstat:
Msfeed_mbox.c | 28+++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/sfeed_mbox.c b/sfeed_mbox.c @@ -1,7 +1,9 @@ #include <sys/types.h> #include <err.h> +#include <inttypes.h> #include <limits.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -13,6 +15,23 @@ static char *line = NULL; static size_t linesize = 0; +/* jenkins one-at-a-time hash, used for Message-Id */ +static uint32_t +jenkins1(const char *s) +{ + uint32_t hash = 0; + + for (; *s; s++) { + hash += (int)*s; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); + + return hash + (hash << 15); +} + /* Unescape / decode fields printed by string_print_encoded() * "\\" to "\", "\t", to TAB, "\n" to newline. Unrecognised escape sequences * are ignored: "\z" etc. Mangle "From " in mboxrd style (always prefix >). */ @@ -89,14 +108,17 @@ printfeed(FILE *fp, const char *feedname) "From: %s <sfeed@>\n" "To: %s <%s@%s>\n" "Subject: %s\n" - "Message-ID: <%s-%s-sfeed>\n" + "Message-ID: <%s%s%"PRIu32"@sfeed>\n" "Content-Type: text/%s; charset=UTF-8\n" "Content-Transfer-Encoding: binary\n" "X-Feedname: %s\n" "\n", - mtimebuf, timebuf, fields[FieldAuthor], + mtimebuf, timebuf, + fields[FieldAuthor][0] ? fields[FieldAuthor] : "anonymous", user, user, host, fields[FieldTitle], - fields[FieldUnixTimestamp], fields[FieldId], + fields[FieldUnixTimestamp], + fields[FieldUnixTimestamp][0] ? "." : "", + jenkins1(fields[FieldTitle]), fields[FieldContentType], feedname); if (!strcmp(fields[FieldContentType], "html")) {