blob: a1ad2885d0b6296948b50821741caaf2eda67d03 [file] [log] [blame]
Harout Hedeshian6202ba72015-04-13 19:02:25 -06001/************************************************************************
Jerome Stanislaus597482d2016-03-04 14:08:46 -07002Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
Harout Hedeshian6202ba72015-04-13 19:02:25 -06003
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are
6met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above
10 copyright notice, this list of conditions and the following
11 disclaimer in the documentation and/or other materials provided
12 with the distribution.
13 * Neither the name of The Linux Foundation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28************************************************************************/
29
30/**
31 * @file datatop_opt.h
32 * @brief Declares methods and defines struct used within datatop_opt.c
33 *
34 * Struct defined is used when parsing the CLI arguments.
35 */
36
37#ifndef DATATOP_OPT_H
38#define DATATOP_OPT_H
39
40#define OPT_CHOSE 1
41#define OPT_NOT_CHOSE 0
42#define DEFAULT_POLL_INTERVAL 1
43#define POLL_NOT_SPECIFIED -1
44#define POLL_TIME_DEFAULT 30
45#define POLL_TIME_SELECTED 1
46#define PARSE_SUCCESS 0
47#define PARSE_FAILURE -1
48#define PARSE_FORCE_EXIT -2
49#define VALID 0
50#define INVALID -1
51#define DEFAULT_NICE 19 /* Lowest priority */
Jerome Stanislaus597482d2016-03-04 14:08:46 -070052#define OUT_DIR_LEN_MAX 150
Harout Hedeshian6202ba72015-04-13 19:02:25 -060053
54/**
55 * @struct cli_opts
56 * @brief Struct used to store arguments from CLI input.
57 *
58 * @var cli_opts::print_cl
59 * Represents -p argument.
60 * @var cli_opts::poll_per
61 * Polling frequency argument.
62 * @var cli_opts::poll_time
63 * Polling duration argument.
64 * @var cli_opts::cli_help
65 * Represents -h argument.
66 * @var cli_opts::file_name
67 * File name argument.
68 * @var cli_opts::print_csv
69 * Represents -w argument.
70 */
71struct cli_opts {
72 int print_cl; /* -p option */
73 long int poll_per; /* -i option */
74 long int poll_time; /* -t option */
75 int cli_help; /* -h option */
76 char *file_name; /* -w option */
77 char *snapshot_file; /* -s option */
Jerome Stanislaus597482d2016-03-04 14:08:46 -070078 int iptables_rules_routes; /* -r option */
79 char out_dir[OUT_DIR_LEN_MAX]; /* -o option */
Harout Hedeshian6202ba72015-04-13 19:02:25 -060080 int print_csv;
81 int poll_time_selected;
82 int priority; /* -n option (niceness) */
83};
84
85int dtop_parse_cli_opts(struct cli_opts *clopts, int argc, char **argv);
86void dtop_print_help_opts(void);
87void dtop_print_interactive_opts(void);
88void dtop_load_default_options(struct cli_opts *clopts);
89
90#endif /* DATATOP_OPT_H */
91