添加初始项目结构,包括代码格式化配置、忽略文件、头文件定义、主程序和构建配置
This commit is contained in:
parent
f4a80d84d2
commit
cb839af1c8
57
.clang-format
Normal file
57
.clang-format
Normal file
@ -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
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.cache/
|
||||
.vscode/
|
||||
.xmake/
|
||||
build/
|
||||
compile_commands.json
|
8
include/kqm/defs.h
Normal file
8
include/kqm/defs.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef DEFS_H
|
||||
#define DEFS_H
|
||||
|
||||
#define CR "\r"
|
||||
#define LF "\n"
|
||||
#define CRLF "\r\n"
|
||||
|
||||
#endif // DEFS_H
|
11
include/kqm/types.h
Normal file
11
include/kqm/types.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <civetweb.h>
|
||||
|
||||
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 // TYPES_H
|
31
src/main.c
Normal file
31
src/main.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include <civetweb.h>
|
||||
|
||||
#include <kqm/defs.h>
|
||||
#include <kqm/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int request_handler(mg_connection* conn, void* cbdata)
|
||||
{
|
||||
mg_printf(conn,
|
||||
"HTTP/1.1 200 OK" CRLF "Content-Type: text/plain" CRLF "Connection: close" CRLF CRLF "Hello, World!");
|
||||
return 200;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const char* options[] = {"document_root", ".", "listening_ports", "8080", NULL};
|
||||
mg_callbacks callbacks;
|
||||
mg_context* ctx;
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
ctx = mg_start(&callbacks, NULL, options);
|
||||
|
||||
mg_set_request_handler(ctx, "/", request_handler, NULL);
|
||||
|
||||
printf("Server started on port(s) %s\n", mg_get_option(ctx, "listening_ports"));
|
||||
getchar();
|
||||
mg_stop(ctx);
|
||||
|
||||
}
|
15
xmake.lua
Normal file
15
xmake.lua
Normal file
@ -0,0 +1,15 @@
|
||||
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")
|
Loading…
Reference in New Issue
Block a user