Exemplo n.º 1
0
struct zonefile *
zonefile_init_fname(const char *fname)
{
	struct zonefile *z = my_calloc(1, sizeof(struct zonefile));

	size_t len_fname = strlen(fname);
	if (len_fname >= 3 &&
	    fname[len_fname - 3] == '.' &&
	    fname[len_fname - 2] == 'g' &&
	    fname[len_fname - 1] == 'z')
	{
		ubuf *u = ubuf_new();
		ubuf_add_cstr(u, "zcat ");
		ubuf_add_cstr(u, fname);
		z->fp = popen(ubuf_cstr(u), "r");
		z->is_pipe = true;
		ubuf_destroy(&u);
	} else {
		z->fp = fopen(fname, "r");
	}

	if (z->fp == NULL)
		return (NULL);

	z->valid = true;
	if (read_soa(z) != LDNS_STATUS_OK)
		zonefile_destroy(&z);

	return (z);
}
Exemplo n.º 2
0
wdns_res
wdns_str_to_rdata(const char * str, uint16_t rrtype, uint16_t rrclass,
		   uint8_t **rdata, size_t *rdlen) {
	ubuf *u;
	wdns_res res;

	u = ubuf_new();
	res = _wdns_str_to_rdata_ubuf(u, str, rrtype, rrclass);
	if (res == wdns_res_success) {
		ubuf_detach(u, (uint8_t **) rdata, rdlen);
	}
	ubuf_destroy(&u);
	return (res);
}
Exemplo n.º 3
0
char *
wdns_rdata_to_str(const uint8_t *rdata, uint16_t rdlen,
		  uint16_t rrtype, uint16_t rrclass)
{
	char *ret;
	size_t retsz;
	ubuf *u;

	u = ubuf_new();
	_wdns_rdata_to_ubuf(u, rdata, rdlen, rrtype, rrclass);
	ubuf_cterm(u);
	ubuf_detach(u, (uint8_t **) &ret, &retsz);
	ubuf_destroy(&u);
	return (ret);
}