{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1711645690,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"6a66524ea9c37f6ed170c42d60b65821",
"oid":{ "oid": "e4be3317ee421f951fb16a85c7edacc9b8a0e6aa", "alias": [ "refs/heads/main"]},"blobname": "test-apps/test-lejp.c", "blob": "/*\n * lejp test app\n *\n * Written in 2010-2019 by Andy Green \u003candy@warmcat.com\u003e\n *\n * This file is made available under the Creative Commons CC0 1.0\n * Universal Public Domain Dedication.\n *\n * This demonstrates a minimal http server that performs a form GET with a couple\n * of parameters. It dumps the parameters to the console log and redirects\n * to another page.\n */\n\n#include \u003clibwebsockets.h\u003e\n#include \u003cstring.h\u003e\n\n\nstatic const char * const reason_names[] \u003d {\n\t\u0022LEJPCB_CONSTRUCTED\u0022,\n\t\u0022LEJPCB_DESTRUCTED\u0022,\n\t\u0022LEJPCB_START\u0022,\n\t\u0022LEJPCB_COMPLETE\u0022,\n\t\u0022LEJPCB_FAILED\u0022,\n\t\u0022LEJPCB_PAIR_NAME\u0022,\n\t\u0022LEJPCB_VAL_TRUE\u0022,\n\t\u0022LEJPCB_VAL_FALSE\u0022,\n\t\u0022LEJPCB_VAL_NULL\u0022,\n\t\u0022LEJPCB_VAL_NUM_INT\u0022,\n\t\u0022LEJPCB_VAL_NUM_FLOAT\u0022,\n\t\u0022LEJPCB_VAL_STR_START\u0022,\n\t\u0022LEJPCB_VAL_STR_CHUNK\u0022,\n\t\u0022LEJPCB_VAL_STR_END\u0022,\n\t\u0022LEJPCB_ARRAY_START\u0022,\n\t\u0022LEJPCB_ARRAY_END\u0022,\n\t\u0022LEJPCB_OBJECT_START\u0022,\n\t\u0022LEJPCB_OBJECT_END\u0022,\n\t\u0022LEJPCB_OBJECT_END_PRE\u0022,\n};\n\nstatic const char * const tok[] \u003d {\n\t\u0022dummy___\u0022\n};\n\nstatic signed char\ncb(struct lejp_ctx *ctx, char reason)\n{\n\tchar buf[1024], *p \u003d buf, *end \u003d \u0026buf[sizeof(buf)];\n\tint n;\n\n\tfor (n \u003d 0; n \u003c ctx-\u003esp; n++)\n\t\t*p++ \u003d ' ';\n\t*p \u003d '\u005c0';\n\n\tif (reason \u0026 LEJP_FLAG_CB_IS_VALUE) {\n\t\tp +\u003d lws_snprintf(p, lws_ptr_diff_size_t(end, p), \u0022 value '%s' \u0022, ctx-\u003ebuf);\n\t\tif (ctx-\u003eipos) {\n\t\t\tint n;\n\n\t\t\tp +\u003d lws_snprintf(p, lws_ptr_diff_size_t(end, p), \u0022(array indexes: \u0022);\n\t\t\tfor (n \u003d 0; n \u003c ctx-\u003eipos; n++)\n\t\t\t\tp +\u003d lws_snprintf(p, lws_ptr_diff_size_t(end, p), \u0022%d \u0022, ctx-\u003ei[n]);\n\t\t\tp +\u003d lws_snprintf(p, lws_ptr_diff_size_t(end, p), \u0022) \u0022);\n\t\t}\n\t\tlwsl_notice(\u0022%s (%s)\u005cr\u005cn\u0022, buf,\n\t\t reason_names[(unsigned int)\n\t\t\t(reason) \u0026 (LEJP_FLAG_CB_IS_VALUE - 1)]);\n\n\t\t(void)reason_names; /* NO_LOGS... */\n\t\treturn 0;\n\t}\n\n\tswitch (reason) {\n\tcase LEJPCB_COMPLETE:\n\t\tlwsl_notice(\u0022%sParsing Completed (LEJPCB_COMPLETE)\u005cn\u0022, buf);\n\t\tbreak;\n\tcase LEJPCB_PAIR_NAME:\n\t\tlwsl_notice(\u0022%spath: '%s' (LEJPCB_PAIR_NAME)\u005cn\u0022, buf, ctx-\u003epath);\n\t\tbreak;\n\t}\n\n\tlwsl_notice(\u0022%s%s: path %s match '%s' statckp %d, ipos %d\u005cr\u005cn\u0022, buf, reason_names[(unsigned int)\n\t\t(reason) \u0026 (LEJP_FLAG_CB_IS_VALUE - 1)], ctx-\u003epath,\n\t\tctx-\u003epath_match ? tok[ctx-\u003epath_match - 1] : \u0022(none)\u0022, ctx-\u003epst[ctx-\u003epst_sp].ppos, ctx-\u003eipos);\n\n\treturn 0;\n}\n\nint\nmain(int argc, char *argv[])\n{\n\tint fd, n \u003d 1, ret \u003d 1, m \u003d 0;\n\tstruct lejp_ctx ctx;\n\tchar buf[128];\n\n\tlws_set_log_level(7, NULL);\n\n\tlwsl_notice(\u0022libwebsockets-test-lejp (C) 2017 - 2018 andy@warmcat.com\u005cn\u0022);\n\tlwsl_notice(\u0022 usage: cat my.json | libwebsockets-test-lejp\u005cn\u005cn\u0022);\n\n\tlejp_construct(\u0026ctx, cb, NULL, tok, LWS_ARRAY_SIZE(tok));\n\n\tfd \u003d 0;\n\n\twhile (n \u003e 0) {\n\t\tn \u003d (int)read(fd, buf, sizeof(buf));\n\t\tif (n \u003c\u003d 0)\n\t\t\tcontinue;\n\n\t\tm \u003d lejp_parse(\u0026ctx, (uint8_t *)buf, n);\n\t\tif (m \u003c 0 \u0026\u0026 m !\u003d LEJP_CONTINUE) {\n\t\t\tlwsl_err(\u0022parse failed %d\u005cn\u0022, m);\n\t\t\tgoto bail;\n\t\t}\n\t}\n\tlwsl_notice(\u0022okay (%d)\u005cn\u0022, m);\n\tret \u003d 0;\nbail:\n\tlejp_destruct(\u0026ctx);\n\n\treturn ret;\n}\n","s":{"c":1711645690,"u": 208}}
],"g": 1135,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}