Initial import to Tizen
[profile/ivi/sphinxbase.git] / test / unit / test_cmdln / cmdln_parse_multiple.c
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
3 #include <stdio.h>
4 #include <string.h>
5
6 #include "cmd_ln.h"
7 #include "ckd_alloc.h"
8
9 const arg_t defs[] = {
10     { "-a", ARG_INT32, "42", "This is the first argument." },
11     { "-b", ARG_STRING, NULL, "This is the second argument." },
12     { "-c", ARG_BOOLEAN, "no", "This is the third argument." },
13     { "-d", ARG_FLOAT64, "1e-50", "This is the fourth argument." },
14     { NULL, 0, NULL, NULL }
15 };
16
17 static char *orig_argv[] = {
18     "foobie",
19     "-a", "69"
20 };
21 static int orig_argc = sizeof(orig_argv) / sizeof(orig_argv[0]);
22
23 int
24 main(int argc, char *argv[])
25 {
26     cmd_ln_parse(defs, orig_argc, orig_argv, TRUE);
27     cmd_ln_parse(defs, argc, argv, FALSE);
28     printf("%d %s %d %f\n",
29            cmd_ln_int32("-a"),
30            cmd_ln_str("-b") ? cmd_ln_str("-b") : "(null)",
31            cmd_ln_boolean("-c"),
32            cmd_ln_float64("-d"));
33     cmd_ln_free();
34            
35     return 0;
36 }