indent
This commit is contained in:
29
helmetctl.c
29
helmetctl.c
@@ -28,33 +28,34 @@ int main(void) {
|
|||||||
|
|
||||||
|
|
||||||
int util_init(void) {
|
int util_init(void) {
|
||||||
logger_dprintf("server init");
|
logger_dprintf("server init");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int util_config(void) {
|
int util_config(void) {
|
||||||
logger_dprintf("server config");
|
logger_dprintf("server config");
|
||||||
|
|
||||||
tconfig_t tconfig;
|
tconfig_t tconfig;
|
||||||
tconfig_init(&tconfig);
|
|
||||||
|
|
||||||
char* logpath = NULL;
|
tconfig_init(&tconfig);
|
||||||
tconfig_bind(&tconfig, TCONF_STR, "logpath", &logpath);
|
|
||||||
ssize_t rsize = tconfig_read(&tconfig, "helmet.conf");
|
|
||||||
|
|
||||||
int res = tconfig_parse(&tconfig);
|
char* logpath = NULL;
|
||||||
MASSERT(res == -1);
|
|
||||||
|
|
||||||
tconfig_destroy(&tconfig);
|
tconfig_bind(&tconfig, TCONF_STR, "logpath", &logpath);
|
||||||
logger_dprintf("logpath = %s", logpath);
|
ssize_t rsize = tconfig_read(&tconfig, "helmet.conf");
|
||||||
|
|
||||||
|
int res = tconfig_parse(&tconfig);
|
||||||
|
|
||||||
|
MASSERT(res == -1);
|
||||||
|
|
||||||
|
tconfig_destroy(&tconfig);
|
||||||
|
logger_dprintf("logpath = %s", logpath);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int util_run(void) {
|
int util_run(void) {
|
||||||
logger_dprintf("server start");
|
logger_dprintf("server start");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
39
helmetd.c
39
helmetd.c
@@ -23,29 +23,32 @@ int main(void) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _main(int argc, char **argv) {
|
int _main(int argc, char** argv) {
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
tconfig_t tconfig;
|
tconfig_t tconfig;
|
||||||
tconfig_init(&tconfig);
|
|
||||||
|
|
||||||
int intkey = 0;
|
tconfig_init(&tconfig);
|
||||||
char* strkey = NULL;
|
|
||||||
|
|
||||||
tconfig_bind(&tconfig, TCONF_INT, "intkey", &intkey);
|
int intkey = 0;
|
||||||
tconfig_bind(&tconfig, TCONF_STR, "strkey", &strkey);
|
char* strkey = NULL;
|
||||||
|
|
||||||
ssize_t rsize = tconfig_read(&tconfig, "helmet.conf");
|
tconfig_bind(&tconfig, TCONF_INT, "intkey", &intkey);
|
||||||
printf("%ld\n", rsize);
|
tconfig_bind(&tconfig, TCONF_STR, "strkey", &strkey);
|
||||||
MASSERT(rsize > 0);
|
|
||||||
|
|
||||||
int res = tconfig_parse(&tconfig);
|
ssize_t rsize = tconfig_read(&tconfig, "helmet.conf");
|
||||||
MASSERT(res == -1);
|
|
||||||
|
|
||||||
tconfig_destroy(&tconfig);
|
printf("%ld\n", rsize);
|
||||||
|
MASSERT(rsize > 0);
|
||||||
|
|
||||||
printf("int key = %d\n", intkey);
|
int res = tconfig_parse(&tconfig);
|
||||||
printf("str key = %s\n", strkey);
|
|
||||||
return 0;
|
MASSERT(res == -1);
|
||||||
|
|
||||||
|
tconfig_destroy(&tconfig);
|
||||||
|
|
||||||
|
printf("int key = %d\n", intkey);
|
||||||
|
printf("str key = %s\n", strkey);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
36
logger.c
36
logger.c
@@ -13,29 +13,31 @@ int logger_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void logger_dprintf(char* message, ...) {
|
void logger_dprintf(char* message, ...) {
|
||||||
printf("debug: ");
|
printf("debug: ");
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, message);
|
|
||||||
|
va_start(argptr, message);
|
||||||
vprintf(message, argptr);
|
vprintf(message, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void logger_iprintf(char* message, ...) {
|
void logger_iprintf(char* message, ...) {
|
||||||
printf("info: ");
|
printf("info: ");
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, message);
|
|
||||||
|
va_start(argptr, message);
|
||||||
vprintf(message, argptr);
|
vprintf(message, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void logger_wprintf(char* message, ...) {
|
void logger_wprintf(char* message, ...) {
|
||||||
printf("warning: ");
|
printf("warning: ");
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, message);
|
|
||||||
vprintf(message, argptr);
|
|
||||||
va_end(argptr);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
va_start(argptr, message);
|
||||||
|
vprintf(message, argptr);
|
||||||
|
va_end(argptr);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|||||||
26
server.c
26
server.c
@@ -9,40 +9,42 @@
|
|||||||
|
|
||||||
|
|
||||||
int server_init(void) {
|
int server_init(void) {
|
||||||
logger_dprintf("server init");
|
logger_dprintf("server init");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SERVER_CONFIG_ERROR -1
|
#define SERVER_CONFIG_ERROR -1
|
||||||
|
|
||||||
int server_config(void) {
|
int server_config(void) {
|
||||||
logger_dprintf("server config");
|
logger_dprintf("server config");
|
||||||
|
|
||||||
tconfig_t tconfig;
|
tconfig_t tconfig;
|
||||||
tconfig_init(&tconfig);
|
|
||||||
|
|
||||||
char* logpath = NULL;
|
tconfig_init(&tconfig);
|
||||||
tconfig_bind(&tconfig, TCONF_STR, "logpath", &logpath);
|
|
||||||
|
char* logpath = NULL;
|
||||||
|
|
||||||
|
tconfig_bind(&tconfig, TCONF_STR, "logpath", &logpath);
|
||||||
|
|
||||||
ssize_t rsize = tconfig_read(&tconfig, "helmet.conf");
|
ssize_t rsize = tconfig_read(&tconfig, "helmet.conf");
|
||||||
|
|
||||||
if (rsize < 0) {
|
if (rsize < 0) {
|
||||||
return SERVER_CONFIG_ERROR;
|
return SERVER_CONFIG_ERROR;
|
||||||
}
|
}
|
||||||
int res = tconfig_parse(&tconfig);
|
int res = tconfig_parse(&tconfig);
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return SERVER_CONFIG_ERROR;
|
return SERVER_CONFIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
tconfig_destroy(&tconfig);
|
tconfig_destroy(&tconfig);
|
||||||
logger_dprintf("logpath = %s", logpath);
|
logger_dprintf("logpath = %s", logpath);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int server_run(void) {
|
int server_run(void) {
|
||||||
logger_dprintf("server start");
|
logger_dprintf("server start");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user