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 | |
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')
-rw-r--r-- | cli/Doxyfile | 2 | ||||
-rw-r--r-- | cli/hitomezashi_cli.c | 33 | ||||
-rw-r--r-- | cli/hitomezashi_cli.h | 3 |
3 files changed, 10 insertions, 28 deletions
diff --git a/cli/Doxyfile b/cli/Doxyfile index 9d87f6b..96d5070 100644 --- a/cli/Doxyfile +++ b/cli/Doxyfile @@ -477,7 +477,7 @@ NUM_PROC_THREADS = 1 # normally produced when WARNINGS is set to YES. # The default value is: NO. -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. 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); diff --git a/cli/hitomezashi_cli.h b/cli/hitomezashi_cli.h index 9f7825c..3c6b9bf 100644 --- a/cli/hitomezashi_cli.h +++ b/cli/hitomezashi_cli.h @@ -37,8 +37,5 @@ void hitomezashi_cli_handle_args(char **out_file_path, int *x_pattern_len, * Hitomezashi_Cli_Exit_Code_Print_Help (2) on failure. */ void hitomezashi_cli_help(void); -/** Convert a string composed of ASCII 0 and 1 digits, eg\. "01010", to an array - * of numeric 0s and 1s stored as char. */ -char *hitomezashi_cli_ascii_binary_str_to_ints(char *ascii_str, size_t n); #endif // HITOMEZASHI_CLI_H |