37 read_line(FILE *input,
char *line,
int multiline,
int skip_comments)
46 c = (char) getc(input);
49 if (c ==
';' && !in_string && lc !=
'\\') {
50 while(c != EOF && c !=
'\n') {
51 if (!skip_comments && !multiline) {
55 c = (char) getc(input);
61 fprintf(stderr,
"bracket mismatch in multiline RR"
62 "; eof, depth=%i, missing )\n", depth);
70 }
else if (c ==
'"' && lc !=
'\\') {
71 in_string = 1 - in_string;
74 }
else if (c ==
'(' && multiline) {
83 }
else if (c ==
')' && multiline) {
89 fprintf(stderr,
"bracket mismatch in multiline RR"
98 }
else if (c !=
'\n') {
102 if (!multiline || depth == 0) {
109 fprintf(stderr,
"bracket mismatch in multiline RR"
110 "; depth=%i, missing )\n", depth);
120 for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
121 ldns_rr_free(ldns_rr_list_rr(rr_list, i));
123 ldns_rr_list_set_rr_count(rr_list, 0);
128 get_soa_rdata(ldns_rr *rr,
int rnum)
131 if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) {
132 rdata = ldns_rdf2native_int32(ldns_rr_rdf(rr, rnum));
138 lookup_soa_rdata(FILE* fd,
int rnum)
146 while (line_len >= 0) {
149 if (line[0] !=
';') {
150 status = ldns_rr_new_frm_str(&cur_rr, line, 0, NULL, NULL);
151 if (status == LDNS_STATUS_OK) {
152 rdata = get_soa_rdata(cur_rr, rnum);
153 ldns_rr_free(cur_rr);
167 return lookup_soa_rdata(fd, 2);
173 return lookup_soa_rdata(fd, 6);
182 ldns_rr_class soa_class;
185 while (line_len >= 0) {
188 if (line[0] !=
';') {
189 status = ldns_rr_new_frm_str(&cur_rr, line, 0, NULL, NULL);
190 if (status == LDNS_STATUS_OK) {
191 soa_class = ldns_rr_get_class(cur_rr);
192 ldns_rr_free(cur_rr);
198 return LDNS_RR_CLASS_IN;