summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c112
1 files changed, 110 insertions, 2 deletions
diff --git a/recording.c b/recording.c
index f45be96..064731d 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 1.21 2000/11/18 16:22:29 kls Exp $
+ * $Id: recording.c 1.24 2001/01/13 12:17:15 kls Exp $
*/
#define _GNU_SOURCE
@@ -26,6 +26,7 @@
#define NAMEFORMAT "%s/%s/" DATAFORMAT
#define SUMMARYFILESUFFIX "/summary.vdr"
+#define MARKSFILESUFFIX "/marks.vdr"
#define FINDCMD "find %s -follow -type d -name '%s' 2> /dev/null | sort -df"
@@ -125,6 +126,7 @@ cRecording::cRecording(const char *FileName)
strncpy(name, FileName, p - FileName);
name[p - FileName] = 0;
strreplace(name, '_', ' ');
+ strreplace(name, '\x01', '\'');
}
// read an optional summary file:
char *SummaryFileName = NULL;
@@ -175,8 +177,10 @@ const char *cRecording::FileName(void)
if (!fileName) {
struct tm *t = localtime(&start);
asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime);
- if (fileName)
+ if (fileName) {
strreplace(fileName, ' ', '_');
+ strreplace(fileName, '\'', '\x01');
+ }
}
return fileName;
}
@@ -269,3 +273,107 @@ bool cRecordings::Load(bool Deleted)
return result;
}
+// --- cMark -----------------------------------------------------------------
+
+char *cMark::buffer = NULL;
+
+cMark::cMark(int Position, const char *Comment)
+{
+ position = Position;
+ comment = Comment ? strdup(Comment) : NULL;
+}
+
+cMark::~cMark()
+{
+ delete comment;
+}
+
+const char *cMark::ToText(void)
+{
+ delete buffer;
+ asprintf(&buffer, "%s%s%s\n", IndexToHMSF(position, true), comment ? " " : "", comment ? comment : "");
+ return buffer;
+}
+
+bool cMark::Parse(const char *s)
+{
+ delete comment;
+ comment = NULL;
+ position = HMSFToIndex(s);
+ const char *p = strchr(s, ' ');
+ if (p) {
+ p = skipspace(p);
+ if (*p) {
+ comment = strdup(p);
+ comment[strlen(comment) - 1] = 0; // strips trailing newline
+ }
+ }
+ return true;
+}
+
+bool cMark::Save(FILE *f)
+{
+ return fprintf(f, ToText()) > 0;
+}
+
+// --- cMarks ----------------------------------------------------------------
+
+bool cMarks::Load(const char *RecordingFileName)
+{
+ const char *MarksFile = AddDirectory(RecordingFileName, MARKSFILESUFFIX);
+ if (cConfig<cMark>::Load(MarksFile)) {
+ Sort();
+ return true;
+ }
+ return false;
+}
+
+void cMarks::Sort(void)
+{
+ for (cMark *m1 = First(); m1; m1 = Next(m1)) {
+ for (cMark *m2 = Next(m1); m2; m2 = Next(m2)) {
+ if (m2->position < m1->position) {
+ swap(m1->position, m2->position);
+ swap(m1->comment, m2->comment);
+ }
+ }
+ }
+}
+
+cMark *cMarks::Add(int Position)
+{
+ cMark *m = Get(Position);
+ if (!m) {
+ cConfig<cMark>::Add(m = new cMark(Position));
+ Sort();
+ }
+ return m;
+}
+
+cMark *cMarks::Get(int Position)
+{
+ for (cMark *mi = First(); mi; mi = Next(mi)) {
+ if (mi->position == Position)
+ return mi;
+ }
+ return NULL;
+}
+
+cMark *cMarks::GetPrev(int Position)
+{
+ for (cMark *mi = Last(); mi; mi = Prev(mi)) {
+ if (mi->position < Position)
+ return mi;
+ }
+ return NULL;
+}
+
+cMark *cMarks::GetNext(int Position)
+{
+ for (cMark *mi = First(); mi; mi = Next(mi)) {
+ if (mi->position > Position)
+ return mi;
+ }
+ return NULL;
+}
+