Should have implemented getting.
This commit is contained in:
parent
3524f752e1
commit
d0384341fe
|
@ -61,15 +61,13 @@ int main(int ac, char **av)
|
|||
p7_handle_t *handle = NULL; int err;
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com);
|
||||
else err = p7_init(&handle, initflags);
|
||||
if (err) goto init_error;
|
||||
if (err) goto fail;
|
||||
|
||||
/* prepare */
|
||||
if (!args.noprepare) {
|
||||
/* make the preparation thing */
|
||||
if (prepare_ops(handle, args.uexe)) {
|
||||
if (args.local) fclose(args.local);
|
||||
return (1);
|
||||
}
|
||||
if ((err = prepare_ops(handle, args.uexe)))
|
||||
goto fail;
|
||||
handle = NULL;
|
||||
|
||||
/* was only about preparing? */
|
||||
|
@ -82,7 +80,7 @@ int main(int ac, char **av)
|
|||
/* re-open the handle */
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com);
|
||||
else err = p7_init(&handle, initflags);
|
||||
if (err) goto init_error;
|
||||
if (err) goto fail;
|
||||
}
|
||||
|
||||
/* check according to menu */
|
||||
|
@ -90,10 +88,9 @@ int main(int ac, char **av)
|
|||
/* backup the thing menu */
|
||||
case mn_get:
|
||||
/* get the os */
|
||||
fprintf(stderr, "Unimplemented, yet.\n"); err = 1;
|
||||
err = p7_backup_rom(handle, args.local);
|
||||
if (err) goto fail;
|
||||
fclose(args.local);
|
||||
/* if there was an error, delete created file */
|
||||
if (err) remove(args.localpath);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -103,9 +100,9 @@ int main(int ac, char **av)
|
|||
/* then we're good */
|
||||
return (0);
|
||||
|
||||
init_error:
|
||||
fail:
|
||||
/* displaying error */
|
||||
switch (err) {
|
||||
if (err > 0) switch (err) {
|
||||
case p7_error_nocalc: log(error_noconnexion); break;
|
||||
case p7_error_noaccess: log(error_noaccess); break;
|
||||
case p7_error_unsupported: log(error_unsupported); break;
|
||||
|
|
|
@ -12,10 +12,6 @@
|
|||
/* ************************************************************************** */
|
||||
/* Error messages */
|
||||
/* ************************************************************************** */
|
||||
/* Generic error */
|
||||
static const char error_gen[] =
|
||||
"An error has occured: %s\n";
|
||||
|
||||
/* Unable to open the embedded thingy */
|
||||
static const char error_fmemopen[] =
|
||||
"Unable to open the embedded update.exe.\n";
|
||||
|
@ -37,7 +33,7 @@ extern char _binary_cake_exe_bin_end[];
|
|||
*
|
||||
* @arg handle the libp7 handle.
|
||||
* @arg uexe the update.exe to use (NULL if use the embedded one).
|
||||
* @return if something went wrong (0 if ok).
|
||||
* @return the error (-1 if not a libp7 error, 0 if ok)
|
||||
*/
|
||||
|
||||
int prepare_ops(p7_handle_t *handle, FILE *uexe)
|
||||
|
@ -56,16 +52,15 @@ int prepare_ops(p7_handle_t *handle, FILE *uexe)
|
|||
uexe = fmemopen(cake_exe_str, usize, "r");
|
||||
if (!uexe) {
|
||||
fprintf(stderr, error_fmemopen);
|
||||
return (1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* send the thing */
|
||||
if ((err = p7_sendexe_stream(handle, uexe, (p7uint_t)usize,
|
||||
0x88030000, 0x88030000))) {
|
||||
fprintf(stderr, error_gen, p7_strerror(err));
|
||||
fclose(uexe);
|
||||
return (1);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* no error! */
|
||||
|
|
Reference in New Issue