spark cVideo: add proc_{get,put} helper functions

Origin commit data
------------------
Branch: master
Commit: 96c3ba2bb0
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2012-02-12 (Sun, 12 Feb 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2012-02-12 10:22:29 +01:00
parent c3b1e87fa4
commit 24296c3708

View File

@@ -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__);