kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit 0b37f49d0cb3ac4d64d7b5eaaffed979ba64114e
parent e9a32808a843e703fa37808406e8727257e0872e
Author: lash <dev@holbrook.no>
Date:   Mon, 15 Apr 2024 20:26:10 +0100

Add libtasn1 code generation from schema

Diffstat:
MMakefile | 2+-
Msrc/Makefile | 8+++++++-
Asrc/asn1/Makefile | 22++++++++++++++++++++++
Asrc/asn1/generate.c | 20++++++++++++++++++++
Rsrc/schema_entry_head.txt -> src/asn1/schema_entry.txt | 0
Msrc/gpg.c | 1-
6 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -24,7 +24,7 @@ debug: gtk all test: testdata test_src test_gtk testdata_schema: - asn1ate src/schema_entry_head.txt > testdata_asn1schema.py + asn1ate src/asn1/schema_entry.txt > testdata_asn1schema.py test_src: all make -C src/tests test diff --git a/src/Makefile b/src/Makefile @@ -8,7 +8,11 @@ LDFLAGS += $(LIBS) #all: aux resource $(OBJS) # $(CC) $(CFLAGS) main.c -o a.out $(OBJS) $(LDFLAGS) aux/varint/varint.o #all: aux $(OBJS) -all: $(OBJS) +all: asn $(OBJS) + +asn: + make -C asn1 compile + cp -v asn1/*.o . %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS) @@ -19,6 +23,8 @@ all: $(OBJS) clean: rm -vf *.o make -C gtk clean + make -C asn1 clean + make -C tests clean # make -C aux clean #.PHONY: clean aux diff --git a/src/asn1/Makefile b/src/asn1/Makefile @@ -0,0 +1,22 @@ +INCLUDES := `pkg-config --cflags libtasn1` +LIBS := `pkg-config --libs libtasn1` +LDFLAGS += $(LIBS) + +all: compile + +src: + $(CC) $(CFLAGS) generate.c -o generate $(LDFLAGS) + +%.o: %_asn1_tab.c + $(CC) $< -o $* $(LDFLAGS) + +compile: generate schema_entry_asn1_tab.o + +generate: src + ./generate + +clean: + rm -vf *.o + rm -vf *_asn1_tab.c + +.PHONY: clean diff --git a/src/asn1/generate.c b/src/asn1/generate.c @@ -0,0 +1,20 @@ +#include <string.h> +#include <stdio.h> +#include <libtasn1.h> + +int main() { + int r; + char err[1024]; + asn1_node node; + + err[0] = 0; + memset(&node, 0, sizeof(asn1_node)); + + r = asn1_parser2array("./schema_entry.txt", NULL, NULL, err); + if (r) { + fprintf(stderr, "%s\n", err); + return r; + } + return 0; + +} diff --git a/src/schema_entry_head.txt b/src/asn1/schema_entry.txt diff --git a/src/gpg.c b/src/gpg.c @@ -168,7 +168,6 @@ static int key_from_data(gcry_sexp_t *key, const char *indata, size_t indata_len } static int key_from_path(gcry_sexp_t *key, const char *p, const char *passphrase) { - int l; int r; char v[BUFLEN]; size_t c;