27 # ifdef HAVE_STRINGS_H
36 #ifdef HAVE_ARPA_NAMESER_H
37 #include <arpa/nameser.h>
72 spfrr->source = spf_dns_server;
73 if (domain && (domain[0] !=
'\0')) {
74 spfrr->domain = strdup(domain);
75 if (spfrr->domain ==
NULL) {
79 spfrr->domain_buf_len = strlen(domain) + 1;
83 spfrr->domain_buf_len = 0;
85 spfrr->rr_type = rr_type;
87 spfrr->herrno = herrno;
97 spfrr = malloc(
sizeof(SPF_dns_rr_t));
100 memset(spfrr, 0,
sizeof(SPF_dns_rr_t));
102 spfrr->domain =
NULL;
103 spfrr->domain_buf_len = 0;
121 for (i = 0; i < spfrr->rr_buf_num; i++)
126 if (spfrr->rr_buf_len)
127 free(spfrr->rr_buf_len);
142 if (spfrr->rr_buf_num <= idx) {
144 new_num = spfrr->rr_buf_num + (idx + (idx >> 2) + 4 );
146 new_data = realloc(spfrr->rr,
147 new_num *
sizeof(*new_data));
148 if (new_data ==
NULL)
150 spfrr->rr = new_data;
152 new_buf_len = realloc(spfrr->rr_buf_len,
153 new_num *
sizeof(*new_buf_len));
154 if (new_buf_len ==
NULL)
156 spfrr->rr_buf_len = new_buf_len;
158 for(j = spfrr->rr_buf_num; j < new_num; j++) {
160 spfrr->rr_buf_len[j] = 0;
163 spfrr->rr_buf_num = new_num;
168 if (spfrr->rr_buf_len[idx] >= len)
171 new_rr = realloc(spfrr->rr[idx], len);
174 spfrr->rr[idx] = new_rr;
175 spfrr->rr_buf_len[idx] = len;
198 src->domain, src->rr_type, src->ttl, src->herrno);
205 dst->utc_ttl = src->utc_ttl;
206 dst->num_rr = src->num_rr;
208 #define SPF_DNS_RR_REALLOC(d, i, s) do { \
209 err = SPF_dns_rr_buf_realloc(d, i, s); \
210 if (err) return err; \
213 for (i = dst->num_rr - 1; i >= 0; i--) {
214 switch (dst->rr_type) {
217 dst->rr[i]->a = src->rr[i]->a;
222 strcpy(dst->rr[i]->ptr, src->rr[i]->ptr);
227 strcpy(dst->rr[i]->mx, src->rr[i]->mx);
233 strcpy(dst->rr[i]->txt, src->rr[i]->txt);
238 dst->rr[i]->aaaa = src->rr[i]->aaaa;