int parse(const char *fname, const char *channel, struct dvb_frontend_parameters *frontend, int *vpid, int *apid, int *sid) { int fd; int err; int tmp; if ((fd = open(fname, O_RDONLY | O_NONBLOCK)) < 0) { PERROR ("could not open file '%s'", fname); perror (""); return -1; } if (find_channel(fd, channel) < 0) { ERROR("could not find channel '%s' in channel list", channel); return -2; } if ((err = try_parse_int(fd, &tmp, "frequency"))) return -3; frontend->frequency = tmp; if ((err = try_parse_param(fd, modulation_list, LIST_SIZE(modulation_list), &tmp, "modulation"))) return -4; frontend->u.vsb.modulation = tmp; if ((err = try_parse_int(fd, vpid, "Video PID"))) return -5; if ((err = try_parse_int(fd, apid, "Audio PID"))) return -6; if ((err = try_parse_int(fd, sid, "Service ID"))) return -7; close(fd); return 0; }
int parse(const char *fname, const char *channel, struct dvb_frontend_parameters *frontend, int *vpid, int *apid, int *sid) { int fd; int err; int tmp; if ((fd = open(fname, O_RDONLY | O_NONBLOCK)) < 0) { PERROR ("could not open file '%s'", fname); perror (""); return -1; } if (find_channel(fd, channel) < 0) { ERROR("could not find channel '%s' in channel list", channel); return -2; } if ((err = try_parse_int(fd, &tmp, "frequency"))) return -3; frontend->frequency = tmp; if ((err = try_parse_param(fd, inversion_list, LIST_SIZE(inversion_list), &tmp, "inversion"))) return -4; frontend->inversion = tmp; if ((err = try_parse_param(fd, bw_list, LIST_SIZE(bw_list), &tmp, "bandwidth"))) return -5; frontend->u.ofdm.bandwidth = tmp; if ((err = try_parse_param(fd, fec_list, LIST_SIZE(fec_list), &tmp, "code_rate_HP"))) return -6; frontend->u.ofdm.code_rate_HP = tmp; if (check_fec(&frontend->u.ofdm.code_rate_HP)) return -6; if ((err = try_parse_param(fd, fec_list, LIST_SIZE(fec_list), &tmp, "code_rate_LP"))) return -7; frontend->u.ofdm.code_rate_LP = tmp; if (check_fec(&frontend->u.ofdm.code_rate_LP)) return -7; if ((err = try_parse_param(fd, constellation_list, LIST_SIZE(constellation_list), &tmp, "constellation"))) return -8; frontend->u.ofdm.constellation = tmp; if ((err = try_parse_param(fd, transmissionmode_list, LIST_SIZE(transmissionmode_list), &tmp, "transmission_mode"))) return -9; frontend->u.ofdm.transmission_mode = tmp; if ((err = try_parse_param(fd, guard_list, LIST_SIZE(guard_list), &tmp, "guard_interval"))) return -10; frontend->u.ofdm.guard_interval = tmp; if ((err = try_parse_param(fd, hierarchy_list, LIST_SIZE(hierarchy_list), &tmp, "hierarchy_information"))) return -11; frontend->u.ofdm.hierarchy_information = tmp; if ((err = try_parse_int(fd, vpid, "Video PID"))) return -12; if ((err = try_parse_int(fd, apid, "Audio PID"))) return -13; if ((err = try_parse_int(fd, sid, "Service ID"))) return -14; close(fd); return 0; }