summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2000-03-11 11:22:37 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2000-03-11 11:22:37 +0100
commit571686d90996968c01a8bc560659e364efab2942 (patch)
tree85cf564cd0f48e44431a93ea2f22bba7fc924e98 /tools.c
parent4a9d9c5876cde9f21ccd165a7630727e6aca576a (diff)
downloadvdr-571686d90996968c01a8bc560659e364efab2942.tar.gz
vdr-571686d90996968c01a8bc560659e364efab2942.tar.bz2
Menu uses colors; support for RGYB buttons; fixed DEBUG_REMOTE; Add, Del and Move for channels and timers; basic record/play file handling0.0.2
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/tools.c b/tools.c
index e0eeaefd..5a21a930 100644
--- a/tools.c
+++ b/tools.c
@@ -4,13 +4,30 @@
* See the main source file 'osm.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.1 2000/02/19 13:36:48 kls Exp $
+ * $Id: tools.c 1.2 2000/03/05 14:33:58 kls Exp $
*/
#include "tools.h"
+#include <errno.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
#include <sys/time.h>
+#define MaxBuffer 1000
+
+char *readline(FILE *f)
+{
+ static char buffer[MaxBuffer];
+ if (fgets(buffer, sizeof(buffer), f) > 0) {
+ int l = strlen(buffer) - 1;
+ if (l >= 0 && buffer[l] == '\n')
+ buffer[l] = 0;
+ return buffer;
+ }
+ return NULL;
+}
+
int time_ms(void)
{
struct timeval t;
@@ -19,6 +36,30 @@ int time_ms(void)
return 0;
}
+bool MakeDirs(const char *FileName)
+{
+ bool result = true;
+ char *s = strdup(FileName);
+ char *p = s;
+ if (*p == '/')
+ p++;
+ while ((p = strchr(p, '/')) != NULL) {
+ *p = 0;
+ struct stat fs;
+ if (stat(s, &fs) != 0 || !S_ISDIR(fs.st_mode)) {
+ isyslog(LOG_INFO, "creating directory %s", s);
+ if (mkdir(s, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) {
+ esyslog(LOG_ERR, "ERROR while creating directory %s: %s", s, strerror(errno));
+ result = false;
+ break;
+ }
+ }
+ *p++ = '/';
+ }
+ delete s;
+ return result;
+}
+
// --- cListObject -----------------------------------------------------------
cListObject::cListObject(void)
@@ -42,6 +83,7 @@ void cListObject::Unlink(void)
next->prev = prev;
if (prev)
prev->next = next;
+ next = prev = NULL;
}
int cListObject::Index(void)
@@ -92,6 +134,33 @@ void cListBase::Del(cListObject *Object)
delete Object;
}
+void cListBase::Move(int From, int To)
+{
+ Move(Get(From), Get(To));
+}
+
+void cListBase::Move(cListObject *From, cListObject *To)
+{
+ if (From && To) {
+ if (From->Index() < To->Index())
+ To = To->Next();
+ if (From == objects)
+ objects = From->Next();
+ if (From == lastObject)
+ lastObject = From->Prev();
+ From->Unlink();
+ if (To) {
+ if (To->Prev())
+ To->Prev()->Append(From);
+ From->Append(To);
+ }
+ else
+ lastObject->Append(From);
+ if (!From->Prev())
+ objects = From;
+ }
+}
+
void cListBase::Clear(void)
{
while (objects) {