2 * Copyright (C) 2012 Timo Kokkonen <timo.t.kokkonen@iki.fi>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 int read_args(int argc, char *argv[], struct user_options *opts)
29 int option_index = 0, c;
30 static struct option long_options[] = {
31 { .val = 'd', .name = "device", .has_arg = 1, },
32 { .val = 'v', .name = "verbose", .has_arg = 2 },
33 { .val = 'o', .name = "output", .has_arg = 1 },
34 { .val = 'f', .name = "format", .has_arg = 1, },
36 char short_options[] = "d:v:o:f:";
39 c = getopt_long(argc, argv, short_options, long_options,
47 opts->usbdev = optarg;
51 opts->trace_level = atoi(optarg);
55 opts->output_path = optarg;
58 if ( strcmp(optarg, "raw") == 0 ) {
59 opts->output_format = RAW;
61 if ( strcmp(optarg, "clean") == 0 ) {
62 opts->output_format = CLEAN;
64 if ( strcmp(optarg, "csv") == 0 ) {
65 opts->output_format = CSV;
67 trace(0, "Unknown format type \"%s\", "
68 "must be one of \"raw\", \"clean\", "
69 "or \"csv\"\n", optarg);
78 while (optind < argc) {
80 * Some day we do something useful here with the rest
81 * of the options.. Maybe