static DFBBoolean parse_command_line( int argc, char *argv[] ) { int n; for (n = 1; n < argc; n++) { const char *arg = argv[n]; if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) { print_usage (argv[0]); return DFB_FALSE; } if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) { fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION); return DFB_FALSE; } if (strcmp (arg, "-l") == 0 || strcmp (arg, "--layer") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_layer( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-m") == 0 || strcmp (arg, "--mode") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_mode( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_format( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-b") == 0 || strcmp (arg, "--buffer") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_buffermode( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-o") == 0 || strcmp (arg, "--opacity") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_opacity( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-L") == 0 || strcmp (arg, "--level") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_level( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-R") == 0 || strcmp (arg, "--rotate") == 0) { if (++n == argc) { print_usage (argv[0]); return DFB_FALSE; } if (!parse_rotation( argv[n] )) return DFB_FALSE; continue; } if (strcmp (arg, "-t") == 0 || strcmp (arg, "--test-lock") == 0) { test_lock = DSLF_READ | DSLF_WRITE; continue; } if (strcmp (arg, "-tr") == 0 || strcmp (arg, "--test-lock-read") == 0) { test_lock = DSLF_READ; continue; } if (strcmp (arg, "-tw") == 0 || strcmp (arg, "--test-lock-write") == 0) { test_lock = DSLF_WRITE; continue; } print_usage (argv[0]); return DFB_FALSE; } return DFB_TRUE; }
void static process_arguments(char **argv, int argc, int *monitoring, int *verbose, int *n_sus_per_file, int *duration_per_file, int *drop_fisus, int *esnf, char **hostname, Channel_t channels[], int *n_channels, char **base_filename, enum PCap_format *format) { int current_arg; while (argc > 1 && argv[1][0] == '-') { switch (argv[1][1]) { case 'c': *format = PCAP_CLASSIC; break; case 'f': if (argc < 3) { usage(); } if (!strcmp("fisu=no", argv[2])) { *drop_fisus = 1; } else if (!strcmp("esnf=yes", argv[2])) { *esnf = 1; } argc--; argv++; break; case 'm': *monitoring = 1; break; case 'n': if (argc < 3) { usage(); } parse_rotation(argv[2], n_sus_per_file, duration_per_file); argc--; argv++; break; case 'v': *verbose = 1; break; default: usage(); } argc--; argv++; } if (argc < 4) { usage(); } *hostname = argv[1]; argv += 2; argc -= 2; current_arg = arguments_to_channels(argc, argv, channels, n_channels); if (!n_channels){ die("No timeslots given (or, perhaps, no output filename given)."); } print_channels(channels, *n_channels); *base_filename = argv[current_arg]; }