diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2020-12-26 15:49:01 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2020-12-26 15:49:01 +0100 |
commit | 2b3556b460665d9a4036b1623e7e7ff5ff6d37d8 (patch) | |
tree | bee99e68a196ba076440ad6516b5a0149996b6f2 /tools.h | |
parent | d2e0087c4e13b2acbecc4bafb3cb2ab656c95339 (diff) | |
download | vdr-2b3556b460665d9a4036b1623e7e7ff5ff6d37d8.tar.gz vdr-2b3556b460665d9a4036b1623e7e7ff5ff6d37d8.tar.bz2 |
Implemented "Pattern Timers"2.5.1
Diffstat (limited to 'tools.h')
-rw-r--r-- | tools.h | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 4.18 2020/09/16 13:48:33 kls Exp $ + * $Id: tools.h 5.1 2020/12/26 15:49:01 kls Exp $ */ #ifndef __TOOLS_H @@ -193,6 +193,33 @@ public: static cString vsprintf(const char *fmt, va_list &ap); }; +class cNullTerminate { +private: + char *p; + char c; +public: + cNullTerminate(void) { + p = NULL; + c = 0; + } + cNullTerminate(char *s) { + Set(s); + } + ~cNullTerminate() { + if (p) + *p = c; + } + void Set(char *s) { + if (s) { + p = s; + c = *s; + *s = 0; + } + else + p = NULL; + } + }; + 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); @@ -206,6 +233,7 @@ 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! 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. int strcountchr(const char *s, char c); ///< returns the number of occurrences of 'c' in 's'. +const char *strgetlast(const char *s, char c); // returns the part of 's' after the last occurrence of 'c', or 's' if there is no 'c'. inline char *skipspace(const char *s) { if ((uchar)*s > ' ') // most strings don't have any leading space, so handle this case as fast as possible |