void chk_iprange(char *value, struct s_ip **base) { int32_t i = 0; char *ptr1, *ptr2, *saveptr1 = NULL; struct s_ip *fip, *lip, *cip; cs_malloc(&cip, sizeof(struct s_ip), SIGINT); fip = cip; for (ptr1=strtok_r(value, ",", &saveptr1); ptr1; ptr1=strtok_r(NULL, ",", &saveptr1)) { if (i == 0) ++i; else { cs_malloc(&cip, sizeof(struct s_ip), SIGINT); lip->next = cip; } if( (ptr2=strchr(trim(ptr1), '-')) ) { *ptr2++ ='\0'; cs_inet_addr(trim(ptr1), &cip->ip[0]); cs_inet_addr(trim(ptr2), &cip->ip[1]); } else { cs_inet_addr(ptr1, &cip->ip[0]); IP_ASSIGN(cip->ip[1], cip->ip[0]); } lip = cip; } lip = *base; *base = fip; clear_sip(&lip); }
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 iprange_free_fn(void *setting) { clear_sip(setting); }