cake
/
p7utils
Archived
1
0
Fork 0

Officially supporting examination mode unlocking.

This commit is contained in:
Thomas Touhey 2017-07-13 17:00:41 +02:00
parent dc97d65696
commit b493a57cae
3 changed files with 25 additions and 6 deletions

View File

@ -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]);

View File

@ -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 */

View File

@ -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 */