diff options
author | untir_l <87096069+untir-l@users.noreply.github.com> | 2022-02-24 14:57:35 +0000 |
---|---|---|
committer | untir-l <87096069+untir-l@users.noreply.github.com> | 2022-02-25 09:56:49 +0000 |
commit | c23118e8e48d043e4bb9b4d813a498af8d454d73 (patch) | |
tree | 265947d2a848e8a3fb27106be38c8ae95b2fffe0 /cli/hitomezashi_cli.c | |
parent | 8a7dde79de6edee01571d2eb4a333d8256f4c342 (diff) | |
download | hitomezashi-c23118e8e48d043e4bb9b4d813a498af8d454d73.tar hitomezashi-c23118e8e48d043e4bb9b4d813a498af8d454d73.tar.gz hitomezashi-c23118e8e48d043e4bb9b4d813a498af8d454d73.zip |
Add web app frontend, restructure almost everything
- Add web app frontend code
- Add .html, .js, .wasm to .gitignore
- Restructure Makefile to work with emmake, add build targets for web app,
add .html, .js, .wasm to make clean
- Explain the pattern in the README
- Add explanation of web frontend to README
- Restructure README generally for better clarity
- Remove "make web app version" from todos in README
- Set Doxygen to EXTRACT_ALL so trivial and useless doc comments are not
needed when the naming suffices to be explanatory.
- Move ascii_binary_str_to_ints to library code in new file
hitomezashi_utils.c (and corresponding header) as web app also needs it.
- Fix SDL2 include path so it also works with Emscripten
- Remove some cluttering and unnecessary doc comments
- Improve some doc comments
Diffstat (limited to 'cli/hitomezashi_cli.c')
-rw-r--r-- | cli/hitomezashi_cli.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/cli/hitomezashi_cli.c b/cli/hitomezashi_cli.c index 70a2812..72d43b7 100644 --- a/cli/hitomezashi_cli.c +++ b/cli/hitomezashi_cli.c @@ -1,17 +1,20 @@ /** @file */ #include "hitomezashi_cli.h" + #include "SDL.h" #define OPTPARSE_IMPLEMENTATION #define OPTPARSE_API static -#include "hitomezashi.h" -#include "optparse/optparse.h" #include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> +#include "hitomezashi.h" +#include "hitomezashi_utils.h" +#include "optparse.h" + /** Initialise SDL, pass the information from hitomezashi_cli_handle_args() to * libhitomezashi, and save the resulting image. */ int main(int argc, char **argv) { @@ -67,24 +70,6 @@ void hitomezashi_cli_help(void) { exit(Hitomezashi_Cli_Exit_Code_Success); } -char *hitomezashi_cli_ascii_binary_str_to_ints(char *ascii_str, size_t n) { - char *res = malloc(n); - for (int i = 0; i < n; ++i) { - switch (ascii_str[i]) { - case '0':; - res[i] = 0; - break; - case '1':; - res[i] = 1; - break; - default:; - free(res); - return NULL; - } - } - return res; -} - void hitomezashi_cli_handle_args(char **out_file_path, int *x_pattern_len, int *y_pattern_len, char **x_pattern, char **y_pattern, int *gap, int *thickness, @@ -112,8 +97,8 @@ void hitomezashi_cli_handle_args(char **out_file_path, int *x_pattern_len, exit(Hitomezashi_Cli_Exit_Code_Err_Handle_Args); } *x_pattern_len = x_pattern_len_l; - *x_pattern = hitomezashi_cli_ascii_binary_str_to_ints(options.optarg, - *x_pattern_len); + *x_pattern = + hitomezashi_ascii_binary_str_to_ints(options.optarg, *x_pattern_len); if (!*x_pattern) { SDL_LogCritical(SDL_LOG_CATEGORY_ERROR, "Invalid x pattern; see -h"); exit(Hitomezashi_Cli_Exit_Code_Err_Handle_Args); @@ -128,8 +113,8 @@ void hitomezashi_cli_handle_args(char **out_file_path, int *x_pattern_len, exit(Hitomezashi_Cli_Exit_Code_Err_Handle_Args); } *y_pattern_len = y_pattern_len_l; - *y_pattern = hitomezashi_cli_ascii_binary_str_to_ints(options.optarg, - *y_pattern_len); + *y_pattern = + hitomezashi_ascii_binary_str_to_ints(options.optarg, *y_pattern_len); if (!*y_pattern) { SDL_LogCritical(SDL_LOG_CATEGORY_ERROR, "Invalid y pattern; see -h"); exit(Hitomezashi_Cli_Exit_Code_Err_Handle_Args); |