char* handle_arguments(int argc, char** argv, struct arg_t* args) { init_default_args(args); Cmdline(args, argc, argv); if (argc == 1 || args->optind+1 != argc) { usage(-1, argv[0]); } if (args->v) { printf("sha256 version %s\n", VERSION); } if (args->_0 != 0) { args->x = false; } else if (args->x == true && args->_0 != 0) { fprintf(stderr, "-x and -0 can not be used at the same time\n"); exit(EXIT_FAILURE); } if (args->b == false && args->m == true) { args->b = true; } if (args->_0 < 0 || args->_0 > 8) { fprintf(stderr, "number of bytes to print must be betwee 1 and 8\n"); exit(EXIT_FAILURE); } return argv[args->optind]; }
/* h / help flag " display this help and exit" v / version flag " output version information and exit" s / size int " size of hands, defaults to 8 (7, 8, 9, 10, J, Q, K, A" l / left flag " left run" r / right flag " right run" u / run string " mutti run" i / hi flag " ace hi" o / low flag " ace low (default)" */ char* handle_arguments(int argc, char** argv, struct arg_t* args) { init_default_args(args); Cmdline(args, argc, argv); if (args->v) { printf("mutti version %s\n", VERSION); } uint32 size1 =0; if (args->u == NULL) { error("Required parameter: -u/--run <run>"); } if (!(args->i ^ args->o)) { error("Excpecting -i/--hi or -o/--low to be set, not both."); } size1 = is_valid_permutation(args->u); if (!size1) { error("Given run (-u) is not a comma delimted permutation."); } if (args->s != 8) { error("Invalid size: expected 8!"); } if (args->s != size1) { error("Given permutation size and specified permutation are not the same size."); } return argv[args->optind]; }
int main(int argc, char *argv[]) { MediastreamDatas *args; cond = 1; args = init_default_args(); if (!parse_args(argc, argv, args)) return 0; setup_media_streams(args); run_non_interactive_loop(args); clear_mediastreams(args); free(args); return 0; }