summaryrefslogtreecommitdiff
path: root/host/lib/include/chromeos_config.h
blob: e83570e5e9565c20d7b08191c6c66dd67409655e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef VBOOT_REFERENCE_CHROMEOS_CONFIG_H_
#define VBOOT_REFERENCE_CHROMEOS_CONFIG_H_

#include <stdbool.h>
#include <stdint.h>

#include "2common.h"
#include "2return_codes.h"

/**
 * Get a value from the model configuration on the device as a string.
 *
 * Note: this function allocates memory by its use of vb2_read_file, and relies
 * on the caller to free the allocated memory. The output parameter will be set
 * to NULL upon failure, so free can be safely called on this parameter.
 *
 * @param path          The path in the config schema to the object containing
 *                      the requested property.
 * @param property      The name of the requested property.
 * @param val_out       Output parameter which gets assigned to a
 *                      null-terminated string.
 * @return VB2_SUCCESS on success, or a relevant error upon error.
 */
vb2_error_t chromeos_config_get_string(const char *path, const char *property,
				       char **val_out);

/**
 * Get a value from the model configuration on the device as a boolean.
 *
 * @param path          The path in the config schema to the object containing
 *                      the requested property.
 * @param property      The name of the requested property.
 * @param val_out       Output parameter which gets assigned to a boolean.
 * @return VB2_SUCCESS on success, or a relevant error upon error.
 */
vb2_error_t chromeos_config_get_boolean(const char *path, const char *property,
					bool *val_out);

/**
 * Get a value from the model configuration on the device as an integer.
 *
 * @param path          The path in the config schema to the object containing
 *                      the requested property.
 * @param property      The name of the requested property.
 * @param val_out       Output parameter which gets assigned to an integer.
 * @return VB2_SUCCESS on success, or a relevant error upon error.
 */
vb2_error_t chromeos_config_get_integer(const char *path, const char *property,
					int *val_out);

#endif /* VBOOT_REFERENCE_CHROMEOS_CONFIG_H_ */