* Generic parse function for all formats each channel is contained into
* just one line.
*/
-struct dvb_file *parse_format_oneline(const char *fname, const char *delimiter,
+struct dvb_file *parse_format_oneline(const char *fname,
uint32_t delsys,
- const struct parse_struct *formats)
+ const struct parse_file *parse_file)
{
+ const char *delimiter = parse_file->delimiter;
+ const struct parse_struct *formats = parse_file->formats;
char *buf = NULL, *p;
size_t size = 0;
int len = 0;
if (*p == '\n' || *p == '#' || *p == '\a' || *p == '\0')
continue;
- if (!delsys) {
+ if (!parse_file->has_delsys_id) {
p = strtok(p, delimiter);
if (!p) {
sprintf(err_msg, "unknown delivery system type for %s",
}
} else {
/* Seek for the delivery system */
- for (i = 0; formats[i].id != NULL; i++) {
+ for (i = 0; formats[i].delsys != 0; i++) {
if (formats[i].delsys == delsys)
break;
}
unsigned int size;
};
+struct parse_file {
+ int has_delsys_id;
+ char *delimiter;
+ struct parse_struct formats[];
+};
+
#define PTABLE(a) .table = a, .size=ARRAY_SIZE(a)
/* FAKE DTV codes, for internal usage */
}
/* From dvb-legacy-channel-format.c */
-extern const const struct parse_struct channel_formats[];
+extern const struct parse_file channel_file_format;
/* From dvb-zap-format.c */
-extern const const struct parse_struct zap_formats[];
+extern const struct parse_file channel_file_zap_format;
/* From dvb-file.c */
-struct dvb_file *parse_format_oneline(const char *fname, const char *delimiter,
+struct dvb_file *parse_format_oneline(const char *fname,
uint32_t delsys,
- const struct parse_struct *formats);
+ const struct parse_file *parse_file);
struct dvb_file *read_dvb_file(const char *fname);
printf("Reading file %s\n", fname);
switch (format) {
case 1: /* DVB channel/transponder old format */
- dvb_file = parse_format_oneline(fname, " \n", SYS_UNDEFINED,
- channel_formats);
+ dvb_file = parse_format_oneline(fname, SYS_UNDEFINED,
+ &channel_file_format);
break;
case 2: /* DVB old zap format */
if (!delsys) {
fprintf(stderr, "Delivery system unknown\n");
return -1;
}
- dvb_file = parse_format_oneline(fname, ":", sys, zap_formats);
+ dvb_file = parse_format_oneline(fname, sys,
+ &channel_file_zap_format);
break;
}
if (!dvb_file)
{ DTV_HIERARCHY, PTABLE(channel_parse_hierarchy) },
};
-const struct parse_struct channel_formats[] = {
- {
- .id = "A",
- .delsys = SYS_ATSC,
- PTABLE(sys_atsc_table),
- }, {
- .id = "C",
- .delsys = SYS_DVBC_ANNEX_A,
- PTABLE(sys_dvbc_table),
- }, {
- .id = "S",
- .delsys = SYS_DVBS,
- PTABLE(sys_dvbs_table),
- }, {
- .id = "T",
- .delsys = SYS_DVBT,
- PTABLE(sys_dvbt_table),
- }, {
- NULL, 0, NULL, 0,
+const struct parse_file channel_file_format = {
+ .has_delsys_id = 1,
+ .delimiter = " \n",
+ .formats = {
+ {
+ .id = "A",
+ .delsys = SYS_ATSC,
+ PTABLE(sys_atsc_table),
+ }, {
+ .id = "C",
+ .delsys = SYS_DVBC_ANNEX_A,
+ PTABLE(sys_dvbc_table),
+ }, {
+ .id = "S",
+ .delsys = SYS_DVBS,
+ PTABLE(sys_dvbs_table),
+ }, {
+ .id = "T",
+ .delsys = SYS_DVBT,
+ PTABLE(sys_dvbt_table),
+ }, {
+ NULL, 0, NULL, 0,
+ }
}
};
{ DTV_SERVICE_ID, NULL, 0 },
};
-const struct parse_struct zap_formats[] = {
- {
- .id = "A",
- .delsys = SYS_ATSC,
- PTABLE(sys_atsc_table),
- }, {
- .id = "C",
- .delsys = SYS_DVBC_ANNEX_A,
- PTABLE(sys_dvbc_table),
- }, {
- .id = "S",
- .delsys = SYS_DVBS,
- PTABLE(sys_dvbs_table),
- }, {
- .id = "T",
- .delsys = SYS_DVBT,
- PTABLE(sys_dvbt_table),
- }, {
- NULL, 0, NULL, 0,
+const struct parse_file channel_file_zap_format = {
+ .has_delsys_id = 0,
+ .delimiter = ":\n",
+ .formats = {
+ {
+ .delsys = SYS_ATSC,
+ PTABLE(sys_atsc_table),
+ }, {
+ .delsys = SYS_DVBC_ANNEX_A,
+ PTABLE(sys_dvbc_table),
+ }, {
+ .delsys = SYS_DVBS,
+ PTABLE(sys_dvbs_table),
+ }, {
+ .delsys = SYS_DVBT,
+ PTABLE(sys_dvbt_table),
+ }, {
+ NULL, 0, NULL, 0,
+ }
}
};
dvb_file = read_dvb_file(args->confname);
break;
case 1: /* DVB channel/transponder old format */
- dvb_file = parse_format_oneline(args->confname, " \n",
+ dvb_file = parse_format_oneline(args->confname,
SYS_UNDEFINED,
- channel_formats);
+ &channel_file_format);
break;
case 2: /* DVB old zap format */
switch (parms->current_sys) {
ERROR("Doesn't know how to emulate the delivery system");
return -1;
}
- dvb_file = parse_format_oneline(args->confname, ":", sys,
- zap_formats);
+ dvb_file = parse_format_oneline(args->confname, sys,
+ &channel_file_zap_format);
break;
}
if (!dvb_file)
}
if (args->old_format)
- dvb_file = parse_format_oneline(args->confname, ":",
- sys, zap_formats);
+ dvb_file = parse_format_oneline(args->confname, sys,
+ &channel_file_zap_format);
else
dvb_file = read_dvb_file(args->confname);
if (!dvb_file)