Adapted to new lib version
This commit is contained in:
parent
09c95e1241
commit
5632e2d3ad
|
@ -170,7 +170,7 @@ int parse_args(int ac, char **av, args_t *args)
|
|||
.local = NULL, .force = 0,
|
||||
.com = 0,
|
||||
.storage = QUOTE(DEFAULT_STORAGE),
|
||||
.initflags = P7_ACTIVE | P7_CHECK, .exitflags = P7_TERM};
|
||||
.initflags = P7_ACTIVE | P7_CHECK | P7_TERM};
|
||||
|
||||
/* define options */
|
||||
char short_options[] = "hvfo:d:t:#";
|
||||
|
@ -219,7 +219,7 @@ int parse_args(int ac, char **av, args_t *args)
|
|||
/* force no initialization */
|
||||
case 'i': args->initflags &= ~P7_CHECK; break;
|
||||
/* force no exit */
|
||||
case 'e': args->exitflags &= ~P7_TERM; break;
|
||||
case 'e': args->initflags &= ~P7_TERM; break;
|
||||
|
||||
/* in case of error */
|
||||
case '?':
|
||||
|
|
|
@ -143,13 +143,16 @@ static void sendfile_display(p7ushort_t id, p7ushort_t total)
|
|||
* print_file_info:
|
||||
* File listing callback.
|
||||
*
|
||||
* @arg cookie (unused)
|
||||
* @arg dir the directory in which the file is stored (NULL if root)
|
||||
* @arg name the filename
|
||||
* @arg size the filesize
|
||||
*/
|
||||
|
||||
static void print_file_info(const char *dir, const char *name, p7uint_t size)
|
||||
static void print_file_info(void *cookie, const char *dir, const char *name,
|
||||
p7uint_t size)
|
||||
{
|
||||
(void)cookie;
|
||||
/* initialize buffer */
|
||||
static char buf[45];
|
||||
|
||||
|
@ -228,7 +231,7 @@ int main(int ac, char **av)
|
|||
args.storage);
|
||||
break;
|
||||
case mn_ls:
|
||||
err = p7_lsfiles(handle, args.storage, &print_file_info);
|
||||
err = p7_lsfiles(handle, args.storage, &print_file_info, NULL);
|
||||
break;
|
||||
case mn_reset:
|
||||
err = p7_resetflash(handle, args.storage);
|
||||
|
@ -272,7 +275,7 @@ int main(int ac, char **av)
|
|||
if (args.local) fclose(args.local);
|
||||
|
||||
/* terminate communication and de-initialize libp7 */
|
||||
p7_exit(handle, args.exitflags);
|
||||
p7_exit(handle);
|
||||
|
||||
/* Then we're good */
|
||||
return (0);
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef struct {
|
|||
int force;
|
||||
|
||||
/* other options */
|
||||
unsigned int initflags, exitflags;
|
||||
unsigned int initflags;
|
||||
int com; const char *storage;
|
||||
} args_t;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ static const char error_unsupported[] =
|
|||
* @return return code (0 if OK)
|
||||
*/
|
||||
|
||||
#define initflags (P7_ACTIVE | P7_CHECK | P7_TERM)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
/* parse args */
|
||||
|
@ -58,8 +59,8 @@ int main(int ac, char **av)
|
|||
|
||||
/* Initialize libp7 and communication */
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if (args.com) err = p7_cominit(&handle, P7_ACTIVE | P7_CHECK, args.com);
|
||||
else err = p7_init(&handle, P7_ACTIVE | P7_CHECK);
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com);
|
||||
else err = p7_init(&handle, initflags);
|
||||
if (err) goto init_error;
|
||||
|
||||
/* prepare */
|
||||
|
@ -79,8 +80,8 @@ int main(int ac, char **av)
|
|||
sleep(1);
|
||||
|
||||
/* re-open the handle */
|
||||
if (args.com) err = p7_cominit(&handle, P7_ACTIVE | P7_CHECK, args.com);
|
||||
else err = p7_init(&handle, P7_ACTIVE | P7_CHECK);
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com);
|
||||
else err = p7_init(&handle, initflags);
|
||||
if (err) goto init_error;
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ int main(int ac, char **av)
|
|||
}
|
||||
|
||||
/* exit libp7 */
|
||||
p7_exit(handle, 1);
|
||||
p7_exit(handle);
|
||||
|
||||
/* then we're good */
|
||||
return (0);
|
||||
|
|
|
@ -160,7 +160,7 @@ int main(int ac, char **av)
|
|||
}
|
||||
|
||||
/* close */
|
||||
p7_exit(handle, 0);
|
||||
p7_exit(handle);
|
||||
|
||||
/* everything went well */
|
||||
return (0);
|
||||
|
|
Reference in New Issue