From b493a57cae973304422e7c2121bbc369119b29a5 Mon Sep 17 00:00:00 2001 From: "Thomas \"Cakeisalie5\" Touhey" Date: Thu, 13 Jul 2017 17:00:41 +0200 Subject: [PATCH] Officially supporting examination mode unlocking. --- src/p7/args.c | 14 ++++++++++++-- src/p7/main.c | 15 ++++++++++++--- src/p7/main.h | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/p7/args.c b/src/p7/args.c index 76d5ce2..6bc962b 100644 --- a/src/p7/args.c +++ b/src/p7/args.c @@ -121,12 +121,19 @@ FOOT; /* Idle */ static const char help_idle[] = -"Usage: " QUOTE(BIN) " idle\n" +"Usage: " QUOTE(BIN) " idle|laze\n" "Only initialize or end the communication.\n" +"\n" "This subcommand is useful when used with `--no-init` and/or `--no-exit`.\n" "It allows you to prepare the communication state for the next calls, or to\n" "end a series of calls, without any side effects.\n" FOOT; + +/* Unlock */ +static const char help_unlock[] = +"Usage: " QUOTE(BIN) " unlock\n" +"Unlock examination mode.\n" +FOOT; /* ************************************************************************** */ /* Help helpers */ /* ************************************************************************** */ @@ -145,7 +152,8 @@ static const char help_main_part0[] = " optimize Optimize the distant filesystem.\n" " list List files on the distant filesystem.\n" " info Dump info about the calculator.\n" -" idle Do nothing (only start or end the communication)\n" +" idle Do nothing. (only start or end the communication)\n" +" unlock Unlock examination mode.\n" "\n" "General options:\n" " -h, --help Display the help page of the (sub)command and quit.\n" @@ -407,6 +415,8 @@ int parse_args(int ac, char **av, args_t *args) args->dirname = s_dir; } else if (!strcmp(aav[0], "idle") || !strcmp(aav[0], "laze")) { sub_init(idle, 0) + } else if (!strcmp(aav[0], "unlock")) { + sub_init(unlock, 0) } else { /* unknown subcommand ! */ log("Unknown subcommand '%s'.\n", aav[0]); diff --git a/src/p7/main.c b/src/p7/main.c index f7c5f1a..e4e7b4b 100644 --- a/src/p7/main.c +++ b/src/p7/main.c @@ -185,13 +185,14 @@ static void print_file_info(void *cookie, const char *dir, const char *name, int main(int ac, char **av) { + int err = 0; args_t args; + casio_link_t *handle = NULL; + /* Parse args */ - args_t args; if (!parse_args(ac, av, &args)) return (0); /* Initialize the link */ - casio_link_t *handle = NULL; int err; if (args.com) err = casio_open_com(&handle, args.initflags, args.com, args.use); else err = casio_open_usb(&handle, args.initflags); @@ -221,6 +222,7 @@ int main(int ac, char **av) /* Check according to menu */ switch (args.menu) { +#if 0 case mn_send: /* get file size */ fseek(args.local, 0, SEEK_END); @@ -246,7 +248,8 @@ int main(int ac, char **av) args.nicedisp ? &sendfile_display : NULL); break; case mn_get: - err = casio_reqfile(handle, args.local, args.dirname, args.filename, + err = casio_reqfile(handle, args.local, + args.dirname, args.filename, args.storage, args.nicedisp && args.local != stdout ? &sendfile_display : NULL); break; @@ -267,11 +270,17 @@ int main(int ac, char **av) case mn_optimize: err = casio_optimize(handle, args.storage); break; +#endif case mn_info: err = dump(handle); break; case mn_idle: break; /* time! */ + case mn_unlock: + break; /* dance! */ + default: + fprintf(stderr, "Unhandled yet.\n"); + break; } /* put error */ diff --git a/src/p7/main.h b/src/p7/main.h index e5313b5..3ab4d24 100644 --- a/src/p7/main.h +++ b/src/p7/main.h @@ -27,7 +27,7 @@ /* Menus */ typedef enum { mn_send, mn_get, mn_copy, mn_del, mn_list, mn_reset, - mn_optimize, mn_info, mn_idle + mn_optimize, mn_info, mn_idle, mn_unlock } menu_t; /* Arguments */