Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1571480686, "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":"f55c47e4f2f9a6b76260855d6647b9f3", "oid":{ "oid": "b7a04a67d15efd0f17bf795b8d3648425b604581", "alias": [ "refs/heads/master"]},"blobname": "minimal-examples/http-server/minimal-http-server/minimal-http-server.c", "blob": "/*\n * lws-minimal-http-server\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 the most minimal http server you can make with lws.\n *\n * To keep it simple, it serves stuff from the subdirectory \n * \u0022./mount-origin\u0022 of the directory it was started in.\n * You can change that by changing mount.origin below.\n */\n\n#include \u003clibwebsockets.h\u003e\n#include \u003cstring.h\u003e\n#include \u003csignal.h\u003e\n\nstatic int interrupted;\n\nstatic const struct lws_http_mount mount \u003d {\n\t/* .mount_next */\t\tNULL,\t\t/* linked-list \u0022next\u0022 */\n\t/* .mountpoint */\t\t\u0022/\u0022,\t\t/* mountpoint URL */\n\t/* .origin */\t\t\t\u0022./mount-origin\u0022, /* serve from dir */\n\t/* .def */\t\t\t\u0022index.html\u0022,\t/* default filename */\n\t/* .protocol */\t\t\tNULL,\n\t/* .cgienv */\t\t\tNULL,\n\t/* .extra_mimetypes */\t\tNULL,\n\t/* .interpret */\t\tNULL,\n\t/* .cgi_timeout */\t\t0,\n\t/* .cache_max_age */\t\t0,\n\t/* .auth_mask */\t\t0,\n\t/* .cache_reusable */\t\t0,\n\t/* .cache_revalidate */\t\t0,\n\t/* .cache_intermediaries */\t0,\n\t/* .origin_protocol */\t\tLWSMPRO_FILE,\t/* files in a dir */\n\t/* .mountpoint_len */\t\t1,\t\t/* char count */\n\t/* .basic_auth_login_file */\tNULL,\n};\n\nvoid sigint_handler(int sig)\n{\n\tinterrupted \u003d 1;\n}\n\nint main(int argc, const char **argv)\n{\n\tstruct lws_context_creation_info info;\n\tstruct lws_context *context;\n\tconst char *p;\n\tint n \u003d 0, logs \u003d LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE\n\t\t\t/* for LLL_ verbosity above NOTICE to be built into lws,\n\t\t\t * lws must have been configured and built with\n\t\t\t * -DCMAKE_BUILD_TYPE\u003dDEBUG instead of \u003dRELEASE */\n\t\t\t/* | LLL_INFO */ /* | LLL_PARSER */ /* | LLL_HEADER */\n\t\t\t/* | LLL_EXT */ /* | LLL_CLIENT */ /* | LLL_LATENCY */\n\t\t\t/* | LLL_DEBUG */;\n\n\tsignal(SIGINT, sigint_handler);\n\n\tif ((p \u003d lws_cmdline_option(argc, argv, \u0022-d\u0022)))\n\t\tlogs \u003d atoi(p);\n\n\tlws_set_log_level(logs, NULL);\n\tlwsl_user(\u0022LWS minimal http server | visit http://localhost:7681\u005cn\u0022);\n\n\tmemset(\u0026info, 0, sizeof info); /* otherwise uninitialized garbage */\n\tinfo.port \u003d 7681;\n\tinfo.mounts \u003d \u0026mount;\n\tinfo.error_document_404 \u003d \u0022/404.html\u0022;\n\tinfo.options \u003d\n\t\tLWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE;\n\n\tcontext \u003d lws_create_context(\u0026info);\n\tif (!context) {\n\t\tlwsl_err(\u0022lws init failed\u005cn\u0022);\n\t\treturn 1;\n\t}\n\n\twhile (n \u003e\u003d 0 \u0026\u0026 !interrupted)\n\t\tn \u003d lws_service(context, 0);\n\n\tlws_context_destroy(context);\n\n\treturn 0;\n}\n","s":{"c":1571349757,"u": 405}} ],"g": 389,"chitpc": 0,"ehitpc": 0, "indexed":0 }