int cmd_show(int argc, char *argv[]) { int ch, fd; while ((ch = getopt(argc, argv, "lu")) != -1) { switch(ch) { case 'l': show_label = 1; break; case 'u': show_uuid = 1; break; default: usage_show(); } } if (argc == optind) usage_show(); while (optind < argc) { fd = gpt_open(argv[optind++]); if (fd == -1) { warn("unable to open device '%s'", device_name); continue; } show(fd); gpt_close(fd); } return (0); }
static int pb_show(int argc, char **argv) { int i, ret; struct stat st; while ((i = getopt(argc, argv, "fd:m:")) != EOF) { switch (i) { case 'f': force = 1; break; case 'd': device = optarg; break; case 'm': mount_point = optarg; break; default: usage_show(); return SYSEXIT_PARAM; } } argc -= optind; argv += optind; GET_DD(argc, argv); if (argc != 0 || fill_opts()) { usage_show(); return SYSEXIT_PARAM; } ret = get_balloon(mount_point, &st, NULL); if (ret) return ret; fprintf(stdout, "Current size of hidden balloon is %llu bytes\n", (unsigned long long) st.st_size); return 0; }
int main(int argc, char **argv) { uint8_t i; arg_init(); if (argc<1) { usage_show(); } else { i=1; //argv[0] is the command itself argc--; //get the real number of arguments while (i<=argc) { //check arguments if (!(strcmp("-h",argv[i]))) { usage_show(); stop_pgm(""); } else if (!(strcmp("-d",argv[i]))) { if (i++==argc) stop_pgm("Argument missed for option -d\n"); memcpy(arg_dst,argv[i],strlen((const char*)argv[i])+1); i++; continue; } else if (!(strcmp("-p",argv[i]))) { if (i++==argc) stop_pgm("Argument missed for option -p\n"); arg_port=atoi(argv[i]); i++; continue; } else if (!(strcmp("-dp",argv[i]))) { if (i++==argc) stop_pgm("Argument missed for option -dp\n"); arg_dport=atoi(argv[i]); i++; continue; } else { usage_show(); stop_pgm("\n--- Argument error ---\n"); } } } pthread_t threads[NUMTHREADS]; for (int index = 0; index < NUMTHREADS; index++) { pthread_create(&threads[index], NULL, create_endpoint, (void *) &index); sleep(1); } for (int i = 0; i < NUMTHREADS; i) { pthread_join(threads[i], NULL); } exit(0); }