| 1 | /* Copyright 2020 The ChromiumOS Authors |
| 2 | * Use of this source code is governed by a BSD-style license that can be |
| 3 | * found in the LICENSE file. |
| 4 | */ |
| 5 | |
| 6 | #ifndef VBOOT_REFERENCE_CHROMEOS_CONFIG_H_ |
| 7 | #define VBOOT_REFERENCE_CHROMEOS_CONFIG_H_ |
| 8 | |
| 9 | #include <stdbool.h> |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | #include "2common.h" |
| 13 | #include "2return_codes.h" |
| 14 | |
| 15 | /** |
| 16 | * Get a value from the model configuration on the device as a string. |
| 17 | * |
| 18 | * Note: this function allocates memory by its use of vb2_read_file, and relies |
| 19 | * on the caller to free the allocated memory. The output parameter will be set |
| 20 | * to NULL upon failure, so free can be safely called on this parameter. |
| 21 | * |
| 22 | * @param path The path in the config schema to the object containing |
| 23 | * the requested property. |
| 24 | * @param property The name of the requested property. |
| 25 | * @param val_out Output parameter which gets assigned to a |
| 26 | * null-terminated string. |
| 27 | * @return VB2_SUCCESS on success, or a relevant error upon error. |
| 28 | */ |
| 29 | vb2_error_t chromeos_config_get_string(const char *path, const char *property, |
| 30 | char **val_out); |
| 31 | |
| 32 | /** |
| 33 | * Get a value from the model configuration on the device as a boolean. |
| 34 | * |
| 35 | * @param path The path in the config schema to the object containing |
| 36 | * the requested property. |
| 37 | * @param property The name of the requested property. |
| 38 | * @param val_out Output parameter which gets assigned to a boolean. |
| 39 | * @return VB2_SUCCESS on success, or a relevant error upon error. |
| 40 | */ |
| 41 | vb2_error_t chromeos_config_get_boolean(const char *path, const char *property, |
| 42 | bool *val_out); |
| 43 | |
| 44 | /** |
| 45 | * Get a value from the model configuration on the device as an integer. |
| 46 | * |
| 47 | * @param path The path in the config schema to the object containing |
| 48 | * the requested property. |
| 49 | * @param property The name of the requested property. |
| 50 | * @param val_out Output parameter which gets assigned to an integer. |
| 51 | * @return VB2_SUCCESS on success, or a relevant error upon error. |
| 52 | */ |
| 53 | vb2_error_t chromeos_config_get_integer(const char *path, const char *property, |
| 54 | int *val_out); |
| 55 | |
| 56 | #endif /* VBOOT_REFERENCE_CHROMEOS_CONFIG_H_ */ |