diff --git a/docs/html/dc/db4/structgeneral__option.html b/docs/html/dc/db4/structgeneral__option.html index 535affe..f1d29e5 100644 --- a/docs/html/dc/db4/structgeneral__option.html +++ b/docs/html/dc/db4/structgeneral__option.html @@ -127,7 +127,7 @@

Detailed Description

The general struct for handling the general arguments.

-

Definition at line 42 of file yiffy.c.

+

Definition at line 40 of file yiffy.c.

Member Data Documentation

◆ function

@@ -141,7 +141,7 @@

-

Definition at line 45 of file yiffy.c.

+

Definition at line 43 of file yiffy.c.

@@ -157,7 +157,7 @@

-

Definition at line 44 of file yiffy.c.

+

Definition at line 42 of file yiffy.c.

diff --git a/docs/html/dc/dc0/yiffy_8c.html b/docs/html/dc/dc0/yiffy_8c.html index 23ff684..d4359ab 100644 --- a/docs/html/dc/dc0/yiffy_8c.html +++ b/docs/html/dc/dc0/yiffy_8c.html @@ -313,7 +313,7 @@

-

Definition at line 78 of file yiffy.c.

+

Definition at line 74 of file yiffy.c.

diff --git a/docs/html/dc/dc0/yiffy_8c_source.html b/docs/html/dc/dc0/yiffy_8c_source.html index d284ed3..20a07d4 100644 --- a/docs/html/dc/dc0/yiffy_8c_source.html +++ b/docs/html/dc/dc0/yiffy_8c_source.html @@ -131,193 +131,179 @@
31
32static bool argument_verify(int argument_count, char *arguments[]);
33static bool is_api_accessible();
-
34static void export_local_data();
-
35static void import_local_data();
-
36static void search_urls(char *tags);
-
37static void fetch_urls(char *tags, char *command);
-
38
- -
43{
-
44 char *option;
-
45 void (*function)(char *argv);
-
46};
-
47
- -
52{
-
53 char *option;
-
54 void (*function)(char *argv, char *command);
-
55};
-
56
-
57static struct general_option general_options[] =
-
58{
-
59 {"--help", show_help},
-
60 {"--version", show_version},
-
61 {"--github", show_github},
-
62 {"--config", show_config},
-
63 {"--export", export_local_data},
-
64 {"--import", import_local_data},
-
65 {"--ivcommand", conf_img_viewer_command},
-
66 {"--nsfw", conf_nsfw},
-
67 {"--uname", conf_uname},
-
68 {"--apikey", conf_apikey},
-
69 {"--search", search_urls}
-
70};
-
71
-
72static struct fetch_option fetch_options[] =
-
73{
-
74 {"--fetch", fetch_urls},
-
75 {"--dfetch", fetch_urls}
-
76};
-
77
-
78int main(int argc, char *argv[])
-
79{
-
80 if (argument_verify(argc, argv))
-
81 {
-
82 for (size_t i = 0; i < sizeof(fetch_options) / sizeof(fetch_options[0]); i++)
-
83 {
-
84 if (strcmp(argv[1], fetch_options[i].option) == 0)
-
85 {
-
86 void (*fetch_function)(char *argv, char *command) = fetch_options[i].function;
-
87 fetch_function(argv[2], fetch_options[i].option);
+
34static void search_urls(char *tags);
+
35static void fetch_urls(char *tags, char *command);
+
36
+ +
41{
+
42 char *option;
+
43 void (*function)(char *argv);
+
44};
+
45
+ +
50{
+
51 char *option;
+
52 void (*function)(char *argv, char *command);
+
53};
+
54
+
55static struct general_option general_options[] =
+
56{
+
57 {"--help", show_help},
+
58 {"--version", show_version},
+
59 {"--github", show_github},
+
60 {"--config", show_config},
+
61 {"--ivcommand", conf_img_viewer_command},
+
62 {"--nsfw", conf_nsfw},
+
63 {"--uname", conf_uname},
+
64 {"--apikey", conf_apikey},
+
65 {"--search", search_urls}
+
66};
+
67
+
68static struct fetch_option fetch_options[] =
+
69{
+
70 {"--fetch", fetch_urls},
+
71 {"--dfetch", fetch_urls}
+
72};
+
73
+
74int main(int argc, char *argv[])
+
75{
+
76 if (argument_verify(argc, argv))
+
77 {
+
78 for (size_t i = 0; i < sizeof(fetch_options) / sizeof(fetch_options[0]); i++)
+
79 {
+
80 if (strcmp(argv[1], fetch_options[i].option) == 0)
+
81 {
+
82 void (*fetch_function)(char *argv, char *command) = fetch_options[i].function;
+
83 fetch_function(argv[2], fetch_options[i].option);
+
84
+
85 break;
+
86 }
+
87 }
88
-
89 break;
-
90 }
-
91 }
-
92
-
93 for (size_t i = 0; i < sizeof(general_options) / sizeof(general_options[0]); i++)
-
94 {
-
95 if (strcmp(argv[1], general_options[i].option) == 0)
-
96 {
-
97 void (*menu_func)(char *argv) = general_options[i].function;
-
98
-
99 if (strcmp(general_options[i].option, "--search") == 0 || strcmp(general_options[i].option, "--nsfw") == 0 || strcmp(general_options[i].option, "--ivcommand") == 0 || strcmp(general_options[i].option, "--uname") == 0 || strcmp(general_options[i].option, "--apikey") == 0) /* THIRD ARGUMENT: tags [yiffy --search "blush+fox+male"]*/
+
89 for (size_t i = 0; i < sizeof(general_options) / sizeof(general_options[0]); i++)
+
90 {
+
91 if (strcmp(argv[1], general_options[i].option) == 0)
+
92 {
+
93 void (*menu_func)(char *argv) = general_options[i].function;
+
94
+
95 if (strcmp(general_options[i].option, "--search") == 0 || strcmp(general_options[i].option, "--nsfw") == 0 || strcmp(general_options[i].option, "--ivcommand") == 0 || strcmp(general_options[i].option, "--uname") == 0 || strcmp(general_options[i].option, "--apikey") == 0) /* THIRD ARGUMENT: tags [yiffy --search "blush+fox+male"]*/
+
96 {
+
97 menu_func(argv[2]);
+
98 }
+
99 else /* NO THIRD ARGUMENT */
100 {
-
101 menu_func(argv[2]);
+
101 menu_func(NULL);
102 }
-
103 else /* NO THIRD ARGUMENT */
-
104 {
-
105 menu_func(NULL);
-
106 }
-
107
-
108 break;
-
109 }
-
110 }
-
111 }
-
112
-
113 return 0;
-
114}
-
115
-
128static bool argument_verify(int argument_count, char *arguments[])
-
129{
-
130 char *one_arguments[] = {"--help", "--version", "--github", "--config", "--export", "--import"};
-
131 char *two_arguments[] = {"--apikey", "--uname", "--ivcommand", "--nsfw", "--dfetch", "--fetch", "--search"};
-
132
-
133
-
134 if (argument_count == 3)
-
135 {
-
147 for (size_t i = 0; i < sizeof(two_arguments) / sizeof(two_arguments[0]); i++)
-
148 {
-
149 if (strcmp(arguments[1], two_arguments[i]) == 0)
-
150 {
-
151 if (strcmp(arguments[2], "on") == 0 || strcmp(arguments[2], "off") == 0 || strcmp(arguments[1], "--dfetch") == 0 || strcmp(arguments[1], "--fetch") == 0 || strcmp(arguments[1], "--search") == 0 || strcmp(arguments[1], "--ivcommand") == 0 || strcmp(arguments[1], "--uname") == 0 || strcmp(arguments[1], "--apikey") == 0)
+
103
+
104 break;
+
105 }
+
106 }
+
107 }
+
108
+
109 return 0;
+
110}
+
111
+
124static bool argument_verify(int argument_count, char *arguments[])
+
125{
+
126 char *one_arguments[] = {"--help", "--version", "--github", "--config"};
+
127 char *two_arguments[] = {"--apikey", "--uname", "--ivcommand", "--nsfw", "--dfetch", "--fetch", "--search"};
+
128
+
129
+
130 if (argument_count == 3)
+
131 {
+
143 for (size_t i = 0; i < sizeof(two_arguments) / sizeof(two_arguments[0]); i++)
+
144 {
+
145 if (strcmp(arguments[1], two_arguments[i]) == 0)
+
146 {
+
147 if (strcmp(arguments[2], "on") == 0 || strcmp(arguments[2], "off") == 0 || strcmp(arguments[1], "--dfetch") == 0 || strcmp(arguments[1], "--fetch") == 0 || strcmp(arguments[1], "--search") == 0 || strcmp(arguments[1], "--ivcommand") == 0 || strcmp(arguments[1], "--uname") == 0 || strcmp(arguments[1], "--apikey") == 0)
+
148 {
+
149 return RECOGNIZED_ARGUMENT; /* Return true. */
+
150 }
+
151 else
152 {
-
153 return RECOGNIZED_ARGUMENT; /* Return true. */
-
154 }
-
155 else
-
156 {
-
157 on_off_msg(arguments[2]);
-
158 return MISSING_ON_OFF; /* Return false. */
-
159 }
-
160 }
-
161 }
-
162
-
168 for (size_t i = 0; i < sizeof(one_arguments) / sizeof(one_arguments[0]); i++)
-
169 {
-
170 if (strcmp(arguments[1], one_arguments[i]) == 0)
-
171 {
-
172 extra_arg_error_msg(arguments[1]);
-
173 return EXTRA_ARG_VALUE; /* Return false. */
-
174 }
-
175 }
-
176
-
177 unrecognized_arg_msg(arguments[1]);
-
178 return UNRECOGNIZED_ARGUMENT; /* Return false. */
-
179 }
-
180 else if (argument_count == 2)
-
181 {
-
187 for (size_t i = 0; i < sizeof(one_arguments) / sizeof(one_arguments[0]); i++)
-
188 {
-
189 if (strcmp(arguments[1], one_arguments[i]) == 0)
-
190 {
-
191 return RECOGNIZED_ARGUMENT; /* Return true. */
-
192 }
-
193 }
-
194
-
200 for (size_t i = 0; i < sizeof(two_arguments) / sizeof(two_arguments[0]); i++)
-
201 {
-
202 if (strcmp(arguments[1], two_arguments[i]) == 0)
-
203 {
-
204 no_arg_value_msg(arguments[1]);
-
205 return NO_ARG_VALUE; /* Return false. */
-
206 }
-
207 }
-
208
-
209 unrecognized_arg_msg(arguments[1]);
-
210 return UNRECOGNIZED_ARGUMENT; /* Return false. */
-
211 }
-
212 else
-
213 {
-
219 argc_error_msg(argument_count);
-
220 return ARGC_QTY_ERROR; /* Return false. */
-
221 }
-
222}
-
223
-
224
-
228static bool is_api_accessible()
-
229{
-
230 /* Send the ping. */
-
231 int ping_result = system("ping -c 1 e621.net >/dev/null 2>&1");
-
232
-
233 if (ping_result == 0)
+
153 on_off_msg(arguments[2]);
+
154 return MISSING_ON_OFF; /* Return false. */
+
155 }
+
156 }
+
157 }
+
158
+
164 for (size_t i = 0; i < sizeof(one_arguments) / sizeof(one_arguments[0]); i++)
+
165 {
+
166 if (strcmp(arguments[1], one_arguments[i]) == 0)
+
167 {
+
168 extra_arg_error_msg(arguments[1]);
+
169 return EXTRA_ARG_VALUE; /* Return false. */
+
170 }
+
171 }
+
172
+
173 unrecognized_arg_msg(arguments[1]);
+
174 return UNRECOGNIZED_ARGUMENT; /* Return false. */
+
175 }
+
176 else if (argument_count == 2)
+
177 {
+
183 for (size_t i = 0; i < sizeof(one_arguments) / sizeof(one_arguments[0]); i++)
+
184 {
+
185 if (strcmp(arguments[1], one_arguments[i]) == 0)
+
186 {
+
187 return RECOGNIZED_ARGUMENT; /* Return true. */
+
188 }
+
189 }
+
190
+
196 for (size_t i = 0; i < sizeof(two_arguments) / sizeof(two_arguments[0]); i++)
+
197 {
+
198 if (strcmp(arguments[1], two_arguments[i]) == 0)
+
199 {
+
200 no_arg_value_msg(arguments[1]);
+
201 return NO_ARG_VALUE; /* Return false. */
+
202 }
+
203 }
+
204
+
205 unrecognized_arg_msg(arguments[1]);
+
206 return UNRECOGNIZED_ARGUMENT; /* Return false. */
+
207 }
+
208 else
+
209 {
+
215 argc_error_msg(argument_count);
+
216 return ARGC_QTY_ERROR; /* Return false. */
+
217 }
+
218}
+
219
+
220
+
224static bool is_api_accessible()
+
225{
+
226 /* Send the ping. */
+
227 int ping_result = system("ping -c 1 e621.net >/dev/null 2>&1");
+
228
+
229 if (ping_result == 0)
+
230 {
+
231 return true;
+
232 }
+
233 else
234 {
-
235 return true;
-
236 }
-
237 else
-
238 {
- -
240 exit(EXIT_FAILURE);
-
241 }
-
242}
-
243
-
245static void export_local_data()
-
246{
-
247 fprintf(stdout, "EXPORT MENU\n");
-
248}
-
249
-
251static void import_local_data()
-
252{
-
253 fprintf(stdout, "IMPORT MENU\n");
-
254}
-
255
-
261static void search_urls(char *tags)
-
262{ if (is_api_accessible())
-
263 {
-
264 search(tags);
-
265 }
-
266}
-
267
-
273static void fetch_urls(char *tags, char *command)
-
274{
-
275 if (is_api_accessible())
-
276 {
-
277 int i = 1;
-
278 while (true)
-
279 {
-
280 fetch(tags, i, command);
-
281 i++;
-
282 }
-
283 }
-
284}
+ +
236 exit(EXIT_FAILURE);
+
237 }
+
238}
+
239
+
245static void search_urls(char *tags)
+
246{ if (is_api_accessible())
+
247 {
+
248 search(tags);
+
249 }
+
250}
+
251
+
257static void fetch_urls(char *tags, char *command)
+
258{
+
259 if (is_api_accessible())
+
260 {
+
261 int i = 1;
+
262 while (true)
+
263 {
+
264 fetch(tags, i, command);
+
265 i++;
+
266 }
+
267 }
+
268}
void access_error_msg()
Gives message about the accessibility to the e621/e926 api.
void argc_error_msg(int argc)
Evaluates the argument count and gives information if not in the requested format.
void conf_apikey(char *argv)
Configures the api key option.
Definition: conf_apikey.c:31
@@ -333,14 +319,14 @@
void show_github()
Shows the project github URL, current issues to user.
Definition: show_github.c:16
void show_help()
Shows the general help menu to user.
Definition: show_help.c:16
void show_version()
Shows the version of yiffy to user.
Definition: show_version.c:16
-
The general struct for handling the fetch arguments.
Definition: yiffy.c:52
-
void(* function)(char *argv, char *command)
Definition: yiffy.c:54
-
char * option
Definition: yiffy.c:53
-
The general struct for handling the general arguments.
Definition: yiffy.c:43
-
char * option
Definition: yiffy.c:44
-
void(* function)(char *argv)
Definition: yiffy.c:45
+
The general struct for handling the fetch arguments.
Definition: yiffy.c:50
+
void(* function)(char *argv, char *command)
Definition: yiffy.c:52
+
char * option
Definition: yiffy.c:51
+
The general struct for handling the general arguments.
Definition: yiffy.c:41
+
char * option
Definition: yiffy.c:42
+
void(* function)(char *argv)
Definition: yiffy.c:43
void unrecognized_arg_msg(char *argument)
Gives information and outputs the command prompted by the user when it is not defined as a valid argu...
-
int main(int argc, char *argv[])
Definition: yiffy.c:78
+
int main(int argc, char *argv[])
Definition: yiffy.c:74
#define UNRECOGNIZED_ARGUMENT
Definition: yiffy.c:26
#define EXTRA_ARG_VALUE
Definition: yiffy.c:30
#define ARGC_QTY_ERROR
Definition: yiffy.c:28
diff --git a/docs/html/de/d0c/show__help_8c_source.html b/docs/html/de/d0c/show__help_8c_source.html index 26914cd..a0b710b 100644 --- a/docs/html/de/d0c/show__help_8c_source.html +++ b/docs/html/de/d0c/show__help_8c_source.html @@ -133,20 +133,15 @@
33 fprintf(stdout, "--version outputs the version\n");
34 fprintf(stdout, "--github outputs the github url\n");
35 fprintf(stdout, "--config outputs the configs-credentials\n\n");
-
36
-
37 fprintf(stdout, "yiffy data import-export arguments\n");
-
38 fprintf(stdout, "----------------------------------\n");
-
39 fprintf(stdout, "--import imports the data to program\n");
-
40 fprintf(stdout, "--export exports the data from program\n\n");
-
41
-
42 fprintf(stdout, "yiffy config and credential arguments\n");
-
43 fprintf(stdout, "-------------------------------------\n");
-
44 fprintf(stdout, "--nsfw [on/off] switches to nsfw/sfw options\n");
-
45 fprintf(stdout, "--ivcommand [cmd] sets the image viewer command\n");
-
46 fprintf(stdout, "--uname [uname] sets the username\n");
-
47 fprintf(stdout, "--apikey [apikey] sets the api key\n");
-
48
-
49}
+
36
+
37 fprintf(stdout, "yiffy config and credential arguments\n");
+
38 fprintf(stdout, "-------------------------------------\n");
+
39 fprintf(stdout, "--nsfw [on/off] switches to nsfw/sfw options\n");
+
40 fprintf(stdout, "--ivcommand [cmd] sets the image viewer command\n");
+
41 fprintf(stdout, "--uname [uname] sets the username\n");
+
42 fprintf(stdout, "--apikey [apikey] sets the api key\n");
+
43
+
44}
void show_help()
Shows the general help menu to user.
Definition: show_help.c:16
This header file is used to generate text based information menus for yiffy.
diff --git a/docs/html/df/d6b/structfetch__option.html b/docs/html/df/d6b/structfetch__option.html index 9dbde9a..f751d28 100644 --- a/docs/html/df/d6b/structfetch__option.html +++ b/docs/html/df/d6b/structfetch__option.html @@ -127,7 +127,7 @@

Detailed Description

The general struct for handling the fetch arguments.

-

Definition at line 51 of file yiffy.c.

+

Definition at line 49 of file yiffy.c.

Member Data Documentation

◆ function

@@ -141,7 +141,7 @@

-

Definition at line 54 of file yiffy.c.

+

Definition at line 52 of file yiffy.c.

@@ -157,7 +157,7 @@

-

Definition at line 53 of file yiffy.c.

+

Definition at line 51 of file yiffy.c.

diff --git a/src/app/yiffy.c b/src/app/yiffy.c index 47fa947..ce976ff 100644 --- a/src/app/yiffy.c +++ b/src/app/yiffy.c @@ -31,8 +31,6 @@ static bool argument_verify(int argument_count, char *arguments[]); static bool is_api_accessible(); -static void export_local_data(); -static void import_local_data(); static void search_urls(char *tags); static void fetch_urls(char *tags, char *command); @@ -60,8 +58,6 @@ static struct general_option general_options[] = {"--version", show_version}, {"--github", show_github}, {"--config", show_config}, - {"--export", export_local_data}, - {"--import", import_local_data}, {"--ivcommand", conf_img_viewer_command}, {"--nsfw", conf_nsfw}, {"--uname", conf_uname}, @@ -127,7 +123,7 @@ int main(int argc, char *argv[]) */ static bool argument_verify(int argument_count, char *arguments[]) { - char *one_arguments[] = {"--help", "--version", "--github", "--config", "--export", "--import"}; + char *one_arguments[] = {"--help", "--version", "--github", "--config"}; char *two_arguments[] = {"--apikey", "--uname", "--ivcommand", "--nsfw", "--dfetch", "--fetch", "--search"}; @@ -241,18 +237,6 @@ static bool is_api_accessible() } } -/// @brief exports the app data as a string -static void export_local_data() -{ - fprintf(stdout, "EXPORT MENU\n"); -} - -/// @brief imports the string and creates app data -static void import_local_data() -{ - fprintf(stdout, "IMPORT MENU\n"); -} - /** * @brief Calls the search function to use yiffy e621-e926 terminal. * diff --git a/src/menus/show_help.c b/src/menus/show_help.c index c7c2a82..4fc4620 100644 --- a/src/menus/show_help.c +++ b/src/menus/show_help.c @@ -33,12 +33,7 @@ void show_help() fprintf(stdout, "--version outputs the version\n"); fprintf(stdout, "--github outputs the github url\n"); fprintf(stdout, "--config outputs the configs-credentials\n\n"); - - fprintf(stdout, "yiffy data import-export arguments\n"); - fprintf(stdout, "----------------------------------\n"); - fprintf(stdout, "--import imports the data to program\n"); - fprintf(stdout, "--export exports the data from program\n\n"); - + fprintf(stdout, "yiffy config and credential arguments\n"); fprintf(stdout, "-------------------------------------\n"); fprintf(stdout, "--nsfw [on/off] switches to nsfw/sfw options\n");