summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/Doxyfile2
-rw-r--r--cli/hitomezashi_cli.c33
-rw-r--r--cli/hitomezashi_cli.h3
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