Home | History | Annotate | Download | only in include
      1 /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      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_CROSSYSTEM_H_
      7 #define VBOOT_REFERENCE_CROSSYSTEM_H_
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 #include <stddef.h>
     14 
     15 /* Recommended size for string property buffers used with
     16  * VbGetSystemPropertyString(). */
     17 #define VB_MAX_STRING_PROPERTY     ((size_t) 8192)
     18 
     19 /* Reads a system property integer.
     20  *
     21  * Returns the property value, or -1 if error. */
     22 int VbGetSystemPropertyInt(const char* name);
     23 
     24 /* Read a system property string into a destination buffer of the
     25  * specified size.  Returned string will be null-terminated.  If the
     26  * buffer is too small, the returned string will be truncated.
     27  *
     28  * The caller can expect an un-truncated value if the size provided is
     29  * at least VB_MAX_STRING_PROPERTY.
     30  *
     31  * Returns the passed buffer, or NULL if error. */
     32 const char* VbGetSystemPropertyString(const char* name, char* dest,
     33                                       size_t size);
     34 
     35 /* Sets a system property integer.
     36  *
     37  * Returns 0 if success, -1 if error. */
     38 int VbSetSystemPropertyInt(const char* name, int value);
     39 
     40 /* Set a system property string.
     41  *
     42  * The maximum length of the value accepted depends on the specific
     43  * property, not on VB_MAX_STRING_PROPERTY.
     44  *
     45  * Returns 0 if success, -1 if error. */
     46 int VbSetSystemPropertyString(const char* name, const char* value);
     47 
     48 #ifdef __cplusplus
     49 }
     50 #endif
     51 
     52 #endif  /* VBOOT_REFERENCE__CROSSYSTEM_H_ */
     53