This commit is contained in:
Олег Бородин
2023-09-04 10:07:17 +02:00
parent 00b5cb548a
commit 0cf61f4ad8
16 changed files with 371 additions and 123 deletions

5
.gitignore vendored
View File

@@ -1,6 +1,8 @@
cworker cworker
configure configure
libtool
Makefile Makefile
config.h
*~ *~
*_test *_test
*.o *.o
@@ -10,3 +12,6 @@ Makefile
*.tar.* *.tar.*
stamp* stamp*
autom4te* autom4te*
*.lo
*.la
.libs

View File

@@ -237,20 +237,20 @@ distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print
ACLOCAL = ${SHELL} /home/ziggi/projects/cworker/missing aclocal ACLOCAL = ${SHELL} /home/ziggi/Projects/cworker/missing aclocal
AMTAR = $${TAR-tar} AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY = 1 AM_DEFAULT_VERBOSITY = 1
APP_CACHEDIR = /home/ziggi/projects/cworker/cache APP_CACHEDIR = /home/ziggi/Projects/cworker/cache
APP_CONFIGDIR = /home/ziggi/projects/cworker/ APP_CONFIGDIR = /home/ziggi/Projects/cworker/
APP_DATABASEDIR = /home/ziggi/projects/cworker/data APP_DATABASEDIR = /home/ziggi/Projects/cworker/data
APP_LIBDIR = /home/ziggi/projects/cworker/lib APP_LIBDIR = /home/ziggi/Projects/cworker/lib
APP_LOGDIR = /home/ziggi/projects/cworker/log APP_LOGDIR = /home/ziggi/Projects/cworker/log
APP_RUNDIR = /home/ziggi/projects/cworker/run APP_RUNDIR = /home/ziggi/Projects/cworker/run
APP_USER = ziggi APP_USER = ziggi
AR = ar AR = ar
AUTOCONF = ${SHELL} /home/ziggi/projects/cworker/missing autoconf AUTOCONF = ${SHELL} /home/ziggi/Projects/cworker/missing autoconf
AUTOHEADER = ${SHELL} /home/ziggi/projects/cworker/missing autoheader AUTOHEADER = ${SHELL} /home/ziggi/Projects/cworker/missing autoheader
AUTOMAKE = ${SHELL} /home/ziggi/projects/cworker/missing automake AUTOMAKE = ${SHELL} /home/ziggi/Projects/cworker/missing automake
AWK = gawk AWK = gawk
CC = clang CC = clang
CCDEPMODE = depmode=none CCDEPMODE = depmode=none
@@ -286,7 +286,7 @@ LIPO =
LN_S = ln -s LN_S = ln -s
LTLIBOBJS = LTLIBOBJS =
LT_SYS_LIBRARY_PATH = LT_SYS_LIBRARY_PATH =
MAKEINFO = ${SHELL} /home/ziggi/projects/cworker/missing makeinfo MAKEINFO = ${SHELL} /home/ziggi/Projects/cworker/missing makeinfo
MANIFEST_TOOL = : MANIFEST_TOOL = :
MKDIR_P = /usr/local/bin/gmkdir -p MKDIR_P = /usr/local/bin/gmkdir -p
NM = /usr/bin/nm NM = /usr/bin/nm
@@ -310,10 +310,10 @@ SHELL = /bin/sh
STRIP = strip STRIP = strip
VALGRIND = /usr/local/bin/valgrind VALGRIND = /usr/local/bin/valgrind
VERSION = 0.0.1 VERSION = 0.0.1
abs_builddir = /home/ziggi/projects/cworker abs_builddir = /home/ziggi/Projects/cworker
abs_srcdir = /home/ziggi/projects/cworker abs_srcdir = /home/ziggi/Projects/cworker
abs_top_builddir = /home/ziggi/projects/cworker abs_top_builddir = /home/ziggi/Projects/cworker
abs_top_srcdir = /home/ziggi/projects/cworker abs_top_srcdir = /home/ziggi/Projects/cworker
ac_ct_AR = ar ac_ct_AR = ar
ac_ct_CC = clang ac_ct_CC = clang
ac_ct_DUMPBIN = ac_ct_DUMPBIN =
@@ -322,13 +322,13 @@ am__leading_dot = .
am__quote = am__quote =
am__tar = $${TAR-tar} chof - "$$tardir" am__tar = $${TAR-tar} chof - "$$tardir"
am__untar = $${TAR-tar} xf - am__untar = $${TAR-tar} xf -
app_cachedir = /home/ziggi/projects/cworker/cache app_cachedir = /home/ziggi/Projects/cworker/cache
app_configdir = /home/ziggi/projects/cworker/ app_configdir = /home/ziggi/Projects/cworker/
app_databasedir = /home/ziggi/projects/cworker/data app_databasedir = /home/ziggi/Projects/cworker/data
app_libdir = /home/ziggi/projects/cworker/lib app_libdir = /home/ziggi/Projects/cworker/lib
app_logdir = /home/ziggi/projects/cworker/log app_logdir = /home/ziggi/Projects/cworker/log
app_name = cworker app_name = cworker
app_rundir = /home/ziggi/projects/cworker/run app_rundir = /home/ziggi/Projects/cworker/run
app_user = ziggi app_user = ziggi
bindir = ${exec_prefix}/bin bindir = ${exec_prefix}/bin
build = amd64-unknown-freebsd12.4 build = amd64-unknown-freebsd12.4
@@ -350,7 +350,7 @@ host_vendor = unknown
htmldir = ${docdir} htmldir = ${docdir}
includedir = ${prefix}/include includedir = ${prefix}/include
infodir = ${datarootdir}/info infodir = ${datarootdir}/info
install_sh = ${SHELL} /home/ziggi/projects/cworker/install-sh install_sh = ${SHELL} /home/ziggi/Projects/cworker/install-sh
libdir = ${exec_prefix}/lib libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale localedir = ${datarootdir}/locale

View File

@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo
SUFFIXES = .c .o SUFFIXES = .c .o
AM_CFLAGS = -Wall AM_CFLAGS = -Wall

View File

@@ -377,7 +377,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo AUTOMAKE_OPTIONS = foreign no-dependencies no-installinfo
SUFFIXES = .c .o SUFFIXES = .c .o
AM_CFLAGS = -Wall AM_CFLAGS = -Wall
AM_LDFLAGS = -pthread AM_LDFLAGS = -pthread

View File

@@ -23,6 +23,13 @@ void jblock_init(jblock_t* jb) {
jb->kvarr = malloc(sizeof(jkeyval_t) * INIT_CAPA); jb->kvarr = malloc(sizeof(jkeyval_t) * INIT_CAPA);
} }
jblock_t* new_jblock() {
jblock_t* jb = malloc(sizeof(jblock_t));
if (jb == NULL) return NULL;
jblock_init(jb);
return jb;
}
static void* jblock_checkalloc(jblock_t* jb) { static void* jblock_checkalloc(jblock_t* jb) {
if (jb->kvsize == jb->kvcapa) { if (jb->kvsize == jb->kvcapa) {
size_t newsize = jb->kvcapa * 2; size_t newsize = jb->kvcapa * 2;
@@ -161,19 +168,44 @@ void jblock_outjson(jblock_t* jb, char** res) {
void jblock_destroy(jblock_t* jb) { void jblock_destroy(jblock_t* jb) {
if (jb == NULL) return; if (jb == NULL) return;
for (int i = 0; i < jb->kvsize; i++) { for (int i = 0; i < jb->kvsize; i++) {
free(jb->kvarr[i].key);
switch (jb->kvarr[i].type) { switch (jb->kvarr[i].type) {
case JKVTYPE_BLK: {
jblock_destroy(jb->kvarr[i].blk);
break;
}
//case JKVTYPE_BLKARR: {
// break;
//}
case JKVTYPE_STR: { case JKVTYPE_STR: {
free(jb->kvarr[i].str); free(jb->kvarr[i].str);
break;
}
case JKVTYPE_INTARR: {
//free(jb->kvarr[i].numarr);
break;
}
case JKVTYPE_BOOLARR: {
//free(jb->kvarr[i].flagarr);
break;
}
case JKVTYPE_FLTARR: {
//free(jb->kvarr[i].fltarr);
break;
} }
} }
free(jb->kvarr[i].key);
} }
jb->kvsize = 0; jb->kvsize = 0;
jb->kvcapa = 0; jb->kvcapa = 0;
jb->kvarr = NULL; jb->kvarr = NULL;
} }
void jblock_free(jblock_t* jb) {
jblock_destroy(jb);
free(jb);
}
/* String container */
static void* jstring_init(jstring_t* str) { static void* jstring_init(jstring_t* str) {
str->data = malloc(INIT_CAPA + 1); str->data = malloc(INIT_CAPA + 1);
if (str->data == NULL) return NULL; if (str->data == NULL) return NULL;
@@ -188,7 +220,7 @@ static void* jstring_append(jstring_t* str, char* add) {
size_t addsize = strlen(add); size_t addsize = strlen(add);
size_t newsize = str->size + addsize; size_t newsize = str->size + addsize;
if (newsize > str->capa) { if (newsize > str->capa) {
char* newstr = malloc(newsize + 1); char* newstr = realloc(str->data, newsize + 1);
if (newstr == NULL) return NULL; if (newstr == NULL) return NULL;
} }
strcpy(&(str->data[str->size]), add); strcpy(&(str->data[str->size]), add);
@@ -202,6 +234,118 @@ static char* jstring_getref(jstring_t* str) {
return str->data; return str->data;
} }
/* Integer array */
jintarr_t* new_jintarr(void) {
jintarr_t* arr = malloc(sizeof(jintarr_t));
if (arr == NULL) return NULL;
if (jintarr_init(arr) == NULL) {
jintarr_free(arr);
return NULL;
}
return arr;
}
void* jintarr_init(jintarr_t* array) {
array->data = malloc(INIT_CAPA * sizeof(int64_t));
if (array->data == NULL) return NULL;
memset(array->data, 0, INIT_CAPA);
array->capa = INIT_CAPA;
array->size = 0;
return array->data;
}
void* jintarr_append(jintarr_t* array, int64_t add) {
if (array->size + 1 > array->capa) {
size_t newcapa = (array->capa * 10) / 6 ;
int64_t* newarray = realloc(array->data, newcapa);
if (newarray == NULL) return NULL;
array->capa = newcapa;
array->data = newarray;
}
array->data[array->size++] = add;
return array->data;
}
int64_t* jintarr_getref(jintarr_t* array) {
return array->data;
}
void jintarr_destroy(jintarr_t* array) {
if (array == NULL) return;
free(array->data);
}
void jintarr_free(jintarr_t* array) {
jintarr_destroy(array);
free(array->data);
}
/* Float array */
void* jfltarr_init(jfltarr_t* array) {
array->data = malloc(INIT_CAPA * sizeof(double));
if (array->data == NULL) return NULL;
memset(array->data, 0, INIT_CAPA);
array->capa = INIT_CAPA;
array->size = 0;
return array->data;
}
void* jfltarr_append(jfltarr_t* array, double add) {
if (array->size + 1 > array->capa) {
size_t newcapa = (array->capa * 10) / 6 ;
double* newarray = realloc(array->data, newcapa);
if (newarray == NULL) return NULL;
array->capa = newcapa;
array->data = newarray;
}
array->data[array->size++] = add;
return array->data;
}
double* jfltarr_getref(jfltarr_t* array) {
return array->data;
}
void jfltarr_destroy(jfltarr_t* array) {
if (array == NULL) return;
free(array->data);
}
/* Bool array */
void* jboolarr_init(jboolarr_t* array) {
array->data = malloc(INIT_CAPA * sizeof(bool));
if (array->data == NULL) return NULL;
memset(array->data, 0, INIT_CAPA);
array->capa = INIT_CAPA;
array->size = 0;
return array->data;
}
void* jboolarr_append(jboolarr_t* array, bool add) {
if (array->size + 1 > array->capa) {
size_t newcapa = (array->capa * 10) / 6 ;
bool* newarray = realloc(array->data, newcapa);
if (newarray == NULL) return NULL;
array->capa = newcapa;
array->data = newarray;
}
array->data[array->size++] = add;
return array->data;
}
bool* jboolarr_getref(jboolarr_t* array) {
return array->data;
}
void jboolarr_destroy(jboolarr_t* array) {
if (array == NULL) return;
free(array->data);
}
/* Tools */
static char* strcopy(char* src) { static char* strcopy(char* src) {
size_t srcsize = strlen(src) + 1; size_t srcsize = strlen(src) + 1;
char* dst = malloc(srcsize); char* dst = malloc(srcsize);

View File

@@ -5,56 +5,106 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
typedef struct { typedef struct {
char* data; char* data;
int capa; int capa;
int size; int size;
} jstring_t; } jstring_t;
typedef struct {
int64_t* data;
int capa;
int size;
} jintarr_t;
typedef struct {
bool* data;
int capa;
int size;
} jboolarr_t;
typedef struct {
double* data;
int capa;
int size;
} jfltarr_t;
typedef struct jblock jblock_t;
typedef struct { typedef struct {
char* key; char* key;
int type; int type;
union { union {
int64_t num; int64_t num;
bool flag; bool flag;
char* str; char* str;
double flt; double flt;
int64_t* numarr; jintarr_t numarr;
char** strarr; jfltarr_t fltarr;
double* fltarr; jboolarr_t flagarr;
bool* flagarr; jblock_t* blk;
jblock_t* blkarr;
char** strarr;
}; };
int arrsize; int arrsize;
int arrcapa; int arrcapa;
} jkeyval_t; } jkeyval_t;
typedef struct { struct jblock {
jkeyval_t* kvarr; jkeyval_t* kvarr;
int kvsize; int kvsize;
int kvcapa; int kvcapa;
} jblock_t; };
#define JKVTYPE_INT 0x01 #define JKVTYPE_INT 0x01
#define JKVTYPE_STR 0x02 #define JKVTYPE_STR 0x02
#define JKVTYPE_BOOL 0x03 #define JKVTYPE_BOOL 0x03
#define JKVTYPE_FLT 0x04 #define JKVTYPE_FLT 0x04
#define JKVTYPE_BLK 0x05
#define JKVTYPE_INTARR 0x11 #define JKVTYPE_INTARR 0x11
#define JKVTYPE_STRARR 0x12 #define JKVTYPE_STRARR 0x12
#define JKVTYPE_BOOLARR 0x13 #define JKVTYPE_BOOLARR 0x13
#define JKVTYPE_FLTARR 0x14 #define JKVTYPE_FLTARR 0x14
#define JKVTYPE_BLKARR 0x15
#define JB_MALLOCERR -1 #define JB_MALLOCERR -1
#define JB_KEYEXISTS -2 #define JB_KEYEXISTS -2
jblock_t* new_jblock();
void jblock_init(jblock_t* block);
void jblock_outjson(jblock_t* block, char** res);
void jblock_destroy(jblock_t* block);
void jblock_free(jblock_t* jb);
void jblock_init(jblock_t* kv); int jblock_addint(jblock_t* block, char* key, int64_t val);
void jblock_outjson(jblock_t* kv, char** res); int jblock_addfloat(jblock_t* block, char* key, double val);
void jblock_destroy(jblock_t* kv); int jblock_addstr(jblock_t* block, char* key, char* val);
int jblock_addbool(jblock_t* block, char* key, bool val);
jintarr_t* new_jintarr(void);
void* jintarr_init(jintarr_t* array);
void* jintarr_append(jintarr_t* array, int64_t add);
int64_t* jintarr_getref(jintarr_t* array);
void jintarr_destroy(jintarr_t* array);
void jintarr_free(jintarr_t* array);
jfltarr_t* new_jfltarr(void);
void* jfltarr_init(jfltarr_t* array);
void* jfltarr_append(jfltarr_t* array, double add);
double* jfltarr_getref(jfltarr_t* array);
void jfltarr_destroy(jfltarr_t* array);
void jfltarr_free(jfltarr_t* array);
jboolarr_t* new_jboolarr(void);
void* jboolarr_init(jboolarr_t* array);
void* jboolarr_append(jboolarr_t* array, bool add);
bool* jboolarr_getref(jboolarr_t* array);
void jboolarr_destroy(jboolarr_t* array);
void jboolarr_free(jboolarr_t* array);
int jblock_addint(jblock_t* kv, char* key, int64_t val);
int jblock_addfloat(jblock_t* kv, char* key, double val);
int jblock_addstr(jblock_t* kv, char* key, char* val);
int jblock_addbool(jblock_t* kv, char* key, bool val);
#endif #endif

View File

@@ -12,25 +12,54 @@
void test01(void) { void test01(void) {
jblock_t jb; jblock_t* jb = new_jblock();
jblock_init(&jb); jblock_init(jb);
jblock_addint(&jb, "id1", 12345); jblock_addint(jb, "id1", 12345);
jblock_addstr(&jb, "id2", "qwerty"); jblock_addstr(jb, "id2", "qwerty");
jblock_addbool(&jb, "b1", true); jblock_addbool(jb, "b1", true);
jblock_addbool(&jb, "b2", false); jblock_addbool(jb, "b2", false);
jblock_addfloat(&jb, "f1", (double)123e1); jblock_addfloat(jb, "f1", (double)123e1);
char* jsonstr = NULL; char* jsonstr = NULL;
jblock_outjson(&jb, &jsonstr); jblock_outjson(jb, &jsonstr);
jblock_destroy(&jb); jblock_free(jb);
printf("%s\n", jsonstr); printf("%s\n", jsonstr);
free(jsonstr); free(jsonstr);
} }
void test02(void) {
jintarr_t* arr = new_jintarr();
jintarr_init(arr);
for (int64_t i = 0; i < 1024 + 1; i++) {
jintarr_append(arr, i);
}
printf("size: %d capa: %d\n", arr->size, arr->capa);
printf("last: %ld\n", arr->data[arr->size - 1]);
jintarr_free(arr);
}
void test03(void) {
jfltarr_t arr;
jfltarr_init(&arr);
for (int64_t i = 0; i < 1024 + 1; i++) {
jfltarr_append(&arr, i);
}
printf("size: %d capa: %d\n", arr.size, arr.capa);
printf("last: %f\n", arr.data[arr.size - 1]);
jfltarr_destroy(&arr);
}
int main(void) { int main(void) {
test01(); //test01();
test02();
test03();
return 0; return 0;
} }

View File

@@ -10,25 +10,27 @@
#include <rcache.h> #include <rcache.h>
#include <jlexer.h> #include <jlexer.h>
#define JLEXCONT_UNDEF 0 #define JLEXCONT_UNDEF 0x00
#define JLEXCONT_WORD 1 #define JLEXCONT_WORD 0x01
#define JLEXCONT_BLOCKB 2 #define JLEXCONT_BLOCKB 0x02
#define JLEXCONT_BLOCKE 3 #define JLEXCONT_BLOCKE 0x03
#define JLEXCONT_SEPAR 4 #define JLEXCONT_SEPAR 0x04
#define JLEXCONT_NUM 5 #define JLEXCONT_NUM 0x05
#define JLEXCONT_UNKNOW 6 #define JLEXCONT_UNKNOW 0x06
#define JLEXCONT_END 9 #define JLEXCONT_END 0x99
#define JLEXTYPE_UNDEF 0 #define JLEXTYPE_UNDEF 0x00
#define JLEXTYPE_BLOCKB 1 #define JLEXTYPE_BLOCKB 0x01
#define JLEXTYPE_BLOCKE 2 #define JLEXTYPE_BLOCKE 0x02
#define JLEXTYPE_WORDL 3 #define JLEXTYPE_WORDL 0x03
#define JLEXTYPE_SPACE 4 #define JLEXTYPE_SPACE 0x04
#define JLEXTYPE_SEPAR 5 #define JLEXTYPE_SEPAR 0x05
#define JLEXTYPE_NUM 6 #define JLEXTYPE_NUM 0x06
#define JLEXTYPE_COMMA 7 #define JLEXTYPE_COMMA 0x07
#define JLEXTYPE_CHAR 8 #define JLEXTYPE_CHAR 0x08
#define JLEXTYPE_EOF 9 #define JLEXTYPE_ARRB 0x11
#define JLEXTYPE_ARRE 0x12
#define JLEXTYPE_EOF 0x99
static int get_ltype(char letter) { static int get_ltype(char letter) {
@@ -39,6 +41,10 @@ static int get_ltype(char letter) {
return JLEXTYPE_BLOCKB; return JLEXTYPE_BLOCKB;
case '}': case '}':
return JLEXTYPE_BLOCKE; return JLEXTYPE_BLOCKE;
case '[':
return JLEXTYPE_ARRB;
case ']':
return JLEXTYPE_ARRE;
case '"': case '"':
return JLEXTYPE_WORDL; return JLEXTYPE_WORDL;
case ' ': case ' ':
@@ -113,6 +119,16 @@ int jlexer_gettoken(jlexer_t * lexer, char* token) {
lexer->context = JLEXCONT_UNDEF; lexer->context = JLEXCONT_UNDEF;
return JLEXTOK_BLOCKE; return JLEXTOK_BLOCKE;
} }
case JLEXTYPE_ARRB:{
strcpy(token, "ARR BEGIN");
lexer->context = JLEXCONT_UNDEF;
return JLEXTOK_ARRB;
}
case JLEXTYPE_ARRE:{
strcpy(token, "ARR END");
lexer->context = JLEXCONT_UNDEF;
return JLEXTOK_ARRE;
}
case JLEXTYPE_SEPAR:{ case JLEXTYPE_SEPAR:{
strcpy(token, "IS"); strcpy(token, "IS");
lexer->context = JLEXCONT_UNDEF; lexer->context = JLEXCONT_UNDEF;

View File

@@ -16,16 +16,18 @@ typedef struct {
#define JLEXTOK_BLOCKB 1 #define JLEXTOK_BLOCKB 0x01
#define JLEXTOK_BLOCKE 2 #define JLEXTOK_BLOCKE 0x02
#define JLEXTOK_SPACE 4 #define JLEXTOK_SPACE 0x04
#define JLEXTOK_SEPAR 3 #define JLEXTOK_SEPAR 0x03
#define JLEXTOK_UNDEF 4 #define JLEXTOK_UNDEF 0x04
#define JLEXTOK_WORD 5 #define JLEXTOK_WORD 0x05
#define JLEXTOK_NUMB 6 #define JLEXTOK_NUMB 0x06
#define JLEXTOK_UNKNOW 7 #define JLEXTOK_UNKNOW 0x07
#define JLEXTOK_NEXT 8 #define JLEXTOK_NEXT 0x08
#define JLEXTOK_END 9 #define JLEXTOK_ARRB 0x10
#define JLEXTOK_ARRE 0x11
#define JLEXTOK_END 0x99

View File

@@ -32,9 +32,9 @@ int main(void) {
int type = 0; int type = 0;
while ((type = jlexer_gettoken(&lexer, token)) != JLEXTOK_END) { while ((type = jlexer_gettoken(&lexer, token)) != JLEXTOK_END) {
printf("%d: %s\n", type, token); printf("%02x: %s\n", type, token);
} }
printf("%d: %s\n", type, token); printf("%02x: %s\n", type, token);
rcache_destroy(&cache); rcache_destroy(&cache);

View File

@@ -31,6 +31,7 @@ void jparser_init(jparser_t * parser, jlexer_t * lexer) {
#define MAX_TOKEN_SIZE 1024 #define MAX_TOKEN_SIZE 1024
int jparser_parse(jparser_t * parser) { int jparser_parse(jparser_t * parser) {
jlexer_t* lex = parser->lexer; jlexer_t* lex = parser->lexer;
char token[MAX_TOKEN_SIZE]; char token[MAX_TOKEN_SIZE];
@@ -40,7 +41,7 @@ int jparser_parse(jparser_t * parser) {
char* key = ""; char* key = "";
while ((type = jlexer_gettoken(lex, token)) != JLEXTOK_END) { while ((type = jlexer_gettoken(lex, token)) != JLEXTOK_END) {
//printf("pos %d %d: %s\n", pos, type, token); printf("pos %d tok 0x%02x: %s\n", pos, type, token);
switch (pos) { switch (pos) {
// POS 0 // POS 0
case 0:{ case 0:{

View File

@@ -23,9 +23,10 @@ typedef struct {
jlexer_t* lexer; jlexer_t* lexer;
} jparser_t; } jparser_t;
#define JVALTYPE_STR 1 #define JVALTYPE_STR 0x01
#define JVALTYPE_NUM 2 #define JVALTYPE_NUM 0x02
#define JVALTYPE_BOOL 3 #define JVALTYPE_BOOL 0x03
#define JVALTYPE_BLK 0x04
void jparser_init(jparser_t* parser, jlexer_t* lexer); void jparser_init(jparser_t* parser, jlexer_t* lexer);

View File

@@ -40,14 +40,14 @@ int main(void) {
int64_t id = 0; int64_t id = 0;
if (jparser_bind(&parser, JVALTYPE_NUM, "id", (void *)&id) < 0) { if (jparser_bind(&parser, JVALTYPE_NUM, "id", (void *)&id) < 0) {
log_error("cannot bind variable\n"); log_error("cannot bind id variable\n");
return 1; return 1;
} }
char* name = ""; char* name = "";
if (jparser_bind(&parser, JVALTYPE_STR, "name", (void *)&name) < 0) { if (jparser_bind(&parser, JVALTYPE_STR, "name", (void *)&name) < 0) {
log_error("cannot bind variable\n"); log_error("cannot bind name variable\n");
} }
printf("id = %ld\n", id); printf("id = %ld\n", id);

View File

@@ -2,8 +2,8 @@
#ifndef CONFIG_H_QWER #ifndef CONFIG_H_QWER
#define CONFIG_H_QWER #define CONFIG_H_QWER
static const char *srv_runpath = "/home/ziggi/projects/cworker/run/cworker.pid"; static const char *srv_runpath = "/home/ziggi/Projects/cworker/run/cworker.pid";
static const char *srv_logpath = "/home/ziggi/projects/cworker/log/cworker.log"; static const char *srv_logpath = "/home/ziggi/Projects/cworker/log/cworker.log";
static const char *srv_configpath = "/home/ziggi/projects/cworker//cworker.conf"; static const char *srv_configpath = "/home/ziggi/Projects/cworker//cworker.conf";
#endif #endif

View File

@@ -430,7 +430,7 @@ Copyright (C) 2021 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it." gives unlimited permission to copy, distribute and modify it."
ac_pwd='/home/ziggi/projects/cworker' ac_pwd='/home/ziggi/Projects/cworker'
srcdir='.' srcdir='.'
INSTALL='/usr/bin/install -c' INSTALL='/usr/bin/install -c'
MKDIR_P='/usr/local/bin/gmkdir -p' MKDIR_P='/usr/local/bin/gmkdir -p'
@@ -811,20 +811,20 @@ S["am__EXEEXT_FALSE"]=""
S["am__EXEEXT_TRUE"]="#" S["am__EXEEXT_TRUE"]="#"
S["LTLIBOBJS"]="" S["LTLIBOBJS"]=""
S["app_name"]="cworker" S["app_name"]="cworker"
S["app_cachedir"]="/home/ziggi/projects/cworker/cache" S["app_cachedir"]="/home/ziggi/Projects/cworker/cache"
S["APP_CACHEDIR"]="/home/ziggi/projects/cworker/cache" S["APP_CACHEDIR"]="/home/ziggi/Projects/cworker/cache"
S["app_databasedir"]="/home/ziggi/projects/cworker/data" S["app_databasedir"]="/home/ziggi/Projects/cworker/data"
S["APP_DATABASEDIR"]="/home/ziggi/projects/cworker/data" S["APP_DATABASEDIR"]="/home/ziggi/Projects/cworker/data"
S["app_user"]="ziggi" S["app_user"]="ziggi"
S["APP_USER"]="ziggi" S["APP_USER"]="ziggi"
S["app_libdir"]="/home/ziggi/projects/cworker/lib" S["app_libdir"]="/home/ziggi/Projects/cworker/lib"
S["APP_LIBDIR"]="/home/ziggi/projects/cworker/lib" S["APP_LIBDIR"]="/home/ziggi/Projects/cworker/lib"
S["app_rundir"]="/home/ziggi/projects/cworker/run" S["app_rundir"]="/home/ziggi/Projects/cworker/run"
S["APP_RUNDIR"]="/home/ziggi/projects/cworker/run" S["APP_RUNDIR"]="/home/ziggi/Projects/cworker/run"
S["app_logdir"]="/home/ziggi/projects/cworker/log" S["app_logdir"]="/home/ziggi/Projects/cworker/log"
S["APP_LOGDIR"]="/home/ziggi/projects/cworker/log" S["APP_LOGDIR"]="/home/ziggi/Projects/cworker/log"
S["app_configdir"]="/home/ziggi/projects/cworker/" S["app_configdir"]="/home/ziggi/Projects/cworker/"
S["APP_CONFIGDIR"]="/home/ziggi/projects/cworker/" S["APP_CONFIGDIR"]="/home/ziggi/Projects/cworker/"
S["SYSTEMD_FALSE"]="" S["SYSTEMD_FALSE"]=""
S["SYSTEMD_TRUE"]="#" S["SYSTEMD_TRUE"]="#"
S["LINUX_OS_FALSE"]="" S["LINUX_OS_FALSE"]=""
@@ -898,12 +898,12 @@ S["mkdir_p"]="$(MKDIR_P)"
S["MKDIR_P"]="/usr/local/bin/gmkdir -p" S["MKDIR_P"]="/usr/local/bin/gmkdir -p"
S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s" S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s"
S["STRIP"]="strip" S["STRIP"]="strip"
S["install_sh"]="${SHELL} /home/ziggi/projects/cworker/install-sh" S["install_sh"]="${SHELL} /home/ziggi/Projects/cworker/install-sh"
S["MAKEINFO"]="${SHELL} /home/ziggi/projects/cworker/missing makeinfo" S["MAKEINFO"]="${SHELL} /home/ziggi/Projects/cworker/missing makeinfo"
S["AUTOHEADER"]="${SHELL} /home/ziggi/projects/cworker/missing autoheader" S["AUTOHEADER"]="${SHELL} /home/ziggi/Projects/cworker/missing autoheader"
S["AUTOMAKE"]="${SHELL} /home/ziggi/projects/cworker/missing automake" S["AUTOMAKE"]="${SHELL} /home/ziggi/Projects/cworker/missing automake"
S["AUTOCONF"]="${SHELL} /home/ziggi/projects/cworker/missing autoconf" S["AUTOCONF"]="${SHELL} /home/ziggi/Projects/cworker/missing autoconf"
S["ACLOCAL"]="${SHELL} /home/ziggi/projects/cworker/missing aclocal" S["ACLOCAL"]="${SHELL} /home/ziggi/Projects/cworker/missing aclocal"
S["VERSION"]="0.0.1" S["VERSION"]="0.0.1"
S["PACKAGE"]="cworker" S["PACKAGE"]="cworker"
S["CYGPATH_W"]="echo" S["CYGPATH_W"]="echo"
@@ -1037,13 +1037,13 @@ D["HAVE_MEMSET"]=" 1"
D["HAVE_MKDIR"]=" 1" D["HAVE_MKDIR"]=" 1"
D["HAVE_SETLOCALE"]=" 1" D["HAVE_SETLOCALE"]=" 1"
D["HAVE_SOCKET"]=" 1" D["HAVE_SOCKET"]=" 1"
D["APP_CONFIGDIR"]=" \"/home/ziggi/projects/cworker/\"" D["APP_CONFIGDIR"]=" \"/home/ziggi/Projects/cworker/\""
D["APP_LOGDIR"]=" \"/home/ziggi/projects/cworker/log\"" D["APP_LOGDIR"]=" \"/home/ziggi/Projects/cworker/log\""
D["APP_RUNDIR"]=" \"/home/ziggi/projects/cworker/run\"" D["APP_RUNDIR"]=" \"/home/ziggi/Projects/cworker/run\""
D["APP_LIBDIR"]=" \"/home/ziggi/projects/cworker/lib\"" D["APP_LIBDIR"]=" \"/home/ziggi/Projects/cworker/lib\""
D["APP_USER"]=" \"ziggi\"" D["APP_USER"]=" \"ziggi\""
D["APP_DATABASEDIR"]=" \"/home/ziggi/projects/cworker/data\"" D["APP_DATABASEDIR"]=" \"/home/ziggi/Projects/cworker/data\""
D["APP_CACHEDIR"]=" \"/home/ziggi/projects/cworker/cache\"" D["APP_CACHEDIR"]=" \"/home/ziggi/Projects/cworker/cache\""
for (key in D) D_is_set[key] = 1 for (key in D) D_is_set[key] = 1
FS = "" FS = ""
} }

View File

@@ -2,22 +2,22 @@
/* defines.h.in. Generated from configure.ac by autoheader. */ /* defines.h.in. Generated from configure.ac by autoheader. */
/* location of cache dir */ /* location of cache dir */
#define APP_CACHEDIR "/home/ziggi/projects/cworker/cache" #define APP_CACHEDIR "/home/ziggi/Projects/cworker/cache"
/* location of configuration files for ${PACKAGE} */ /* location of configuration files for ${PACKAGE} */
#define APP_CONFIGDIR "/home/ziggi/projects/cworker/" #define APP_CONFIGDIR "/home/ziggi/Projects/cworker/"
/* location of database dir */ /* location of database dir */
#define APP_DATABASEDIR "/home/ziggi/projects/cworker/data" #define APP_DATABASEDIR "/home/ziggi/Projects/cworker/data"
/* location of libs */ /* location of libs */
#define APP_LIBDIR "/home/ziggi/projects/cworker/lib" #define APP_LIBDIR "/home/ziggi/Projects/cworker/lib"
/* location of ${PACKAGE} logdir */ /* location of ${PACKAGE} logdir */
#define APP_LOGDIR "/home/ziggi/projects/cworker/log" #define APP_LOGDIR "/home/ziggi/Projects/cworker/log"
/* location of pid file */ /* location of pid file */
#define APP_RUNDIR "/home/ziggi/projects/cworker/run" #define APP_RUNDIR "/home/ziggi/Projects/cworker/run"
/* effective user */ /* effective user */
#define APP_USER "ziggi" #define APP_USER "ziggi"