diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..5ee97e7 --- /dev/null +++ b/.clang-format @@ -0,0 +1,57 @@ +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: Left +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false +AlignOperands: Align +AllowAllParametersOfDeclarationOnNextLine: true +AllowAllArgumentsOnNextLine: false +AllowShortLambdasOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: Empty +AllowShortBlocksOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakTemplateDeclarations: "Yes" +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +BreakBeforeBinaryOperators: NonAssignment +ColumnLimit: 120 +CommentPragmas: "^ IWYU pragma:" +ConstructorInitializerIndentWidth: 4 +IndentWidth: 4 +Language: Cpp +MaxEmptyLinesToKeep: 2 +PointerAlignment: Left +TabWidth: 4 +UseTab: Never +SortIncludes: CaseSensitive +BraceWrapping: + AfterEnum: true + AfterStruct: true + AfterClass: true + AfterUnion: true + AfterExternBlock: true + AfterFunction: true + AfterNamespace: true +IndentRequires: true +FixNamespaceComments: false +NamespaceIndentation: None +BreakBeforeConceptDeclarations: Always +RequiresClausePosition: OwnLine +IndentRequiresClause: true +AllowBreakBeforeNoexceptSpecifier: OnlyWithParen diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39e9a10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.cache/ +.vscode/ +.xmake/ +build/ +compile_commands.json diff --git a/include/kqm/defs.h b/include/kqm/defs.h new file mode 100644 index 0000000..8543214 --- /dev/null +++ b/include/kqm/defs.h @@ -0,0 +1,8 @@ +#ifndef KQM_DEFS_H +#define KQM_DEFS_H + +#define CR "\r" +#define LF "\n" +#define CRLF "\r\n" + +#endif // KQM_DEFS_H diff --git a/include/kqm/types.h b/include/kqm/types.h new file mode 100644 index 0000000..ddcfe3d --- /dev/null +++ b/include/kqm/types.h @@ -0,0 +1,11 @@ +#ifndef KQM_TYPES_H +#define KQM_TYPES_H + +#include + +typedef struct mg_callbacks mg_callbacks; +typedef struct mg_context mg_context; +typedef struct mg_connection mg_connection; +typedef struct mg_request_info mg_request_info; + +#endif // KQM_TYPES_H diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..0c48a7e --- /dev/null +++ b/src/main.c @@ -0,0 +1,21 @@ +#include + +#include +#include + +#include +#include + +int main(int argc, char** argv) +{ + const char* options[] = {"document_root", "./www", "listening_ports", "8080", NULL}; + mg_callbacks callbacks; + mg_context* ctx; + + memset(&callbacks, 0, sizeof(callbacks)); + ctx = mg_start(&callbacks, NULL, options); + + printf("Server started on port(s) %s\n", mg_get_option(ctx, "listening_ports")); + getchar(); + mg_stop(ctx); +} diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..de7e415 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,27 @@ +add_rules("mode.debug", "mode.release") +add_rules("plugin.compile_commands.autoupdate") + +set_languages("c23") + +set_warnings("all") +set_warnings("error") + +add_requires("civetweb") + +target("math") + set_kind("binary") + add_packages("civetweb") + add_includedirs("include") + add_files("src/main.c") + + after_build(function (target) + local npm = "npm" + if is_host("windows") then + npm = "npm.cmd" + end + os.execv(npm, {"--prefix", "ui", "run", "build"}) + + local vue_dist_dir = "ui/dist" + local target_dir = target:targetdir() .. "/www" + os.cp(vue_dist_dir, target_dir) + end)