diff --git a/Makefile b/Makefile index 69feb81..c4310e2 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,8 @@ sbin_PROGRAMS = helmetd$(EXEEXT) bin_PROGRAMS = helmetctl$(EXEEXT) noinst_PROGRAMS = libxtools/tconfig_test$(EXEEXT) \ libxtools/clconfig_test$(EXEEXT) \ - libxtools/clcomp_test$(EXEEXT) libxtools/cllexer_test$(EXEEXT) + libxtools/clcomp_test$(EXEEXT) libxtools/cllexer_test$(EXEEXT) \ + server_test$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -147,6 +148,10 @@ libxtools_cllexer_test_DEPENDENCIES = $(libxtools_NAME) am_libxtools_tconfig_test_OBJECTS = libxtools/tconfig_test.$(OBJEXT) libxtools_tconfig_test_OBJECTS = $(am_libxtools_tconfig_test_OBJECTS) libxtools_tconfig_test_DEPENDENCIES = $(libxtools_NAME) +am_server_test_OBJECTS = server_test.$(OBJEXT) server.$(OBJEXT) \ + logger.$(OBJEXT) +server_test_OBJECTS = $(am_server_test_OBJECTS) +server_test_DEPENDENCIES = $(libxtools_NAME) AM_V_P = $(am__v_P_$(V)) am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY)) am__v_P_0 = false @@ -179,13 +184,13 @@ SOURCES = $(libxasync_a_SOURCES) $(libxtools_a_SOURCES) \ $(libxtools_clcomp_test_SOURCES) \ $(libxtools_clconfig_test_SOURCES) \ $(libxtools_cllexer_test_SOURCES) \ - $(libxtools_tconfig_test_SOURCES) + $(libxtools_tconfig_test_SOURCES) $(server_test_SOURCES) DIST_SOURCES = $(libxasync_a_SOURCES) $(libxtools_a_SOURCES) \ $(helmetctl_SOURCES) $(helmetd_SOURCES) \ $(libxtools_clcomp_test_SOURCES) \ $(libxtools_clconfig_test_SOURCES) \ $(libxtools_cllexer_test_SOURCES) \ - $(libxtools_tconfig_test_SOURCES) + $(libxtools_tconfig_test_SOURCES) $(server_test_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -363,6 +368,8 @@ libxtools_clcomp_test_SOURCES = libxtools/clcomp_test.c libxtools_clcomp_test_LDADD = $(libxtools_NAME) libxtools_cllexer_test_SOURCES = libxtools/cllexer_test.c libxtools_cllexer_test_LDADD = $(libxtools_NAME) +server_test_SOURCES = server_test.c server.c logger.c +server_test_LDADD = $(libxtools_NAME) all: all-am .SUFFIXES: @@ -545,6 +552,10 @@ libxtools/tconfig_test$(EXEEXT): $(libxtools_tconfig_test_OBJECTS) $(libxtools_t @rm -f libxtools/tconfig_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(libxtools_tconfig_test_OBJECTS) $(libxtools_tconfig_test_LDADD) $(LIBS) +server_test$(EXEEXT): $(server_test_OBJECTS) $(server_test_DEPENDENCIES) $(EXTRA_server_test_DEPENDENCIES) + @rm -f server_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(server_test_OBJECTS) $(server_test_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f libxasync/*.$(OBJEXT) @@ -923,14 +934,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS .PRECIOUS: Makefile -test:: libxtools/cllexer_test - cd libxtools && ./cllexer_test - -test:: libxtools/clcomp_test - cd libxtools && ./clcomp_test - -test:: libxtools/clconfig_test - cd libxtools && ./clconfig_test +test:: server_test + ./server_test clean-local: rm -f *~ diff --git a/Makefile.am b/Makefile.am index 002e93c..6b4ec5d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,14 +63,22 @@ noinst_PROGRAMS += libxtools/cllexer_test libxtools_cllexer_test_SOURCES = libxtools/cllexer_test.c libxtools_cllexer_test_LDADD = $(libxtools_NAME) -test:: libxtools/cllexer_test - cd libxtools && ./cllexer_test +#test:: libxtools/cllexer_test +# cd libxtools && ./cllexer_test -test:: libxtools/clcomp_test - cd libxtools && ./clcomp_test +#test:: libxtools/clcomp_test +# cd libxtools && ./clcomp_test + +#test:: libxtools/clconfig_test +# cd libxtools && ./clconfig_test + +noinst_PROGRAMS += server_test +server_test_SOURCES = server_test.c server.c logger.c +server_test_LDADD = $(libxtools_NAME) + +test:: server_test + ./server_test -test:: libxtools/clconfig_test - cd libxtools && ./clconfig_test clean-local: rm -f *~ diff --git a/Makefile.in b/Makefile.in index 4ad2616..ad8129d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -91,7 +91,8 @@ sbin_PROGRAMS = helmetd$(EXEEXT) bin_PROGRAMS = helmetctl$(EXEEXT) noinst_PROGRAMS = libxtools/tconfig_test$(EXEEXT) \ libxtools/clconfig_test$(EXEEXT) \ - libxtools/clcomp_test$(EXEEXT) libxtools/cllexer_test$(EXEEXT) + libxtools/clcomp_test$(EXEEXT) libxtools/cllexer_test$(EXEEXT) \ + server_test$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -147,6 +148,10 @@ libxtools_cllexer_test_DEPENDENCIES = $(libxtools_NAME) am_libxtools_tconfig_test_OBJECTS = libxtools/tconfig_test.$(OBJEXT) libxtools_tconfig_test_OBJECTS = $(am_libxtools_tconfig_test_OBJECTS) libxtools_tconfig_test_DEPENDENCIES = $(libxtools_NAME) +am_server_test_OBJECTS = server_test.$(OBJEXT) server.$(OBJEXT) \ + logger.$(OBJEXT) +server_test_OBJECTS = $(am_server_test_OBJECTS) +server_test_DEPENDENCIES = $(libxtools_NAME) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -179,13 +184,13 @@ SOURCES = $(libxasync_a_SOURCES) $(libxtools_a_SOURCES) \ $(libxtools_clcomp_test_SOURCES) \ $(libxtools_clconfig_test_SOURCES) \ $(libxtools_cllexer_test_SOURCES) \ - $(libxtools_tconfig_test_SOURCES) + $(libxtools_tconfig_test_SOURCES) $(server_test_SOURCES) DIST_SOURCES = $(libxasync_a_SOURCES) $(libxtools_a_SOURCES) \ $(helmetctl_SOURCES) $(helmetd_SOURCES) \ $(libxtools_clcomp_test_SOURCES) \ $(libxtools_clconfig_test_SOURCES) \ $(libxtools_cllexer_test_SOURCES) \ - $(libxtools_tconfig_test_SOURCES) + $(libxtools_tconfig_test_SOURCES) $(server_test_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -363,6 +368,8 @@ libxtools_clcomp_test_SOURCES = libxtools/clcomp_test.c libxtools_clcomp_test_LDADD = $(libxtools_NAME) libxtools_cllexer_test_SOURCES = libxtools/cllexer_test.c libxtools_cllexer_test_LDADD = $(libxtools_NAME) +server_test_SOURCES = server_test.c server.c logger.c +server_test_LDADD = $(libxtools_NAME) all: all-am .SUFFIXES: @@ -545,6 +552,10 @@ libxtools/tconfig_test$(EXEEXT): $(libxtools_tconfig_test_OBJECTS) $(libxtools_t @rm -f libxtools/tconfig_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(libxtools_tconfig_test_OBJECTS) $(libxtools_tconfig_test_LDADD) $(LIBS) +server_test$(EXEEXT): $(server_test_OBJECTS) $(server_test_DEPENDENCIES) $(EXTRA_server_test_DEPENDENCIES) + @rm -f server_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(server_test_OBJECTS) $(server_test_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f libxasync/*.$(OBJEXT) @@ -923,14 +934,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS .PRECIOUS: Makefile -test:: libxtools/cllexer_test - cd libxtools && ./cllexer_test - -test:: libxtools/clcomp_test - cd libxtools && ./clcomp_test - -test:: libxtools/clconfig_test - cd libxtools && ./clconfig_test +test:: server_test + ./server_test clean-local: rm -f *~ diff --git a/libxtools/tccomp.c b/libxtools/tccomp.c index c6a17f0..788d22d 100644 --- a/libxtools/tccomp.c +++ b/libxtools/tccomp.c @@ -19,10 +19,10 @@ #define RES_OK 0 #define RES_ERR -1 -#define POS1TYPE TOKEN_WORD -#define POS2TYPE TOKEN_OPER -#define POS3TYPE TOKEN_WORD -#define POS4TYPE TOKEN_COMM +//#define POS1TYPE TLEX_TOKEN_WORD +//#define POS2TYPE TLEX_TOKEN_OPER +//#define POS3TYPE TLEX_TOKEN_WORD +//#define POS4TYPE TLEX_TOKEN_COMM static char* strcopy(char* src) { size_t srcsize = strlen(src) + 1; @@ -62,25 +62,25 @@ int tccomp_parse(tccomp_t * comp) { while (true) { toktype = tclexer_get_token(lexer, token, MAX_TOK_SIZE); - if (toktype == TOKEN_SPACE) { + if (toktype == TLEX_TOKEN_SPACE) { continue; } - if (toktype == TOKEN_COMM) { + if (toktype == TLEX_TOKEN_COMM) { continue; } //printf("tok=%d pos=%d line=%d [%s]\n", toktype, comp->pos, comp->lnum, token); - if (toktype == TOKEN_NEWLN) { + if (toktype == TLEX_TOKEN_NEWLN) { comp->lnum++; } switch (comp->pos) { case 0:{ - if (toktype == TOKEN_NEWLN) { + if (toktype == TLEX_TOKEN_NEWLN) { comp->pos = 0; break; } - if (toktype != TOKEN_WORD) { + if (toktype != TLEX_TOKEN_WORD) { return -1; } comp->pos++; @@ -88,14 +88,14 @@ int tccomp_parse(tccomp_t * comp) { break; } case 1:{ - if (toktype != TOKEN_OPER) { + if (toktype != TLEX_TOKEN_OPER) { return -1; } comp->pos++; break; } case 2:{ - if (toktype != TOKEN_WORD) { + if (toktype != TLEX_TOKEN_WORD) { return -1; } comp->pos++; @@ -103,7 +103,7 @@ int tccomp_parse(tccomp_t * comp) { break; } case 3:{ - if (toktype != TOKEN_NEWLN && toktype != TOKEN_ENDFL) { + if (toktype != TLEX_TOKEN_NEWLN && toktype != TLEX_TOKEN_ENDFL) { return -1; } comp->pos = 0; @@ -114,7 +114,7 @@ int tccomp_parse(tccomp_t * comp) { break; } } - if (toktype == TOKEN_ENDFL) + if (toktype == TLEX_TOKEN_ENDFL) break; } return 0; diff --git a/libxtools/tclexer.c b/libxtools/tclexer.c index 4334d39..186b475 100644 --- a/libxtools/tclexer.c +++ b/libxtools/tclexer.c @@ -78,7 +78,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { switch (lexer->context) { case LEXCONT_ENDFL:{ - return TOKEN_ENDFL; + return TLEX_TOKEN_ENDFL; } case LEXCONT_WORD:{ int newcontext = LEXCONT_WORD; @@ -108,7 +108,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { if (newcontext != lexer->context) { lexer->context = newcontext; token[lexer->pos++] = '\0'; - return TOKEN_WORD; + return TLEX_TOKEN_WORD; } token[lexer->pos++] = lexer->letter; break; @@ -129,7 +129,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { if (newcontext != lexer->context) { token[lexer->pos++] = '\0'; lexer->context = newcontext; - return TOKEN_COMM; + return TLEX_TOKEN_COMM; } token[lexer->pos++] = lexer->letter; break; @@ -162,7 +162,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { if (newcontext != lexer->context) { lexer->context = newcontext; strcpy(token, "SPACE"); - return TOKEN_SPACE; + return TLEX_TOKEN_SPACE; } token[lexer->pos++] = lexer->letter; break; @@ -195,7 +195,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { if (newcontext != lexer->context) { lexer->context = newcontext; strcpy(token, "="); - return TOKEN_OPER; + return TLEX_TOKEN_OPER; } token[lexer->pos++] = lexer->letter; break; @@ -224,7 +224,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { if (newcontext != lexer->context) { lexer->context = newcontext; strcpy(token, "NL"); - return TOKEN_NEWLN; + return TLEX_TOKEN_NEWLN; } token[lexer->pos++] = lexer->letter; break; @@ -267,7 +267,7 @@ int tclexer_get_token(tclexer_t * lexer, char* token, int maxsize) { } lexer->letter = bstream_getc(lexer->stream); } - return TOKEN_ENDFL; + return TLEX_TOKEN_ENDFL; } void tclexer_destroy(tclexer_t * lexer) { diff --git a/libxtools/tclexer.h b/libxtools/tclexer.h index 3971b4a..f8e92f8 100644 --- a/libxtools/tclexer.h +++ b/libxtools/tclexer.h @@ -16,13 +16,13 @@ typedef struct { #define MAX_TOK_SIZE 1024 -#define TOKEN_NULL 0 -#define TOKEN_WORD 1 -#define TOKEN_SPACE 2 -#define TOKEN_COMM 3 -#define TOKEN_OPER 4 -#define TOKEN_ENDFL 5 -#define TOKEN_NEWLN 7 +#define TLEX_TOKEN_NULL 0 +#define TLEX_TOKEN_WORD 1 +#define TLEX_TOKEN_SPACE 2 +#define TLEX_TOKEN_COMM 3 +#define TLEX_TOKEN_OPER 4 +#define TLEX_TOKEN_ENDFL 5 +#define TLEX_TOKEN_NEWLN 7 tclexer_t* new_tclexer(bstream_t * stream); void tclexer_init(tclexer_t * tclexer, bstream_t * stream); diff --git a/server.c b/server.c index 30da6ac..6d2c777 100644 --- a/server.c +++ b/server.c @@ -4,19 +4,27 @@ #include #include +#include #include #include +typedef struct { + +} server_t; + + +static server_t server; + int server_init(void) { - logger_dprintf("server inited"); + logger_dprintf("server initialization"); return 0; } #define SERVER_CONFIG_ERROR -1 int server_config(void) { - logger_dprintf("server configi"); + logger_dprintf("server configuration"); tconfig_t tconfig; tconfig_init(&tconfig); @@ -35,16 +43,13 @@ int server_config(void) { tconfig_destroy(&tconfig); logger_dprintf("logpath = %s", logpath); - clconfig_t tconfig; - tconfig_init(&tconfig); - - + //clconfig_t clconfig; + //clconfig_init(&clconfig); return 0; } - int server_run(void) { - logger_dprintf("server started"); + logger_dprintf("start the server"); return 0; } diff --git a/server_test.c b/server_test.c new file mode 100644 index 0000000..0b413e3 --- /dev/null +++ b/server_test.c @@ -0,0 +1,22 @@ +/* + * + * Copyright 2023 Oleg Borodin + * + */ + +#include +//#include +//#include +#include + +#include + + +int main(int argc, char** argv) { + (void)argc; + (void)argv; + + server_init(); + + return 0; +}