1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
/*
* tools.c: The 'EnigmaNG' VDR skin
*
* See the README file for copyright information and how to reach the author.
*
*/
#include <sstream>
#ifndef __STL_CONFIG_H
#define __STL_CONFIG_H
#endif
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "i18n.h"
#include "tools.h"
using namespace std;
#define AUX_HEADER_EPGSEARCH "EPGSearch: "
#define AUX_TAGS_EPGSEARCH_START "<epgsearch>"
#define AUX_TAGS_EPGSEARCH_ITEM_1A_START "<Channel>"
#define AUX_TAGS_EPGSEARCH_ITEM_1A_END "</Channel>"
#define AUX_TAGS_EPGSEARCH_ITEM_2A_START "<Search timer>"
#define AUX_TAGS_EPGSEARCH_ITEM_2A_END "</Search timer>"
#define AUX_TAGS_EPGSEARCH_ITEM_1B_START "<update>"
#define AUX_TAGS_EPGSEARCH_ITEM_1B_END "</update>"
#define AUX_TAGS_EPGSEARCH_ITEM_2B_START "<eventid>"
#define AUX_TAGS_EPGSEARCH_ITEM_2B_END "</eventid>"
#define AUX_TAGS_EPGSEARCH_END "</epgsearch>"
#define AUX_HEADER_VDRADMIN "VDRAdmin-AM: "
#define AUX_TAGS_VDRADMIN_START "<vdradmin-am>"
#define AUX_TAGS_VDRADMIN_ITEM1_START "<pattern>"
#define AUX_TAGS_VDRADMIN_ITEM1_END "</pattern>"
#define AUX_TAGS_VDRADMIN_END "</vdradmin-am>"
#define AUX_HEADER_PIN "Protected: "
#define AUX_TAGS_PIN_START "<pin-plugin>"
#define AUX_TAGS_PIN_ITEM1_START "<protected>"
#define AUX_TAGS_PIN_ITEM1_END "</protected>"
#define AUX_TAGS_PIN_END "</pin-plugin>"
const char *parseaux(const char *aux)
{
bool founditem = false;
stringstream sstrReturn;
char *start, *end;
// check if egpsearch
start = strcasestr(aux, AUX_TAGS_EPGSEARCH_START);
end = strcasestr(aux, AUX_TAGS_EPGSEARCH_END);
if (start && end) {
// add header
sstrReturn << AUX_HEADER_EPGSEARCH;
// parse first item
char *tmp;
if ((tmp = strcasestr(start, AUX_TAGS_EPGSEARCH_ITEM_1A_START)) != NULL) {
if (tmp < end) {
tmp += strlen(AUX_TAGS_EPGSEARCH_ITEM_1A_START);
char *tmp2;
if ((tmp2 = strcasestr(tmp, AUX_TAGS_EPGSEARCH_ITEM_1A_END)) != NULL) {
// add channel
sstrReturn << string(tmp, tmp2 - tmp);
founditem = true;
} else {
founditem = false;
}
}
}
// parse second item
if ((tmp = strcasestr(start, AUX_TAGS_EPGSEARCH_ITEM_2A_START)) != NULL) {
if (tmp < end) {
tmp += strlen(AUX_TAGS_EPGSEARCH_ITEM_2A_START);
char *tmp2;
if ((tmp2 = strcasestr(tmp, AUX_TAGS_EPGSEARCH_ITEM_2A_END)) != NULL) {
// add separator
if (founditem) {
sstrReturn << ", ";
}
// add search item
sstrReturn << string(tmp, tmp2 - tmp);
founditem = true;
} else {
founditem = false;
}
}
}
// timer check?
if ((tmp = strcasestr(start, AUX_TAGS_EPGSEARCH_ITEM_1B_START)) != NULL) {
if (tmp < end) {
tmp += strlen(AUX_TAGS_EPGSEARCH_ITEM_1B_START);
char *tmp2;
if ((tmp2 = strcasestr(tmp, AUX_TAGS_EPGSEARCH_ITEM_1B_END)) != NULL) {
if (string(tmp, tmp2 - tmp) != "0") {
// add separator
if (founditem) {
sstrReturn << ", ";
}
founditem = true;
// add search item
sstrReturn << tr("Timer check");
// parse second item
if ((tmp = strcasestr(start, AUX_TAGS_EPGSEARCH_ITEM_2B_START)) != NULL) {
if (tmp < end) {
tmp += strlen(AUX_TAGS_EPGSEARCH_ITEM_2B_START);
char *tmp2;
if ((tmp2 = strcasestr(tmp, AUX_TAGS_EPGSEARCH_ITEM_2B_END)) != NULL) {
// add separator
if (founditem) {
sstrReturn << ", ";
}
// add search item
sstrReturn << "eventid=" << string(tmp, tmp2 - tmp);
}
}
}
} else {
founditem = false;
}
} else {
founditem = false;
}
}
}
// use old syntax
if (!founditem) {
start += strlen(AUX_HEADER_EPGSEARCH);
sstrReturn << string(start, end - start);
}
sstrReturn << endl;
}
// check if VDRAdmin-AM
start = strcasestr(aux, AUX_TAGS_VDRADMIN_START);
end = strcasestr(aux, AUX_TAGS_VDRADMIN_END);
if (start && end) {
// add header
sstrReturn << AUX_HEADER_VDRADMIN;
// parse first item
char *tmp;
if ((tmp = strcasestr(start, AUX_TAGS_VDRADMIN_ITEM1_START)) != NULL) {
if (tmp < end) {
tmp += strlen(AUX_TAGS_VDRADMIN_ITEM1_START);
char *tmp2;
if ((tmp2 = strcasestr(tmp, AUX_TAGS_VDRADMIN_ITEM1_END)) != NULL) {
// add search item
sstrReturn << string(tmp, tmp2 - tmp) << endl;
}
}
}
}
// check if pin
start = strcasestr(aux, AUX_TAGS_PIN_START);
end = strcasestr(aux, AUX_TAGS_PIN_END);
if (start && end) {
// add header
sstrReturn << AUX_HEADER_PIN;
// parse first item
char *tmp;
if ((tmp = strcasestr(start, AUX_TAGS_PIN_ITEM1_START)) != NULL) {
if (tmp < end) {
tmp += strlen(AUX_TAGS_PIN_ITEM1_START);
char *tmp2;
if ((tmp2 = strcasestr(tmp, AUX_TAGS_PIN_ITEM1_END)) != NULL) {
// add search item
sstrReturn << string(tmp, tmp2 - tmp) << endl;
}
}
}
}
if (!sstrReturn.str().empty())
return sstrReturn.str().c_str();
return aux;
}
bool ischaracters(const char *str, const char *mask)
{
bool match = true;
const char *p = str;
for (; *p; ++p) {
const char *m = mask;
bool tmp = false;
for (; *m; ++m) {
if (*p == *m)
tmp = true;
}
match = match && tmp;
}
return match;
}
|