[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:
Michael Brown
2013-07-22 16:13:25 +01:00
parent 8ea5822afd
commit b87020a090
6 changed files with 25 additions and 26 deletions

View File

@@ -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 );