/* * Copyright (c) 2018 Oticon A/S * * SPDX-License-Identifier: Apache-2.0 */ #ifndef _CMDLINE_COMMON_H #define _CMDLINE_COMMON_H #include #include #ifdef __cplusplus extern "C" { #endif #define _MAX_LINE_WIDTH 100 /*Total width of the help message*/ /* Horizontal alignment of the 2nd column of the help message */ #define _LONG_HELP_ALIGN 30 #define _MAXOPT_SWITCH_LEN 32 /* Maximum allowed length for a switch name */ #define _MAXOPT_NAME_LEN 32 /* Maximum allowed length for a variable name */ #define _HELP_SWITCH "[-h] [--h] [--help] [-?]" #define _HELP_DESCR "Display this help" #define _MAX_STRINGY_LEN (_MAXOPT_SWITCH_LEN + _MAXOPT_NAME_LEN + 2 + 1 + 2 + 1) /** * Prototype for a callback function when an option is found: * inputs: * argv: Whole argv[i] option as received in main * offset: Offset to the end of the option string * (including a possible ':' or '=') * If the option had a value, it would be placed in &argv[offset] */ typedef void (*option_found_callback_f)(char *argv, int offset); /* * Structure defining each command line option */ struct args_struct_t { /* * if manual is set cmd_args_parse*() will ignore it except for * displaying it the help messages and initializing to its * default */ bool manual; /* For help messages, should it be wrapped in "[]" */ bool is_mandatory; /* It is just a switch: it does not have something to store after */ bool is_switch; /* Option name we search for: --