From 24296c37084ae8e65bed9d283a2ba2dfad22d82b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2012 10:22:29 +0100 Subject: [PATCH] spark cVideo: add proc_{get,put} helper functions Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/96c3ba2bb0a8501e86e9ae83ef95e46eb2d8750a Author: Stefan Seyfried Date: 2012-02-12 (Sun, 12 Feb 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libspark/video.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/libspark/video.cpp b/libspark/video.cpp index be61533..87e8c22 100644 --- a/libspark/video.cpp +++ b/libspark/video.cpp @@ -64,6 +64,43 @@ static pthread_mutex_t stillp_mutex = PTHREAD_MUTEX_INITIALIZER; /* debugging hacks */ static bool noscart = false; +static int proc_put(const char *path, const char *value, const int len) +{ + int ret, ret2; + int pfd = open(path, O_WRONLY); + if (pfd < 0) + return pfd; + ret = write(pfd, value, len); + ret2 = close(pfd); + if (ret2 < 0) + return ret2; + return ret; +} + +static int proc_get(const char *path, char *value, const int len) +{ + int ret, ret2; + int pfd = open(path, O_RDONLY); + if (pfd < 0) + return pfd; + ret = read(pfd, value, len); + value[len-1] = '\0'; /* make sure string is terminated */ + ret2 = close(pfd); + if (ret2 < 0) + return ret2; + return ret; +} + +static unsigned int proc_get_hex(const char *path) +{ + unsigned int n, ret = 0; + char buf[16]; + n = proc_get(path, buf, 16); + if (n > 0) + sscanf(buf, "%x", &ret); + return ret; +} + cVideo::cVideo(int, void *, void *) { lt_debug("%s\n", __FUNCTION__);