*/
static int set_core_exec ( int argc, char **argv,
struct command_descriptor *cmd,
- int ( * get_value ) ( char **args, char **value ) ) {
+ int ( * get_value ) ( const char *name,
+ char **args, char **value ) ) {
struct set_core_options opts;
const char *name;
char *value;
name = argv[optind];
/* Parse setting value */
- if ( ( rc = get_value ( &argv[ optind + 1 ], &value ) ) != 0 )
+ if ( ( rc = get_value ( name, &argv[ optind + 1 ], &value ) ) != 0 )
goto err_get_value;
/* Determine total length of command line */
/**
* Get setting value for "set" command
*
+ * @v name Setting name
* @v args Remaining arguments
* @ret value Setting value
* @ret rc Return status code
*/
-static int set_value ( char **args, char **value ) {
+static int set_value ( const char *name __unused, char **args, char **value ) {
*value = concat_args ( args );
if ( ! *value )
/**
* Get setting value for "clear" command
*
+ * @v name Setting name
* @v args Remaining arguments
* @ret value Setting value
* @ret rc Return status code
*/
-static int clear_value ( char **args __unused, char **value ) {
+static int clear_value ( const char *name __unused, char **args __unused,
+ char **value ) {
*value = NULL;
return 0;
/**
* Get setting value for "read" command
*
+ * @v name Setting name
+ * @v args Remaining arguments
* @ret value Setting value
* @ret rc Return status code
*/
-static int read_value ( char **args __unused, char **value ) {
+static int read_value ( const char *name, char **args __unused, char **value ) {
+ char *existing;
+ int rc;
- *value = readline ( NULL );
- if ( ! *value )
- return -ENOMEM;
+ /* Read existing value */
+ if ( ( rc = fetchf_named_setting_copy ( name, &existing ) ) < 0 )
+ return rc;
+
+ /* Read new value */
+ *value = readline_history ( NULL, existing, NULL );
+
+ /* Free existing value */
+ free ( existing );
return 0;
}