commit 90b639eba51370ef07426f271f70a58085a3118a
parent ca4a2602a8087d75a09ffa0a8f2d3b98e57bedf2
Author: lash <dev@holbrook.no>
Date: Sat, 25 May 2024 08:20:06 +0100
Add aux deps
Diffstat:
35 files changed, 1158 insertions(+), 100 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,10 +1,9 @@
-src/gtk/*.ui
-**/*.o
-testdata_*
-*\~
-**/test_*
-**/*.out
-src/aux/include
-testdata
-src/asn1/schema_*.c
-src/asn1/generate_asn1
+*.o
+*.bin
+*.out
+beamenu_gen
+beamenu.dat
+beamenu_defs.c
+src/aux/**/*test*
+src/aux/**/.gitignore
+src/gtk/resources.c
diff --git a/src/Makefile b/src/Makefile
@@ -3,11 +3,11 @@ INCLUDES := `pkg-config --cflags libgcrypt lmdb libxdg-basedir libqrencode zbar`
CFLAGS += $(INCLUDES) -Wall
LIBS := `pkg-config --libs libgcrypt zlib lmdb libxdg-basedir libqrencode zbar` -lb64 -llash
LDFLAGS += $(LIBS)
+AUXLIBS := `pkg-config --libs kee`
#all: aux resource $(OBJS)
# $(CC) $(CFLAGS) main.c -o a.out $(OBJS) $(LDFLAGS) aux/varint/varint.o
-#all: aux $(OBJS)
-all: aux asn $(OBJS)
+all: aux $(OBJS)
asn:
make -C asn1 compile
@@ -26,5 +26,4 @@ clean:
make -C tests clean
# make -C aux clean
-#.PHONY: clean aux
-.PHONY: clean
+.PHONY: clean aux
diff --git a/src/aux/Makefile b/src/aux/Makefile
@@ -1,9 +1,15 @@
-all: lash
+all: lash local
-lash: llog rerr
+lash: llog rerr beamenu
llog:
make -C llog
rerr:
make -C rerr
+
+beamenu:
+ make -C beamenu
+
+local:
+ -make -f Makefile.local
diff --git a/src/aux/beamenu/Makefile b/src/aux/beamenu/Makefile
@@ -0,0 +1,25 @@
+OBJS := $(patsubst %.c,%.o,$(filter-out test.c gen.c,$(wildcard *.c)))
+INCLUDES := -I.
+CFLAGS += $(INCLUDES) -DBEAMENU_N_EXITS=3 -DBEAMENU_N_DST=4
+VERSION = 0.0.1
+
+all: $(OBJS) gen
+
+test: all
+ $(CC) $(CFLAGS) test.c beamenu.o export.o import.o -o test.out $(LDFLAGS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
+
+clean:
+ rm -vf *.o
+ rm -vf *.out
+ rm -vf *.tar.gz
+ rm -vf beamenu_gen
+ rm -vf beamenu_defs.c
+
+archive:
+ git archive --format=tar.gz HEAD -o beamenu-$(VERSION).tar.gz
+
+gen:
+ $(CC) $(CFLAGS) gen.c beamenu.o export.o import.o -o beamenu_gen $(LDFLAGS)
diff --git a/src/aux/beamenu/beamenu.c b/src/aux/beamenu/beamenu.c
@@ -0,0 +1,79 @@
+#include <string.h>
+#include <stdlib.h>
+
+#include "beamenu.h"
+
+
+static struct beamenu_node node[BEAMENU_N_DST + 1];
+
+int beamenu_now;
+
+int beamenu_register(int idx, char *cn) {
+ int i;
+ int l;
+ char *p;
+
+ l = strlen(cn) + 1;
+ if (node[idx].cn) {
+ free(node[idx].cn);
+ }
+ node[idx].cn = malloc(l);
+ if (!node[idx].cn) {
+ return 1;
+ }
+ memcpy(node[idx].cn, cn, l);
+ for (i = 0; i < BEAMENU_N_EXITS; i++) {
+ node[idx].dst[i] = 0;
+ }
+ return 0;
+}
+
+void beamenu_free() {
+ int i;
+ char *p;
+
+ for (i = 0; i <= BEAMENU_N_DST; i++) {
+ if (node[i].cn) {
+ free(node[i].cn);
+ node[i].cn = 0;
+ }
+ }
+}
+
+void beamenu_set(int idx_node, int idx_exit, int idx_dst) {
+ struct beamenu_node *o;
+
+ o = beamenu_get(idx_node);
+ o->dst[idx_exit] = idx_dst;
+}
+
+int beamenu_move(int idx_exit) {
+ struct beamenu_node *o;
+ int r;
+ int idx;
+
+ o = beamenu_get(beamenu_now);
+ idx = idx_exit;
+ r = o->dst[idx_exit];
+ switch(r) {
+ case BEAMENU_INACTIVE:
+ return 1;
+ break;
+ case BEAMENU_ROOT:
+ idx = 0;
+ break;
+ default:
+ idx = r;
+ }
+
+ beamenu_now = idx;
+ return 0;
+}
+
+struct beamenu_node *beamenu_get(int idx_node) {
+ if (idx_node < 0) {
+ return &node[beamenu_now];
+ }
+ return &node[idx_node];
+}
+
diff --git a/src/aux/beamenu/beamenu.h b/src/aux/beamenu/beamenu.h
@@ -0,0 +1,32 @@
+#ifndef BEAMENU_H_
+#define BEAMENU_H_
+
+#define BEAMENU_INACTIVE 0x0
+#define BEAMENU_ROOT 0xffffffff
+#define BEAMENU_CN_MAXLEN 32
+
+#ifndef BEAMENU_N_DST
+#define BEAMENU_N_DST 0
+#endif
+
+#ifndef BEAMENU_N_EXITS
+#define BEAMENU_N_EXITS 0
+#endif
+
+#define BEAMENU_EXIT_SIZE 1
+
+
+struct beamenu_node {
+ char *cn;
+ int dst[BEAMENU_N_EXITS]; // all are 0
+};
+
+int beamenu_register(int idx, char *cn);
+void beamenu_free();
+void beamenu_set(int idx_node, int idx_exit, int idx_dst);
+struct beamenu_node *beamenu_get(int idx_node);
+int beamenu_load_file(const char *path, int msize);
+int beamenu_move(int idx_exit);
+int beamenu_export(char *out, int width);
+
+#endif
diff --git a/src/aux/beamenu/export.c b/src/aux/beamenu/export.c
@@ -0,0 +1,71 @@
+#include <string.h>
+
+#include "beamenu.h"
+
+
+union export_width {
+ char c;
+ short s;
+ int i;
+};
+
+static int beamenu_export_exits(struct beamenu_node *o, char *b, int width) {
+ int c;
+ char *p;
+ union export_width w;
+ int i;
+
+ c = 0;
+ p = b;
+ for (i = 0; i < BEAMENU_N_EXITS; i++) {
+ w.i = o->dst[i];
+ switch (width) {
+ case 4:
+ memcpy(p, &w.i, 4);
+ break;
+ case 2:
+ memcpy(p, &w.s, 2);
+ break;
+ case 1:
+ *p = w.c;
+ break;
+ default:
+ return 0;
+ }
+ c += width;
+ p += width;
+ }
+
+ return c;
+}
+
+int beamenu_export(char *out, int width) {
+ char *p;
+ int l;
+ int c;
+ int i;
+ struct beamenu_node *o;
+
+ if (width == 0) {
+ width = 1;
+ }
+
+ l = 0;
+ c = 0;
+ p = out;
+ for (i = 0; i < BEAMENU_N_DST; i++) {
+ o = beamenu_get(i);
+ p = strcpy(p, o->cn);
+ c = strlen(o->cn) + 1;
+ l += c;
+ p += c;
+ c = beamenu_export_exits(o, p, width);
+ if (!c) {
+ return 0;
+ }
+ l += c;
+ p += c;
+ }
+
+ return l;
+}
diff --git a/src/aux/beamenu/gen.c b/src/aux/beamenu/gen.c
@@ -0,0 +1,344 @@
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <search.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "beamenu.h"
+
+#define BUFSIZE 4096
+#define KEYMAXLEN BEAMENU_CN_MAXLEN
+#define MAXENTRIES 256
+
+#define MODE_READ 0
+#define MODE_SEEK 1
+
+/// \todo forces use of char in output, should allow 2 and 4 width too
+
+char buf[BUFSIZE];
+char tmpk[KEYMAXLEN];
+char *keys[MAXENTRIES];
+int vals[MAXENTRIES];
+int crsr;
+int tmpbi;
+int tmpki;
+int tmpc = 0;
+int tmpl = 0;
+int tmpm = 0;
+int debug = 0;
+
+int uc(char *b) {
+ int i;
+ char v;
+
+ i = 0;
+ v = 1;
+ while(v > 0) {
+ v = *(b+i);
+ if (v > 0x60 && v < 0x7b) {
+ *(b+i) -= 0x20;
+ }
+ i++;
+ }
+ return 0;
+}
+
+int fill(int f) {
+ int c;
+
+ c = read(f, buf, BUFSIZE);
+ tmpbi = 0;
+
+ return c;
+}
+
+int addkey(char *k, int v) {
+ ENTRY o;
+ int l;
+
+ l = strlen(k);
+ keys[crsr] = malloc(l);
+ strcpy(keys[crsr], k);
+ o.key = keys[crsr];
+
+ vals[crsr] = v;
+ o.data = &vals[crsr];
+
+ if (beamenu_register(tmpc, keys[crsr])) {
+ return 1;
+ }
+ if (!hsearch(o, ENTER)) {
+ return 1;
+ }
+
+ crsr++;
+ return 0;
+}
+
+int scan(int f, int l) {
+ int r;
+ char v;
+
+ if (tmpm == MODE_READ) {
+ while(tmpbi < l) {
+ tmpk[tmpki] = buf[tmpbi];
+ if (tmpk[tmpki] == ',') {
+ tmpk[tmpki] = 0;
+ r = addkey((char*)tmpk, tmpc);
+ if (r) {
+ return -1;
+ }
+ if (debug) {
+ fprintf(stderr, "found key %d: %s\n", tmpc, tmpk);
+ }
+ tmpm = MODE_SEEK;
+ tmpki = 0;
+ tmpbi++;
+ tmpc++;
+ break;
+ }
+ tmpki++;
+ tmpbi++;
+ }
+ }
+
+ if (tmpm == MODE_SEEK) {
+ while(tmpbi < l) {
+ if (buf[tmpbi] == 0x0a) {
+ tmpm = MODE_READ;
+ tmpbi++;
+ break;
+ }
+ tmpbi++;
+ }
+ }
+
+ if (tmpbi < l) {
+ return 0;
+ }
+
+ return 1;
+}
+
+int set(int c) {
+ ENTRY o;
+ ENTRY *p;
+ int v;
+
+ o.key = (char*)tmpk;
+ if (*o.key == 0) {
+ beamenu_set(c, tmpc, 0);
+ if (debug) {
+ fprintf(stderr, "set zero %d %d\n", c, tmpc);
+ }
+ return 0;
+ }
+ p = hsearch(o, FIND);
+ if (!p) {
+ return 1;
+ }
+ v = *((int*)p->data);
+ beamenu_set(c, tmpc, v);
+ if (debug) {
+ fprintf(stderr, "set %d %d %d\n", c, tmpc, v);
+ }
+ return 0;
+}
+
+int linkscan(int f, int l, int *c) {
+ int r;
+ char v;
+
+ if (tmpm == MODE_SEEK) {
+ while(tmpbi < l) {
+ if (buf[tmpbi] == ',') {
+ tmpm = MODE_READ;
+ tmpbi++;
+ break;
+ }
+ tmpbi++;
+ }
+ }
+
+ if (tmpm == MODE_READ) {
+ while(tmpbi < l) {
+ v = buf[tmpbi];
+ if (v == 0x0a) {
+ tmpk[tmpki] = 0;
+ r = set(*c);
+ if (r) {
+ return -1;
+ }
+ tmpk[0] = 0;
+ tmpm = MODE_SEEK;
+ tmpbi++;
+ *c += 1;
+ tmpc = 0;
+ break;
+ } else if (v == ',') {
+ tmpk[tmpki] = 0;
+ r = set(*c);
+ if (r) {
+ return -1;
+ }
+ tmpc++;
+ tmpki = 0;
+ } else {
+ tmpk[tmpki] = v;
+ tmpki++;
+ }
+ tmpbi++;
+ }
+ }
+
+ if (tmpbi < l) {
+ return 0;
+ }
+
+ return 1;
+}
+
+int write_data() {
+ char *buf;
+ int c;
+ int f;
+ int l;
+
+ buf = malloc(BEAMENU_N_DST * (BEAMENU_CN_MAXLEN + BEAMENU_N_EXITS + 1));
+ if (!buf) {
+ return 1;
+ }
+
+ l = beamenu_export(buf, BEAMENU_EXIT_SIZE);
+ f = open("beamenu.dat", O_WRONLY | O_CREAT, S_IRWXU);
+ while (l > 0) {
+ c = write(f, buf, l);
+ if (!c) {
+ close(f);
+ free(buf);
+ return 1;
+ }
+ l -= c;
+ }
+
+ close(f);
+ free(buf);
+ return 0;
+}
+
+int write_defs() {
+ struct beamenu_node *o;
+ char buf[1024];
+ char k[KEYMAXLEN + 1];
+ int c;
+ int f;
+ int l;
+ int r;
+ int i;
+
+ r = 0;
+ f = open("beamenu_defs.c", O_WRONLY | O_CREAT, S_IRWXU);
+ for (i = 0; i < BEAMENU_N_DST; i++) {
+ o = beamenu_get(i);
+ strcpy(k, o->cn);
+ r = uc(k);
+ sprintf(buf, "#define BEAMENU_DST_%s %d\n", k, i);
+ l = strlen(buf);
+ c = write(f, buf, l);
+ if (c != l) {
+ close(f);
+ return 0;
+ }
+ r += c;
+ }
+ close(f);
+ return r;
+}
+
+
+int main(int argc, char **argv) {
+ int i;
+ int r;
+ int f;
+ int l;
+ int c;
+
+ crsr = 0;
+ tmpbi = 0;
+ tmpki = 0;
+ tmpc = 0;
+ tmpm = MODE_READ;
+
+ if (getenv("BEAMENU_DEBUG")) {
+ debug = 1;
+ }
+
+ r = hcreate(BEAMENU_N_DST);
+ if (!r) {
+ return 1;
+ }
+
+ f = open(*(argv+1), O_RDONLY);
+ l = fill(f);
+ if (l == 0) {
+ return 1;
+ }
+ if (debug) {
+ fprintf(stderr, "initial read is %d\n", l);
+ }
+
+ while (1) {
+ r = scan(f, l);
+ if (r < 0) {
+ return 1;
+ } else if (r) {
+ l = fill(f);
+ if (l == 0) {
+ break;
+ }
+ }
+ }
+
+ tmpbi = 0;
+ tmpki = 0;
+ tmpm = MODE_SEEK;
+ r = lseek(f, 0, SEEK_SET);
+ if (r < 0) {
+ return 1;
+ }
+ l = fill(f);
+ if (l == 0) {
+ return 1;
+ }
+ i = 0;
+ tmpki = 0;
+ c = tmpc;
+ tmpc = 0;
+ while (i < c) {
+ r = linkscan(f, l, &i);
+ if (r < 0) {
+ return 1;
+ } else if (r) {
+ l = fill(f);
+ if (l == 0) {
+ break;
+ }
+ }
+ }
+
+ close(f);
+ hdestroy();
+
+ r = write_data();
+ if (r) {
+ return 1;
+ }
+
+ r = write_defs();
+ if (r) {
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/aux/beamenu/import.c b/src/aux/beamenu/import.c
@@ -0,0 +1,51 @@
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "beamenu.h"
+
+int beamenu_load_file(const char *path, int msize) {
+ int r;
+ int f;
+ int v;
+ int i;
+ int ii;
+ size_t c;
+ char p[BEAMENU_CN_MAXLEN + 1];
+ struct beamenu_node *o;
+
+ f = open(path, O_RDONLY);
+ if (f < 0) {
+ return 1;
+ }
+
+ for (i = 0; i < BEAMENU_N_DST; i++) {
+ v = 1;
+ ii = 0;
+ while (v) {
+ if (ii > BEAMENU_CN_MAXLEN) {
+ return 1;
+ }
+ c = read(f, &v, 1);
+ if (c == 0) {
+ return 1;
+ }
+ p[ii] = v;
+ ii++;
+ }
+ p[ii] = 0;
+ r = beamenu_register(i, p);
+ if (r) {
+ return 1;
+ }
+
+ for (ii = 0; ii < BEAMENU_N_EXITS; ii++) {
+ c = read(f, &v, 1);
+ if (c == 0) {
+ return 1;
+ }
+ beamenu_set(i, ii, v);
+ }
+ }
+ return 0;
+}
diff --git a/src/aux/llog/Makefile b/src/aux/llog/Makefile
@@ -0,0 +1,20 @@
+OBJS := $(patsubst %.c,%.o,$(filter-out test.c,$(wildcard *.c)))
+INCLUDES := -I.
+CFLAGS += $(INCLUDES)
+VERSION = 0.0.1
+
+all: $(OBJS)
+
+test: all
+ $(CC) $(CFLAGS) test.c llog.o hex.o -o test.out $(LDFLAGS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
+
+clean:
+ rm -vf *.o
+ rm -vf *.out
+ rm -vf *.tar.gz
+
+archive:
+ git archive --format=tar.gz HEAD -o llog-$(VERSION).tar.gz
diff --git a/src/aux/llog/llog.c b/src/aux/llog/llog.c
@@ -0,0 +1,240 @@
+#include "llog.h"
+
+extern void b2h(const unsigned char *b, int l, char *hx);
+extern char* c2h(char in, char *out);
+
+
+char lloglvl_str[][4] = {
+ "???",
+ "crt",
+ "err",
+ "wrn",
+ "inf",
+ "dbg",
+ "gru",
+ "usr",
+};
+
+char _llogbuf_v[LLOG_LENGTH];
+char* _llogbuf = (char*)_llogbuf_v;
+int _llogbuf_crsr;
+
+static int cpy(const char *s) {
+ char *p;
+ int c;
+
+ p = _llogbuf + _llogbuf_crsr;
+ c = 0;
+ while (1) {
+ if (*s == 0) {
+ break;
+ }
+ *p = *s;
+ s++;
+ p++;
+ c++;
+ }
+ return c;
+}
+
+static int pfxfmt(char *v) {
+ int c;
+ char *p;
+
+ p = _llogbuf + _llogbuf_crsr;
+
+ *p = '[';
+ p++;
+ _llogbuf_crsr++;
+
+ c = cpy(v);
+ p += c;
+
+ *p = ']';
+ c++;
+ _llogbuf_crsr += c;
+
+ return c+1;
+}
+
+static int lvlfmt(enum lloglvl_e lvl) {
+ char *v;
+
+ v = lloglvl_str[(int)lvl];
+
+ return pfxfmt(v);
+}
+
+static char* kvstart(char *k) {
+ char *p;
+ int c;
+
+ p = _llogbuf + _llogbuf_crsr;
+ *p = 0x09;
+ p++;
+
+ _llogbuf_crsr++;
+ c = cpy(k);
+ p += c;
+ *p = '=';
+ c++;
+
+ _llogbuf_crsr += c;
+
+ return _llogbuf + _llogbuf_crsr;
+}
+
+char *llog_new(enum lloglvl_e lvl, char *msg) {
+ char *p;
+ int c;
+
+ _llogbuf_crsr = 0;
+ c = lvlfmt(lvl);
+ p = _llogbuf + c;
+ *p = ' ';
+ p++;
+ _llogbuf_crsr++;
+
+ c = cpy(msg);
+ _llogbuf_crsr += c;
+ p += c;
+ *p = 0;
+
+ return _llogbuf;
+}
+
+char *llog_new_ns(enum lloglvl_e lvl, char *msg, char *ns) {
+ char *p;
+ int c;
+
+ _llogbuf_crsr = 0;
+ c = pfxfmt(ns);
+ p = _llogbuf + c;
+ c = lvlfmt(lvl);
+ p += c;
+
+ *p = ' ';
+ p++;
+ _llogbuf_crsr++;
+ c = cpy(msg);
+
+ _llogbuf_crsr += c;
+ p += c;
+ *p = 0;
+
+ return _llogbuf;
+}
+
+char* llog_add_s(const char *k, char *v) {
+ char *p;
+ int c;
+
+ p = kvstart((char*)k);
+ c = 0;
+ while (1) {
+ if (*v == 0) {
+ break;
+ }
+ *p = *v;
+ p++;
+ c++;
+ v++;
+ }
+
+ _llogbuf_crsr += c;
+ *p = 0;
+
+ return _llogbuf;
+}
+
+
+char* llog_add_n(const char *k, long long v) {
+ char *p;
+ int c;
+ char i;
+ long long r;
+ char *b;
+
+ r = 0;
+ p = kvstart((char*)k);
+ c = 0;
+ b = (char*)&r;
+ b += (sizeof(r) - 1);
+ while (v != 0) {
+ i = v % 10;
+ i += 0x30;
+ *b = i;
+ b--;
+ c++;
+ v /= 10;
+ }
+ for (i = 0; i < c; i++) {
+ b++;
+ *p = *b;
+ p++;
+ }
+
+ _llogbuf_crsr += c;
+ *p = 0;
+
+ return _llogbuf;
+}
+
+char* llog_add_x(const char *k, long long v) {
+ char *p;
+ int c;
+ char i;
+ long long r;
+ char *b;
+
+ r = 0;
+ p = kvstart((char*)k);
+ c = 0;
+ //b = (char*)&r;
+ //b += (sizeof(r) - 1);
+ b = (char*)&v;
+ b += (sizeof(v) - 1);
+
+ i = 0;
+ while (*b == 0 && i < 8) {
+ b--;
+ i++;
+ }
+
+ if (i == 8) {
+ b++;
+ i--;
+ }
+ *p = '0';
+ p++;
+ *p = 'x';
+ p++;
+ c = 2;
+ for (; i < 8; i++) {
+ c2h(*b, p);
+ p += 2;
+ c += 2;
+ b--;
+ }
+
+ _llogbuf_crsr += c;
+ *p = 0;
+
+ return _llogbuf;
+}
+
+
+char* llog_add_b(const char *k, void *v, int l) {
+ char *p;
+ int c;
+
+ c = 0;
+ p = kvstart((char*)k);
+ b2h(v, l, p);
+ c += (l * 2);
+ _llogbuf_crsr += c;
+ p += c;
+ *p = 0;
+
+ return _llogbuf;
+}
diff --git a/src/aux/llog/llog.h b/src/aux/llog/llog.h
@@ -0,0 +1,30 @@
+#ifndef LLOG_H_
+#define LLOG_H_
+
+#define LLOG_LENGTH 1024
+
+#ifndef LLOG_DEFAULT_NS
+#define LLOG_DEFAULT_NS "llog"
+#endif
+
+enum lloglvl_e {
+ LLOG_NONE = 0,
+ LLOG_CRITICAL,
+ LLOG_ERROR,
+ LLOG_WARNING,
+ LLOG_INFO,
+ LLOG_DEBUG,
+ LLOG_GURU,
+ LLOG_USR,
+ LLOG_N_LEVELS,
+};
+
+char* llog_new(enum lloglvl_e lvl, char *msg);
+char* llog_new_ns(enum lloglvl_e lvl, char *msg, char *ns);
+char* llog_add_s(const char *k, char *v);
+char* llog_add_n(const char *k, long long v);
+char* llog_add_x(const char *k, long long v);
+char* llog_add_b(const char *k, void *v, int l);
+extern void llog_out(const char *v);
+
+#endif
diff --git a/src/aux/rerr/Makefile b/src/aux/rerr/Makefile
@@ -0,0 +1,19 @@
+OBJS := $(patsubst %.c,%.o,$(filter-out test.c,$(wildcard *.c)))
+INCLUDES := -I.
+CFLAGS += $(INCLUDES) -DRERR -DRERR_N_PFX=2
+VERSION = 0.0.1
+
+all: $(OBJS)
+
+test: all
+ $(CC) $(CFLAGS) test.c rerr.o -o test.out $(LDFLAGS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
+
+clean:
+ rm -vf *.o
+ rm -vf *.out
+
+archive:
+ git archive --format=tar.gz HEAD -o rerr-$(VERSION).tar.gz
diff --git a/src/aux/rerr/rerr.c b/src/aux/rerr/rerr.c
@@ -0,0 +1,109 @@
+#include "rerr.h"
+
+#ifdef RERR
+static char** rerr[RERR_N_PFX + 1];
+static char* rerr_pfx[RERR_N_PFX + 1];
+char *rerr_base[3] = {
+ "OK",
+ "FAIL",
+ "UNSUPPORTED",
+};
+#endif
+
+void rerr_init() {
+#ifdef RERR
+ int i;
+
+ for (i = 1; i < RERR_N_PFX + 1; i++) {
+ rerr[i] = 0x0;
+ rerr_pfx[i] = 0x0;
+ }
+ rerr[0] = rerr_base;
+ rerr_pfx[0] = 0x0;
+#endif
+}
+
+void rerr_register(int pfx, char *label, void *start) {
+#ifdef RERR
+ pfx >>= 8;
+ rerr_pfx[pfx] = label;
+ rerr[pfx] = start;
+#endif
+}
+
+#ifdef RERR
+static void splitcode(int code, short *k, char *v) {
+ *v = code & 0xff;
+ *k = 0;
+ if (code > 0xff) {
+ *k = ((code >> 8) & 0xffff);
+ }
+}
+
+static char *strv(short k, char v) {
+ return (char*)(*(rerr[k]+v));
+}
+#endif
+
+char *rerrpfx(int code) {
+ short k;
+ char v;
+ splitcode(code, &k, &v);
+ return rerr_pfx[k];
+}
+
+char *rerrstrv(int code) {
+#ifdef RERR
+ short k;
+ char v;
+ splitcode(code, &k, &v);
+ return strv(k, v);
+#endif
+}
+
+char* rerrstr(int code, char *buf) {
+#ifdef RERR
+ short k;
+ char v;
+ char *src;
+ char *dst;
+ int i;
+
+ splitcode(code, &k, &v);
+
+ dst = buf;
+ src = (char*)rerr_pfx[k];
+ if (src) {
+ while (1) {
+ if (*src == 0) {
+ break;
+ }
+ *dst = *src;
+ src++;
+ dst++;
+ }
+ *dst = ':';
+ dst++;
+ *dst = ' ';
+ dst++;
+ }
+
+ src = strv(k, v);
+ //src = (char*)(*(rerr[k]+v));
+ while (1) {
+ if (*src == 0) {
+ break;
+ }
+ *dst = *src;
+ src++;
+ dst++;
+ }
+
+ *dst = 0;
+
+ return buf;
+#else
+ return 0;
+#endif
+}
+
diff --git a/src/aux/rerr/rerr.h b/src/aux/rerr/rerr.h
@@ -0,0 +1,18 @@
+#ifndef RERR_H_
+#define RERR_H_
+
+#define ERR_OK 0x0
+#define ERR_FAIL 0x1
+#define ERR_UNSUPPORTED 0x2
+
+#ifndef RERR_N_PFX
+#define RERR_N_PFX 0
+#endif
+
+void rerr_init();
+void rerr_register(int pfx, char *label, void *start);
+char* rerrstr(int code, char *buf);
+char* rerrstrv(int code);
+char* rerrpfx(int code);
+
+#endif // RERR_H
diff --git a/src/debug.c b/src/debug.c
@@ -2,14 +2,18 @@
void debug_log(enum debugLevel level, const char *s);
-void debug_logerr(enum lloglvl_e lvl, char *msg, int err) {
+int debug_logerr(enum lloglvl_e lvl, int err, char *msg) {
char *e;
char *s;
+ if (msg == 0) {
+ msg = "debug logerr";
+ }
s = rerrpfx(err);
e = llog_new_ns(lvl, msg, s);
- e = llog_add_n("errcode", err);
+ e = llog_add_x("errcode", err);
s = rerrstrv(err);
e = llog_add_s("err", s);
debug_log(lvl, e);
+ return err;
}
diff --git a/src/debug.h b/src/debug.h
@@ -32,6 +32,6 @@ enum debugLevel {
*/
//void debug_log(enum debugLevel level, const char *s);
void debug_log(enum debugLevel level, const char *s);
-void debug_logerr(enum lloglvl_e, char *s, int err);
+int debug_logerr(enum lloglvl_e, int err, char *s);
#endif
diff --git a/src/gpg.c b/src/gpg.c
@@ -61,17 +61,17 @@ static int create_handle(gcry_cipher_hd_t *h, const char *key, const char *nonce
e = gcry_cipher_open(h, GCRY_CIPHER_CHACHA20, GCRY_CIPHER_MODE_POLY1305, GCRY_CIPHER_SECURE);
if (e) {
- return ERR_NOCRYPTO;
+ return 1;
}
e = gcry_cipher_setkey(*h, key, CHACHA20_KEY_LENGTH_BYTES);
if (e) {
- return ERR_NOCRYPTO;
+ return 1;
}
e = gcry_cipher_setiv(*h, nonce, CHACHA20_NONCE_LENGTH_BYTES);
if (e) {
- return ERR_NOCRYPTO;
+ return 1;
}
- return ERR_OK;
+ return 0;
}
@@ -80,6 +80,7 @@ static void free_handle(gcry_cipher_hd_t *h) {
}
int encryptb (char *ciphertext, size_t ciphertext_len, const char *indata, size_t indata_len, const char *key, const char *nonce) {
+ const char *p;
int r;
gcry_cipher_hd_t h;
gcry_error_t e;
@@ -87,13 +88,14 @@ int encryptb (char *ciphertext, size_t ciphertext_len, const char *indata, size_
r = create_handle(&h, key, nonce);
if (r) {
- return r;
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, NULL);
}
memcpy(indata_raw, indata, indata_len);
padb(indata_raw, ciphertext_len, indata_len);
e = gcry_cipher_encrypt(h, (unsigned char*)ciphertext, ciphertext_len, (const unsigned char*)indata_raw, ciphertext_len);
if (e) {
- return ERR_NOCRYPTO;
+ p = gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, (char*)p);
}
free_handle(&h);
@@ -102,6 +104,7 @@ int encryptb (char *ciphertext, size_t ciphertext_len, const char *indata, size_
}
int encrypt(char *ciphertext, size_t ciphertext_len, const char *indata, const char *key, const char *nonce) {
+ char *p;
int r;
gcry_cipher_hd_t h;
gcry_error_t e;
@@ -109,13 +112,14 @@ int encrypt(char *ciphertext, size_t ciphertext_len, const char *indata, const c
r = create_handle(&h, key, nonce);
if (r) {
- return r;
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, NULL);
}
pad(indata_raw, ciphertext_len, indata);
e = gcry_cipher_encrypt(h, (unsigned char*)ciphertext, ciphertext_len, (const unsigned char*)indata_raw, ciphertext_len);
if (e) {
- return ERR_NOCRYPTO;
+ p = (char*)gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, p);
}
free_handle(&h);
@@ -124,27 +128,29 @@ int encrypt(char *ciphertext, size_t ciphertext_len, const char *indata, const c
}
int decryptb(char *outdata, const char *ciphertext, size_t ciphertext_len, const char *key, const char *nonce) {
+ char *p;
int r;
gcry_cipher_hd_t h;
gcry_error_t e;
r = create_handle(&h, key, nonce);
if (r) {
- return r;
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, NULL);
}
e = gcry_cipher_decrypt(h, outdata, ciphertext_len, ciphertext, ciphertext_len);
if (e) {
- return ERR_NOCRYPTO;
+ p = (char*)gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, p);
}
free_handle(&h);
return ERR_OK;
-
}
int decrypt(char *outdata, const char *ciphertext, size_t ciphertext_len, const char *key, const char *nonce) {
+ char *p;
int r;
gcry_cipher_hd_t h;
gcry_error_t e;
@@ -153,12 +159,13 @@ int decrypt(char *outdata, const char *ciphertext, size_t ciphertext_len, const
outdata_raw[0] = 0;
r = create_handle(&h, key, nonce);
if (r) {
- return r;
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, NULL);
}
e = gcry_cipher_decrypt(h, outdata_raw, ciphertext_len, ciphertext, ciphertext_len);
if (e) {
- return ERR_NOCRYPTO;
+ p = (char*)gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_NOCRYPTO, p);
}
//outdata->assign(outdata_raw);
strcpy(outdata, outdata_raw);
@@ -175,19 +182,19 @@ static int key_apply_public(struct gpg_store *gpg, gcry_sexp_t key) {
pubkey = gcry_sexp_find_token(key, "public-key", 10);
if (pubkey == NULL) {
- return 1;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
pubkey = gcry_sexp_find_token(pubkey, "q", 1);
if (pubkey == NULL) {
- return 1;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
c = PUBKEY_LENGTH;
p = (char*)gcry_sexp_nth_data(pubkey, 1, &c);
if (p == NULL) {
- return 1;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
memcpy(gpg->public_key, p, PUBKEY_LENGTH);
- return 0;
+ return ERR_OK;
}
static char *key_filename(struct gpg_store *gpg, char *path) {
@@ -212,7 +219,7 @@ static int key_from_data(gcry_sexp_t *key, const char *indata, size_t indata_len
e = gcry_sexp_new(key, indata, indata_len, 0);
if (e != GPG_ERR_NO_ERROR) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
return ERR_OK;
}
@@ -229,7 +236,7 @@ static int key_from_file(gcry_sexp_t *key, const char *path, const char *passphr
f = fopen(path, "r");
if (f == NULL) {
- return ERR_NOKEY;
+ return debug_logerr(LLOG_ERROR, ERR_NOKEY, NULL);
}
/// \todo length must be in the ciphertext
@@ -243,26 +250,26 @@ static int key_from_file(gcry_sexp_t *key, const char *path, const char *passphr
i += c;
}
if (i == 0) {
- return ERR_NOKEY;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFILE, (char*)path);
}
fclose(f);
outdata = malloc(i);
r = decryptb((char*)outdata, v, i, passphrase, nonce);
if (r) {
- return ERR_NOKEY;
+ return r;
}
//r = key_from_data(key, (char*)outdata, l);
c = (size_t)(*((int*)outdata));
p = (char*)(outdata+sizeof(int));
r = key_from_data(key, p, c);
free(outdata);
- return r;
+ return ERR_OK;
}
static int key_create(struct gpg_store *gpg, gcry_sexp_t *key) {
int r;
- char *p;
+ const char *p;
const char *sexp_quick = "(genkey(ecc(flags eddsa)(curve Ed25519)))";
//char *pv;
gcry_sexp_t in;
@@ -270,25 +277,26 @@ static int key_create(struct gpg_store *gpg, gcry_sexp_t *key) {
e = gcry_sexp_new(&in, (const void*)sexp_quick, strlen(sexp_quick), 0);
if (e) {
- printf("error sexp: %s\n", gcry_strerror(e));
- return (int)e;
+ p = gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, (char*)p);
}
e = gcry_pk_genkey(key, in);
if (e) {
- printf("error gen: %s\n", gcry_strerror(e));
- return (int)e;
+ p = gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, (char*)p);
}
p = (char*)gcry_pk_get_keygrip(*key, (unsigned char*)gpg->fingerprint);
if (p == NULL) {
- return ERR_KEYFAIL;
+ p = gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, (char*)p);
}
r = key_apply_public(gpg, *key);
if (r) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
- return 0;
+ return ERR_OK;
}
/**
@@ -312,7 +320,7 @@ static int key_create_file(struct gpg_store *gpg, gcry_sexp_t *key, const char *
r = key_create(gpg, key);
if (r) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
kl = gcry_sexp_sprint(*key, GCRYSEXP_FMT_CANON, NULL, 0);
@@ -335,24 +343,24 @@ static int key_create_file(struct gpg_store *gpg, gcry_sexp_t *key, const char *
gcry_create_nonce(nonce, CHACHA20_NONCE_LENGTH_BYTES);
r = encryptb(ciphertext, c, v, m+sizeof(int), passphrase, nonce);
if (r) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
p = key_filename(gpg, path);
if (p == NULL) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
f = fopen((char*)path, "w");
if (f == NULL) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
l = c;
c = fwrite(nonce, CHACHA20_NONCE_LENGTH_BYTES, 1, f);
if (c != 1) {
fclose(f);
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
i = 0;
c = 1;
@@ -378,12 +386,12 @@ int gpg_key_create(struct gpg_store *gpg, const char *passphrase) {
r = key_create_file(gpg, &key, passphrase);
if (r) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
p = key_filename(gpg, key_path);
if (p == NULL) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
strcpy(link_path, gpg->path);
@@ -392,12 +400,12 @@ int gpg_key_create(struct gpg_store *gpg, const char *passphrase) {
r = unlink(link_path);
if (r == -1 && errno != ENOENT) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
r = symlink(key_path, link_path);
if (r) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
return ERR_OK;
}
@@ -416,7 +424,7 @@ int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mo
strcpy(p, "kee.key");
r = key_from_file(&gpg->k, path, passphrase);
if (r) {
- return ERR_FAIL;
+ return debug_logerr(LLOG_WARNING, ERR_KEYFAIL, NULL);
}
break;
case KEE_GPG_FIND_FINGERPRINT:
@@ -425,25 +433,25 @@ int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mo
c = 41;
r = bin_to_hex((const unsigned char*)criteria, FINGERPRINT_LENGTH, (unsigned char*)p, &c);
if (r) {
- return ERR_FAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
r = key_from_file(&gpg->k, path, passphrase);
if (r) {
- return ERR_FAIL;
+ return debug_logerr(LLOG_WARNING, ERR_KEYFAIL, NULL);
}
break;
default:
- return ERR_FAIL;
+ return debug_logerr(LLOG_WARNING, ERR_FAIL, NULL);
}
p = (char*)gcry_pk_get_keygrip(gpg->k, (unsigned char*)gpg->fingerprint);
if (p == NULL) {
- return ERR_KEYFAIL;
+ return debug_logerr(LLOG_ERROR, ERR_KEYFAIL, NULL);
}
r = key_apply_public(gpg, gpg->k);
if (r) {
- return ERR_FAIL;
+ return debug_logerr(LLOG_ERROR, ERR_FAIL, NULL);
}
return ERR_OK;
@@ -451,24 +459,22 @@ int gpg_key_load(struct gpg_store *gpg, const char *passphrase, enum gpg_find_mo
int gpg_verify(gcry_sexp_t *sig, gcry_sexp_t *key, const char *v) {
+ const char *p;
gcry_error_t e;
gcry_sexp_t data;
size_t err_offset;
- char in[BUFLEN];
e = gcry_sexp_build(&data, &err_offset, "(data(flags eddsa)(hash-algo sha512)(value %b))", 64, v);
if (e) {
- sprintf(in, "error sign sexp data build: %s\n", gcry_strerror(e));
- debug_log(DEBUG_ERROR, in);
- return ERR_KEYFAIL;
+ p = gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_FAIL, (char*)p);
}
e = gcry_pk_verify(*sig, data, *key);
if (e != GPG_ERR_NO_ERROR) {
- sprintf(in, "error verify: %s\n", gcry_strerror(e));
- debug_log(DEBUG_ERROR, in);
- return 1;
+ p = gcry_strerror(e);
+ return debug_logerr(LLOG_ERROR, ERR_FAIL, (char*)p);
}
- return 0;
+ return ERR_OK;
}
char *gpg_store_get_fingerprint(struct gpg_store *gpg) {
diff --git a/src/gpg.h b/src/gpg.h
@@ -23,12 +23,14 @@
#define ERR_NOCRYPTO 0x101
/// Crypto authentication fail
#define ERR_KEYFAIL 0x102
+/// Fail access to keyfile
+#define ERR_KEYFILE 0x103
/// Last attempt to unlock key failed
-#define ERR_KEY_UNLOCK 0x103
+#define ERR_KEY_UNLOCK 0x104
/// Usage of key for signature has been rejected (by user)
-#define ERR_KEY_REJECT 0x104
+#define ERR_KEY_REJECT 0x105
/// Crypto resource fail
-#define ERR_NOKEY 0x105
+#define ERR_NOKEY 0x106
enum gpg_find_mode_e {
diff --git a/src/gtk/Makefile b/src/gtk/Makefile
@@ -4,13 +4,15 @@ INCLUDES := -I.. -I../aux/include
CFLAGS += `pkg-config --cflags gtk4 gstreamer-1.0 libtasn1 libqrencode zbar` $(INCLUDES) -g3 -Wall
LIBS := `pkg-config --libs gtk4 zlib lmdb libgcrypt libxdg-basedir gstreamer-1.0 libtasn1 libqrencode zbar` -lb64 -lcmime -llash -lldap
LDFLAGS += $(LIBS)
+AUXLIBS := `pkg-config --libs kee`
all: resource $(OBJS)
- $(CC) $(CFLAGS) main.c -o a.out $(LINKOBJS) $(LDFLAGS)
+ $(CC) $(CFLAGS) main.c -o a.out $(LINKOBJS) $(LDFLAGS) $(AUXLIBS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
+
debug: all
clean:
diff --git a/src/gtk/context.c b/src/gtk/context.c
@@ -28,7 +28,7 @@ int kee_context_init(struct kee_context *ctx, struct kee_settings *settings) {
kee_entry_store_set_resolve(ctx->entry_store, (char*)settings->resource);
//ctx->resolver.locator = malloc(KEE_LOCATOR_LENGTH);
- ctx->resolver.locator = settings->resource;
+ ctx->resolver.locator = (char*)settings->resource;
return ERR_OK;
}
diff --git a/src/gtk/debug.c b/src/gtk/debug.c
@@ -2,8 +2,6 @@
#include "debug.h"
-#define G_LOG_DOMAIN "Kee"
-
void debug_log(enum debugLevel level, const char *s) {
int loglevel;
@@ -21,4 +19,4 @@ void debug_log(enum debugLevel level, const char *s) {
g_log(G_LOG_DOMAIN, loglevel, s);
}
-extern void debug_logerr(enum lloglvl_e lvl, char *msg, int err);
+extern int debug_logerr(enum lloglvl_e lvl, int err, char *msg);
diff --git a/src/gtk/kee-entry-item-store.c b/src/gtk/kee-entry-item-store.c
@@ -8,7 +8,6 @@
#include "db.h"
#include "err.h"
-#define G_LOG_DOMAIN "Kee"
const size_t entry_ref_len = 65;
const size_t entry_key_len = 73;
diff --git a/src/gtk/kee-entry-list.c b/src/gtk/kee-entry-list.c
@@ -5,8 +5,8 @@
#include "kee-entry.h"
#include "kee-menu.h"
#include "err.h"
+#include "debug.h"
-#define G_LOG_DOMAIN "Kee"
typedef struct {
} KeeEntryListPrivate;
diff --git a/src/gtk/kee-entry-store.c b/src/gtk/kee-entry-store.c
@@ -11,8 +11,6 @@
#include "cadiz.h"
#include "ledger.h"
-#define G_LOG_DOMAIN "Kee"
-
typedef struct {
} KeeEntryStorePrivate;
diff --git a/src/gtk/kee-entry.c b/src/gtk/kee-entry.c
@@ -28,7 +28,6 @@
#include "transport.h"
#include "qr.h"
-#define G_LOG_DOMAIN "Kee"
typedef struct {
} KeeEntryPrivate;
diff --git a/src/gtk/kee-import.c b/src/gtk/kee-import.c
@@ -138,14 +138,14 @@ static void kee_import_handle_import_data_text(KeeImport *o, GString *v, GtkText
g_simple_action_set_enabled(G_SIMPLE_ACTION(act), true);
g_action_activate(act, NULL);
}
-
-static void accept_cmd(KeeImport *o, char cmd) {
- o->cmd_accept = cmd;
-}
-
-static int check_cmd(KeeImport *o, char cmd) {
- return 1;
-}
+//
+//static void accept_cmd(KeeImport *o, char cmd) {
+// o->cmd_accept = cmd;
+//}
+//
+//static int check_cmd(KeeImport *o, char cmd) {
+// return 1;
+//}
/// \todo too long, split up
diff --git a/src/gtk/kee-key.c b/src/gtk/kee-key.c
@@ -5,8 +5,8 @@
#include "gpg.h"
#include "err.h"
#include "hex.h"
+#include "debug.h"
-#define G_LOG_DOMAIN "Kee"
typedef struct {
} KeeKeyPrivate;
diff --git a/src/gtk/kee-menu.c b/src/gtk/kee-menu.c
@@ -10,7 +10,6 @@
#include "context.h"
#include "debug.h"
-#define G_LOG_DOMAIN "Kee"
typedef struct {
} KeeMenuPrivate;
@@ -201,6 +200,7 @@ static void kee_menu_header_update(KeeMenu *o, const char *label) {
act = g_action_map_lookup_action(G_ACTION_MAP(o), "back");
g_simple_action_set_enabled(G_SIMPLE_ACTION(act), true);
} else if (!(strcmp(label, "import"))) {
+ } else if (!(strcmp(label, "transport"))) {
} else {
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "unknown nav label: %s", label);
}
diff --git a/src/gtk/menu.c b/src/gtk/menu.c
@@ -6,8 +6,8 @@
#include "context.h"
#include "state.h"
#include "menu.h"
+#include "debug.h"
-#define G_LOG_DOMAIN "Kee"
static void act_quit(GAction *act, GVariant *param, GApplication *gapp) {
g_application_quit(gapp);
diff --git a/src/gtk/nav.h b/src/gtk/nav.h
@@ -3,12 +3,18 @@
#include <gtk/gtk.h>
+#ifndef KEE_NAV_N_DST
+#define KEE_NAV_N_DST 0
+#endif
+
struct KeeNav {
// GtkWidget *now;
// struct KeeNav *prev;
GtkWidget *now;
GtkWidget *widgets[128];
int c;
+ int flags;
+ void *dst[KEE_NAV_N_DST + 1];
};
int kee_nav_push(struct KeeNav *nav, GtkWidget *page);
diff --git a/src/gtk/tests/Makefile b/src/gtk/tests/Makefile
@@ -7,11 +7,12 @@ CFLAGS += `pkg-config --cflags gtk4 gstreamer-1.0 libqrencode` $(INCLUDES) -Wa
#LIBS := `pkg-config --libs gtk4 zlib lmdb libgcrypt libxdg-basedir gstreamer-1.0` -lb64 -lvarint -lcmime -llash
LIBS := `pkg-config --libs gtk4 zlib lmdb libgcrypt libxdg-basedir gstreamer-1.0 libqrencode` -lb64 -lcmime -llash -ltasn1 -lldap
LDFLAGS += $(LIBS)
+AUXLIBS := `pkg-config --libs kee`
all: $(OBJS)
%.o: %.c
- $(CC) $(CFLAGS) $< -o test_$* $(LINKOBJS) $(LDFLAGS)
+ $(CC) $(CFLAGS) $< -o test_$* $(LINKOBJS) $(LDFLAGS) $(AUXLIBS)
test_run: $(wildcard test_*)
./$<
diff --git a/src/tests/Makefile b/src/tests/Makefile
@@ -6,6 +6,7 @@ INCLUDES := -I..
CFLAGS += `pkg-config --cflags gtk4 gstreamer-1.0 zbar` $(INCLUDES) -Wall -DRERR -DRERR_N_PREFIX=2
LIBS := `pkg-config --libs gtk4 zlib lmdb libgcrypt libxdg-basedir gstreamer-1.0 libqrencode zbar` -lb64 -llash -ltasn1 -lcmime -lldap
LDFLAGS += $(LIBS)
+AUXLIBS := `pkg-config --libs kee`
all: obj_debug $(OBJS)
@@ -17,7 +18,7 @@ obj_debug: util
%.o: %.c
# $(CC) $(CFLAGS) $< -o test_$* debug.o testutil.o $(LINKOBJS) $(LDFLAGS)
- $(CC) $(CFLAGS) $< -o test_$* testutil.o $(LINKOBJS) $(LDFLAGS)
+ $(CC) $(CFLAGS) $< -o test_$* testutil.o $(LINKOBJS) $(LDFLAGS) $(AUXLIBS)
#test_run: $(wildcard test_*)
# ./$<
diff --git a/src/tests/debugdebug.c b/src/tests/debugdebug.c
@@ -9,7 +9,7 @@ char *_rerr[2] = {
int main() {
rerr_init();
rerr_register(0x100, "debugtest", _rerr);
- debug_logerr(LLOG_INFO, "foo", 0x101);
+ debug_logerr(LLOG_INFO, 0x101, "foo");
return ERR_OK;
}
diff --git a/src/tests/testutil.c b/src/tests/testutil.c
@@ -14,7 +14,7 @@ void debug_log(enum debugLevel level, const char *s) {
fprintf(stderr, "%s\n", s);
}
-extern void debug_logerr(enum lloglvl_e lvl, char *msg, int err);
+extern int debug_logerr(enum lloglvl_e lvl, int err, char *msg);
int kee_test_db(struct kee_test_t *t) {