diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2020-12-16 16:43:07 +0100 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-03-26 18:53:25 +0100 |
commit | a94b0e36ad9383f40351582689ffdfdd96720f23 (patch) | |
tree | ecb82bad0d3d476e015c9e6dd247cdbf6d4c1273 /src | |
parent | 15159254cf97c35dfe320efb46c8e25fbeb8b462 (diff) | |
download | polecat-a94b0e36ad9383f40351582689ffdfdd96720f23.tar.gz polecat-a94b0e36ad9383f40351582689ffdfdd96720f23.zip |
add debug method to test out variable parser for memory safety
Diffstat (limited to 'src')
-rw-r--r-- | src/lutris.c | 27 | ||||
-rw-r--r-- | src/lutris.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/lutris.c b/src/lutris.c index cc6d8c4..df5feef 100644 --- a/src/lutris.c +++ b/src/lutris.c @@ -11,10 +11,37 @@ static const struct Command lutris_commands[] = { #ifdef DEBUG { .name = "install", .func = lutris_install, .description = "install a lutris script" }, + { .name = "debug", .func = lutris_debug, .description = "" }, #endif { .name = "info", .func = lutris_info, .description = "show information about a lutris script" }, }; +void func() +{ + printf("I got called because $func was found\n"); +} + +COMMAND(lutris, debug) +{ + struct list_t variables[] = { + { .key = "string", .type = value_string, .value.str = "output" }, + { .key = "func", .type = value_function, .value.func = func }, + }; + + char* str = malloc(255); + + strcpy(str, "$string and $func $fun"); + + printf("Input: %s\n", str); + parseVar(&str, variables, ARRAY_LEN(variables)); + printf("Output: %s\n", str); + + + free(str); + + return 0; +} + COMMAND_GROUP_FUNC(lutris) COMMAND(lutris, install) diff --git a/src/lutris.h b/src/lutris.h index bc815c1..643c8ff 100644 --- a/src/lutris.h +++ b/src/lutris.h @@ -139,6 +139,8 @@ struct script_t { #include "command.h" +COMMAND(lutris, debug); + COMMAND_GROUP(lutris); COMMAND(lutris, install); COMMAND(lutris, info); |