Adapted to new libp7 logic (flags)
This commit is contained in:
parent
e4553a75de
commit
09c95e1241
|
@ -170,7 +170,7 @@ int parse_args(int ac, char **av, args_t *args)
|
|||
.local = NULL, .force = 0,
|
||||
.com = 0,
|
||||
.storage = QUOTE(DEFAULT_STORAGE),
|
||||
.noinit = 0, .noexit = 0};
|
||||
.initflags = P7_ACTIVE | P7_CHECK, .exitflags = P7_TERM};
|
||||
|
||||
/* define options */
|
||||
char short_options[] = "hvfo:d:t:#";
|
||||
|
@ -217,9 +217,9 @@ int parse_args(int ac, char **av, args_t *args)
|
|||
/* storage */
|
||||
case 's': args->storage = optarg; break;
|
||||
/* force no initialization */
|
||||
case 'i': args->noinit = 1; break;
|
||||
case 'i': args->initflags &= ~P7_CHECK; break;
|
||||
/* force no exit */
|
||||
case 'e': args->noexit = 1; break;
|
||||
case 'e': args->exitflags &= ~P7_TERM; break;
|
||||
|
||||
/* in case of error */
|
||||
case '?':
|
||||
|
|
|
@ -187,8 +187,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, 1, !args.noinit, args.com);
|
||||
else err = p7_init(&handle, 1, !args.noinit);
|
||||
if (args.com) err = p7_cominit(&handle, args.initflags, args.com);
|
||||
else err = p7_init(&handle, args.initflags);
|
||||
if (err) {
|
||||
/* display error */
|
||||
switch (err) {
|
||||
|
@ -272,7 +272,7 @@ int main(int ac, char **av)
|
|||
if (args.local) fclose(args.local);
|
||||
|
||||
/* terminate communication and de-initialize libp7 */
|
||||
p7_exit(handle, !args.noexit);
|
||||
p7_exit(handle, args.exitflags);
|
||||
|
||||
/* Then we're good */
|
||||
return (0);
|
||||
|
|
|
@ -34,10 +34,8 @@ typedef struct {
|
|||
int force;
|
||||
|
||||
/* other options */
|
||||
int com;
|
||||
const char *storage;
|
||||
int noinit;
|
||||
int noexit;
|
||||
unsigned int initflags, exitflags;
|
||||
int com; const char *storage;
|
||||
} args_t;
|
||||
|
||||
/* Parsing function */
|
||||
|
|
|
@ -58,8 +58,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, 1, 1, args.com);
|
||||
else err = p7_init(&handle, 1, 1);
|
||||
if (args.com) err = p7_cominit(&handle, P7_ACTIVE | P7_CHECK, args.com);
|
||||
else err = p7_init(&handle, P7_ACTIVE | P7_CHECK);
|
||||
if (err) goto init_error;
|
||||
|
||||
/* prepare */
|
||||
|
@ -79,8 +79,8 @@ int main(int ac, char **av)
|
|||
sleep(1);
|
||||
|
||||
/* re-open the handle */
|
||||
if (args.com) err = p7_cominit(&handle, 1, 1, args.com);
|
||||
else err = p7_init(&handle, 1, 1);
|
||||
if (args.com) err = p7_cominit(&handle, P7_ACTIVE | P7_CHECK, args.com);
|
||||
else err = p7_init(&handle, P7_ACTIVE | P7_CHECK);
|
||||
if (err) goto init_error;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,9 +68,6 @@ int prepare_ops(p7_handle_t *handle, FILE *uexe)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/* close the handle */
|
||||
p7_exit(handle, 0);
|
||||
|
||||
/* no error! */
|
||||
fclose(uexe);
|
||||
return (0);
|
||||
|
|
|
@ -128,8 +128,8 @@ int main(int ac, char **av)
|
|||
|
||||
/* Initialize libp7 */
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if (com) err = p7_cominit(&handle, 0, 0, com);
|
||||
else err = p7_init(&handle, 0, 0);
|
||||
if (com) err = p7_cominit(&handle, 0, com);
|
||||
else err = p7_init(&handle, 0);
|
||||
if (err) {
|
||||
/* display error */
|
||||
switch (err) {
|
||||
|
|
Reference in New Issue