diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2008-02-15 14:57:48 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2008-02-15 14:57:48 +0100 |
commit | 9495aa9923fed16aeb6f49c69ccd249b9e17dba7 (patch) | |
tree | 5bf8b7683e3bf3b6e0725adf834b0d5344283ad3 /recording.c | |
parent | c8584521f794492d81d87d448f2c4dcefc636b34 (diff) | |
download | vdr-9495aa9923fed16aeb6f49c69ccd249b9e17dba7.tar.gz vdr-9495aa9923fed16aeb6f49c69ccd249b9e17dba7.tar.bz2 |
Using cString::sprintf() instead of asprintf()
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/recording.c b/recording.c index e4e2be6a..096e0f85 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.158 2008/02/10 12:52:14 kls Exp $ + * $Id: recording.c 1.159 2008/02/10 21:57:09 kls Exp $ */ #include "recording.h" @@ -351,7 +351,7 @@ bool cRecordingInfo::Read(FILE *f) char *p = strchr(t, ' '); if (p) { free(channelName); - asprintf(&channelName, "%s", compactspace(p)); + channelName = strdup(compactspace(p)); *p = 0; // strips optional channel name } if (*t) @@ -525,7 +525,7 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event) else if (Timer->IsSingleEvent() || !Setup.UseSubtitle) name = strdup(Timer->File()); else - asprintf(&name, "%s~%s", Timer->File(), Subtitle); + name = strdup(cString::sprintf("%s~%s", Timer->File(), Subtitle)); // substitute characters that would cause problems in file names: strreplace(name, '\n', ' '); start = Timer->StartTime(); @@ -566,22 +566,19 @@ cRecording::cRecording(const char *FileName) } GetResume(); // read an optional info file: - char *InfoFileName = NULL; - asprintf(&InfoFileName, "%s%s", fileName, INFOFILESUFFIX); + cString InfoFileName = cString::sprintf("%s%s", fileName, INFOFILESUFFIX); FILE *f = fopen(InfoFileName, "r"); if (f) { if (!info->Read(f)) - esyslog("ERROR: EPG data problem in file %s", InfoFileName); + esyslog("ERROR: EPG data problem in file %s", *InfoFileName); fclose(f); } else if (errno != ENOENT) - LOG_ERROR_STR(InfoFileName); - free(InfoFileName); + LOG_ERROR_STR(*InfoFileName); #ifdef SUMMARYFALLBACK // fall back to the old 'summary.vdr' if there was no 'info.vdr': if (isempty(info->Title())) { - char *SummaryFileName = NULL; - asprintf(&SummaryFileName, "%s%s", fileName, SUMMARYFILESUFFIX); + cString SummaryFileName = cString::sprintf("%s%s", fileName, SUMMARYFILESUFFIX); FILE *f = fopen(SummaryFileName, "r"); if (f) { int line = 0; @@ -627,8 +624,7 @@ cRecording::cRecording(const char *FileName) free(data[i]); } else if (errno != ENOENT) - LOG_ERROR_STR(SummaryFileName); - free(SummaryFileName); + LOG_ERROR_STR(*SummaryFileName); } #endif } @@ -697,7 +693,7 @@ const char *cRecording::FileName(void) const struct tm tm_r; struct tm *t = localtime_r(&start, &tm_r); name = ExchangeChars(name, true); - asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime); + fileName = strdup(cString::sprintf(NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime)); name = ExchangeChars(name, false); } return fileName; @@ -716,7 +712,7 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) cons s++; else s = name; - asprintf(&titleBuffer, "%02d.%02d.%02d%c%02d:%02d%c%c%s", + titleBuffer = strdup(cString::sprintf("%02d.%02d.%02d%c%02d:%02d%c%c%s", t->tm_mday, t->tm_mon + 1, t->tm_year % 100, @@ -725,7 +721,7 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) cons t->tm_min, New, Delimiter, - s); + s)); // let's not display a trailing '~': if (!NewIndicator) stripspace(titleBuffer); @@ -785,16 +781,14 @@ bool cRecording::IsEdited(void) const bool cRecording::WriteInfo(void) { - char *InfoFileName = NULL; - asprintf(&InfoFileName, "%s%s", fileName, INFOFILESUFFIX); + cString InfoFileName = cString::sprintf("%s%s", fileName, INFOFILESUFFIX); FILE *f = fopen(InfoFileName, "w"); if (f) { info->Write(f); fclose(f); } else - LOG_ERROR_STR(InfoFileName); - free(InfoFileName); + LOG_ERROR_STR(*InfoFileName); return true; } @@ -911,8 +905,7 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev struct dirent *e; while ((Foreground || Running()) && (e = d.Next()) != NULL) { if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) { - char *buffer; - asprintf(&buffer, "%s/%s", DirName, e->d_name); + char *buffer = strdup(AddDirectory(DirName, e->d_name)); struct stat st; if (stat(buffer, &st) == 0) { int Link = 0; @@ -1071,9 +1064,7 @@ cMark::~cMark() cString cMark::ToText(void) { - char *buffer; - asprintf(&buffer, "%s%s%s\n", *IndexToHMSF(position, true), comment ? " " : "", comment ? comment : ""); - return cString(buffer, true); + return cString::sprintf("%s%s%s\n", *IndexToHMSF(position, true), comment ? " " : "", comment ? comment : ""); } bool cMark::Parse(const char *s) @@ -1162,11 +1153,9 @@ const char *cRecordingUserCommand::command = NULL; void cRecordingUserCommand::InvokeCommand(const char *State, const char *RecordingFileName) { if (command) { - char *cmd; - asprintf(&cmd, "%s %s \"%s\"", command, State, *strescape(RecordingFileName, "\"$")); - isyslog("executing '%s'", cmd); + cString cmd = cString::sprintf("%s %s \"%s\"", command, State, *strescape(RecordingFileName, "\"$")); + isyslog("executing '%s'", *cmd); SystemExec(cmd); - free(cmd); } } |