Files
dragonpilot/selfdrive/common/params.h

48 lines
1.4 KiB
C
Raw Normal View History

2017-05-11 12:41:17 -07:00
#ifndef _SELFDRIVE_COMMON_PARAMS_H_
#define _SELFDRIVE_COMMON_PARAMS_H_
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
2019-10-09 18:43:53 +00:00
#define ERR_NO_VALUE -33
2017-05-11 12:41:17 -07:00
int write_db_value(const char* params_path, const char* key, const char* value,
size_t value_size);
// Reads a value from the params database.
// Inputs:
2017-09-30 03:07:27 -07:00
// params_path: The path of the database, or NULL to use the default.
2017-05-11 12:41:17 -07:00
// key: The key to read.
// value: A pointer where a newly allocated string containing the db value will
// be written.
// value_sz: A pointer where the size of value will be written. Does not
// include the NULL terminator.
//
// Returns: Negative on failure, otherwise 0.
int read_db_value(const char* params_path, const char* key, char** value,
size_t* value_sz);
2019-10-09 18:43:53 +00:00
// Delete a value from the params database.
// Inputs are the same as read_db_value, without value and value_sz.
int delete_db_value(const char* params_path, const char* key);
2017-05-11 12:41:17 -07:00
// Reads a value from the params database, blocking until successful.
// Inputs are the same as read_db_value.
void read_db_value_blocking(const char* params_path, const char* key,
char** value, size_t* value_sz);
#ifdef __cplusplus
} // extern "C"
#endif
2018-09-03 16:43:12 -07:00
#ifdef __cplusplus
#include <map>
#include <string>
int read_db_all(const char* params_path, std::map<std::string, std::string> *params);
#endif
2017-05-11 12:41:17 -07:00
#endif // _SELFDRIVE_COMMON_PARAMS_H_