Harout Hedeshian | 6202ba7 | 2015-04-13 19:02:25 -0600 | [diff] [blame] | 1 | /************************************************************************ |
Jerome Stanislaus | 597482d | 2016-03-04 14:08:46 -0700 | [diff] [blame] | 2 | Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. |
Harout Hedeshian | 6202ba7 | 2015-04-13 19:02:25 -0600 | [diff] [blame] | 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are |
| 6 | met: |
| 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 | |
| 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | IF 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 Stanislaus | 597482d | 2016-03-04 14:08:46 -0700 | [diff] [blame] | 52 | #define OUT_DIR_LEN_MAX 150 |
Harout Hedeshian | 6202ba7 | 2015-04-13 19:02:25 -0600 | [diff] [blame] | 53 | |
| 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 | */ |
| 71 | struct 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 Stanislaus | 597482d | 2016-03-04 14:08:46 -0700 | [diff] [blame] | 78 | int iptables_rules_routes; /* -r option */ |
| 79 | char out_dir[OUT_DIR_LEN_MAX]; /* -o option */ |
Harout Hedeshian | 6202ba7 | 2015-04-13 19:02:25 -0600 | [diff] [blame] | 80 | int print_csv; |
| 81 | int poll_time_selected; |
| 82 | int priority; /* -n option (niceness) */ |
| 83 | }; |
| 84 | |
| 85 | int dtop_parse_cli_opts(struct cli_opts *clopts, int argc, char **argv); |
| 86 | void dtop_print_help_opts(void); |
| 87 | void dtop_print_interactive_opts(void); |
| 88 | void dtop_load_default_options(struct cli_opts *clopts); |
| 89 | |
| 90 | #endif /* DATATOP_OPT_H */ |
| 91 | |