From d7b25b944bccc8c63a971975173f931e4857e2f1 Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Thu, 30 Apr 2026 08:08:34 -0400 Subject: [PATCH] initial commit Signed-off-by: Chloe M. --- .gitignore | 3 +++ Makefile | 26 +++++++++++++++++++++++ README | 4 ++++ core/blobchain.c | 47 ++++++++++++++++++++++++++++++++++++++++++ inc/blobchain/common.h | 11 ++++++++++ 5 files changed, 91 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README create mode 100644 core/blobchain.c create mode 100644 inc/blobchain/common.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1daad9e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.d +/blobchain diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..643dcf2 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +# +# Copyright (c) 2026, Chloe M. +# Provided under the BSD-3 clause +# + +CFILES = $(shell find . -name "*.c") +DFILES = $(CFILES:.c=.d) +OFILES = $(CFILES:.c=.o) + +CC = gcc +CFLAGS = \ + -Wall \ + -pedantic \ + -Iinc/ \ + -MMD + +.PHONY: all +all: blobchain + +.PHONY: blobchain +blobchain: $(OFILES) + $(CC) $< -o $@ + +-include $(DFILES) +%.o: %.c + $(CC) -c $< $(CFLAGS) -o $@ diff --git a/README b/README new file mode 100644 index 0000000..131018e --- /dev/null +++ b/README @@ -0,0 +1,4 @@ +-- Blobchain -- + +The blobchain format allows one to create a list of files and have a content-addressed snapshot of a directory +in the form of a blockchain for verification purposes. diff --git a/core/blobchain.c b/core/blobchain.c new file mode 100644 index 0000000..c593b52 --- /dev/null +++ b/core/blobchain.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause + */ + +#include +#include +#include "blobchain/common.h" + +static void +help(void) +{ + printf("usage: ./blobchain \n"); + printf("... [-h] Display this help menu\n"); + printf("... [-v] Display the version\n"); +} + +static void +version(void) +{ + printf("Version v%s\n", BLOBCHAIN_VERSION); +} + +int +main(int argc, char **argv) +{ + int opt; + + if (argc < 2) { + printf("fatal: too few arguments!\n"); + help(); + return -1; + } + + while ((opt = getopt(argc, argv, "hv")) != -1) { + switch (opt) { + case 'h': + help(); + return -1; + case 'v': + version(); + return -1; + } + } + + return 0; +} diff --git a/inc/blobchain/common.h b/inc/blobchain/common.h new file mode 100644 index 0000000..25739e5 --- /dev/null +++ b/inc/blobchain/common.h @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause + */ + +#ifndef BLOBCHAIN_COMMON_H +#define BLOBCHAIN_COMMON_H 1 + +#define BLOBCHAIN_VERSION "0.0.1" + +#endif /* !BLOBCHAIN_COMMON_H */