27 char *sourcebuf = NULL;
32 int fields = sscanf(s,
"%a[^-]-%d-%d-%d-%d", &sourcebuf, &nid, &tid, &sid, &rid);
33 if (fields == 4 || fields == 5) {
89 if (Channel->linkChannels) {
90 for (
cLinkChannel *lc = Channel->linkChannels->First(); lc; lc = Channel->linkChannels->
Next(lc)) {
91 if (lc->Channel() ==
this) {
92 Channel->linkChannels->
Del(lc);
96 if (Channel->linkChannels->Count() == 0) {
97 delete Channel->linkChannels;
98 Channel->linkChannels = NULL;
146 switch (toupper(Polarization)) {
147 case 'H': Frequency += 100000;
break;
148 case 'V': Frequency += 200000;
break;
149 case 'L': Frequency += 300000;
break;
150 case 'R': Frequency += 400000;
break;
151 default:
esyslog(
"ERROR: invalid value for Polarization '%c'", Polarization);
162 const char *p = strpbrk(
parameters,
"HVLRhvlr");
172 if (Timer->Channel() ==
this)
197 if (strchr(Parameters,
':')) {
198 esyslog(
"ERROR: parameter string '%s' contains ':'", Parameters);
210 if (abs(
srate - Srate) <= 1)
233 if (
nid != Nid ||
tid != Tid ||
sid != Sid ||
rid != Rid) {
253 bool nn = strcmp(
name, Name) != 0;
254 bool ns = strcmp(
shortName, ShortName) != 0;
255 bool np = strcmp(
provider, Provider) != 0;
256 if (nn || ns || np) {
294 for (
int i = 0; a[i] || b[i]; i++) {
295 if (!a[i] || !b[i]) {
299 if (na && nb && strcmp(na[i], nb[i]) != 0)
311 while (a[i] || i == 0) {
312 q += sprintf(q, Base == 16 ?
"%s%X" :
"%s%d", i ?
"," :
"", a[i]);
313 const char *Delim =
"=";
316 q += sprintf(q,
"%s%s", Delim, n[i]);
320 q += sprintf(q,
"%s@%d", Delim, t[i]);
330 void cChannel::SetPids(
int Vpid,
int Ppid,
int Vtype,
int *Apids,
int *Atypes,
char ALangs[][
MAXLANGCODE2],
int *Dpids,
int *Dtypes,
char DLangs[][MAXLANGCODE2],
int *Spids,
char SLangs[][MAXLANGCODE2],
int Tpid)
335 int m =
IntArraysDiffer(
apids, Apids,
alangs, ALangs) |
IntArraysDiffer(
atypes, Atypes) |
IntArraysDiffer(
dpids, Dpids,
dlangs, DLangs) |
IntArraysDiffer(
dtypes, Dtypes) |
IntArraysDiffer(
spids, Spids,
slangs, SLangs);
341 const int BufferSize = (
MAXAPIDS +
MAXDPIDS) * (5 + 1 + MAXLANGCODE2 + 5) + 10;
342 char OldApidsBuf[BufferSize];
343 char NewApidsBuf[BufferSize];
344 char *q = OldApidsBuf;
359 char OldSpidsBuf[SBufferSize];
360 char NewSpidsBuf[SBufferSize];
368 dsyslog(
"changing pids of channel %d from %d+%d=%d:%s:%s:%d to %d+%d=%d:%s:%s:%d",
Number(),
vpid,
ppid,
vtype, OldApidsBuf, OldSpidsBuf,
tpid, Vpid, Ppid, Vtype, NewApidsBuf, NewSpidsBuf, Tpid);
372 for (
int i = 0; i <
MAXAPIDS; i++) {
378 for (
int i = 0; i <
MAXDPIDS; i++) {
384 for (
int i = 0; i <
MAXSPIDS; i++) {
397 if (SubtitlingTypes) {
401 if (CompositionPageIds) {
405 if (AncillaryPageIds) {
436 char OldCaIdsBuf[
MAXCAIDS * 5 + 10];
437 char NewCaIdsBuf[
MAXCAIDS * 5 + 10];
441 dsyslog(
"changing caids of channel %d from %s to %s",
Number(), OldCaIdsBuf, NewCaIdsBuf);
442 for (
int i = 0; i <=
MAXCAIDS; i++) {
457 if (
Number() && Level > 1)
475 lcb = LinkChannels->
Next(lcb);
484 q += sprintf(q,
"linking channel %d from",
Number());
487 lc->Channel()->SetRefChannel(NULL);
488 q += sprintf(q,
" %d", lc->Channel()->Number());
493 q += sprintf(q,
" none");
494 q += sprintf(q,
" to");
498 lc->Channel()->SetRefChannel(
this);
499 q += sprintf(q,
" %d", lc->Channel()->Number());
504 q += sprintf(q,
" none");
523 char FullName[strlen(Channel->
name) + 1 + strlen(Channel->
shortName) + 1 + strlen(Channel->
provider) + 1 + 10];
525 q += sprintf(q,
"%s", Channel->
name);
527 q += sprintf(q,
",%s", Channel->
shortName);
528 else if (strchr(Channel->
name,
','))
529 q += sprintf(q,
",");
531 q += sprintf(q,
";%s", Channel->
provider);
544 q += snprintf(q,
sizeof(vpidbuf),
"%d", Channel->
vpid);
546 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"+%d", Channel->
ppid);
548 q += snprintf(q,
sizeof(vpidbuf) - (q - vpidbuf),
"=%d", Channel->
vtype);
551 char apidbuf[ABufferSize];
554 if (Channel->
dpids[0]) {
560 char tpidbuf[TBufferSize];
562 q += snprintf(q,
sizeof(tpidbuf),
"%d", Channel->
tpid);
570 if (Channel->
spids[0]) {
578 buffer =
cString::sprintf(
"%s:%d:%s:%s:%d:%s:%s:%s:%s:%d:%d:%d:%d\n", FullName, Channel->
frequency, *Channel->
parameters, *
cSource::ToString(Channel->
source), Channel->
srate, vpidbuf, apidbuf, tpidbuf, caidbuf, Channel->
sid, Channel->
nid, Channel->
tid, Channel->
rid);
593 if (*++s ==
'@' && *++s) {
596 int n = strtol(s, &p, 10);
597 if (!errno && p != s && n > 0) {
607 char *namebuf = NULL;
608 char *sourcebuf = NULL;
609 char *parambuf = NULL;
610 char *vpidbuf = NULL;
611 char *apidbuf = NULL;
612 char *tpidbuf = NULL;
613 char *caidbuf = NULL;
614 int fields = sscanf(s,
"%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%a[^:]:%a[^:]:%d :%d :%d :%d ", &namebuf, &
frequency, ¶mbuf, &sourcebuf, &
srate, &vpidbuf, &apidbuf, &tpidbuf, &caidbuf, &
sid, &
nid, &
tid, &
rid);
621 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
635 if (parambuf && sourcebuf && vpidbuf && apidbuf) {
640 if ((p = strchr(vpidbuf,
'=')) != NULL) {
642 if (sscanf(p,
"%d", &
vtype) != 1)
645 if ((p = strchr(vpidbuf,
'+')) != NULL) {
647 if (sscanf(p,
"%d", &
ppid) != 1)
650 if (sscanf(vpidbuf,
"%d", &
vpid) != 1)
657 char *dpidbuf = strchr(apidbuf,
';');
664 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
667 char *l = strchr(q,
'=');
670 char *t = strchr(l,
'@');
673 atypes[NumApids] = strtol(t, NULL, 10);
679 if ((
apids[NumApids] = strtol(q, NULL, 10)) != 0)
683 esyslog(
"ERROR: too many APIDs!");
693 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
696 char *l = strchr(q,
'=');
699 char *t = strchr(l,
'@');
702 dtypes[NumDpids] = strtol(t, NULL, 10);
708 if ((
dpids[NumDpids] = strtol(q, NULL, 10)) != 0)
712 esyslog(
"ERROR: too many DPIDs!");
719 if ((p = strchr(tpidbuf,
';')) != NULL) {
723 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
725 char *l = strchr(q,
'=');
732 spids[NumSpids++] = strtol(q, NULL, 10);
735 esyslog(
"ERROR: too many SPIDs!");
741 if ((p = strchr(tpidbuf,
'+')) != NULL) {
745 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
748 char *l = strchr(q,
'=');
751 if (sscanf(q,
"%d", &page) == 1) {
758 esyslog(
"ERROR: invalid Teletext page!");
761 esyslog(
"ERROR: too many Teletext pages!");
766 if (sscanf(tpidbuf,
"%d", &
tpid) != 1)
773 while ((q = strtok_r(p,
",", &strtok_next)) != NULL) {
775 caids[NumCaIds++] = strtol(q, NULL, 16) & 0xFFFF;
780 esyslog(
"ERROR: too many CA ids!");
788 char *p = strchr(namebuf,
';');
793 p = strrchr(namebuf,
',');
810 esyslog(
"ERROR: channel data results in invalid ID!");
822 return fprintf(f,
"%s", *
ToText()) > 0;
857 if (!channel->GroupSep())
860 ChannelSorter.
Sort();
895 while (channel && !(channel->
GroupSep() && *channel->
Name()))
896 channel =
Get(++Idx);
897 return channel ? Idx : -1;
903 while (channel && !(channel->
GroupSep() && *channel->
Name()))
904 channel =
Get(--Idx);
905 return channel ? Idx : -1;
911 while (channel && channel->
GroupSep())
912 channel =
Get(++Idx);
913 return channel ? Idx : -1;
919 while (channel && channel->
GroupSep())
920 channel =
Get(--Idx);
921 return channel ? Idx : -1;
930 if (channel->GroupSep()) {
931 if (channel->Number() > Number)
932 Number = channel->Number();
937 channel->SetNumber(Number++);
946 if (!channel->GroupSep()) {
947 if (channel->Number() == Number)
949 else if (SkipGap && channel->Number() > Number)
950 return SkipGap > 0 ? channel : previous;
972 int sid = ChannelID.
Sid();
988 if (TryWithoutPolarization) {
1001 int source = ChannelID.
Source();
1002 int nid = ChannelID.
Nid();
1003 int tid = ChannelID.
Tid();
1005 if (channel->Tid() == tid && channel->Nid() == nid && channel->Source() == source)
1015 if (!channel->GroupSep() && channel != OldChannel && channel->
GetChannelID() == NewChannelID)
1031 if (!channel->GroupSep())
1042 if (!channel->GroupSep())
1065 dsyslog(
"creating new channel '%s,%s;%s' on %s transponder %d with id %d-%d-%d-%d", Name, ShortName, Provider, *
cSource::ToString(Transponder->
Source()), Transponder->
Transponder(), Nid, Tid, Sid, Rid);
1068 NewChannel->SetId(Nid, Tid, Sid, Rid);
1069 NewChannel->SetName(Name, ShortName, Provider);
1082 snprintf(buffer,
sizeof(buffer),
"%s", Channel->
Name());
1084 snprintf(buffer,
sizeof(buffer),
"%d%s %s", Channel->
Number(), Number ?
"-" :
"", Channel->
Name());
1087 snprintf(buffer,
sizeof(buffer),
"%d-", Number);
1089 snprintf(buffer,
sizeof(buffer),
"%s",
tr(
"*** Invalid Channel ***"));