int main(int argc, char **argv) { int c; /* for getopt */ int start = 0; size_t length = 0; static const struct option longopts[] = { {"destination", required_argument, 0, 'x'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {NULL, no_argument, 0, '0'}, }; setlocale(LC_MESSAGES, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); atexit(close_stdout); page_size = getpagesize(); outbuffer = xmalloc(page_size * 2); /* command line options */ while ((c = getopt_long(argc, argv, "x:vVh", longopts, NULL)) != EOF) switch (c) { case 'h': usage(FSCK_EX_OK); break; case 'V': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'x': #ifdef INCLUDE_FS_TESTS opt_extract = 1; extract_dir = optarg; break; #else errx(FSCK_EX_USAGE, _("compiled without -x support")); #endif case 'v': opt_verbose++; break; } if ((argc - optind) != 1) usage(FSCK_EX_USAGE); filename = argv[optind]; test_super(&start, &length); test_crc(start); #ifdef INCLUDE_FS_TESTS test_fs(start); #endif if (opt_verbose) printf(_("%s: OK\n"), filename); exit(FSCK_EX_OK); }
int main(int argc, char **argv) { int c; /* for getopt */ int start = 0; size_t length; page_size = sysconf(_SC_PAGESIZE); if (argc) progname = argv[0]; outbuffer = malloc(page_size * 2); if (!outbuffer) die(FSCK_ERROR, 1, "failed to allocate outbuffer"); /* command line options */ while ((c = getopt(argc, argv, "hx:v")) != EOF) { switch (c) { case 'h': usage(FSCK_OK); case 'x': #ifdef INCLUDE_FS_TESTS opt_extract = 1; extract_dir = optarg; break; #else /* not INCLUDE_FS_TESTS */ die(FSCK_USAGE, 0, "compiled without -x support"); #endif /* not INCLUDE_FS_TESTS */ case 'v': opt_verbose++; break; } } if ((argc - optind) != 1) usage(FSCK_USAGE); filename = argv[optind]; test_super(&start, &length); test_crc(start); #ifdef INCLUDE_FS_TESTS test_fs(start); #endif /* INCLUDE_FS_TESTS */ if (opt_verbose) { printf("%s: OK\n", filename); } exit(FSCK_OK); }
void run_super(int argc, char **argv) { if(argc < 4){ fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]); return; } char *cfg = argv[3]; char *weights = (argc > 4) ? argv[4] : 0; char *filename = (argc > 5) ? argv[5] : 0; int clear = find_arg(argc, argv, "-clear"); if(0==strcmp(argv[2], "train")) train_super(cfg, weights, clear); else if(0==strcmp(argv[2], "test")) test_super(cfg, weights, filename); /* else if(0==strcmp(argv[2], "valid")) validate_super(cfg, weights); */ }
int main(int argc, char **argv) { int c; /* for getopt */ int start = 0; size_t length = 0; static const struct option longopts[] = { {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {"blocksize", required_argument, 0, 'b'}, {"extract", optional_argument, 0, 'x'}, {NULL, no_argument, 0, '0'}, }; setlocale(LC_MESSAGES, ""); setlocale(LC_CTYPE, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); atexit(close_stdout); /* command line options */ while ((c = getopt_long(argc, argv, "ayvVhb:", longopts, NULL)) != EOF) switch (c) { case 'a': /* ignore */ case 'y': break; case 'h': usage(FSCK_EX_OK); break; case 'V': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'x': opt_extract = 1; if(optarg) extract_dir = optarg; break; case 'v': opt_verbose++; break; case 'b': blksize = strtou32_or_err(optarg, _("invalid blocksize argument")); break; default: usage(FSCK_EX_USAGE); } if ((argc - optind) != 1) usage(FSCK_EX_USAGE); filename = argv[optind]; test_super(&start, &length); test_crc(start); if(opt_extract) { if (blksize == 0) blksize = getpagesize(); outbuffer = xmalloc(blksize * 2); test_fs(start); } if (opt_verbose) printf(_("%s: OK\n"), filename); exit(FSCK_EX_OK); }
int main(int argc, char **argv) { int c; /* for getopt */ int start = 0; size_t length; char *ep; blksize = sysconf(_SC_PAGESIZE); if (argc) progname = argv[0]; /* command line options */ while ((c = getopt(argc, argv, "hb:x:v")) != EOF) { switch (c) { case 'h': usage(FSCK_OK); case 'b': errno = 0; blksize = strtoul(optarg, &ep, 10); if (errno || optarg[0] == '\0' || *ep != '\0') usage(FSCK_USAGE); if (blksize < 512 || (blksize & (blksize - 1))) die(FSCK_ERROR, 0, "invalid blocksize: %u", blksize); break; case 'x': #ifdef INCLUDE_FS_TESTS opt_extract = 1; extract_dir = optarg; break; #else /* not INCLUDE_FS_TESTS */ die(FSCK_USAGE, 0, "compiled without -x support"); #endif /* not INCLUDE_FS_TESTS */ case 'v': opt_verbose++; break; } } if ((argc - optind) != 1) usage(FSCK_USAGE); filename = argv[optind]; read_buffer = malloc(ROMBUFFERSIZE * 2); if (!read_buffer) die(FSCK_ERROR, 1, "failed to allocate read_buffer"); outbuffer = malloc(blksize * 2); if (!outbuffer) die(FSCK_ERROR, 1, "failed to allocate outbuffer"); test_super(&start, &length); test_crc(start); #ifdef INCLUDE_FS_TESTS test_fs(start); #endif /* INCLUDE_FS_TESTS */ if (opt_verbose) { printf("%s: OK\n", filename); } exit(FSCK_OK); }