summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2015-05-22 13:44:43 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2015-05-22 13:44:43 +0200
commitc3b03475569b7a59186b5a30c09325a4b3408cbe (patch)
tree38fa011cc6c2ca151a6233d4ec8308288cf11be1 /tools.c
parent2b9e988dd563d66a8a341a359d17c51032cbca40 (diff)
downloadvdr-c3b03475569b7a59186b5a30c09325a4b3408cbe.tar.gz
vdr-c3b03475569b7a59186b5a30c09325a4b3408cbe.tar.bz2
Implemented SVDRP peering
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/tools.c b/tools.c
index 5418f5e2..d8e4ac7d 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.4 2015/02/07 16:07:22 kls Exp $
+ * $Id: tools.c 4.1 2015/05/11 14:15:15 kls Exp $
*/
#include "tools.h"
@@ -274,6 +274,28 @@ cString strescape(const char *s, const char *chars)
return cString(s, t != NULL);
}
+cString strgetval(const char *s, const char *name, char d)
+{
+ if (s && name) {
+ int l = strlen(name);
+ const char *t = s;
+ while (const char *p = strstr(t, name)) {
+ t = skipspace(p + l);
+ if (p == s || *(p - 1) <= ' ') {
+ if (*t == d) {
+ t = skipspace(t + 1);
+ const char *v = t;
+ while (*t > ' ')
+ t++;
+ return cString(v, t);
+ break;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
bool startswith(const char *s, const char *p)
{
while (*p) {
@@ -1061,6 +1083,17 @@ cString &cString::operator=(const char *String)
return *this;
}
+cString &cString::Append(const char *String)
+{
+ int l1 = strlen(s);
+ int l2 = strlen(String);
+ char *p = (char *)realloc(s, l1 + l2 + 1);
+ if (p != s)
+ strcpy(p, s);
+ strcpy(p + l1, String);
+ return *this;
+}
+
cString &cString::Truncate(int Index)
{
int l = strlen(s);
@@ -1440,6 +1473,19 @@ bool cPoller::Add(int FileHandle, bool Out)
return false;
}
+void cPoller::Del(int FileHandle, bool Out)
+{
+ if (FileHandle >= 0) {
+ for (int i = 0; i < numFileHandles; i++) {
+ if (pfd[i].fd == FileHandle && pfd[i].events == (Out ? POLLOUT : POLLIN)) {
+ if (i < numFileHandles - 1)
+ memmove(&pfd[i], &pfd[i + 1], (numFileHandles - i - 1) * sizeof(pollfd));
+ numFileHandles--;
+ }
+ }
+ }
+}
+
bool cPoller::Poll(int TimeoutMs)
{
if (numFileHandles) {