- proc_tools: add some more wrappers

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2019-12-29 00:17:23 +01:00
committed by Thilo Graf
parent d007474a48
commit c70b012bf7
2 changed files with 44 additions and 0 deletions

View File

@@ -14,6 +14,8 @@
#include <cstdio> /* sscanf */
#include <cstring>
#include <system/helpers.h>
#include "proc_tools.h"
int proc_put(const char *path, const char *value, const int len)
@@ -34,6 +36,41 @@ int proc_put(const char *path, const char *value)
return proc_put(path, value, strlen(value));
}
int proc_put(const char *path, std::string value)
{
return proc_put(path, value.c_str());
}
int proc_put(const char *path, int value)
{
return proc_put(path, to_string(value).c_str());
}
int proc_put(const char *path, unsigned int value)
{
return proc_put(path, to_string(value).c_str());
}
int proc_put(const char *path, long value)
{
return proc_put(path, to_string(value).c_str());
}
int proc_put(const char *path, unsigned long value)
{
return proc_put(path, to_string(value).c_str());
}
int proc_put(const char *path, long long value)
{
return proc_put(path, to_string(value).c_str());
}
int proc_put(const char *path, unsigned long long value)
{
return proc_put(path, to_string(value).c_str());
}
int proc_put(const char *path, bool state)
{
return proc_put(path, state ? "1" : "0", 1);

View File

@@ -10,6 +10,13 @@
#define __PROC_TOOLS_H__
int proc_put(const char *path, const char *value, const int len);
int proc_put(const char *path, const char *value);
int proc_put(const char *path, std::string value);
int proc_put(const char *path, int value);
int proc_put(const char *path, unsigned int value);
int proc_put(const char *path, long value);
int proc_put(const char *path, unsigned long value);
int proc_put(const char *path, long long value);
int proc_put(const char *path, unsigned long long value);
int proc_put(const char *path, bool state);
int proc_get(const char *path, char *value, const int len);
unsigned int proc_get_hex(const char *path);