Home

Dokumentation

Impressum

Dokumentation VDR
 

Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

tools.h File Reference

#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <sys/stat.h>
#include <sys/types.h>

Include dependency graph for tools.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

class  cFile
 File handling. More...

class  cList
class  cListBase
 Basic object listing. More...

class  cListObject
 List menu objects. More...

class  cLockFile
 File handling (lock). More...

class  cPoller
class  cSafeFile
 File handling (safe). More...


Defines

#define esyslog(a...)   void( (SysLogLevel > 0) ? syslog(LOG_ERR, a) : void() )
#define isyslog(a...)   void( (SysLogLevel > 1) ? syslog(LOG_INFO, a) : void() )
#define dsyslog(a...)   void( (SysLogLevel > 2) ? syslog(LOG_DEBUG, a) : void() )
#define LOG_ERROR   esyslog("ERROR (%s,%d): %m", __FILE__, __LINE__)
#define LOG_ERROR_STR(s)   esyslog("ERROR: %s: %m", s)
#define SECSINDAY   86400
#define KILOBYTE(n)   ((n) * 1024)
#define MEGABYTE(n)   ((n) * 1024 * 1024)
#define MAXPARSEBUFFER   KILOBYTE(10)
#define MALLOC(type, size)   (type *)malloc(sizeof(type) * (size))
#define DELETENULL(p)   (delete (p), p = NULL)
#define CHECK(s)   { if ((s) < 0) LOG_ERROR; }
#define FATALERRNO   (errno != EAGAIN && errno != EINTR)

Typedefs

typedef unsigned char uchar
typedef unsigned long long int uint64

Functions

template<class T> T min (T a, T b)
template<class T> T max (T a, T b)
template<class T> int sgn (T a)
template<class T> void swap (T &a, T &b)
ssize_t safe_read (int filedes, void *buffer, size_t size)
ssize_t safe_write (int filedes, const void *buffer, size_t size)
void writechar (int filedes, char c)
char * readline (FILE *f)
char * strcpyrealloc (char *dest, const char *src)
char * strn0cpy (char *dest, const char *src, size_t n)
char * strreplace (char *s, char c1, char c2)
char * strreplace (char *s, const char *s1, const char *s2)
 re-allocates 's' and deletes the original string if necessary!

char * skipspace (const char *s)
char * stripspace (char *s)
char * compactspace (char *s)
const char * strescape (const char *s, const char *chars)
 
Warning:
returns a statically allocated string!


bool startswith (const char *s, const char *p)
bool endswith (const char *s, const char *p)
bool isempty (const char *s)
int numdigits (int n)
int time_ms (void)
void delay_ms (int ms)
bool isnumber (const char *s)
const char * itoa (int n)
 
Warning:
returns a statically allocated string!


const char * AddDirectory (const char *DirName, const char *FileName)
 
Warning:
returns a statically allocated string!


int FreeDiskSpaceMB (const char *Directory, int *UsedMB=NULL)
bool DirectoryOk (const char *DirName, bool LogErrors=false)
bool MakeDirs (const char *FileName, bool IsDirectory=false)
bool RemoveFileOrDir (const char *FileName, bool FollowSymlinks=false)
bool RemoveEmptyDirectories (const char *DirName, bool RemoveThis=false)
char * ReadLink (const char *FileName)
bool SpinUpDisk (const char *FileName)
const char * WeekDayName (int WeekDay)
 
Warning:
returns a statically allocated string!


const char * DayDateTime (time_t t=0)
 
Warning:
returns a statically allocated string!



Variables

int SysLogLevel


Define Documentation

#define CHECK      { if ((s) < 0) LOG_ERROR; }
 

Definition at line 45 of file tools.h.

Referenced by cDvbTuner::Action(), cDvbDevice::Clear(), cDvbDevice::Freeze(), cDvbDevice::Mute(), cDvbDevice::Play(), cDvbDevice::SetChannelDevice(), cDvbTuner::SetFrontend(), cDvbDevice::SetPid(), cDvbDevice::SetPlayMode(), cDvbDevice::SetVideoFormat(), cDvbDevice::SetVolumeDevice(), cDvbDevice::StillPicture(), and cDvbDevice::TrickSpeed().

#define DELETENULL      (delete (p), p = NULL)
 

Definition at line 43 of file tools.h.

Referenced by cSVDRP::Close(), cSVDRP::CmdPUTE(), cRecordControl::cRecordControl(), cSVDRP::Execute(), main(), cRecordControls::Process(), cRecordControls::Shutdown(), and cRecordControl::Stop().

#define dsyslog a...       void( (SysLogLevel > 2) ? syslog(LOG_DEBUG, a) : void() )
 

Definition at line 29 of file tools.h.

Referenced by cTransfer::Action(), cKbdRemote::Action(), cRecorder::Action(), cRcuRemote::Action(), cLircRemote::Action(), cSIProcessor::Action(), cDvbPlayer::Action(), cDvbTuner::Action(), cDevice::Action(), cCuttingThread::Action(), cRecordControl::cRecordControl(), cDvbSpuDecoder::Draw(), cCommand::Execute(), cRecordControl::GetEventInfo(), cInterface::LearnKeys(), main(), MakeDirs(), cFileName::Open(), cDvbDevice::Probe(), cRingBufferLinear::Put(), cInterface::QueryKeys(), cThread::RaisePanic(), cSIProcessor::Read(), RemoveEmptyDirectories(), RemoveFileOrDir(), ReportEpgBugFixStats(), cRecorder::RunningLowOnDiskSpace(), safe_read(), safe_write(), SpinUpDisk(), cDevice::SwitchChannel(), and cRingBuffer::~cRingBuffer().

#define esyslog a...       void( (SysLogLevel > 0) ? syslog(LOG_ERR, a) : void() )
 

Definition at line 27 of file tools.h.

Referenced by cDvbTuner::Action(), cDevice::Action(), cCuttingThread::Action(), cPoller::Add(), cSIProcessor::AddFilter(), cDevice::AddPid(), cDevice::AttachReceiver(), cThread::Cancel(), cIndexFile::CatchUp(), cBitmap::cBitmap(), cCuttingThread::cCuttingThread(), cDevice::cDevice(), cDvbDevice::cDvbDevice(), cDvbOsd::cDvbOsd(), cDvbPlayer::cDvbPlayer(), cFileName::cFileName(), cFrame::cFrame(), cIndexFile::cIndexFile(), cDiseqc::Codes(), cOsdBase::Create(), cReceiver::cReceiver(), cRecorder::cRecorder(), cRecording::cRecording(), cResumeFile::cResumeFile(), cRingBufferLinear::cRingBufferLinear(), cTS2PES::cTS2PES(), DirectoryOk(), cRingBufferFrame::Drop(), cThread::EmergencyExit(), cInterface::Error(), cCommand::Execute(), cSource::FromString(), cTSBuffer::Get(), cIndexFile::GetNextIFrame(), cDvbDevice::GetTSPacket(), I18nTranslate(), cPalette::Index(), cTS2PES::instant_repack(), cDll::Load(), cConfig< cDiseqc >::Load(), cSetup::Load(), cLockFile::Lock(), main(), cDevice::NextCardIndex(), cFile::Open(), OpenVideoFile(), cTimer::Parse(), cKeyMacro::Parse(), cDiseqc::Parse(), cChannel::Parse(), ParseParameter(), cExternalAudio::Play(), cPlayer::PlayAudio(), cPlayer::PlayVideo(), cSVDRP::Process(), cRemux::Process(), cKeys::PutSetup(), cThread::RaisePanic(), cSchedule::Read(), cEventInfo::Read(), ReadFrame(), ReadLink(), cTransfer::Receive(), cRecorder::Receive(), cOsdBase::Relocate(), cRecording::Remove(), RemoveFileOrDir(), cSVDRP::Reply(), cDvbDevice::SetChannelDevice(), cDvbTuner::SetFrontend(), cFileName::SetOffset(), cDevice::SetPrimaryDevice(), cMJD::SetSystemTime(), cDvbSpuDecoder::setTime(), cDvbOsd::SetWindow(), SkipQuote(), SpinUpDisk(), cRecordControls::Start(), cCutter::Stop(), cTS2PES::store(), strcpyrealloc(), cChannel::StringToParameters(), cDevice::SwitchChannel(), cDiseqc::Wait(), and Watchdog().

#define FATALERRNO   (errno != EAGAIN && errno != EINTR)
 

Definition at line 46 of file tools.h.

Referenced by cTransfer::Action(), and cDvbPlayer::Action().

#define isyslog a...       void( (SysLogLevel > 1) ? syslog(LOG_INFO, a) : void() )
 

Definition at line 28 of file tools.h.

Referenced by cSocket::Accept(), cSIProcessor::Action(), cDvbPlayer::Action(), AssertFreeDiskSpace(), cDvbPlayer::cDvbPlayer(), cIndexFile::cIndexFile(), cSVDRP::Close(), cSVDRP::CmdDELT(), cSVDRP::CmdMESG(), cSVDRP::CmdMODC(), cSVDRP::CmdMODT(), cSVDRP::CmdNEWC(), cSVDRP::CmdNEWT(), cSVDRP::CmdUPDT(), cInterface::Confirm(), cRcuRemote::cRcuRemote(), cRecorder::cRecorder(), cSVDRP::cSVDRP(), cRecording::Delete(), cMenuTimers::Delete(), cMenuChannels::Delete(), cMenuTimers::Edit(), cDvbDevice::GrabImage(), cInterface::Info(), cRcuRemote::Initialize(), cDvbDevice::Initialize(), cRecordingUserCommand::InvokeCommand(), cDll::Load(), cConfig< cDiseqc >::Load(), main(), cMenuTimers::Move(), cMenuChannels::Move(), cMenuTimers::New(), cMenuTimers::OnOff(), cSVDRP::Process(), cMenuEditTimer::ProcessKey(), cMenuEditChannel::ProcessKey(), cMenuSchedule::Record(), cMenuWhatsOn::Record(), cRecording::Remove(), cSetup::Save(), cDevice::SetPrimaryDevice(), cTimer::SetRecording(), cMJD::SetSystemTime(), cPluginManager::Shutdown(), cRecordControls::Start(), cPluginManager::StartPlugins(), cRecordControls::Stop(), cRecordControl::Stop(), cCutter::Stop(), and cDevice::SwitchChannel().

#define KILOBYTE      ((n) * 1024)
 

Definition at line 36 of file tools.h.

#define LOG_ERROR   esyslog("ERROR (%s,%d): %m", __FILE__, __LINE__)
 

Definition at line 31 of file tools.h.

Referenced by cSocket::Accept(), cTransfer::Action(), cKbdRemote::Action(), cSIProcessor::Action(), cDvbPlayer::Action(), cThread::Active(), cDvbDevice::cDvbDevice(), cIndexFile::cIndexFile(), cPipe::Close(), cPUTEhandler::cPUTEhandler(), cDvbDevice::GetTSPacket(), cPipe::Open(), cSocket::Open(), cExternalAudio::Play(), cSIProcessor::Read(), ReadFrame(), cRcuRemote::ReceiveByte(), cSVDRP::Send(), cRcuRemote::SendByteHandshake(), cDvbDevice::SetPid(), and SystemExec().

#define LOG_ERROR_STR      esyslog("ERROR: %s: %m", s)
 

Definition at line 32 of file tools.h.

Referenced by cRecorder::Action(), cIndexFile::CatchUp(), cIndexFile::cIndexFile(), cLircRemote::cLircRemote(), cSafeFile::Close(), cFileName::Close(), cRcuRemote::cRcuRemote(), cRecording::cRecording(), cResumeFile::Delete(), DirectoryOk(), DvbOpen(), FreeDiskSpaceMB(), cDvbDevice::GrabImage(), cConfig< cDiseqc >::Load(), cLockFile::Lock(), MakeDirs(), cSafeFile::Open(), cPipe::Open(), cFileName::Open(), OpenVideoFile(), cDvbDevice::Probe(), cResumeFile::Read(), ReadLink(), RemoveEmptyDirectories(), RemoveFileOrDir(), RenameVideoFile(), cResumeFile::Save(), cFileName::SetOffset(), SpinUpDisk(), SystemExec(), cIndexFile::Write(), and cRecording::WriteSummary().

#define MALLOC type,
size       (type *)malloc(sizeof(type) * (size))
 

Definition at line 41 of file tools.h.

Referenced by cBitmap::cBitmap(), cFileName::cFileName(), cIndexFile::cIndexFile(), cRecording::cRecording(), cResumeFile::cResumeFile(), cSafeFile::cSafeFile(), cTS2PES::cTS2PES(), cTSBuffer::cTSBuffer(), cTimer::Parse(), cCommand::Parse(), cMenuSchedule::PrepareSchedule(), RemoveFileOrDir(), cRecording::SortName(), cRecording::Title(), and cInterface::WrapText().

#define MAXPARSEBUFFER   KILOBYTE(10)
 

Definition at line 39 of file tools.h.

Referenced by cConfig< cDiseqc >::Load(), readline(), and cSetup::StoreCaCaps().

#define MEGABYTE      ((n) * 1024 * 1024)
 

Definition at line 37 of file tools.h.

Referenced by cCuttingThread::Action(), cRecorder::NextFile(), and cDvbDevice::OpenDvr().

#define SECSINDAY   86400
 

Definition at line 34 of file tools.h.

Referenced by AssertFreeDiskSpace(), cTimer::Matches(), and cMenuEditDateItem::ProcessKey().


Typedef Documentation

typedef unsigned char uchar
 

tools.h: Various tools

See the main source file 'vdr.c' for copyright information and how to reach the author.

Id
tools.h 1.54 2002/12/15 14:59:53 kls Exp

Definition at line 22 of file tools.h.

Referenced by cTransfer::Action(), cKbdRemote::Action(), cRecorder::Action(), cDvbPlayer::Action(), cDevice::Action(), cCuttingThread::Action(), cFrame::cFrame(), cDiseqc::Codes(), cRingBufferLinear::cRingBufferLinear(), cFrame::Data(), cTSBuffer::Get(), cDvbPlayer::Goto(), cRemux::Process(), cDvbPlayer::Resume(), cDvbTuner::SetFrontend(), cTransfer::StripAudioPackets(), and cDvbPlayer::StripAudioPackets().

typedef unsigned long long int uint64
 

Definition at line 23 of file tools.h.

Referenced by cKbdRemote::Action(), cRcuRemote::Action(), and cKbdRemote::MapFuncToCode().


Function Documentation

const char* AddDirectory const char *    DirName,
const char *    FileName
 

Warning:
returns a statically allocated string!

Definition at line 255 of file tools.c.

Referenced by cSIProcessor::GetEpgDataFileName(), cMarks::Load(), main(), and cSIProcessor::SetEpgDataFileName().

char* compactspace char *    s
 

Definition at line 145 of file tools.c.

References skipspace(), and stripspace().

Referenced by cEventInfo::FixEpgBugs(), and cSetupLine::Parse().

const char* DayDateTime time_t    t = 0
 

Warning:
returns a statically allocated string!

Definition at line 490 of file tools.c.

References WeekDayName().

Referenced by cDisplayChannel::DisplayChannel(), and cOsdMenu::SetTitle().

void delay_ms int    ms
 

Definition at line 229 of file tools.c.

References time_ms().

Referenced by cRcuRemote::DetectCode().

bool DirectoryOk const char *    DirName,
bool    LogErrors = false
 

Definition at line 280 of file tools.c.

References esyslog, and LOG_ERROR_STR.

Referenced by cLockFile::cLockFile(), main(), cVideoDirectory::Next(), cSIProcessor::SetEpgDataFileName(), and SpinUpDisk().

bool endswith const char *    s,
const char *    p
 

Definition at line 194 of file tools.c.

Referenced by cRecording::Remove().

int FreeDiskSpaceMB const char *    Directory,
int *    UsedMB = NULL
 

Definition at line 263 of file tools.c.

References LOG_ERROR_STR.

Referenced by cVideoDirectory::FreeMB(), OpenVideoFile(), and cRecorder::RunningLowOnDiskSpace().

bool isempty const char *    s
 

Definition at line 205 of file tools.c.

References skipspace().

Referenced by cMenuEvent::cMenuEvent(), cRecording::cRecording(), cTimer::cTimer(), cOsdMenu::Display(), cDisplayChannel::DisplayInfo(), cEventInfo::Dump(), cConfig< cDiseqc >::Load(), cCommand::Parse(), cTimer::SetFile(), and cMenuTimers::Summary().

bool isnumber const char *    s
 

Definition at line 236 of file tools.c.

Referenced by cSVDRP::CmdCHAN(), cSVDRP::CmdDELR(), cSVDRP::CmdDELT(), cSVDRP::CmdGRAB(), cSVDRP::CmdLSTC(), cSVDRP::CmdLSTR(), cSVDRP::CmdLSTT(), cSVDRP::CmdVOLU(), and main().

const char* itoa int    n
 

Warning:
returns a statically allocated string!

Definition at line 248 of file tools.c.

Referenced by cTimer::ToText().

bool MakeDirs const char *    FileName,
bool    IsDirectory = false
 

Definition at line 298 of file tools.c.

References dsyslog, and LOG_ERROR_STR.

Referenced by cPlugin::ConfigDirectory(), cRecorder::cRecorder(), OpenVideoFile(), and cCutter::Start().

template<class T>
T max   a,
  b
[inline]
 

Definition at line 50 of file tools.h.

Referenced by cReplayControl::DisplayAtBottom(), cDvbPlayer::GetIndex(), cOsdMenu::PageDown(), cDevice::Priority(), cMenuTextItem::ScrollUp(), cDevice::SetVolume(), cDvbPlayer::SkipSeconds(), and strcpyrealloc().

template<class T>
T min   a,
  b
[inline]
 

Definition at line 49 of file tools.h.

Referenced by cOsdMenu::PageUp(), cMenuTextItem::ScrollDown(), cDvbTuner::SetFrontend(), cDevice::SetVolume(), and cReplayControl::TimeSearchProcess().

int numdigits int    n
 

Definition at line 210 of file tools.c.

char* readline FILE *    f
 

Definition at line 60 of file tools.c.

References MAXPARSEBUFFER.

Referenced by cRecordings::Load(), cSchedule::Read(), and cEventInfo::Read().

char* ReadLink const char *    FileName
 

Definition at line 424 of file tools.c.

References esyslog, and LOG_ERROR_STR.

Referenced by cSafeFile::cSafeFile().

bool RemoveEmptyDirectories const char *    DirName,
bool    RemoveThis = false
 

Definition at line 382 of file tools.c.

References dsyslog, and LOG_ERROR_STR.

Referenced by RemoveEmptyVideoDirectories().

bool RemoveFileOrDir const char *    FileName,
bool    FollowSymlinks = false
 

Definition at line 326 of file tools.c.

References dsyslog, esyslog, LOG_ERROR_STR, and MALLOC.

Referenced by RemoveVideoFile().

ssize_t safe_read int    filedes,
void *    buffer,
size_t    size
 

Definition at line 23 of file tools.c.

References dsyslog.

Referenced by cLircRemote::Action(), cSIProcessor::Action(), cIndexFile::CatchUp(), cIndexFile::cIndexFile(), cRecording::cRecording(), cSVDRP::Process(), cResumeFile::Read(), ReadFrame(), and cRcuRemote::ReceiveByte().

ssize_t safe_write int    filedes,
const void *    buffer,
size_t    size
 

Definition at line 35 of file tools.c.

References dsyslog.

Referenced by cRecorder::Action(), cCuttingThread::Action(), cResumeFile::Save(), cSVDRP::Send(), cDvbDevice::StillPicture(), cIndexFile::Write(), and writechar().

template<class T>
int sgn   a [inline]
 

Definition at line 51 of file tools.h.

Referenced by cDevice::SwitchChannel().

char* skipspace const char *    s
 

Definition at line 126 of file tools.c.

Referenced by cSVDRP::CmdMODC(), cSVDRP::CmdMODT(), cDiseqc::Codes(), compactspace(), cSVDRP::Execute(), cOsdMenu::HotKey(), isempty(), cTimer::Parse(), cMark::Parse(), cKey::Parse(), cCommand::Parse(), cChannel::Parse(), cSchedule::Read(), and cEventInfo::Read().

bool SpinUpDisk const char *    FileName
 

Definition at line 444 of file tools.c.

References DirectoryOk(), dsyslog, esyslog, and LOG_ERROR_STR.

Referenced by cRecorder::cRecorder().

bool startswith const char *    s,
const char *    p
 

Definition at line 185 of file tools.c.

Referenced by cEventInfo::FixEpgBugs().

char* strcpyrealloc char *    dest,
const char *    src
 

Definition at line 72 of file tools.c.

References esyslog, and max().

Referenced by cEventInfo::SetExtendedDescription(), cEventInfo::SetSubtitle(), and cEventInfo::SetTitle().

const char* strescape const char *    s,
const char *    chars
 

Warning:
returns a statically allocated string!

Definition at line 162 of file tools.c.

Referenced by cRecordingUserCommand::InvokeCommand(), and main().

char* stripspace char *    s
 

Definition at line 133 of file tools.c.

Referenced by compactspace(), cConfig< cDiseqc >::Load(), cCommand::Parse(), cMenuEditStrItem::ProcessKey(), and cRecording::Title().

char* strn0cpy char *    dest,
const char *    src,
size_t    n
 

Definition at line 89 of file tools.c.

Referenced by cTimer::cTimer(), cTimer::Parse(), cSetup::Parse(), cCommand::Parse(), cChannel::Parse(), cTimer::SetFile(), cReplayControl::ShowMode(), cRecording::Title(), and cInterface::Title().

char* strreplace char *    s,
const char *    s1,
const char *    s2
 

re-allocates 's' and deletes the original string if necessary!

Definition at line 109 of file tools.c.

Referenced by cSVDRP::CmdLSTR(), cRecording::cRecording(), cEventInfo::FixEpgBugs(), cTimer::Parse(), cChannel::Parse(), cTimer::ToText(), and cChannel::ToText().

char* strreplace char *    s,
char    c1,
char    c2
 

Definition at line 97 of file tools.c.

template<class T>
void swap T &    a,
T &    b
[inline]
 

Definition at line 52 of file tools.h.

Referenced by cMarks::Sort().

int time_ms void   
 

Definition at line 217 of file tools.c.

Referenced by cLircRemote::Action(), cRcuRemote::Action(), cKbdRemote::Action(), cDisplayChannel::cDisplayChannel(), cDisplayVolume::cDisplayVolume(), delay_ms(), cDisplayChannel::DisplayInfo(), cDisplayChannel::ProcessKey(), cDisplayVolume::ProcessKey(), and cDisplayChannel::Refresh().

const char* WeekDayName int    WeekDay
 

Warning:
returns a statically allocated string!

Definition at line 476 of file tools.c.

References tr.

Referenced by DayDateTime(), and cMenuEditDateItem::Set().

void writechar int    filedes,
char    c
 

Definition at line 55 of file tools.c.

References safe_write().

Referenced by cIndexFile::cIndexFile().


Variable Documentation

int SysLogLevel
 

Definition at line 25 of file tools.h.


Generated on Wed Feb 5 23:30:57 2003 for VDR by doxygen1.3-rc2