This commit is contained in:
2023-08-19 11:39:01 +02:00
parent d5441fa611
commit 59e67f1975
20 changed files with 402 additions and 24783 deletions

View File

@@ -33,6 +33,7 @@
#include <rcache.h>
#include <jlexer.h>
#include <jparser.h>
#include <jblock.h>
#include <config.h>
@@ -291,9 +292,25 @@ int cworker_handler(const cworker_t* worker, int socket) {
if (jparser_bind(&parser, JVALTYPE_STR, "name", (void *)&name) < 0) {
log_error("Cannot bind name");
}
dprintf(socket, "{}");
char* msg = NULL;
asprintf(&msg, "hello, %s!", name);
jblock_t jb;
jblock_init(&jb);
jblock_addstr(&jb, "message", msg);
jblock_addbool(&jb, "error", false);
char* jsonstr = NULL;
jblock_outjson(&jb, &jsonstr);
jblock_destroy(&jb);
write(socket, jsonstr, strlen(jsonstr));
free(jsonstr);
free(name);
free(msg);
exit:
jparser_destroy(&parser);
jlexer_destroy(&lexer);