Branch data Line data Source code
1 : : /*
2 : : * Copyright (C) 2014 Cisco Systems, Inc.
3 : : *
4 : : * Licensed under the Apache License, Version 2.0 (the "License");
5 : : * you may not use this file except in compliance with the License.
6 : : * You may obtain a copy of the License at:
7 : : *
8 : : * http://www.apache.org/licenses/LICENSE-2.0
9 : : *
10 : : * Unless required by applicable law or agreed to in writing, software
11 : : * distributed under the License is distributed on an "AS IS" BASIS,
12 : : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 : : * See the License for the specific language governing permissions and
14 : : * limitations under the License.
15 : : */
16 : :
17 : : #include <config.h>
18 : : #include <stdio.h>
19 : : #include <stdlib.h>
20 : : #include <getopt.h>
21 : : #include <openvswitch/compiler.h>
22 : : #include <openvswitch/thread.h>
23 : : #include <openvswitch/types.h>
24 : : #include <openvswitch/util.h>
25 : : #include <openvswitch/vconn.h>
26 : : #include <openvswitch/vlog.h>
27 : :
28 : : static void
29 : 0 : show_version(void)
30 : : {
31 : 0 : printf("%s - %s\n",
32 : : ovs_get_program_name(), ovs_get_program_version());
33 : 0 : exit(EXIT_SUCCESS);
34 : : }
35 : :
36 : : static void
37 : 0 : usage(void)
38 : : {
39 : 0 : printf("%s: Open vSwitch library test utility\n"
40 : : "usage: %s [OPTIONS] COMMAND [ARG...]\n\n",
41 : : ovs_get_program_name(), ovs_get_program_name());
42 : 0 : vlog_usage();
43 : 0 : exit(EXIT_SUCCESS);
44 : : }
45 : :
46 : : static void
47 : 1 : parse_options(int argc, char *argv[])
48 : : {
49 : : static const struct option long_options[] = {
50 : : {"help", no_argument, NULL, 'h'},
51 : : {"version", no_argument, NULL, 'V'},
52 : : {"verbose", optional_argument, NULL, 'v'},
53 : : {NULL, 0, NULL, 0},
54 : : };
55 : 1 : char *short_options = "hVv";
56 : :
57 : : for (;;) {
58 : : int c;
59 : :
60 : 1 : c = getopt_long(argc, argv, short_options, long_options, NULL);
61 [ + - ]: 1 : if (c == -1) {
62 : 1 : break;
63 : : }
64 : :
65 [ # # # # : 0 : switch (c) {
# ]
66 : : case 'V':
67 : 0 : show_version();
68 : 0 : break;
69 : :
70 : : case 'h':
71 : 0 : usage();
72 : 0 : break;
73 : :
74 : : case 'v':
75 : 0 : vlog_set_verbosity(optarg);
76 : 0 : break;
77 : :
78 : : case '?':
79 : 0 : exit(EXIT_FAILURE);
80 : :
81 : : default:
82 : 0 : abort();
83 : : }
84 : 0 : }
85 : 1 : }
86 : :
87 : : int
88 : 1 : main(int argc, char *argv[])
89 : : {
90 : 1 : ovs_set_program_name(argv[0], "1.0");
91 : 1 : parse_options(argc, argv);
92 : :
93 : 1 : return 0;
94 : : }
|