static int handle_options(int argc, char **argv) { while (true) { int c; int option_index = 0; c = getopt_long (argc, argv, "lhRsairS", long_options, &option_index); if (c == -1) break; switch (c) { case 0: handle_long_options(long_options[option_index], optarg); break; case '?': case 'h': usage(0); break; default: printf ("?? getopt returned character code 0%o ??\n", c); usage(-1); } } return 0; }
static int handle_options(int argc, char **argv) { while (1) { int c; int option_index = 0; c = getopt_long (argc, argv, "b:n:h", long_options, &option_index); if (c == -1) break; switch (c) { case 0: handle_long_options(long_options[option_index], optarg); break; case 'b': if (!get_int(optarg, &block_size) || block_size <= 0) { printf("'%s': no es un entero válido\n", optarg); usage(-3); } break; case 'n': if (!get_int(optarg, &num_blocks) || num_blocks <= 0) { printf("'%s': no es un entero válido\n", optarg); usage(-3); } break; case '?': case 'h': usage(0); break; default: printf ("?? getopt returned character code 0%o ??\n", c); usage(-1); } } return 0; }