2 Commits

Author SHA1 Message Date
068d6963a1 Added build dir, and gitignore 2026-03-05 20:09:45 +01:00
d2171d59a6 Fixed bug with formatting and large integers 2026-03-05 20:04:46 +01:00
4 changed files with 13 additions and 9 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
build/

View File

@@ -1,7 +1,9 @@
SHELL := /bin/bash
CC := cc
CFLAGS := -Wall -O2
TARGET := fa2json
MKDIR := mkdir
CFLAGS := -Wall -Werror -Os
BUILD_DIR := build
TARGET := $(BUILD_DIR)/fa2json
SRCS := fs-watcher.c json-writer.c
.PHONY: all test dev clean
@@ -9,6 +11,7 @@ SRCS := fs-watcher.c json-writer.c
all: $(TARGET)
$(TARGET): $(SRCS)
$(MKDIR) -p $(BUILD_DIR)
$(CC) $(CFLAGS) -o $@ $^
test: $(TARGET)
@@ -18,4 +21,4 @@ dev: $(TARGET)
node test/dev.mjs $(ARGS)
clean:
rm -f $(TARGET)
rm -rf $(BUILD_DIR)

View File

@@ -58,7 +58,7 @@ static void handle_events(int fafd, int mount_fd) {
clock_gettime(CLOCK_MONOTONIC, &mono);
clock_gettime(CLOCK_REALTIME, &wall);
fprintf(stdout, "{\"ts\": [%i, %i, %i, %i]", wall.tv_sec, wall.tv_nsec, mono.tv_sec, mono.tv_nsec);
fprintf(stdout, "{\"ts\": [%li, %li, %li, %li]", wall.tv_sec, wall.tv_nsec, mono.tv_sec, mono.tv_nsec);
char *ptr = (char *)(metadata + 1);
char *end = (char *)metadata + metadata->event_len;
@@ -98,7 +98,7 @@ static void handle_events(int fafd, int mount_fd) {
}
if (entry_index++) { fprintf(stdout, ", "); }
fprintf(stdout, ", \"mask\": %i}\n", metadata->mask);
fprintf(stdout, ", \"mask\": %lli}\n", metadata->mask);
metadata = FAN_EVENT_NEXT(metadata, size);

View File

@@ -3,7 +3,7 @@ import { mkdtempSync, mkdirSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
const FA2JSON = new URL('../../fa2json', import.meta.url).pathname;
const FA2JSON = new URL('../../build/fa2json', import.meta.url).pathname;
export async function setup() {
// Create image file and format