summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-10-10 13:13:30 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2013-10-10 13:13:30 +0200
commit2bdb599fbcfea5bac49fcf5550cd0fd1bc328d4a (patch)
tree88e9d6c0b7505f1c4d9374c26a4c3ee27dd6ee90 /tools.c
parent3971cc6e8845f2a70018b20706f4a30d71edd41d (diff)
downloadvdr-2bdb599fbcfea5bac49fcf5550cd0fd1bc328d4a.tar.gz
vdr-2bdb599fbcfea5bac49fcf5550cd0fd1bc328d4a.tar.bz2
Added renaming and moving recordings and folders, and editing a recording's priority and lifetime; added cutting queue
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/tools.c b/tools.c
index f690fb8a..a2055ec8 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 3.1 2013/05/23 10:10:00 kls Exp $
+ * $Id: tools.c 3.2 2013/09/22 13:19:19 kls Exp $
*/
#include "tools.h"
@@ -173,6 +173,31 @@ char *strreplace(char *s, const char *s1, const char *s2)
return s;
}
+const char *strchrn(const char *s, char c, size_t n)
+{
+ if (n == 0)
+ return s;
+ if (s) {
+ for ( ; *s; s++) {
+ if (*s == c && --n == 0)
+ return s;
+ }
+ }
+ return NULL;
+}
+
+int strcountchr(const char *s, char c)
+{
+ int n = 0;
+ if (s && c) {
+ for ( ; *s; s++) {
+ if (*s == c)
+ n++;
+ }
+ }
+ return n;
+}
+
char *stripspace(char *s)
{
if (s && *s) {
@@ -202,6 +227,30 @@ char *compactspace(char *s)
return s;
}
+char *compactchars(char *s, char c)
+{
+ if (s && *s && c) {
+ char *t = s;
+ char *p = s;
+ int n = 0;
+ while (*p) {
+ if (*p != c) {
+ *t++ = *p;
+ n = 0;
+ }
+ else if (t != s && n == 0) {
+ *t++ = *p;
+ n++;
+ }
+ p++;
+ }
+ if (n)
+ t--; // the last character was c
+ *t = 0;
+ }
+ return s;
+}
+
cString strescape(const char *s, const char *chars)
{
char *buffer;
@@ -970,6 +1019,20 @@ cString::cString(const char *S, bool TakePointer)
s = TakePointer ? (char *)S : S ? strdup(S) : NULL;
}
+cString::cString(const char *S, const char *To)
+{
+ if (!S)
+ s = NULL;
+ else if (!To)
+ s = strdup(S);
+ else {
+ int l = To - S;
+ s = MALLOC(char, l + 1);
+ strncpy(s, S, l);
+ s[l] = 0;
+ }
+}
+
cString::cString(const cString &String)
{
s = String.s ? strdup(String.s) : NULL;
@@ -1008,6 +1071,12 @@ cString &cString::Truncate(int Index)
return *this;
}
+cString &cString::CompactChars(char c)
+{
+ compactchars(s, c);
+ return *this;
+}
+
cString cString::sprintf(const char *fmt, ...)
{
va_list ap;