From a7281947d38f3c741c7f957f3cc2c4a4b3b803f8 Mon Sep 17 00:00:00 2001 From: jf_HS Date: Thu, 21 Dec 2023 16:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8E=9F=E5=A7=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/tasks.json | 28 ++++++++++++ CMakelists.txt | 10 +++++ main.c | 104 +++++++++++++++++++++++++++++++++++++++++++++ test.c | 12 ++++++ test.py | 1 + 5 files changed, 155 insertions(+) create mode 100644 .vscode/tasks.json create mode 100644 CMakelists.txt create mode 100644 main.c create mode 100644 test.c create mode 100644 test.py diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..956ee69 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc.exe 生成活动文件", + "command": "D:\\Program Files (x86)\\TDM-GCC-64\\bin\\gcc.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "调试器生成的任务。" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/CMakelists.txt b/CMakelists.txt new file mode 100644 index 0000000..07da573 --- /dev/null +++ b/CMakelists.txt @@ -0,0 +1,10 @@ + +cmake_minimum_required(VERSION 3.8) + +set(CMAKE_C_COMPILER "D:\\Program Files (x86)\\TDM-GCC-64\\bin\\gcc.exe") + + +project(demo) + +add_executable(demo main.c) + diff --git a/main.c b/main.c new file mode 100644 index 0000000..3365622 --- /dev/null +++ b/main.c @@ -0,0 +1,104 @@ + +#include +#include +#include + +typedef struct list_t +{ + uint8_t data; + struct list_t *next; +} list_t; + +void list_init(struct list_t *list) +{ + list->data = 0; + list->next = NULL; +} + +void list_add(struct list_t *list, uint8_t data) +{ + struct list_t *p = NULL; + p = list; + while (p->next != NULL) + { + p = p->next; + if (p->data == data) + { + return; + } + } + p->next = (struct list_t *)malloc(sizeof(struct list_t)); + p->next->data = data; + p->next->next = NULL; + return; +} + +void list_print(struct list_t *list) +{ + struct list_t *p = NULL; + p = list; + while (p->next != NULL) + { + printf("%02d\n", p->data); + p = p->next; + if (p->next == NULL) + { + printf("%02d\n", p->data); + break; + } + } +} + +void list_free(struct list_t *list) +{ + struct list_t *p = NULL; + p = list; + while (p->next != NULL) + { + p = p->next; + free(p->next); + p->next = NULL; + if (p->next == NULL) + { + break; + } + } +} + + +void list_demo(void) +{ + struct list_t list; + list_init(&list); + for(uint32_t i = 0; i < 10; ++i) + { + list_add(&list, i); + } + list_print(&list); +} + + +void main(int arg, char *argv[]) +{ +#if 0 + uint32_t i = 0; + for (i = 0; i < 10; ++i) + { + printf("%02d\n", i); + } + printf("\n"); + + printf("Hello World!\n"); +#else + // struct list_t list; + // list_init(&list); + // list_add(&list, 1); + // list_add(&list, 2); + // list_add(&list, 3); + // list_add(&list, 4); + + // list_print(&list); + + list_demo(); +#endif +} diff --git a/test.c b/test.c new file mode 100644 index 0000000..e636e13 --- /dev/null +++ b/test.c @@ -0,0 +1,12 @@ + +#include + +bool aes_encrypt(const char *key, const char *iv, const char *input, size_t input_len, char **output) +{ + return true; +} + +bool aes_decrypt(const char *key, const char *iv, const char *input, size_t input_len, char **output) +{ + return false; +} diff --git a/test.py b/test.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test.py @@ -0,0 +1 @@ +