Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
main.c File Reference
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ykyh.h>
#include <openssl/evp.h>
#include "parsing.h"
#include "cmdline.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

bool reset_device (ykyh_state *state)
 
bool get_version (ykyh_state *state)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ get_version()

bool get_version ( ykyh_state * state)

Definition at line 272 of file main.c.

272 {
273 ykyh_rc ykyhrc;
274 char version[64];
275 size_t version_len = sizeof(version);
276
277 ykyhrc = ykyh_get_version(state, version, version_len);
278 if (ykyhrc != YKYHR_SUCCESS) {
279 fprintf(stderr, "Unable to get version: %s\n", ykyh_strerror(ykyhrc));
280 return false;
281 }
282
283 fprintf(stdout, "Version %s\n", version);
284
285 return true;
286}
const char * ykyh_strerror(ykyh_rc err)
Definition error.c:40
ykyh_rc ykyh_get_version(ykyh_state *state, char *version, size_t len)
Definition ykyh.c:260
ykyh_rc
Definition ykyh.h:76
@ YKYHR_SUCCESS
Definition ykyh.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 288 of file main.c.

288 {
289 struct gengetopt_args_info args_info;
290 ykyh_state *state = NULL;
291 ykyh_rc ykyhrc;
292
293 int rc = EXIT_FAILURE;
294
295 if (cmdline_parser(argc, argv, &args_info) != 0) {
296 goto main_exit;
297 }
298
299 ykyhrc = ykyh_init(&state, args_info.verbose_arg);
300 if (ykyhrc != YKYHR_SUCCESS) {
301 fprintf(stderr, "Failed to initialize libykyh\n");
302 goto main_exit;
303 }
304
305 ykyhrc = ykyh_connect(state, args_info.reader_arg);
306 if (ykyhrc != YKYHR_SUCCESS) {
307 fprintf(stderr, "Unable to connect: %s\n", ykyh_strerror(ykyhrc));
308 goto main_exit;
309 }
310
311 bool result = false;
312 switch (args_info.action_arg) {
313 case action_arg_delete:
314 result = delete_credential(state, args_info.name_arg);
315 break;
316
317 case action_arg_list:
318 result = list_credentials(state);
319 break;
320
321 case action_arg_put:
322 result = put_credential(state, args_info.name_arg,
323 args_info.derivation_password_arg,
324 args_info.enckey_arg, args_info.mackey_arg,
325 args_info.password_arg, args_info.touch_arg);
326 break;
327
328 case action_arg_reset:
329 result = reset_device(state);
330 break;
331
332 case action_arg_version:
333 result = get_version(state);
334 break;
335
336 case action__NULL:
337 fprintf(stderr, "No action given, nothing to do\n");
338 break;
339 }
340
341 if (result == true) {
342 rc = EXIT_SUCCESS;
343 }
344
345main_exit:
346
348
349 return rc;
350}
char ** argv
bool get_version(ykyh_state *state)
Definition main.c:272
bool reset_device(ykyh_state *state)
Definition main.c:258
ykyh_rc ykyh_done(ykyh_state *state)
Definition ykyh.c:64
ykyh_rc ykyh_connect(ykyh_state *state, const char *wanted)
Definition ykyh.c:92
ykyh_rc ykyh_init(ykyh_state **state, int verbose)
Definition ykyh.c:35
yh_rc rc
Here is the call graph for this function:

◆ reset_device()

bool reset_device ( ykyh_state * state)

Definition at line 258 of file main.c.

258 {
259 ykyh_rc ykyhrc;
260
261 ykyhrc = ykyh_reset(state);
262 if (ykyhrc != YKYHR_SUCCESS) {
263 fprintf(stderr, "Unable to reset device: %s\n", ykyh_strerror(ykyhrc));
264 return false;
265 }
266
267 fprintf(stdout, "Device successuflly reset\n");
268
269 return true;
270}
ykyh_rc ykyh_reset(ykyh_state *state)
Definition ykyh.c:483
Here is the call graph for this function:
Here is the caller graph for this function: