summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/rdar.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/core/rdar.c b/core/rdar.c
new file mode 100644
index 0000000..ff5022f
--- /dev/null
+++ b/core/rdar.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2026, Chloe M.
+ * Provided under the BSD-3 clause.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stddef.h>
+
+/* Version conversion macros */
+#define VERSION_U16(MAJOR, MINOR) \
+ (((MINOR) << 8) | (MAJOR))
+#define VERSION_MAJOR(VERSION) \
+ ((VERSION) & 0xFF)
+#define VERSION_MINOR(VERSION) \
+ (((VERSION) >> 8) & 0xFF)
+
+/*
+ * Software version
+ *
+ * XXX: We encode it as a U16 so that we may bundle it
+ * with the file data as binary.
+ */
+#define RDAR_VERSION VERSION_U16(1, 0) /* v1.0 */
+
+static void
+help(void)
+{
+ printf("usage: ./rdar <... flags>\n");
+ printf("[-h] Display this help menu\n");
+ printf("[-v] Display the program version\n");
+}
+
+static void
+version(void)
+{
+ uint16_t Major, Minor;
+
+ Major = VERSION_MAJOR(RDAR_VERSION);
+ Minor = VERSION_MINOR(RDAR_VERSION);
+ printf("Version v%d.%d\n", Major, Minor);
+}
+
+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;
+ }
+ }
+}