Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] [Patch] Threadsafe (poison) patch for wapd 0.0.6d
Nobody else seems to have done a patch for this yet, so here's my
effort. It seems to work OK, but I never noticed any symptoms with the
pre-poisoned code anyway.
Is there a similar patch to provide access via a web browser? The only
WML browser I could find for Linux is wApua which is a bit primitive.
One problem I have is that I get asked for a password for every page,
instead of just once. Is that a limitation with the plugin or the
browser?
--
TH * http://www.realh.co.uk
--- server.c.orig 2004-12-06 21:54:16.000000000 +0000
+++ server.c 2004-12-06 21:56:31.000000000 +0000
@@ -124,11 +124,12 @@
{
time_t now;
char timebuf[100];
+ struct tm gmt;
Reply("%s %d %s\n", PROTOCOL, status, title);
Reply("Server: %s\n", SERVER_NAME);
now = time((time_t*)0);
- strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&now));
+ strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime_r(&now, &gmt));
Reply("Date: %s\n", timebuf);
if (mime_type != NULL)
Reply("Content-Type: %s\n", mime_type);
@@ -332,6 +333,7 @@
{
time_t base = time(NULL);
char *totext = NULL;
+ char *tokbuf = NULL;
char *name = NULL;;
char *frequency = NULL;
char *parameters = NULL;
@@ -353,19 +355,20 @@
channel = Channels.GetByNumber(channel_nr);
if (channel) {
totext = strdup(channel->ToText());
- name = strtok(totext, ":");
- frequency = strtok(NULL, ":");
- parameters = strtok(NULL, ":");
- source = strtok(NULL, ":");
- srate = strtok(NULL, ":");
- vpid = strtok(NULL, ":");
- apid = strtok(NULL, ":");
- tpid = strtok(NULL, ":");
- ca = strtok(NULL, ":");
- sid = strtok(NULL, ":");
- nid = strtok(NULL, ":");
- tid = strtok(NULL, ":");
- rid = strtok(NULL, "\n");
+ tokbuf = new char[strlen(totext) + 1];
+ name = strtok_r(totext, ":", &tokbuf);
+ frequency = strtok_r(NULL, ":", &tokbuf);
+ parameters = strtok_r(NULL, ":", &tokbuf);
+ source = strtok_r(NULL, ":", &tokbuf);
+ srate = strtok_r(NULL, ":", &tokbuf);
+ vpid = strtok_r(NULL, ":", &tokbuf);
+ apid = strtok_r(NULL, ":", &tokbuf);
+ tpid = strtok_r(NULL, ":", &tokbuf);
+ ca = strtok_r(NULL, ":", &tokbuf);
+ sid = strtok_r(NULL, ":", &tokbuf);
+ nid = strtok_r(NULL, ":", &tokbuf);
+ tid = strtok_r(NULL, ":", &tokbuf);
+ rid = strtok_r(NULL, "\n", &tokbuf);
}
}
}
@@ -423,6 +426,7 @@
wmltr("Save"),
base, base, base, base, base, base, base, base, base, base, base, base, base);
free(totext);
+ delete[] tokbuf;
}
void cWapServer::EditTimer(void)
@@ -517,13 +521,15 @@
Reply("%s" WML_BR(), title);
if (recording->Summary()) {
char *sum = wmlescape(strdup(recording->Summary()));
- char *subtitle = strtok(sum, "\n");
- subtitle = strtok(NULL, "\n");
- char *description = strtok(NULL, "\n");
+ char *tokbuf = new char[strlen(sum) + 1];
+ char *subtitle = strtok_r(sum, "\n", &tokbuf);
+ subtitle = strtok_r(NULL, "\n", &tokbuf);
+ char *description = strtok_r(NULL, "\n", &tokbuf);
Reply("%s" WML_BR() "%s",
subtitle ? subtitle : wmltr("no subtitle"),
description ? description : wmltr("no description"));
free(sum);
+ delete[] tokbuf;
}
else
Reply(wmltr("No summary available."));
@@ -944,9 +950,10 @@
int level = recording->HierarchyLevels();
if (i >= offset && i < (offset + MAXLINES)) {
char *rec = wmlescape(strdup(recording->Title('|', true, level)));
- char *date = strtok(rec, "|");
- char *time = strtok(NULL, "|");
- char *title = strtok(NULL, "|");
+ char *tokbuf = new char[strlen(rec) + 1];
+ char *date = strtok_r(rec, "|", &tokbuf);
+ char *time = strtok_r(NULL, "|", &tokbuf);
+ char *title = strtok_r(NULL, "|", &tokbuf);
Reply("%s %s" WML_BR() ". " WML_A(URI_EDITRECORDING "/?id=%d", "%s") "%s",
date ? date : "-",
time ? time : "-",
@@ -954,6 +961,7 @@
title ? title : "-",
(i + 1) < (offset + MAXLINES) && Recordings.Next(recording) ? WML_BR() : "");
free(rec);
+ delete[] tokbuf;
}
recording = Recordings.Next(recording);
i++;
Home |
Main Index |
Thread Index