summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2002-01-27 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2002-01-27 18:00:00 +0100
commit27919ee969866b68fc95b327a047a9989e4b4153 (patch)
tree1857862abf169ff6e9287152cd6fec6a1d9dbc41 /tools.c
parentb420457467ad0c8ae71f8b985914e85b7a0ff5aa (diff)
downloadvdr-patch-lnbsharing-27919ee969866b68fc95b327a047a9989e4b4153.tar.gz
vdr-patch-lnbsharing-27919ee969866b68fc95b327a047a9989e4b4153.tar.bz2
Version 0.99pre2vdr-0.99pre2
- Fixed setting the OSD size in the 'Confirm' interface call (thanks to Deti Fliegl). - Removed the 'read incomplete section...' error message in the EIT processor. - Fixed channel data for "DW TV" (thanks to Axel Gruber). - Added DPID to "PREMIERE MOVIE 1" in channels.conf.cable (thanks to Stephan Schreiber). - Prepared the OSD functions for multiple overlapping windows. - Removed the check to see whether the system time is running linearly. - Improved performance of SVDRP command entry. - Removed EPGBugfixLevel '3' - after more than a year Pro-7 finally managed to broadcast the correct timestamps for EPG events between 0:00 and 6:00! - Fixed failing watchdog timer if program hangs in OSD activities (thanks to Carsten Koch). - No longer requiring 'libncurses' if compiling without DEBUG_OSD=1 and REMOTE=KBD (thanks to Lauri Pesonen). - The "Recordings" menu now displays a hierarchical structure if there are subdirectories for the recordings. This can be controlled through the "RecordingDirs" parameter in the "Setup" menu. See "MANUAL/Replaying a Recording" for details. - Improved speed of setting the Help button texts. - Fixed handling file names that contain single quotes (') or dollar signs ($) in the call to the shutdown command (option '-s') and the recording command (option '-r'). - Improved error handling in the editing process; the resulting file will be deleted if an error occured. - A message is now prompted at the end of the editing process, indicating whether the process succeeded or failed. - Fixed setting the LastActivity timestamp after a shutdown prompt (thanks to Sergei Haller). - A message is now prompted if free disk space becomes low during recording. - The editing process now calls AssertFreeDiskSpace() to remove deleted recordings if the disk becomes full. - The "Main" menu now displays in its title the used disk space (in percent) and the estimated free disk space (in hh:mm), assuming a data rate of 30 MB per minute. - Activating the "Recordings" menu now displays "scanning recordings..." to give the user some feedback in case this takes longer. - Status messages are now displayed centered. - Removed the 'Tools' subdirectory from the VDR archive. All contributed tools can now be found at ftp://ftp.cadsoft.de/pub/people/kls/vdr/Tools.
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/tools.c b/tools.c
index 472c50d..dc579e5 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.50 2001/10/19 13:12:45 kls Exp $
+ * $Id: tools.c 1.53 2002/01/27 12:36:23 kls Exp $
*/
#include "tools.h"
@@ -136,6 +136,29 @@ char *compactspace(char *s)
return s;
}
+const char *strescape(const char *s, const char *chars)
+{
+ static char *buffer = NULL;
+ const char *p = s;
+ char *t = NULL;
+ while (*p) {
+ if (strchr(chars, *p)) {
+ if (!t) {
+ buffer = (char *)realloc(buffer, 2 * strlen(s) + 1);
+ t = buffer + (p - s);
+ s = strcpy(buffer, s);
+ }
+ *t++ = '\\';
+ }
+ if (t)
+ *t++ = *p;
+ p++;
+ }
+ if (t)
+ *t = 0;
+ return s;
+}
+
bool startswith(const char *s, const char *p)
{
while (*p) {
@@ -145,6 +168,17 @@ bool startswith(const char *s, const char *p)
return true;
}
+bool endswith(const char *s, const char *p)
+{
+ const char *se = s + strlen(s) - 1;
+ const char *pe = p + strlen(p) - 1;
+ while (pe >= p) {
+ if (*pe-- != *se-- || (se < s && pe >= p))
+ return false;
+ }
+ return true;
+}
+
bool isempty(const char *s)
{
return !(s && *skipspace(s));
@@ -189,10 +223,12 @@ const char *AddDirectory(const char *DirName, const char *FileName)
#define DFCMD "df -m -P '%s'"
-uint FreeDiskSpaceMB(const char *Directory)
+int FreeDiskSpaceMB(const char *Directory, int *UsedMB)
{
//TODO Find a simpler way to determine the amount of free disk space!
- uint Free = 0;
+ if (UsedMB)
+ *UsedMB = 0;
+ int Free = 0;
char *cmd = NULL;
asprintf(&cmd, DFCMD, Directory);
FILE *p = popen(cmd, "r");
@@ -200,8 +236,10 @@ uint FreeDiskSpaceMB(const char *Directory)
char *s;
while ((s = readline(p)) != NULL) {
if (strchr(s, '/')) {
- uint available;
- sscanf(s, "%*s %*d %*d %u", &available);
+ int used, available;
+ sscanf(s, "%*s %*d %d %d", &used, &available);
+ if (UsedMB)
+ *UsedMB = used;
Free = available;
break;
}