/* * Copyright 2018 Oticon A/S * * SPDX-License-Identifier: Apache-2.0 */ #ifndef BS_CMD_LINE_H #define BS_CMD_LINE_H #include #include "bs_oswrap.h" #ifdef __cplusplus extern "C" { #endif #define _MAX_LINE_WIDTH 120 /*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 "Print 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 */ typedef struct { /* * if manual is set bs_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: --