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
|
/*
* * xtvrc2vdr.c: Converts 'xtvrc' files to 'vdr' channel format
* *
* * Copyright (C) 2000 Plamen Ganev
* *
* * This program is free software; you can redistribute it and/or
* * modify it under the terms of the GNU General Public License
* * as published by the Free Software Foundation; either version 2
* * of the License, or (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public License
* * along with this program; if not, write to the Free Software
* * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
* *
* * The author can be reached at pganev@comm.it
* *
* */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#define MAX_LINE_LEN 1024
#define MAX_NAME 100
#define TOKS ": \n\r"
#define NAMETOKS ":\n\r"
typedef struct {
char Name[MAX_NAME+1];
int freq;
int color, hue, bright, saturation ;
int nitv, input ;
int pol, srate, fec, vpid, apid, lnbnum, type;
} CHANNEL_DATA ;
void strlwr( char *s ){
while ( s && *s ){
*s = tolower(*s);
s++;
}
}
int ReadChannel( FILE *f, CHANNEL_DATA *channel ) {
static char s[MAX_LINE_LEN+1];
char *p;
memset( channel, sizeof( CHANNEL_DATA ), 0 ) ;
while ((p=fgets( s, MAX_LINE_LEN, f ))!=NULL){
// printf("%s", s ) ;
if (s[0] == '*')
break ;
}
if ( !p ) { /* EOF? */
// printf("EOF\n");
return 0 ;
}
while (fgets( s, MAX_LINE_LEN, f )){
if ( s[0] == '\n' )
return channel->freq ? 1 : 0;
p = strtok( s, TOKS ) ;
if ( !p ) {
return 0;
}
strlwr( p ) ;
if ( !strcmp( p, "channel" )){
p=strtok( NULL, NAMETOKS );
while ( p && *p==' ')
p++;
strcpy( channel->Name, p );
// printf("%d ", channel->freq ) ;
} else if ( !strcmp( p, "frequency")) {
channel->freq = atoi( p=strtok( NULL, TOKS ));
// printf("%d ", channel->freq ) ;
} else if ( !strcmp( p, "cbhc")) {
channel->color = atoi(p=strtok(NULL,TOKS));
channel->hue = atoi(p=strtok(NULL,TOKS));
channel->bright = atoi(p=strtok(NULL,TOKS));
channel->saturation = atoi(p=strtok(NULL,TOKS));
} else if ( !strcmp( p, "ni")) {
channel->nitv = atoi(p=strtok(NULL,TOKS));
channel->input = atoi(p=strtok(NULL,TOKS));
} else if ( !strcmp( p, "sat")) {
channel->pol = atoi(p=strtok(NULL,TOKS));
channel->srate = atoi(p=strtok(NULL,TOKS));
channel->fec = atoi(p=strtok(NULL,TOKS));
channel->vpid = atoi(p=strtok(NULL,TOKS));
channel->apid = atoi(p=strtok(NULL,TOKS));
channel->lnbnum = atoi(p=strtok(NULL,TOKS));
channel->type = atoi(p=strtok(NULL,TOKS));
} else
printf("Unknown token %s\n", p ) ;
}
return 1 ;
}
int main ( int argc, char *argv[] ){
FILE *f, *fo ;
int cnt = 0;
CHANNEL_DATA channel ;
if ( argc != 3 ){
printf("USAGE: %s <xtvrc file> <vdr file>\n\n", argv[0] ) ;
return 0;
}
if ( !(f=fopen(argv[1], "rt"))){
printf("Can't open %s for reading\n\n", argv[1]);
return 0;
}
if ( !(fo=fopen(argv[2], "wt"))){
printf("Can't open %s for writing\n\n", argv[2]);
return 0;
}
while ( ReadChannel( f, &channel ) ) {
cnt++;
fprintf(fo, "%s:%d:%c:%d:%d:%d:%d:%d:%d\n",
channel.Name ,
channel.freq ,
channel.pol ? 'v' : 'h' ,
1, //channel.lnbnum ,
channel.srate ,
channel.vpid ,
channel.apid ,
0, //channel.type ,
0 ); //channel.fec ) ;
}
printf( "%d channels read.\n\n", cnt ) ;
fclose(f);
fclose(fo);
return 1;
}
|