1 /************************************************************************ 2 Copyright (c) 2015, The Linux Foundation. All rights reserved. 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 */ 52 53 /** 54 * @struct cli_opts 55 * @brief Struct used to store arguments from CLI input. 56 * 57 * @var cli_opts::print_cl 58 * Represents -p argument. 59 * @var cli_opts::poll_per 60 * Polling frequency argument. 61 * @var cli_opts::poll_time 62 * Polling duration argument. 63 * @var cli_opts::cli_help 64 * Represents -h argument. 65 * @var cli_opts::file_name 66 * File name argument. 67 * @var cli_opts::print_csv 68 * Represents -w argument. 69 */ 70 struct cli_opts { 71 int print_cl; /* -p option */ 72 long int poll_per; /* -i option */ 73 long int poll_time; /* -t option */ 74 int cli_help; /* -h option */ 75 char *file_name; /* -w option */ 76 char *snapshot_file; /* -s option */ 77 int print_csv; 78 int poll_time_selected; 79 int priority; /* -n option (niceness) */ 80 }; 81 82 int dtop_parse_cli_opts(struct cli_opts *clopts, int argc, char **argv); 83 void dtop_print_help_opts(void); 84 void dtop_print_interactive_opts(void); 85 void dtop_load_default_options(struct cli_opts *clopts); 86 87 #endif /* DATATOP_OPT_H */ 88 89