Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Automatic channel settings
Servus
Well I've just hacked a little pascal proggy which takes a list of all
channel settings (currently called astra.conf) and brings the channels
into a selectable order.
It's like this:
astra.conf contains all channels you can get
input.conf is either an old channels.conf, or a list with all the
channels you want and in what order (one per line)
cat input.conf | vdrchannels >channels.conf
So here's the programm: (I don't think I have to waste space with
mime-encoding here)
I'm sorry for the waste of memory here, but it makes the whole programm
a lot simpler.
PROGRAM vdrchannels; {little hack by Casandro einStein@donau.de }
TYPE
TChannel=RECORD
name:string[32]; {name of the station}
line:string[64]; {the whole line}
used:integer;
END;
CONST channelcount=4096;
channelfile='astra.conf';
FUNCTION channelname(line:string):string;
VAR x:integer;
BEGIN
x:=pos(':',line);
IF x=0 THEN channelname:=line ELSE
channelname:=copy(line,1,x-1);
END;
VAR channels:ARRAY[0..channelcount-1] OF TChannel;
channelposition:integer;
PRoCEDURe initchannels;
VAR n:integer;
BEGIN
FOR n:=0 TO channelcount-1 DO
WITH channels[n] DO
BEGIN
name:='';
line:='';
used:=0;
END;
channelposition:=0;
END;
PROCEDURE readinputfile;
VAR f:text;
s:string;
BEGIN
assign(f,channelfile);
reset(f);
WHILE not(eof(f)) DO
BEGIN
readln(f,s);
channels[channelposition].line:=s;
channels[channelposition].name:=channelname(s);
IF channels[channelposition].name<>'' THEN
inc(channelposition);
END;
close(f);
END;
PROCEDURE writechannel(name:string);
VAR n:integer;
BEGIN
FOR n:=0 TO channelposition-1 DO
BEGIN
IF channels[n].name=name THEN
BEGIN
writeln(channels[n].line);
inc(channels[n].used);
exit;
END;
END;
END;
PROCEDURE writeunused;
VAR n:integer;
BEGIN
FOR n:=0 TO channelposition-1 DO
BEGIN
IF channels[n].used=0 THEN
BEGIN
writeln(channels[n].line);
END;
END;
END;
VAR s,s2:string;
BEGIN
initchannels;
readinputfile;
WHILE not eof DO
BEGIN
readln(s);
s2:=channelname(s);
IF s2='' THEN writeln(s) {if it's a group seperator, just keep it}
ELSE writechannel(s2);
END;
writeln(':others');
writeunused;
END.
Home |
Main Index |
Thread Index