From 5508af3d83398c11361c9f5df02e7ea962ca1ba6 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 29 Dec 2019 00:17:23 +0100 Subject: [PATCH] proc_tools: add some more wrappers Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ee0807f04894e47916bc7c6faab8826289e0755a Author: vanhofen Date: 2019-12-29 (Sun, 29 Dec 2019) Origin message was: ------------------ - proc_tools: add some more wrappers ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/proc_tools.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/system/proc_tools.h | 7 +++++++ 2 files changed, 44 insertions(+) diff --git a/src/system/proc_tools.cpp b/src/system/proc_tools.cpp index a4c06296e..dba4d2c35 100644 --- a/src/system/proc_tools.cpp +++ b/src/system/proc_tools.cpp @@ -14,6 +14,8 @@ #include /* sscanf */ #include +#include + #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); diff --git a/src/system/proc_tools.h b/src/system/proc_tools.h index 187516423..46afdd2c7 100644 --- a/src/system/proc_tools.h +++ b/src/system/proc_tools.h @@ -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);