diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2001-01-18 18:00:00 +0100 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2001-01-18 18:00:00 +0100 |
commit | 3fe3c15d5db9c1f3982ffe6dac1ae4ad56d1664d (patch) | |
tree | e1c4e489899c119fdfaad6f6bdf9bde988616df2 /tools.c | |
parent | 9aa2cda494d7af2733362de78234441a25959e86 (diff) | |
download | vdr-patch-lnbsharing-3fe3c15d5db9c1f3982ffe6dac1ae4ad56d1664d.tar.gz vdr-patch-lnbsharing-3fe3c15d5db9c1f3982ffe6dac1ae4ad56d1664d.tar.bz2 |
Version 0.70vdr-0.70
- VDR now requires driver version 0.8.1 or higher.
- Recordings are now saved in PES mode. Note that you now need to install the
driver *WITHOUT* 'outstream=0'! This is the default when you 'make insmod' in
the DVB/driver directory.
Old recordings (in AV_PES mode) can still be replayed (as long as the driver
still supports replaying AV_PES files). The only limitation with this is that
in fast forward/back mode the picture may be slightly distorted and there may
be sound fragments.
- The EPG data is now dumped into the file /video/epg.data every ten minutes.
Use the Perl script 'epg2html.pl' to convert the raw EPG data into a simple
HTML programme listing.
- Fixed handling of channel switching with the "Blue" button in the "What's on
now/next?" menus.
- Fixed saving the MarginStop setup parameter.
- Fixed missing initialization in cConfig.
- Implemented "On Disk Editing".
- There is no more default 'timers.conf' file.
- Added Italian language texts (thanks to Alberto Carraro).
- Fixed starting a replay session when the program is currently in "transfer
mode".
- Fixed setting/modifying timers via SVDRP with empty summary fields.
- Fixed a problem with recordings that have a single quote character in their
name (this is now mapped to 0x01).
- Changed the value for Diseqc to '0' in the default 'channels.conf'.
- Fixed displaying channels and recording status in the RCU's LED display when
a recording is interrupted due to higher priority.
- Implemented safe writing of config files (first writes into a temporary file
and then renames it).
- In case the video data stream is broken the log message will come only every
5 seconds.
- The current channel is now saved in the 'setup.conf' file when VDR is cancelled,
and will be restored next time it is started (thanks to Deti Fliegl).
- The EIT scanning thread is now locked when switching channels to avoid problems.
- Encrypted channels can now be selected even without knowing the PNR (however, it
is still necessary for the EPG info).
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 119 |
1 files changed, 60 insertions, 59 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.23 2000/11/11 15:17:12 kls Exp $ + * $Id: tools.c 1.27 2001/01/13 15:35:02 kls Exp $ */ #define _GNU_SOURCE @@ -15,10 +15,7 @@ #if defined(DEBUG_OSD) #include <ncurses.h> #endif -#include <signal.h> -#include <stdlib.h> #include <sys/time.h> -#include <sys/wait.h> #include <unistd.h> #define MaxBuffer 1000 @@ -30,29 +27,6 @@ void writechar(int filedes, char c) write(filedes, &c, sizeof(c)); } -void writeint(int filedes, int n) -{ - write(filedes, &n, sizeof(n)); -} - -char readchar(int filedes) -{ - char c; - read(filedes, &c, 1); - return c; -} - -bool readint(int filedes, int &n) -{ - return cFile::AnyFileReady(filedes, 0) && read(filedes, &n, sizeof(n)) == sizeof(n); -} - -void purge(int filedes) -{ - while (cFile::AnyFileReady(filedes, 0)) - readchar(filedes); -} - char *readline(FILE *f) { static char buffer[MaxBuffer]; @@ -146,7 +120,7 @@ const char *AddDirectory(const char *DirName, const char *FileName) return buf; } -#define DFCMD "df -m %s" +#define DFCMD "df -m '%s'" uint FreeDiskSpaceMB(const char *Directory) { @@ -205,7 +179,7 @@ bool MakeDirs(const char *FileName, bool IsDirectory) if (stat(s, &fs) != 0 || !S_ISDIR(fs.st_mode)) { dsyslog(LOG_INFO, "creating directory %s", s); if (mkdir(s, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) { - esyslog(LOG_ERR, "ERROR: %s: %s", s, strerror(errno)); + LOG_ERROR_STR(s); result = false; break; } @@ -266,44 +240,32 @@ bool RemoveFileOrDir(const char *FileName, bool FollowSymlinks) if (remove(FileName) == 0) return true; } - else + else if (errno != ENOENT) { LOG_ERROR_STR(FileName); - return false; -} - -bool CheckProcess(pid_t pid) -{ - pid_t Pid2Check = pid; - int status; - pid = waitpid(Pid2Check, &status, WNOHANG); - if (pid < 0) { - if (errno != ECHILD) - LOG_ERROR; return false; } return true; } -void KillProcess(pid_t pid, int Timeout) +char *ReadLink(const char *FileName) { - pid_t Pid2Wait4 = pid; - for (time_t t0 = time(NULL); time(NULL) - t0 < Timeout; ) { - int status; - pid_t pid = waitpid(Pid2Wait4, &status, WNOHANG); - if (pid < 0) { - if (errno != ECHILD) - LOG_ERROR; - return; - } - if (pid == Pid2Wait4) - return; - } - esyslog(LOG_ERR, "ERROR: process %d won't end (waited %d seconds) - terminating it...", Pid2Wait4, Timeout); - if (kill(Pid2Wait4, SIGTERM) < 0) { - esyslog(LOG_ERR, "ERROR: process %d won't terminate (%s) - killing it...", Pid2Wait4, strerror(errno)); - if (kill(Pid2Wait4, SIGKILL) < 0) - esyslog(LOG_ERR, "ERROR: process %d won't die (%s) - giving up", Pid2Wait4, strerror(errno)); + char RealName[_POSIX_PATH_MAX]; + const char *TargetName = NULL; + int n = readlink(FileName, RealName, sizeof(RealName) - 1); + if (n < 0) { + if (errno == ENOENT || errno == EINVAL) // file doesn't exist or is not a symlink + TargetName = FileName; + else { // some other error occurred + LOG_ERROR_STR(FileName); + } + } + else if (n < int(sizeof(RealName))) { // got it! + RealName[n] = 0; + TargetName = RealName; } + else + esyslog(LOG_ERR, "ERROR: symlink's target name too long: %s", FileName); + return TargetName ? strdup(TargetName) : NULL; } // --- cFile ----------------------------------------------------------------- @@ -426,6 +388,45 @@ bool cFile::FileReady(int FileDes, int TimeoutMs) return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(FileDes, &set); } +// --- cSafeFile ------------------------------------------------------------- + +cSafeFile::cSafeFile(const char *FileName) +{ + f = NULL; + fileName = ReadLink(FileName); + tempName = fileName ? new char[strlen(fileName) + 5] : NULL; + if (tempName) + strcat(strcpy(tempName, fileName), ".$$$"); +} + +cSafeFile::~cSafeFile() +{ + if (f) + fclose(f); + unlink(tempName); + delete fileName; + delete tempName; +} + +bool cSafeFile::Open(void) +{ + if (!f && fileName && tempName) { + f = fopen(tempName, "w"); + if (!f) + LOG_ERROR_STR(tempName); + } + return f != NULL; +} + +void cSafeFile::Close(void) +{ + if (f) { + fclose(f); + f = NULL; + rename(tempName, fileName); + } +} + // --- cListObject ----------------------------------------------------------- cListObject::cListObject(void) |