/* 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]; }
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]; }
int main (int argc, char *argv[]) { struct arg_t *kom_arg, arg; pid_t child_pid; int fifofd1; /* Setup a signal handler for SIGINT */ signal(SIGINT, int_proc); signal(SIGTERM, int_proc); kom_arg = &arg; Cmdline (kom_arg, argc, argv); if (kom_arg->v) { printf ("%s: version %s\n", argv[0], PACKAGE_VERSION); return EXIT_FAILURE; } verbose = kom_arg->V; if (verbose) printf ("start\n"); fifofd1 = fifo_create (FILENAME, 4096, 0); child_pid = fork (); if (child_pid == 0) child_process (); while (!stop) { fifo_write (fifofd1, "Hallo", 5); printf ("write\n"); sleep (1); } fifo_destroy (fifofd1); if (verbose) printf ("done\n"); return EXIT_SUCCESS; }