|
@@ -389,6 +389,38 @@ int fetch_string_setting ( struct settings *settings, struct setting *setting,
|
389
|
389
|
( ( len > 0 ) ? ( len - 1 ) : 0 ) );
|
390
|
390
|
}
|
391
|
391
|
|
|
392
|
+/**
|
|
393
|
+ * Fetch value of string setting
|
|
394
|
+ *
|
|
395
|
+ * @v settings Settings block, or NULL to search all blocks
|
|
396
|
+ * @v setting Setting to fetch
|
|
397
|
+ * @v data Buffer to allocate and fill with setting string data
|
|
398
|
+ * @ret len Length of string setting, or negative error
|
|
399
|
+ *
|
|
400
|
+ * The resulting string is guaranteed to be correctly NUL-terminated.
|
|
401
|
+ * The returned length will be the length of the underlying setting
|
|
402
|
+ * data. The caller is responsible for eventually freeing the
|
|
403
|
+ * allocated buffer.
|
|
404
|
+ */
|
|
405
|
+int fetch_string_setting_copy ( struct settings *settings,
|
|
406
|
+ struct setting *setting,
|
|
407
|
+ char **data ) {
|
|
408
|
+ int len;
|
|
409
|
+ int check_len;
|
|
410
|
+
|
|
411
|
+ len = fetch_setting_len ( settings, setting );
|
|
412
|
+ if ( len < 0 )
|
|
413
|
+ return len;
|
|
414
|
+
|
|
415
|
+ *data = malloc ( len + 1 );
|
|
416
|
+ if ( ! *data )
|
|
417
|
+ return -ENOMEM;
|
|
418
|
+
|
|
419
|
+ fetch_string_setting ( settings, setting, *data, ( len + 1 ) );
|
|
420
|
+ assert ( check_len == len );
|
|
421
|
+ return len;
|
|
422
|
+}
|
|
423
|
+
|
392
|
424
|
/**
|
393
|
425
|
* Fetch value of IPv4 address setting
|
394
|
426
|
*
|