diff --git a/docs/html/dc/dc0/yiffy_8c_source.html b/docs/html/dc/dc0/yiffy_8c_source.html index 20a07d4..6ae7a85 100644 --- a/docs/html/dc/dc0/yiffy_8c_source.html +++ b/docs/html/dc/dc0/yiffy_8c_source.html @@ -208,102 +208,100 @@
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 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 access_error_msg();
-
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}
+
129 if (argument_count == 3)
+
130 {
+
142 for (size_t i = 0; i < sizeof(two_arguments) / sizeof(two_arguments[0]); i++)
+
143 {
+
144 if (strcmp(arguments[1], two_arguments[i]) == 0)
+
145 {
+
146 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)
+
147 {
+
148 return RECOGNIZED_ARGUMENT; /* Return true. */
+
149 }
+
150 else
+
151 {
+
152 on_off_msg(arguments[2]);
+
153 return MISSING_ON_OFF; /* Return false. */
+
154 }
+
155 }
+
156 }
+
157
+
163 for (size_t i = 0; i < sizeof(one_arguments) / sizeof(one_arguments[0]); i++)
+
164 {
+
165 if (strcmp(arguments[1], one_arguments[i]) == 0)
+
166 {
+
167 extra_arg_error_msg(arguments[1]);
+
168 return EXTRA_ARG_VALUE; /* Return false. */
+
169 }
+
170 }
+
171
+
172 unrecognized_arg_msg(arguments[1]);
+
173 return UNRECOGNIZED_ARGUMENT; /* Return false. */
+
174 }
+
175 else if (argument_count == 2)
+
176 {
+
182 for (size_t i = 0; i < sizeof(one_arguments) / sizeof(one_arguments[0]); i++)
+
183 {
+
184 if (strcmp(arguments[1], one_arguments[i]) == 0)
+
185 {
+
186 return RECOGNIZED_ARGUMENT; /* Return true. */
+
187 }
+
188 }
+
189
+
195 for (size_t i = 0; i < sizeof(two_arguments) / sizeof(two_arguments[0]); i++)
+
196 {
+
197 if (strcmp(arguments[1], two_arguments[i]) == 0)
+
198 {
+
199 no_arg_value_msg(arguments[1]);
+
200 return NO_ARG_VALUE; /* Return false. */
+
201 }
+
202 }
+
203
+
204 unrecognized_arg_msg(arguments[1]);
+
205 return UNRECOGNIZED_ARGUMENT; /* Return false. */
+
206 }
+
207 else
+
208 {
+
214 argc_error_msg(argument_count);
+
215 return ARGC_QTY_ERROR; /* Return false. */
+
216 }
+
217}
+
218
+
222static bool is_api_accessible()
+
223{
+
224 /* Send the ping. */
+
225 int ping_result = system("ping -c 1 e621.net >/dev/null 2>&1");
+
226
+
227 if (ping_result == 0)
+
228 {
+
229 return true;
+
230 }
+
231 else
+
232 {
+
233 access_error_msg();
+
234 exit(EXIT_FAILURE);
+
235 }
+
236}
+
237
+
243static void search_urls(char *tags)
+
244{ if (is_api_accessible())
+
245 {
+
246 search(tags);
+
247 }
+
248}
+
249
+
255static void fetch_urls(char *tags, char *command)
+
256{
+
257 if (is_api_accessible())
+
258 {
+
259 int i = 1;
+
260 while (true)
+
261 {
+
262 fetch(tags, i, command);
+
263 i++;
+
264 }
+
265 }
+
266}
access_error_msg
void access_error_msg()
Gives message about the accessibility to the e621/e926 api.
Definition: access_error_msg.c:16
argc_error_msg
void argc_error_msg(int argc)
Evaluates the argument count and gives information if not in the requested format.
Definition: argc_error_msg.c:18
conf_apikey
void conf_apikey(char *argv)
Configures the api key option.
Definition: conf_apikey.c:31
diff --git a/src/app/yiffy.c b/src/app/yiffy.c index ce976ff..a4d6404 100644 --- a/src/app/yiffy.c +++ b/src/app/yiffy.c @@ -126,7 +126,6 @@ static bool argument_verify(int argument_count, char *arguments[]) char *one_arguments[] = {"--help", "--version", "--github", "--config"}; char *two_arguments[] = {"--apikey", "--uname", "--ivcommand", "--nsfw", "--dfetch", "--fetch", "--search"}; - if (argument_count == 3) { /** @@ -217,7 +216,6 @@ static bool argument_verify(int argument_count, char *arguments[]) } } - /** * @brief Sends ping to the e621/e926 to check if it accessible. */ @@ -245,7 +243,7 @@ static bool is_api_accessible() static void search_urls(char *tags) { if (is_api_accessible()) { - search(tags); + search(tags); } }