|
vdr 2.8.3
|
#include "tools.h"#include <ctype.h>#include <dirent.h>#include <errno.h>#include <jpeglib.h>#include <locale.h>#include <stdlib.h>#include <sys/time.h>#include <sys/vfs.h>#include <time.h>#include <unistd.h>#include <utime.h>#include "i18n.h"#include "thread.h"Go to the source code of this file.
Classes | |
| struct | tJpegCompressData |
Macros | |
| #define | DECIMAL_POINT_C '.' |
| #define | MT(s, m, v) |
| #define | JPEGCOMPRESSMEM 500000 |
| #define | USE_FADVISE_READ 0 |
| #define | USE_FADVISE_WRITE 1 |
| #define | WRITE_BUFFER KILOBYTE(800) |
| #define | FADVGRAN KILOBYTE(4) |
| #define | READCHUNK MEGABYTE(8) |
| #define | LOCKFILENAME ".lock-vdr" |
| #define | LOCKFILESTALETIME 600 |
| #define | LIST_GARBAGE_COLLECTOR_TIMEOUT 5 |
Functions | |
| void | syslog_with_tid (int priority, const char *format,...) |
| int | BCD2INT (int x) |
| 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) |
| int | WriteAllOrNothing (int fd, const uchar *Data, int Length, int TimeoutMs, int RetryMs) |
| 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) |
| const char * | strchrn (const char *s, char c, size_t n) |
| int | strcountchr (const char *s, char c) |
| cString | strgetbefore (const char *s, char c, int n) |
| const char * | strgetlast (const char *s, char c) |
| char * | stripspace (char *s) |
| char * | strtrim (char *s, bool Shift) |
| char * | compactspace (char *s) |
| char * | compactchars (char *s, char c) |
| cString | strescape (const char *s, const char *chars) |
| cString | strgetval (const char *s, const char *name, char d) |
| char * | strshift (char *s, int n) |
| 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) |
| bool | isnumber (const char *s) |
| int64_t | StrToNum (const char *s) |
| bool | StrInArray (const char *a[], const char *s) |
| cString | Indent (int n, const char *s) |
| cString | AddDirectory (const char *DirName, const char *FileName) |
| double | atod (const char *s) |
| cString | dtoa (double d, const char *Format) |
| cString | itoa (int n) |
| bool | EntriesOnSameFileSystem (const char *File1, const char *File2) |
| int | FreeDiskSpaceMB (const char *Directory, int *UsedMB) |
| bool | DirectoryOk (const char *DirName, bool LogErrors) |
| bool | MakeDirs (const char *FileName, bool IsDirectory) |
| bool | RemoveFileOrDir (const char *FileName, bool FollowSymlinks) |
| bool | RemoveEmptyDirectories (const char *DirName, bool RemoveThis, const char *IgnoreFiles[]) |
| int | DirSizeMB (const char *DirName) |
| char * | ReadLink (const char *FileName) |
| bool | SpinUpDisk (const char *FileName) |
| void | TouchFile (const char *FileName, bool Create) |
| time_t | LastModifiedTime (const char *FileName) |
| off_t | FileSize (const char *FileName) |
| int | Utf8CharLen (const char *s) |
| uint | Utf8CharGet (const char *s, int Length) |
| int | Utf8CharSet (uint c, char *s) |
| int | Utf8SymChars (const char *s, int Symbols) |
| int | Utf8StrLen (const char *s) |
| char * | Utf8Strn0Cpy (char *Dest, const char *Src, int n) |
| int | Utf8ToArray (const char *s, uint *a, int Size) |
| int | Utf8FromArray (const uint *a, char *s, int Size, int Max) |
| cString | WeekDayName (int WeekDay) |
| cString | WeekDayName (time_t t) |
| cString | WeekDayNameFull (int WeekDay) |
| cString | WeekDayNameFull (time_t t) |
| cString | DayDateTime (time_t t) |
| cString | TimeToString (time_t t) |
| cString | DateString (time_t t) |
| cString | ShortDateString (time_t t) |
| cString | TimeString (time_t t) |
| static void | JpegCompressInitDestination (j_compress_ptr cinfo) |
| static boolean | JpegCompressEmptyOutputBuffer (j_compress_ptr cinfo) |
| static void | JpegCompressTermDestination (j_compress_ptr cinfo) |
| uchar * | RgbToJpeg (uchar *Mem, int Width, int Height, int &Size, int Quality) |
| const char * | GetHostName (void) |
| static int | CompareListObjects (const void *a, const void *b) |
Variables | |
| int | SysLogLevel = 3 |
| static uint | SystemToUtf8 [128] = { 0 } |
| cListGarbageCollector | ListGarbageCollector |
| #define DECIMAL_POINT_C '.' |
| #define FADVGRAN KILOBYTE(4) |
Definition at line 1907 of file tools.c.
Referenced by cUnbufferedFile::FadviseDrop().
| #define JPEGCOMPRESSMEM 500000 |
Definition at line 1358 of file tools.c.
Referenced by JpegCompressEmptyOutputBuffer(), and JpegCompressInitDestination().
| #define LIST_GARBAGE_COLLECTOR_TIMEOUT 5 |
Definition at line 2162 of file tools.c.
Referenced by cListGarbageCollector::Purge().
| #define LOCKFILENAME ".lock-vdr" |
Definition at line 2050 of file tools.c.
Referenced by cLockFile::cLockFile().
| #define LOCKFILESTALETIME 600 |
Definition at line 2051 of file tools.c.
Referenced by cLockFile::Lock().
| #define MT | ( | s, | |
| m, | |||
| v ) |
| #define READCHUNK MEGABYTE(8) |
Definition at line 1908 of file tools.c.
Referenced by cUnbufferedFile::Read().
| #define WRITE_BUFFER KILOBYTE(800) |
Definition at line 1856 of file tools.c.
Referenced by cUnbufferedFile::Write().
| cString AddDirectory | ( | const char * | DirName, |
| const char * | FileName ) |
Definition at line 445 of file tools.c.
References AddDirectory(), and cString::sprintf().
Referenced by cDirCopier::Action(), AddDirectory(), cLockFile::cLockFile(), cSVDRPServer::CmdGRAB(), CopyMarks(), DirSizeMB(), GenerateIndex(), GetRecordingsSortMode(), GetRecordingTimerId(), HasRecordingsSortMode(), cDvbDevice::Initialize(), cFileNameList::Load(), cMarks::Load(), cPesIndex::Load(), cPictureEntry::Load(), cThemes::Load(), main(), cMarks::MarksFileName(), cTsWriter::Open(), cPictureEntry::Path(), cPesInfo::Read(), cPesResume::Read(), cPesSummary::Read(), cArgs::ReadDirectory(), RemoveEmptyDirectories(), RemoveFileOrDir(), cVideoDirectoryScannerThread::ScanVideoDir(), SetLogFileName(), SetRecordingsSortMode(), SetRecordingTimerId(), StillRecording(), cRecordings::UpdateFileName(), cPesInfo::Write(), and cPesResume::Write().
| double atod | ( | const char * | s | ) |
Converts the given string, which is a floating point number using a '.
' as the decimal point, to a double value, independent of the currently selected locale.
Definition at line 454 of file tools.c.
References atod(), and DECIMAL_POINT_C.
Referenced by atod(), cSetup::Parse(), and cRecordingInfo::Read().
| int BCD2INT | ( | int | x | ) |
Definition at line 42 of file tools.c.
References BCD2INT(), and BCDCHARTOINT.
Referenced by BCD2INT(), and cNitFilter::Process().
| char * compactchars | ( | char * | s, |
| char | c ) |
removes all occurrences of 'c' from the beginning an end of 's' and replaces sequences of multiple 'c's with a single 'c'.
Definition at line 286 of file tools.c.
References compactchars().
Referenced by cString::CompactChars(), and compactchars().
| char * compactspace | ( | char * | s | ) |
Definition at line 271 of file tools.c.
References compactspace(), skipspace(), and strtrim().
Referenced by compactspace(), cEvent::FixEpgBugs(), cSetupLine::Parse(), cSdtFilter::Process(), and cRecordingInfo::Read().
|
static |
Definition at line 2345 of file tools.c.
References cListObject::Compare(), and CompareListObjects().
Referenced by CompareListObjects(), and cListBase::Sort().
| cString DateString | ( | time_t | t | ) |
Converts the given time to a string of the form "www dd.mm.yyyy".
Definition at line 1328 of file tools.c.
References DateString(), and WeekDayName().
Referenced by DateString(), cEvent::GetDateString(), cSkinClassicDisplayMenu::SetRecording(), cSkinCursesDisplayMenu::SetRecording(), cSkinLCARSDisplayMenu::SetRecording(), cSkinSTTNGDisplayMenu::SetRecording(), and cPluginSvdrpdemo::SVDRPCommand().
| cString DayDateTime | ( | time_t | t = 0 | ) |
Converts the given time to a string of the form "www dd.mm. hh:mm".
If no time is given, the current time is taken.
Definition at line 1307 of file tools.c.
References DayDateTime(), and WeekDayName().
Referenced by DayDateTime(), cPictureControl::DisplayCaption(), cSkinLCARSDisplayChannel::DrawDate(), cSkinLCARSDisplayMenu::DrawDate(), cSkinLCARSDisplayReplay::DrawDate(), cSkinLCARSDisplayMenu::DrawTimer(), cStateLockLog::Dump(), cSkinClassicDisplayChannel::Flush(), cSkinClassicDisplayMenu::Flush(), cSkinCursesDisplayChannel::Flush(), cSkinCursesDisplayMenu::Flush(), cSkinSTTNGDisplayChannel::Flush(), cSkinSTTNGDisplayMenu::Flush(), and cSkinSTTNGDisplayMenu::SetButtons().
| bool DirectoryOk | ( | const char * | DirName, |
| bool | LogErrors ) |
Definition at line 524 of file tools.c.
References DirectoryOk(), esyslog, and LOG_ERROR_STR.
Referenced by cDirCopier::Action(), cLockFile::cLockFile(), CutRecording(), DirectoryOk(), GenerateIndex(), main(), Pes2Ts(), and SpinUpDisk().
| int DirSizeMB | ( | const char * | DirName | ) |
returns the total size of the files in the given directory, or -1 in case of an error
Definition at line 682 of file tools.c.
References AddDirectory(), DirSizeMB(), LOG_ERROR_STR, MEGABYTE, cReadDir::Next(), and cReadDir::Ok().
Referenced by DirSizeMB(), EnoughFreeDiskSpaceForEdit(), cRecording::FileSizeMB(), FileSizeMBafterEdit(), and cRecordingsHandler::GetRequiredDiskSpaceMB().
| cString dtoa | ( | double | d, |
| const char * | Format = "%f" ) |
Converts the given double value to a string, making sure it uses a '.
' as the decimal point, independent of the currently selected locale. If Format is given, it will be used instead of the default.
Definition at line 475 of file tools.c.
References DECIMAL_POINT_C, dtoa(), and strreplace().
Referenced by dtoa(), cRecordingInfo::FrameParams(), cSetup::Store(), and cRecordingInfo::Write().
| bool endswith | ( | const char * | s, |
| const char * | p ) |
Definition at line 376 of file tools.c.
References endswith().
Referenced by endswith(), cChannels::MarkObsoleteChannels(), MatchPattern(), cArgs::ReadDirectory(), cRecording::Remove(), cVideoDirectoryScannerThread::ScanVideoDir(), and cRecordingInfo::SetFileName().
| bool EntriesOnSameFileSystem | ( | const char * | File1, |
| const char * | File2 ) |
Checks whether the given files are on the same file system.
If either of the files doesn't exist, this function returns true to avoid any actions that might be triggered if files are on different file system.
Definition at line 492 of file tools.c.
References EntriesOnSameFileSystem(), and LOG_ERROR_STR.
Referenced by cVideoDirectory::Contains(), EntriesOnSameFileSystem(), cRecordingsHandler::GetRequiredDiskSpaceMB(), and cVideoDirectory::Move().
| off_t FileSize | ( | const char * | FileName | ) |
returns the size of the given file, or -1 in case of an error (e.g. if the file doesn't exist)
Definition at line 782 of file tools.c.
References FileSize().
Referenced by cDirCopier::Action(), cIndexFileGenerator::Action(), cIndexFile::cIndexFile(), FileSize(), and cPesFile::Open().
| int FreeDiskSpaceMB | ( | const char * | Directory, |
| int * | UsedMB ) |
Definition at line 507 of file tools.c.
References FreeDiskSpaceMB(), and LOG_ERROR_STR.
Referenced by FreeDiskSpaceMB(), cVideoDirectory::FreeMB(), and cRecorder::RunningLowOnDiskSpace().
| const char * GetHostName | ( | void | ) |
Gets the host name of this machine.
Definition at line 1456 of file tools.c.
References GetHostName(), and LOG_ERROR.
Referenced by cSetup::cSetup(), GetHostName(), and cSetup::Save().
| cString Indent | ( | int | n, |
| const char * | s ) |
Returns the given string s, preceeded with n blanks for indentation.
Definition at line 440 of file tools.c.
References Indent(), and cString::sprintf().
Referenced by Indent(), cMenuSetupMisc::Set(), cMenuSetupDVB::Setup(), cMenuSetupEPG::Setup(), and cNestedItemList::Write().
| bool isempty | ( | const char * | s | ) |
Definition at line 387 of file tools.c.
References isempty(), and skipspace().
Referenced by cPluginManager::Active(), cMenuEditFolder::cMenuEditFolder(), cRecording::cRecording(), cRecording::cRecording(), cTimer::cTimer(), cMenuFolder::Delete(), cMenuFolder::DescendPath(), cOsdMenu::Display(), cEvent::Dump(), cMenuCommands::Execute(), cTheme::FileNameOk(), cEvent::FixEpgBugs(), cSource::FromString(), tComponent::FromString(), isempty(), cRecording::IsInPath(), cConfig< T >::Load(), cTheme::Load(), MakePatternFileName(), cChannel::Name(), cNestedItemList::Parse(), cSkins::QueueMessage(), cArgs::ReadDirectory(), cMenuFolder::Select(), cMenuCam::Set(), cMenuFolder::Set(), cComponents::SetComponent(), cSkinClassicDisplayMenu::SetEvent(), cSkinCursesDisplayMenu::SetEvent(), cSkinLCARSDisplayMenu::SetEvent(), cSkinSTTNGDisplayMenu::SetEvent(), cTimer::SetFile(), cMenuEditTimer::SetFolder(), cChannel::SetName(), cChannel::SetPortalName(), cSkinClassicDisplayMenu::SetRecording(), cSkinCursesDisplayMenu::SetRecording(), cSkinLCARSDisplayMenu::SetRecording(), cSkinSTTNGDisplayMenu::SetRecording(), cChannel::ShortName(), and cChannel::ToText().
| bool isnumber | ( | const char * | s | ) |
Definition at line 402 of file tools.c.
References isnumber().
Referenced by cSVDRPServer::CmdAUDI(), cSVDRPServer::CmdCHAN(), cSVDRPServer::CmdCLRE(), cSVDRPServer::CmdDELC(), cSVDRPServer::CmdDELR(), cSVDRPServer::CmdDELT(), cSVDRPServer::CmdEDIT(), cSVDRPServer::CmdGRAB(), cSVDRPServer::CmdLSTC(), cSVDRPServer::CmdLSTE(), cSVDRPServer::CmdLSTR(), cSVDRPServer::CmdLSTT(), cSVDRPServer::CmdMOVR(), cSVDRPServer::CmdPLAY(), cSVDRPServer::CmdPRIM(), cSVDRPServer::CmdVOLU(), isnumber(), main(), cCamResponse::Parse(), cTimer::Parse(), and SetUser().
| cString itoa | ( | int | n | ) |
Definition at line 485 of file tools.c.
References itoa().
Referenced by cDisplaySubtitleTracks::cDisplaySubtitleTracks(), cDisplayTracks::cDisplayTracks(), DrawDeviceData(), cSkinLCARSDisplayMenu::DrawDisk(), DrawEllipseAlignments(), cSkinLCARSDisplayMenu::DrawLive(), cSkinLCARSDisplayMenu::DrawTimers(), itoa(), cMenuTimerItem::Set(), cResumeFile::SetFileName(), cTimer::ToText(), and cRecordingInfo::Write().
|
static |
Definition at line 1374 of file tools.c.
References esyslog, JpegCompressEmptyOutputBuffer(), JPEGCOMPRESSMEM, tJpegCompressData::mem, and tJpegCompressData::size.
Referenced by JpegCompressEmptyOutputBuffer(), and RgbToJpeg().
|
static |
Definition at line 1365 of file tools.c.
References JpegCompressInitDestination(), JPEGCOMPRESSMEM, MALLOC, tJpegCompressData::mem, and tJpegCompressData::size.
Referenced by JpegCompressInitDestination(), and RgbToJpeg().
|
static |
Definition at line 1397 of file tools.c.
References esyslog, JpegCompressTermDestination(), tJpegCompressData::mem, and tJpegCompressData::size.
Referenced by JpegCompressTermDestination(), and RgbToJpeg().
| time_t LastModifiedTime | ( | const char * | FileName | ) |
Definition at line 774 of file tools.c.
References LastModifiedTime().
Referenced by cIndexFile::cIndexFile(), LastModifiedTime(), cRecordings::NeedsUpdate(), cMarks::Save(), cRecording::SetDeleted(), and cMarks::Update().
| bool MakeDirs | ( | const char * | FileName, |
| bool | IsDirectory ) |
Definition at line 542 of file tools.c.
References dsyslog, LOG_ERROR_STR, and MakeDirs().
Referenced by cPlugin::CacheDirectory(), cRecording::ChangeName(), cPlugin::ConfigDirectory(), cRecordControl::cRecordControl(), MakeDirs(), cPlugin::ResourceDirectory(), cThemes::SetThemesDirectory(), and cCutter::Start().
| int numdigits | ( | int | n | ) |
| char * ReadLink | ( | const char * | FileName | ) |
returns a new string allocated on the heap, which the caller must delete (or NULL in case of an error)
Definition at line 714 of file tools.c.
References LOG_ERROR_STR, and ReadLink().
Referenced by cSafeFile::cSafeFile(), and ReadLink().
| bool RemoveEmptyDirectories | ( | const char * | DirName, |
| bool | RemoveThis = false, | ||
| const char * | IgnoreFiles[] = NULL ) |
Removes all empty directories under the given directory DirName.
If RemoveThis is true, DirName will also be removed if it is empty. IgnoreFiles can be set to an array of file names that will be ignored when considering whether a directory is empty. If IgnoreFiles is given, the array must end with a NULL pointer.
Definition at line 628 of file tools.c.
References AddDirectory(), dsyslog, LOG_ERROR_STR, cReadDir::Next(), cReadDir::Ok(), RemoveEmptyDirectories(), and StrInArray().
Referenced by cVideoDirectory::Cleanup(), and RemoveEmptyDirectories().
| bool RemoveFileOrDir | ( | const char * | FileName, |
| bool | FollowSymlinks ) |
Definition at line 570 of file tools.c.
References AddDirectory(), dsyslog, LOG_ERROR_STR, MALLOC, cReadDir::Next(), cReadDir::Ok(), and RemoveFileOrDir().
Referenced by cVideoDirectory::Remove(), and RemoveFileOrDir().
Converts the given Memory to a JPEG image and returns a pointer to the resulting image.
Mem must point to a data block of exactly (Width * Height) triplets of RGB image data bytes. Upon return, Size will hold the number of bytes of the resulting JPEG data. Quality can be in the range 0..100 and controls the quality of the resulting image, where 100 is "best". The caller takes ownership of the result and has to delete it once it is no longer needed. The result may be NULL in case of an error.
Definition at line 1413 of file tools.c.
References JpegCompressEmptyOutputBuffer(), JpegCompressInitDestination(), JpegCompressTermDestination(), tJpegCompressData::mem, RgbToJpeg(), and tJpegCompressData::size.
Referenced by RgbToJpeg(), and cSubtitleDebug::WriteJpeg().
| ssize_t safe_read | ( | int | filedes, |
| void * | buffer, | ||
| size_t | size ) |
Definition at line 50 of file tools.c.
References dsyslog, and safe_read().
Referenced by cDirCopier::Action(), cLircUsrRemote::Action(), cIndexFile::CatchUp(), cIndexFile::cIndexFile(), cPesIndex::Load(), cSVDRPClient::Process(), cSVDRPServer::Process(), cDvbCiAdapter::Read(), cPesFile::Read(), cPesResume::Read(), cResumeFile::Read(), cRingBufferLinear::Read(), cUnbufferedFile::Read(), cDevice::ReadFilter(), cKbdRemote::ReadKey(), and safe_read().
| ssize_t safe_write | ( | int | filedes, |
| const void * | buffer, | ||
| size_t | size ) |
Definition at line 62 of file tools.c.
References dsyslog, and safe_write().
Referenced by cDirCopier::Action(), cSVDRPServer::CmdGRAB(), cDevice::GrabImageFile(), safe_write(), cResumeFile::Save(), cSVDRPClient::Send(), cSVDRPServer::Send(), cDvbCiAdapter::Write(), cIndexFile::Write(), cUnbufferedFile::Write(), and writechar().
| cString ShortDateString | ( | time_t | t | ) |
Converts the given time to a string of the form "dd.mm.yy".
Definition at line 1339 of file tools.c.
References ShortDateString().
Referenced by cSkinLCARSDisplayMenu::DrawPlay(), cSkinLCARSDisplayReplay::SetRecording(), and ShortDateString().
| bool SpinUpDisk | ( | const char * | FileName | ) |
Definition at line 728 of file tools.c.
References DirectoryOk(), dsyslog, esyslog, LOG_ERROR_STR, SpinUpDisk(), and cString::sprintf().
Referenced by cSpinUpDisk::Action(), cRecorder::cRecorder(), and SpinUpDisk().
| bool startswith | ( | const char * | s, |
| const char * | p ) |
Definition at line 367 of file tools.c.
References startswith().
Referenced by cSVDRPServer::CmdLSTC(), cSocket::Discover(), cTimer::Matches(), MatchPattern(), cArgs::ReadDirectory(), cTimer::SpawnPatternTimer(), and startswith().
| const char * strchrn | ( | const char * | s, |
| char | c, | ||
| size_t | n ) |
returns a pointer to the n'th occurrence (counting from 1) of c in s, or NULL if no such character was found. If n is 0, s is returned.
Definition at line 183 of file tools.c.
References strchrn().
Referenced by cMenuRecordings::Info(), and strchrn().
| int strcountchr | ( | const char * | s, |
| char | c ) |
returns the number of occurrences of 'c' in 's'.
Definition at line 196 of file tools.c.
References strcountchr().
Referenced by strcountchr().
| char * strcpyrealloc | ( | char * | dest, |
| const char * | src ) |
Definition at line 111 of file tools.c.
References esyslog, max(), and strcpyrealloc().
Referenced by cEvent::FixEpgBugs(), cChannel::operator=(), cChannel::Parse(), cMenuEditChannel::ProcessKey(), cComponents::SetComponent(), cEvent::SetDescription(), cChannel::SetName(), cChannel::SetPortalName(), cEvent::SetShortText(), cEvent::SetTitle(), and strcpyrealloc().
| cString strescape | ( | const char * | s, |
| const char * | chars ) |
Definition at line 310 of file tools.c.
References cString::cString(), MALLOC, and strescape().
Referenced by cShutdownHandler::CallShutdownCommand(), cMenuRecordings::Commands(), cRecordingUserCommand::InvokeCommand(), and strescape().
| cString strgetbefore | ( | const char * | s, |
| char | c, | ||
| int | n ) |
Definition at line 208 of file tools.c.
References cString::cString(), and strgetbefore().
Referenced by cVideoDirectory::Move(), and strgetbefore().
| const char * strgetlast | ( | const char * | s, |
| char | c ) |
Definition at line 218 of file tools.c.
References strgetlast().
Referenced by cRecording::BaseName(), cRecording::cRecording(), cRecording::IsEdited(), cTimer::Matches(), cMenuEditTimer::SetFolder(), cMenuEditTimer::SetPatternItem(), cRecordControl::Stop(), strgetlast(), and strgetlast().
| cString strgetval | ( | const char * | s, |
| const char * | name, | ||
| char | d = '=' ) |
Returns the value part of a 'name=value' pair in s.
name must either be at the beginning of s, or has to be preceded by white space. There may be any number of white space around the '=' sign. The value is everything up to (and excluding) the next white space, or the end of s. If an other delimiter shall be used (like, e.g., ':'), it can be given as the third parameter. If name occurs more than once in s, only the first occurrence is taken.
Definition at line 333 of file tools.c.
References cString::cString(), skipspace(), and strgetval().
Referenced by cSVDRPServerParams::cSVDRPServerParams(), cSocket::Discover(), and strgetval().
| bool StrInArray | ( | const char * | a[], |
| const char * | s ) |
Returns true if the string s is equal to one of the strings pointed to by the (NULL terminated) array a.
Definition at line 428 of file tools.c.
References StrInArray().
Referenced by RemoveEmptyDirectories(), and StrInArray().
| char * stripspace | ( | char * | s | ) |
Definition at line 224 of file tools.c.
References stripspace().
Referenced by GetRecordingTimerId(), cConfig< T >::Load(), cMenuCommands::Parse(), cNestedItemList::Parse(), cTextWrapper::Set(), stripspace(), and cRecording::Title().
| char * strn0cpy | ( | char * | dest, |
| const char * | src, | ||
| size_t | n ) |
Definition at line 128 of file tools.c.
References strn0cpy().
Referenced by cLircUsrRemote::Action(), cDvbFrontend::cDvbFrontend(), cEIT::cEIT(), cStateLockLog::Check(), cLircUsrRemote::cLircUsrRemote(), cMenuEditChannel::cMenuEditChannel(), cMenuEditFolder::cMenuEditFolder(), cMenuEditTimer::cMenuEditTimer(), cMenuPathEdit::cMenuPathEdit(), cMenuRecordingEdit::cMenuRecordingEdit(), cMenuSetupPictures::cMenuSetupPictures(), cRecordingInfo::cRecordingInfo(), cSetup::cSetup(), cSkinLCARSDisplayChannel::DrawTrack(), cSkinLCARSDisplayReplay::DrawTrack(), cStateLockLog::Dump(), cSkinSTTNGDisplayChannel::Flush(), cChannel::Parse(), cMenuCommands::Parse(), cSetup::Parse(), cTimer::Parse(), cSetup::ParseLanguages(), cPatPmtParser::ParsePmt(), cPatFilter::Process(), cPluginPictures::ProcessArgs(), cMenuSetupOSD::ProcessKey(), cMenuRecordingEdit::RemoveName(), cMenuEditStrlItem::Set(), cPatPmtMaker::SetApid(), cDevice::SetAvailableTrack(), cComponents::SetComponent(), cPatPmtMaker::SetDpid(), cMenuEditTimer::SetFolder(), cMenuPathEdit::SetFolder(), cMenuRecordingEdit::SetFolder(), cEvent::SetLanguage(), cSkinClassicDisplayReplay::SetMode(), cSkinCursesDisplayReplay::SetMode(), cMenuEditTimer::SetPatternItem(), cChannel::SetPids(), cPatPmtMaker::SetSpid(), cPluginPictures::SetupParse(), cMenuSetupPictures::Store(), strn0cpy(), cRecording::Title(), Utf8Strn0Cpy(), and WeekDayName().
| char * strreplace | ( | char * | s, |
| char | c1, | ||
| char | c2 ) |
Definition at line 139 of file tools.c.
References strreplace().
Referenced by AddRecordingFolders(), cRecording::cRecording(), cSetupLine::cSetupLine(), dtoa(), cEvent::Dump(), cEvent::FixEpgBugs(), cFont::GetAvailableFontNames(), cFont::GetFontFileName(), HandleUnderscores(), MakePatternFileName(), cChannel::Parse(), cEvent::Parse(), cTimer::Parse(), cRecording::SortName(), strreplace(), strreplace(), cChannel::ToText(), and cTimer::ToText().
| char * strreplace | ( | char * | s, |
| const char * | s1, | ||
| const char * | s2 ) |
re-allocates 's' and deletes the original string if necessary!
Definition at line 152 of file tools.c.
References esyslog, and strreplace().
| char * strshift | ( | char * | s, |
| int | n ) |
Shifts the given string to the left by the given number of bytes, thus removing the first n bytes from s.
If n is greater than the length of s, the resulting string will be empty. If n is <= 0 s will be unchanged. Returns s.
Definition at line 355 of file tools.c.
References strshift().
Referenced by cSVDRPClient::GetRemoteTimers(), and strshift().
| int64_t StrToNum | ( | const char * | s | ) |
Converts the given string to a number.
The numerical part of the string may be followed by one of the letters K, M, G or T to abbreviate Kilo-, Mega-, Giga- or Terabyte, respectively (based on 1024). Everything after the first non-numeric character is silently ignored, as are any characters other than the ones mentioned here.
Definition at line 413 of file tools.c.
References StrToNum().
Referenced by main(), and StrToNum().
| char * strtrim | ( | char * | s, |
| bool | Shift = false ) |
Returns a pointer to the first non white space character in s.
If s contains trailing white space, it is stripped by inserting a null character. If Shift is true and there is leading white space, the result is shifted towards s.
Definition at line 236 of file tools.c.
References strtrim().
Referenced by compactspace(), cMenuEditStrItem::LeaveEditMode(), cDll::Load(), cTheme::Load(), cNestedItemList::Parse(), cArgs::ReadDirectory(), and strtrim().
| void syslog_with_tid | ( | int | priority, |
| const char * | format, | ||
| ... ) |
Definition at line 33 of file tools.c.
References syslog_with_tid(), cThread::ThreadId(), and cString::vsprintf().
Referenced by syslog_with_tid(), and syslog_with_tid().
| cString TimeString | ( | time_t | t | ) |
Converts the given time to a string of the form "hh:mm".
Definition at line 1348 of file tools.c.
References TimeString().
Referenced by cTimer::AdjustSpawnedTimer(), cEIT::cEIT(), cSkinLCARSDisplayMenu::DrawPlay(), cSkinLCARSDisplayMenu::DrawTimer(), cEvent::GetEndTimeString(), cEvent::GetTimeString(), cSkinClassicDisplayMenu::SetRecording(), cSkinCursesDisplayMenu::SetRecording(), cSkinLCARSDisplayMenu::SetRecording(), cSkinLCARSDisplayReplay::SetRecording(), cSkinSTTNGDisplayMenu::SetRecording(), cPluginSvdrpdemo::SVDRPCommand(), and TimeString().
| cString TimeToString | ( | time_t | t | ) |
Converts the given time to a string of the form "www mmm dd hh:mm:ss yyyy".
Definition at line 1318 of file tools.c.
References TimeToString().
Referenced by cSVDRPServer::CmdNEXT(), cSVDRPServer::cSVDRPServer(), cTDT::cTDT(), cShutdownHandler::DoShutdown(), cTsChecker::Report(), and TimeToString().
| void TouchFile | ( | const char * | FileName, |
| bool | Create ) |
Definition at line 760 of file tools.c.
References isyslog, LOG_ERROR_STR, and TouchFile().
Referenced by cRecording::Delete(), TouchFile(), and cRecordings::TouchUpdate().
| uint Utf8CharGet | ( | const char * | s, |
| int | Length = 0 ) |
Returns the UTF-8 symbol at the beginning of the given string.
Length can be given from a previous call to Utf8CharLen() to avoid calculating it again. If no Length is given, Utf8CharLen() will be called.
Definition at line 888 of file tools.c.
References cCharSetConv::SystemCharacterTable(), SystemToUtf8, Utf8CharGet(), and Utf8CharLen().
Referenced by cFreetypeFont::DrawText(), cFreetypeFont::DrawText(), cKbdRemote::ReadKeySequence(), cTextWrapper::Set(), cCharSetConv::SetSystemCharacterTable(), Utf8CharGet(), Utf8ToArray(), and cFreetypeFont::Width().
| int Utf8CharLen | ( | const char * | s | ) |
Returns the number of character bytes at the beginning of the given string that form a UTF-8 symbol.
Definition at line 874 of file tools.c.
References MT, cCharSetConv::SystemCharacterTable(), and Utf8CharLen().
Referenced by cFreetypeFont::DrawText(), cFreetypeFont::DrawText(), LimitNameLengths(), cTimer::PrintDay(), cTextWrapper::Set(), cCharSetConv::SetSystemCharacterTable(), StripControlCharacters(), Utf8CharGet(), Utf8CharLen(), Utf8StrLen(), Utf8Strn0Cpy(), Utf8SymChars(), Utf8ToArray(), and cFreetypeFont::Width().
| int Utf8CharSet | ( | uint | c, |
| char * | s = NULL ) |
Converts the given UTF-8 symbol to a sequence of character bytes and copies them to the given string.
Returns the number of bytes written. If no string is given, only the number of bytes is returned and nothing is copied.
Definition at line 903 of file tools.c.
References cCharSetConv::SystemCharacterTable(), and Utf8CharSet().
Referenced by Utf8CharSet(), and Utf8FromArray().
| int Utf8FromArray | ( | const uint * | a, |
| char * | s, | ||
| int | Size, | ||
| int | Max = -1 ) |
Converts the given array of UTF-8 symbols (including the terminating 0) into a sequence of character bytes of at most Size length.
Returns the number of character bytes written (without the terminating 0). If Max is given, only that many symbols will be converted. The resulting string is always zero-terminated if Size is big enough.
Definition at line 1003 of file tools.c.
References cCharSetConv::SystemCharacterTable(), Utf8CharSet(), and Utf8FromArray().
Referenced by cMenuEditStrItem::LeaveEditMode(), cMenuEditStrItem::Set(), and Utf8FromArray().
| int Utf8StrLen | ( | const char * | s | ) |
Returns the number of UTF-8 symbols formed by the given string of character bytes.
Definition at line 950 of file tools.c.
References cCharSetConv::SystemCharacterTable(), Utf8CharLen(), and Utf8StrLen().
Referenced by cSkinCursesDisplayChannel::Flush(), cSkinCursesDisplayMenu::Flush(), cChannels::MaxChannelNameLength(), cChannels::MaxShortChannelNameLength(), cSkinCursesDisplayReplay::SetCurrent(), cSkinCursesDisplayMenu::SetEvent(), cSkinCursesDisplayMenu::SetRecording(), cSkinCursesDisplayReplay::SetTotal(), cSkinCursesDisplayVolume::SetVolume(), Utf8StrLen(), and cCursesFont::Width().
| char * Utf8Strn0Cpy | ( | char * | Dest, |
| const char * | Src, | ||
| int | n ) |
Copies at most n character bytes from Src to Dest, making sure that the resulting copy ends with a complete UTF-8 symbol.
The copy is guaranteed to be zero terminated. Returns a pointer to Dest.
Definition at line 962 of file tools.c.
References strn0cpy(), cCharSetConv::SystemCharacterTable(), Utf8CharLen(), and Utf8Strn0Cpy().
Referenced by cTimer::cTimer(), cSetup::Parse(), cTimer::Parse(), cMenuSetupOSD::ProcessKey(), cDevice::SetAvailableTrack(), cTimer::SetFile(), cTimer::SetPattern(), and Utf8Strn0Cpy().
| int Utf8SymChars | ( | const char * | s, |
| int | Symbols ) |
Returns the number of character bytes at the beginning of the given string that form at most the given number of UTF-8 symbols.
Definition at line 937 of file tools.c.
References cCharSetConv::SystemCharacterTable(), Utf8CharLen(), and Utf8SymChars().
Referenced by cMenuScheduleItem::Update(), Utf8SymChars(), and WeekDayName().
| int Utf8ToArray | ( | const char * | s, |
| uint * | a, | ||
| int | Size ) |
Converts the given character bytes (including the terminating 0) into an array of UTF-8 symbols of the given Size.
Returns the number of symbols in the array (without the terminating 0).
Definition at line 985 of file tools.c.
References cCharSetConv::SystemCharacterTable(), Utf8CharGet(), Utf8CharLen(), and Utf8ToArray().
Referenced by cMenuEditStrItem::EnterEditMode(), and Utf8ToArray().
| cString WeekDayName | ( | int | WeekDay | ) |
Converts the given WeekDay (0=Sunday, 1=Monday, ...) to a three letter day name.
Definition at line 1265 of file tools.c.
References min(), strn0cpy(), tr, Utf8SymChars(), and WeekDayName().
Referenced by DateString(), DayDateTime(), cSkinLCARSDisplayMenu::DrawTimer(), cMenuEditDateItem::Set(), cMenuTimerItem::Set(), WeekDayName(), and WeekDayName().
| cString WeekDayName | ( | time_t | t | ) |
Converts the week day of the given time to a three letter day name.
Definition at line 1280 of file tools.c.
References WeekDayName().
| cString WeekDayNameFull | ( | int | WeekDay | ) |
Converts the given WeekDay (0=Sunday, 1=Monday, ...) to a full day name.
Definition at line 1286 of file tools.c.
References tr, and WeekDayNameFull().
Referenced by WeekDayNameFull(), and WeekDayNameFull().
| cString WeekDayNameFull | ( | time_t | t | ) |
Converts the week day of the given time to a full day name.
Definition at line 1301 of file tools.c.
References WeekDayNameFull().
| int WriteAllOrNothing | ( | int | fd, |
| const uchar * | Data, | ||
| int | Length, | ||
| int | TimeoutMs = 0, | ||
| int | RetryMs = 0 ) |
Writes either all Data to the given file descriptor, or nothing at all.
If TimeoutMs is greater than 0, it will only retry for that long, otherwise it will retry forever. RetryMs defines the time between two retries.
Definition at line 87 of file tools.c.
References cTimeMs::Elapsed(), FATALERRNO, cPoller::Poll(), and WriteAllOrNothing().
Referenced by WriteAllOrNothing().
| void writechar | ( | int | filedes, |
| char | c ) |
Definition at line 82 of file tools.c.
References safe_write(), and writechar().
Referenced by cIndexFile::cIndexFile(), and writechar().
| cListGarbageCollector ListGarbageCollector |
Definition at line 2164 of file tools.c.
Referenced by cListBase::Del(), and main().
|
static |
Definition at line 872 of file tools.c.
Referenced by cCharSetConv::SetSystemCharacterTable(), and Utf8CharGet().