summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-10-24 20:59:04 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-10-25 23:00:27 +0200
commit6fb7a2d6189335be489424d9aebc73cd53d151ec (patch)
treec2e748af7c58dee07d75aee29392333b0672b7b3
parent34e4c3f859af9c68d26decc55251b2e940702cef (diff)
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.
-rw-r--r--sfeed_mbox.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sfeed_mbox.c b/sfeed_mbox.c
index 924b6d2..e6c756f 100644
--- 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);