static void account_au_fn(const char *token, char *value, void *setting, FILE *f) { struct s_auth *account = setting; if (value) { // set default values for usage during runtime from Webif account->autoau = 0; if (!account->aureader_list) account->aureader_list = ll_create("aureader_list"); if (streq(value, "1")) account->autoau = 1; strtolower(value); ll_clear(account->aureader_list); LL_ITER itr = ll_iter_create(configured_readers); struct s_reader *rdr; char *pch, *saveptr1 = NULL; for (pch = strtok_r(value, ",", &saveptr1); pch != NULL; pch = strtok_r(NULL, ",", &saveptr1)) { ll_iter_reset(&itr); while ((rdr = ll_iter_next(&itr))) { if (streq(rdr->label, pch) || account->autoau) { ll_append(account->aureader_list, rdr); } } } return; } if (account->autoau == 1) { fprintf_conf(f, token, "%d\n", account->autoau); } else if (account->aureader_list) { value = mk_t_aureader(account); if (strlen(value) > 0) fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } else if (cfg.http_full_cfg) { fprintf_conf(f, token, "%s\n", ""); } }
void caidvaluetab_fn(const char *token, char *value, void *setting, FILE *f) { CAIDVALUETAB *caid_value_table = setting; if(value) { if (strlen(value)) { chk_caidvaluetab(value, caid_value_table); if (streq(token, "lb_retrylimits")) { int32_t i; for (i = 0; i < caid_value_table->cvnum; i++) { if (caid_value_table->cvdata[i].value < 50) caid_value_table->cvdata[i].value = 50; } } } else { caidvaluetab_clear(caid_value_table); } return; } if(caid_value_table->cvnum || cfg.http_full_cfg) { value = mk_t_caidvaluetab(caid_value_table); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void gbox_proxy_card_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) { if (value) { char *ptr1, *saveptr1 = NULL; const char *s; memset(cfg.gbox_proxy_card, 0, sizeof(cfg.gbox_proxy_card)); int n = 0, i; for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < 8) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) { s=ptr1; if ((n < GBOX_MAX_PROXY_CARDS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0)) { cfg.gbox_proxy_card[n++] = a2i(ptr1, 8); } } cfg.gbox_proxy_cards_num = n; return; } if (cfg.gbox_proxy_cards_num > 0) { value = mk_t_gbox_proxy_card(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void logfile_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) { if (value) { char *saveptr1 = NULL; cfg.logtostdout = 0; cfg.logtosyslog = 0; NULLFREE(cfg.logfile); if (strlen(value) > 0) { char *pch; for(pch = strtok_r(value, ";", &saveptr1); pch != NULL; pch = strtok_r(NULL, ";", &saveptr1)){ pch=trim(pch); if(!strcmp(pch, "stdout")) cfg.logtostdout = 1; else if(!strcmp(pch, "syslog")) cfg.logtosyslog = 1; else { NULLFREE(cfg.logfile); if (!(cfg.logfile = cs_strdup(pch))) continue; } } } else { if (!(cfg.logfile = cs_strdup(CS_LOGFILE))) cfg.logtostdout = 1; } return; } if (cfg.logfile || cfg.logtostdout == 1 || cfg.logtosyslog == 1 || cfg.http_full_cfg) { value = mk_t_logfile(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void account_allowedprotocols_fn(const char *token, char *value, void *setting, FILE *f) { struct s_auth *account = setting; if (value) { account->allowedprotocols = 0; if (strlen(value) > 3) { int i; char *ptr, *saveptr1 = NULL; for (i = 0, ptr = strtok_r(value, ",", &saveptr1); ptr; ptr = strtok_r(NULL, ",", &saveptr1), i++) { if (streq(ptr, "camd33")) account->allowedprotocols |= LIS_CAMD33TCP; else if (streq(ptr, "camd35")) account->allowedprotocols |= LIS_CAMD35UDP; else if (streq(ptr, "cs357x")) account->allowedprotocols |= LIS_CAMD35UDP; else if (streq(ptr, "cs378x")) account->allowedprotocols |= LIS_CAMD35TCP; else if (streq(ptr, "newcamd")) account->allowedprotocols |= LIS_NEWCAMD; else if (streq(ptr, "cccam")) account->allowedprotocols |= LIS_CCCAM; else if (streq(ptr, "csp")) account->allowedprotocols |= LIS_CSPUDP; else if (streq(ptr, "gbox")) account->allowedprotocols |= LIS_GBOX; else if (streq(ptr, "radegast")) account->allowedprotocols |= LIS_RADEGAST; // these have no listener ports so it doesn't make sense else if (streq(ptr, "dvbapi")) account->allowedprotocols |= LIS_DVBAPI; else if (streq(ptr, "constcw")) account->allowedprotocols |= LIS_CONSTCW; else if (streq(ptr, "serial")) account->allowedprotocols |= LIS_SERIAL; } } return; } if (account->allowedprotocols || cfg.http_full_cfg ){ value = mk_t_allowedprotocols(account); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void account_services_fn(const char *token, char *value, void *setting, FILE *f) { struct s_auth *account = setting; if (value) { strtolower(value); chk_services(value, &account->sidtabok, &account->sidtabno); return; } value = mk_t_service((uint64_t)account->sidtabok, (uint64_t)account->sidtabno); if (strlen(value) > 0 || cfg.http_full_cfg) fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }
static void caidvaluetab_fn(const char *token, char *value, void *setting, FILE *f) { CAIDVALUETAB *caid_value_table = setting; int limit = streq(token, "lb_retrylimits") ? 50 : 1; if (value) { chk_caidvaluetab(value, caid_value_table, limit); return; } if (caid_value_table->n > 0 || cfg.http_full_cfg) { value = mk_t_caidvaluetab(caid_value_table); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void account_chid_fn(const char *token, char *value, void *setting, FILE *f) { struct s_auth *account = setting; if (value) { strtolower(value); chk_ftab(value, &account->fchid, "user", account->usr, "chid"); return; } if (account->fchid.nfilts || cfg.http_full_cfg) { value = mk_t_ftab(&account->fchid); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void account_class_fn(const char *token, char *value, void *setting, FILE *f) { struct s_auth *account = setting; if (value) { strtolower(value); chk_cltab(value, &account->cltab); return; } if ((account->cltab.bn > 0 || account->cltab.an > 0) || cfg.http_full_cfg) { value = mk_t_cltab(&account->cltab); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void porttab_fn(const char *token, char *value, void *setting, long type, FILE *f) { PTAB *ptab = setting; if (value) { if(strlen(value) == 0) { clear_ptab(ptab); } else { chk_port_tab(value, ptab); } return; } value = (type == PORTTAB_CS378X) ? mk_t_camd35tcp_port() : mk_t_newcamd_port(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }
void services_fn(const char *token, char *value, void *setting, FILE *f) { SIDTABS *sidtabs = setting; if(value) { strtolower(value); chk_services(value, sidtabs); return; } value = mk_t_service(sidtabs); if(strlen(value) > 0 || cfg.http_full_cfg) { fprintf_conf(f, token, "%s\n", value); } free_mk_t(value); }
static void porttab_newcamd_fn(const char *token, char *value, void *setting, FILE *f) { PTAB *ptab = setting; if (value) { if(strlen(value) == 0) { clear_ptab(ptab); } else { chk_port_tab(value, ptab); } return; } value = mk_t_newcamd_port(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }
void iprange_fn(const char *token, char *value, void *setting, FILE *f) { struct s_ip **ip = setting; if (value) { if(strlen(value) == 0) { clear_sip(ip); } else { chk_iprange(value, ip); } return; } value = mk_t_iprange(*ip); if (strlen(value) > 0 || cfg.http_full_cfg) fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }
void cacheex_hitvaluetab_fn(const char *token, char *value, void *setting, FILE *f) { CECSPVALUETAB *cacheex_value_table = setting; if (value) { if (strlen(value) == 0) clear_cacheextab(cacheex_value_table); else chk_cacheex_hitvaluetab(value, cacheex_value_table); return; } if (cacheex_value_table->n || cfg.http_full_cfg) { value = mk_t_cacheex_hitvaluetab(cacheex_value_table); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
void check_caidtab_fn(const char *token, char *value, void *setting, FILE *f) { CAIDTAB *caid_table = setting; if (value) { if (strlen(value) == 0) clear_caidtab(caid_table); else chk_caidtab(value, caid_table); return; } if (caid_table->caid[0] || cfg.http_full_cfg) { value = mk_t_caidtab(caid_table); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
void chk_ftab_fn(const char *token, char *value, void *setting, FILE *f) { FTAB *ftab = setting; if(value) { if(strlen(value)) chk_ftab(value, ftab); else ftab_clear(ftab); return; } value = mk_t_ftab(ftab); if(strlen(value) > 0 || cfg.http_full_cfg) { fprintf_conf(f, token, "%s\n", value); } free_mk_t(value); }
static void cccam_port_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) { if (value) { int i; char *ptr, *saveptr1 = NULL; memset(cfg.cc_port, 0, sizeof(cfg.cc_port)); for (i = 0, ptr = strtok_r(value, ",", &saveptr1); ptr && i < CS_MAXPORTS; ptr = strtok_r(NULL, ",", &saveptr1)) { cfg.cc_port[i] = strtoul(ptr, NULL, 10); if (cfg.cc_port[i]) i++; } return; } value = mk_t_cccam_port(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }
static void account_tuntab_fn(const char *token, char *value, void *setting, FILE *f) { TUNTAB *ttab = setting; if (value) { if (strlen(value) == 0) { clear_tuntab(ttab); } else { chk_tuntab(value, ttab); } return; } if (ttab->bt_caidfrom[0] || cfg.http_full_cfg) { value = mk_t_tuntab(ttab); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
void class_fn(const char *token, char *value, void *setting, FILE *f) { CLASSTAB *cltab = setting; if(value) { strtolower(value); chk_cltab(value, cltab); return; } value = mk_t_cltab(cltab); if(strlen(value) > 0 || cfg.http_full_cfg) { fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void ecmheaderwhitelist_fn(const char *token, char *value, void *setting, FILE *f) { struct s_reader *rdr = setting; if(value) { if(strlen(value)) chk_ecm_hdr_whitelist(value, &rdr->ecm_hdr_whitelist); else ecm_hdr_whitelist_clear(&rdr->ecm_hdr_whitelist); return; } value = mk_t_ecm_hdr_whitelist(&rdr->ecm_hdr_whitelist); if(strlen(value) > 0 || cfg.http_full_cfg) { fprintf_conf(f, token, "%s\n", value); } free_mk_t(value); }
static void account_group_fn(const char *token, char *value, void *setting, FILE *f) { uint64_t *grp = setting; if (value) { char *ptr1, *saveptr1 = NULL; *grp = 0; for (ptr1 = strtok_r(value, ",", &saveptr1); ptr1; ptr1 = strtok_r(NULL, ",", &saveptr1)) { int32_t g; g = atoi(ptr1); if (g > 0 && g < 65) *grp |= (((uint64_t)1) << (g-1)); } return; } if (*grp || cfg.http_full_cfg) { value = mk_t_group(*grp); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void run_parser_test(struct test_type *t) { memset(t->data, 0, t->data_sz); memset(t->data_c, 0, t->data_sz); printf("%s\n", t->desc); const struct test_vec *vec = t->test_vec; while (vec->in) { bool ok; printf(" Testing \"%s\"", vec->in); char *input_setting = cs_strdup(vec->in); t->chk_fn(input_setting, t->data); t->clone_fn(t->data, t->data_c); // Check if 'clone' works t->clear_fn(t->data); // Check if 'clear' works char *generated = t->mk_t_fn(t->data_c); // Use cloned data if (vec->out) ok = strcmp(vec->out, generated) == 0; else ok = strcmp(vec->in, generated) == 0; if (ok) { printf(" [OK]\n"); } else { printf("\n"); printf(" === ERROR ===\n"); printf(" Input data: \"%s\"\n", vec->in); printf(" Got result: \"%s\"\n", generated); printf(" Expected out: \"%s\"\n", vec->out ? vec->out : vec->in); printf("\n"); } free_mk_t(generated); free(input_setting); fflush(stdout); vec++; } t->clear_fn(t->data_c); }
void cacheex_cwcheck_tab_fn(const char *token, char *value, void *setting, FILE *f) { CWCHECKTAB *cacheex_value_table = setting; if(value) { if(strlen(value) == 0) { cacheex_value_table->cwchecknum = 0; NULLFREE(cacheex_value_table->cwcheckdata); } else { chk_cacheex_cwcheck_valuetab(value, cacheex_value_table); } return; } if(cacheex_value_table->cwchecknum || cfg.http_full_cfg) { value = mk_t_cacheex_cwcheck_valuetab(cacheex_value_table); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void gbox_ignored_peer_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) { if (value) { char *ptr1, *saveptr1 = NULL; const char *s; memset(cfg.gbox_ignored_peer, 0, sizeof(cfg.gbox_ignored_peer)); int n = 0, i; for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < 4) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) { s=ptr1; if ((n < GBOX_MAX_IGNORED_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0)) { cfg.gbox_ignored_peer[n++] = a2i(ptr1, 4); } } cfg.gbox_ignored_peer_num = n; return; } if (cfg.gbox_ignored_peer_num > 0) { value = mk_t_gbox_ignored_peer(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
void cacheex_cwcheck_tab_fn(const char *token, char *value, void *setting, FILE *f) { CWCHECKTAB *cacheex_value_table = setting; if(value) { if(strlen(value) == 0) { memset(cacheex_value_table, -1, sizeof(CWCHECKTAB)); cacheex_value_table->n = 0; } else { chk_cacheex_cwcheck_valuetab(value, cacheex_value_table); } return; } if(cacheex_value_table->n || cfg.http_full_cfg) { value = mk_t_cacheex_cwcheck_valuetab(cacheex_value_table); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void gbox_dest_peers_fn(const char *token, char *value, void *UNUSED(setting), FILE *f) { if (value) { char *ptr1, *saveptr1 = NULL; const char *s; memset(cfg.gbox_dest_peers, 0, sizeof(cfg.gbox_dest_peers)); int n = 0; for (ptr1 = strtok_r(value, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1)) { s=trim(ptr1); if ((n < GBOX_MAX_DEST_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0)) { cfg.gbox_dest_peers[n++] = a2i(trim(ptr1), strlen(trim(ptr1))); } } cfg.gbox_dest_peers_num = n; return; } if ((cfg.gbox_dest_peers_num > 0) && cfg.gbox_save_gsms) { value = mk_t_gbox_dest_peers(); fprintf_conf(f, token, "%s\n", value); free_mk_t(value); } }
static void ecmheaderwhitelist_fn(const char *token, char *value, void *setting, FILE *f) { struct s_reader *rdr = setting; if (value) { char *ptr, *ptr2, *ptr3; struct s_ecmHeaderwhitelist *tmp, *last = NULL; if (strlen(value) == 0) { for (tmp = rdr->ecmHeaderwhitelist; tmp; tmp=tmp->next) add_garbage(tmp); rdr->ecmHeaderwhitelist = NULL; } else { char *ptr4, *ptr5, *ptr6, *saveptr = NULL, *saveptr4 = NULL, *saveptr5 = NULL, *saveptr6 = NULL; uint16_t caid = 0; uint32_t provid = 0; int16_t len = 0; for (ptr = strtok_r(value, ";", &saveptr); ptr; ptr = strtok_r(NULL, ";", &saveptr)) { caid = 0; provid = 0; ptr2 = strchr(ptr, '@'); ptr3 = strchr(ptr, ':'); if (ptr2 == NULL && ptr3 == NULL) { //no Caid no Provid for (ptr4 = strtok_r(ptr, ",", &saveptr4); ptr4; ptr4 = strtok_r(NULL, ",", &saveptr4)) { if (cs_malloc(&tmp, sizeof(struct s_ecmHeaderwhitelist))) { ptr4 = trim(ptr4); len = strlen(ptr4); key_atob_l(ptr4, tmp->header, len); tmp->len = len; tmp->caid = 0; tmp->provid = 0; tmp->next = NULL; if (last == NULL) { rdr->ecmHeaderwhitelist = tmp; } else { last->next = tmp; } last = tmp; } } } if (ptr3 != NULL && ptr2 == NULL) { // only with Caid ptr3[0] = '\0'; ++ptr3; caid = (int16_t)dyn_word_atob(ptr); for (ptr5 = strtok_r(ptr3, ",", &saveptr5); ptr5; ptr5 = strtok_r(NULL, ",", &saveptr5)) { if (cs_malloc(&tmp, sizeof(struct s_ecmHeaderwhitelist))) { tmp->caid = caid; tmp->provid = 0; ptr5 = trim(ptr5); len = strlen(ptr5); key_atob_l(ptr5, tmp->header, len); tmp->len = len; tmp->next = NULL; if (last == NULL) { rdr->ecmHeaderwhitelist = tmp; } else { last->next = tmp; } last = tmp; } } } if (ptr3 != NULL && ptr2 != NULL) { // with Caid & Provid ptr2[0] = '\0'; ++ptr2; // -> provid ptr3[0] = '\0'; ++ptr3; // -> headers caid = (int16_t)dyn_word_atob(ptr); provid = (uint32_t)a2i(ptr2, 6); for (ptr6 = strtok_r(ptr3, ",", &saveptr6); ptr6; ptr6 = strtok_r(NULL, ",", &saveptr6)) { if (cs_malloc(&tmp, sizeof(struct s_ecmHeaderwhitelist))) { tmp->caid = caid; tmp->provid = provid; ptr6 = trim(ptr6); len = strlen(ptr6); key_atob_l(ptr6, tmp->header, len); tmp->len = len; tmp->next = NULL; if (last == NULL) { rdr->ecmHeaderwhitelist = tmp; } else { last->next = tmp; } last = tmp; } } } } } /* if (rdr->ecmHeaderwhitelist != NULL) { // debug cs_log("**********Begin ECM Header List for Reader: %s **************", rdr->label); struct s_ecmHeaderwhitelist *tmp; for(tmp = rdr->ecmHeaderwhitelist; tmp; tmp=tmp->next){ cs_log("Caid: %i Provid: %i Header: %02X Len: %i", tmp->caid, tmp->provid, tmp->header[0], tmp->len); } cs_log("***********End ECM Header List for Reader: %s ***************", rdr->label); } */ return; } value = mk_t_ecmheaderwhitelist(rdr->ecmHeaderwhitelist); if (strlen(value) > 0 || cfg.http_full_cfg) fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }
static void ecmwhitelist_fn(const char *token, char *value, void *setting, FILE *f) { struct s_reader *rdr = setting; if (value) { char *ptr, *ptr2, *ptr3, *saveptr1 = NULL; struct s_ecmWhitelist *tmp, *last; struct s_ecmWhitelistIdent *tmpIdent, *lastIdent; struct s_ecmWhitelistLen *tmpLen, *lastLen; for(tmp = rdr->ecmWhitelist; tmp; tmp=tmp->next) { for(tmpIdent = tmp->idents; tmpIdent; tmpIdent=tmpIdent->next) { for(tmpLen = tmpIdent->lengths; tmpLen; tmpLen=tmpLen->next) { add_garbage(tmpLen); } add_garbage(tmpIdent); } add_garbage(tmp); } rdr->ecmWhitelist = NULL; if(strlen(value) > 0) { saveptr1 = NULL; char *saveptr2 = NULL; for (ptr = strtok_r(value, ";", &saveptr1); ptr; ptr = strtok_r(NULL, ";", &saveptr1)) { int16_t caid = 0, len; uint32_t ident = 0; ptr2=strchr(ptr,':'); if(ptr2 != NULL) { ptr2[0] = '\0'; ++ptr2; ptr3=strchr(ptr,'@'); if(ptr3 != NULL) { ptr3[0] = '\0'; ++ptr3; ident = (uint32_t)a2i(ptr3, 6); } caid = (int16_t)dyn_word_atob(ptr); } else ptr2 = ptr; for (ptr2 = strtok_r(ptr2, ",", &saveptr2); ptr2; ptr2 = strtok_r(NULL, ",", &saveptr2)) { len = (int16_t)dyn_word_atob(ptr2); last = NULL, tmpIdent = NULL, lastIdent = NULL, tmpLen = NULL, lastLen = NULL; for(tmp = rdr->ecmWhitelist; tmp; tmp=tmp->next) { last = tmp; if(tmp->caid == caid) { for(tmpIdent = tmp->idents; tmpIdent; tmpIdent=tmpIdent->next) { lastIdent = tmpIdent; if(tmpIdent->ident == ident) { for(tmpLen = tmpIdent->lengths; tmpLen; tmpLen=tmpLen->next) { lastLen = tmpLen; if(tmpLen->len == len) break; } break; } } } } if(tmp == NULL) { if (cs_malloc(&tmp, sizeof(struct s_ecmWhitelist))) { tmp->caid = caid; tmp->idents = NULL; tmp->next = NULL; if(last == NULL) { rdr->ecmWhitelist = tmp; } else { last->next = tmp; } } } if(tmp != NULL && tmpIdent == NULL) { if (cs_malloc(&tmpIdent, sizeof(struct s_ecmWhitelistIdent))) { tmpIdent->ident = ident; tmpIdent->lengths = NULL; tmpIdent->next = NULL; if(lastIdent == NULL) { tmp->idents = tmpIdent; } else { lastIdent->next = tmpIdent; } } } if(tmp != NULL && tmpIdent != NULL && tmpLen == NULL) { if (cs_malloc(&tmpLen, sizeof(struct s_ecmWhitelistLen))) { tmpLen->len = len; tmpLen->next = NULL; if(lastLen == NULL) { tmpIdent->lengths = tmpLen; } else { lastLen->next = tmpLen; } } } } } } return; } value = mk_t_ecmwhitelist(rdr->ecmWhitelist); if (strlen(value) > 0 || cfg.http_full_cfg) fprintf_conf(f, token, "%s\n", value); free_mk_t(value); }