mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-22 09:31:51 +00:00
[parseopt] Allow parsed option to be modified
Parsing a setting name requires the ability to modify the text being parsed. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
8ea5822afd
commit
b87020a090
@ -59,7 +59,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
* @ret value String value
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_string ( const char *text, const char **value ) {
|
||||
int parse_string ( char *text, char **value ) {
|
||||
|
||||
/* Sanity check */
|
||||
assert ( text != NULL );
|
||||
@ -77,7 +77,7 @@ int parse_string ( const char *text, const char **value ) {
|
||||
* @ret value Integer value
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_integer ( const char *text, unsigned int *value ) {
|
||||
int parse_integer ( char *text, unsigned int *value ) {
|
||||
char *endp;
|
||||
|
||||
/* Sanity check */
|
||||
@ -100,7 +100,7 @@ int parse_integer ( const char *text, unsigned int *value ) {
|
||||
* @ret netdev Network device
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_netdev ( const char *text, struct net_device **netdev ) {
|
||||
int parse_netdev ( char *text, struct net_device **netdev ) {
|
||||
|
||||
/* Sanity check */
|
||||
assert ( text != NULL );
|
||||
@ -122,7 +122,7 @@ int parse_netdev ( const char *text, struct net_device **netdev ) {
|
||||
* @ret menu Menu
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_menu ( const char *text, struct menu **menu ) {
|
||||
int parse_menu ( char *text, struct menu **menu ) {
|
||||
|
||||
/* Find menu */
|
||||
*menu = find_menu ( text );
|
||||
@ -145,7 +145,7 @@ int parse_menu ( const char *text, struct menu **menu ) {
|
||||
* @ret flag Flag to set
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_flag ( const char *text __unused, int *flag ) {
|
||||
int parse_flag ( char *text __unused, int *flag ) {
|
||||
|
||||
/* Set flag */
|
||||
*flag = 1;
|
||||
@ -160,7 +160,7 @@ int parse_flag ( const char *text __unused, int *flag ) {
|
||||
* @ret key Key
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_key ( const char *text, unsigned int *key ) {
|
||||
int parse_key ( char *text, unsigned int *key ) {
|
||||
|
||||
/* Interpret single characters as being a literal key character */
|
||||
if ( text[0] && ! text[1] ) {
|
||||
@ -198,7 +198,7 @@ int reparse_options ( int argc, char **argv, struct command_descriptor *cmd,
|
||||
char shortopts[ cmd->num_options * 3 /* possible "::" */ + 1 /* "h" */
|
||||
+ 1 /* NUL */ ];
|
||||
unsigned int shortopt_idx = 0;
|
||||
int ( * parse ) ( const char *text, void *value );
|
||||
int ( * parse ) ( char *text, void *value );
|
||||
void *value;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
@ -43,7 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
* @ret port Fibre Channel port
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int parse_fc_port ( const char *text, struct fc_port **port ) {
|
||||
static int parse_fc_port ( char *text, struct fc_port **port ) {
|
||||
|
||||
/* Sanity check */
|
||||
assert ( text != NULL );
|
||||
@ -65,7 +65,7 @@ static int parse_fc_port ( const char *text, struct fc_port **port ) {
|
||||
* @ret port_id Fibre Channel port ID
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int parse_fc_port_id ( const char *text, struct fc_port_id *port_id ) {
|
||||
static int parse_fc_port_id ( char *text, struct fc_port_id *port_id ) {
|
||||
int rc;
|
||||
|
||||
/* Sanity check */
|
||||
@ -87,8 +87,7 @@ static int parse_fc_port_id ( const char *text, struct fc_port_id *port_id ) {
|
||||
* @ret handler Fibre Channel ELS handler
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int parse_fc_els_handler ( const char *text,
|
||||
struct fc_els_handler **handler ) {
|
||||
static int parse_fc_els_handler ( char *text, struct fc_els_handler **handler ){
|
||||
|
||||
for_each_table_entry ( (*handler), FC_ELS_HANDLERS ) {
|
||||
if ( strcasecmp ( (*handler)->name, text ) == 0 )
|
||||
|
@ -39,7 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
/** "img{single}" options */
|
||||
struct imgsingle_options {
|
||||
/** Image name */
|
||||
const char *name;
|
||||
char *name;
|
||||
/** Replace image */
|
||||
int replace;
|
||||
/** Free image after execution */
|
||||
|
@ -84,7 +84,7 @@ static int imgtrust_exec ( int argc, char **argv ) {
|
||||
/** "imgverify" options */
|
||||
struct imgverify_options {
|
||||
/** Required signer common name */
|
||||
const char *signer;
|
||||
char *signer;
|
||||
/** Keep signature after verification */
|
||||
int keep;
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ FEATURE ( FEATURE_MISC, "Menu", DHCP_EB_FEATURE_MENU, 1 );
|
||||
/** "menu" options */
|
||||
struct menu_options {
|
||||
/** Name */
|
||||
const char *name;
|
||||
char *name;
|
||||
/** Delete */
|
||||
int delete;
|
||||
};
|
||||
@ -107,7 +107,7 @@ static int menu_exec ( int argc, char **argv ) {
|
||||
/** "item" options */
|
||||
struct item_options {
|
||||
/** Menu name */
|
||||
const char *menu;
|
||||
char *menu;
|
||||
/** Shortcut key */
|
||||
unsigned int key;
|
||||
/** Use as default */
|
||||
@ -192,11 +192,11 @@ static int item_exec ( int argc, char **argv ) {
|
||||
/** "choose" options */
|
||||
struct choose_options {
|
||||
/** Menu name */
|
||||
const char *menu;
|
||||
char *menu;
|
||||
/** Timeout */
|
||||
unsigned int timeout;
|
||||
/** Default selection */
|
||||
const char *select;
|
||||
char *select;
|
||||
/** Keep menu */
|
||||
int keep;
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ struct option_descriptor {
|
||||
* @v value Option value to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int ( * parse ) ( const char *text, void *value );
|
||||
int ( * parse ) ( char *text, void *value );
|
||||
};
|
||||
|
||||
/**
|
||||
@ -43,9 +43,9 @@ struct option_descriptor {
|
||||
* @ret _parse Generic option parser
|
||||
*/
|
||||
#define OPTION_PARSER( _struct, _field, _parse ) \
|
||||
( ( int ( * ) ( const char *text, void *value ) ) \
|
||||
( ( int ( * ) ( char *text, void *value ) ) \
|
||||
( ( ( ( typeof ( _parse ) * ) NULL ) == \
|
||||
( ( int ( * ) ( const char *text, \
|
||||
( ( int ( * ) ( char *text, \
|
||||
typeof ( ( ( _struct * ) NULL )->_field ) * ) ) \
|
||||
NULL ) ) ? _parse : _parse ) )
|
||||
|
||||
@ -114,12 +114,12 @@ struct command_descriptor {
|
||||
.usage = _usage, \
|
||||
}
|
||||
|
||||
extern int parse_string ( const char *text, const char **value );
|
||||
extern int parse_integer ( const char *text, unsigned int *value );
|
||||
extern int parse_netdev ( const char *text, struct net_device **netdev );
|
||||
extern int parse_menu ( const char *text, struct menu **menu );
|
||||
extern int parse_flag ( const char *text __unused, int *flag );
|
||||
extern int parse_key ( const char *text, unsigned int *key );
|
||||
extern int parse_string ( char *text, char **value );
|
||||
extern int parse_integer ( char *text, unsigned int *value );
|
||||
extern int parse_netdev ( char *text, struct net_device **netdev );
|
||||
extern int parse_menu ( char *text, struct menu **menu );
|
||||
extern int parse_flag ( char *text __unused, int *flag );
|
||||
extern int parse_key ( char *text, unsigned int *key );
|
||||
extern void print_usage ( struct command_descriptor *cmd, char **argv );
|
||||
extern int reparse_options ( int argc, char **argv,
|
||||
struct command_descriptor *cmd, void *opts );
|
||||
|
Loading…
Reference in New Issue
Block a user