summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-11-28 19:59:36 -0500
committerJune McEnroe <june@causal.agency>2020-11-28 21:11:49 -0500
commitab563dd4f7101b11d251e675ac504e63770df357 (patch)
tree429df7caf33709300f86894f81cef708ae6ecb84
parentUnlink existing UNIX socket if it can't be connected to (diff)
downloadpounce-2.1p1.tar.gz
pounce-2.1p1.zip
Use uint64_t for save file signature 2.1p1
This fixes building on 32-bit platforms.
-rw-r--r--ring.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ring.c b/ring.c
index e675526..0a46b09 100644
--- a/ring.c
+++ b/ring.c
@@ -27,6 +27,8 @@
 
 #include <assert.h>
 #include <err.h>
+#include <inttypes.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/time.h>
@@ -139,17 +141,17 @@ void ringInfo(void) {
 	}
 }
 
-static const size_t Signatures[] = {
+static const uint64_t Signatures[] = {
 	0x0165636E756F70, // no ring size
 	0x0265636E756F70, // time_t only
 	0x0365636E756F70,
 };
 
-static size_t signatureVersion(size_t signature) {
+static size_t signatureVersion(uint64_t signature) {
 	for (size_t i = 0; i < ARRAY_LEN(Signatures); ++i) {
 		if (signature == Signatures[i]) return i;
 	}
-	errx(EX_DATAERR, "unknown file signature %zX", signature);
+	errx(EX_DATAERR, "unknown file signature %" PRIX64, signature);
 }
 
 static int writeSize(FILE *file, size_t value) {
@@ -163,7 +165,7 @@ static int writeString(FILE *file, const char *str) {
 }
 
 int ringSave(FILE *file) {
-	if (writeSize(file, Signatures[2])) return -1;
+	if (!fwrite(&Signatures[2], sizeof(*Signatures), 1, file)) return -1;
 	if (writeSize(file, ring.len)) return -1;
 	if (writeSize(file, producer)) return -1;
 	if (writeSize(file, consumers.len)) return -1;
@@ -202,7 +204,7 @@ static void readString(FILE *file, char **buf, size_t *cap) {
 }
 
 void ringLoad(FILE *file) {
-	size_t signature;
+	uint64_t signature;
 	fread(&signature, sizeof(signature), 1, file);
 	if (ferror(file)) err(EX_IOERR, "fread");
 	if (feof(file)) return;
logmsg'> 2024-10-12Add photos from October 5June McEnroe 2024-10-09Add photos from October 1June McEnroe Ok the first 3 are from September 29 but I didn't want to spoil the black and white roll. 2024-10-07Add photos from September 29June McEnroe 2024-10-07Add photos from September 28June McEnroe 2024-10-07Add photos from September 22June McEnroe 2024-09-25Add photos from September 15June McEnroe 2024-09-24Add photos from September 14June McEnroe 2024-09-24Add photos from September 12June McEnroe 2024-09-24Add photos from September 7June McEnroe 2024-09-24Allow not having descriptionsJune McEnroe I'm sorry, I can't keep writing descriptions. It makes posting photos take too long, I often don't know the words for what I'm looking at, and a good description is an entirely different work of art than the photo I took, and I'm just a photographer. It's visual art. 2024-09-23Automatically select the last used lens for a bodyJune McEnroe 2024-09-19Add photos from September 5June McEnroe Had to prefix the folder number onto these file names manually because they must have come out of a different scanner or something. 2024-09-15Add some more film stocks to the listJune McEnroe 2024-09-13Add photos from September 2June McEnroe 2024-09-13Add Fomapan 200 to films listJune McEnroe 2024-09-10Add August 29 picnic photosJune McEnroe 2024-09-08Apply some bold to trips renderingJune McEnroe This seems easier to visually scan. The only other thing I'd like is a nicer date rendering but JavaScript is useless for that. 2024-09-08Render trips hopefully more efficientlyJune McEnroe 2024-09-08Allow removing bodies and lensesJune McEnroe 2024-09-08Limit body width so it looks less silly on desktopJune McEnroe 2024-09-07Handle no film being loadedJune McEnroe 2024-09-07Fancy up the text a littleJune McEnroe