mirror of https://github.com/getdnsapi/getdns.git
Pretty print constant names for values
With the "status", "dnssec_status" and "answer_type" keys.
This commit is contained in:
parent
b6856eb620
commit
7e2bc9771a
|
@ -6,7 +6,7 @@
|
||||||
#include "const-info.h"
|
#include "const-info.h"
|
||||||
|
|
||||||
static struct const_info consts_info[] = {
|
static struct const_info consts_info[] = {
|
||||||
{ -1, "/* <unknown const value> */", "/* <unknown const value> */" },
|
{ -1, NULL, "/* <unknown getdns value> */" },
|
||||||
{ 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
|
{ 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
|
||||||
{ 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
|
{ 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
|
||||||
{ 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
|
{ 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
|
||||||
|
|
13
src/dict.c
13
src/dict.c
|
@ -41,6 +41,7 @@
|
||||||
#include "util-internal.h"
|
#include "util-internal.h"
|
||||||
#include "dict.h"
|
#include "dict.h"
|
||||||
#include "rr-dict.h"
|
#include "rr-dict.h"
|
||||||
|
#include "const-info.h"
|
||||||
|
|
||||||
/*---------------------------------------- getdns_dict_find */
|
/*---------------------------------------- getdns_dict_find */
|
||||||
/**
|
/**
|
||||||
|
@ -689,13 +690,23 @@ getdns_pp_dict(ldns_buffer * buf, size_t indent,
|
||||||
switch (item->dtype) {
|
switch (item->dtype) {
|
||||||
case t_int:
|
case t_int:
|
||||||
if ((strcmp(item->node.key, "type") == 0 ||
|
if ((strcmp(item->node.key, "type") == 0 ||
|
||||||
strcmp(item->node.key, "type_covered") == 0) &&
|
strcmp(item->node.key, "type_covered") == 0 ||
|
||||||
|
strcmp(item->node.key, "qtype") == 0) &&
|
||||||
(strval = priv_getdns_rr_type_name(item->data.n))) {
|
(strval = priv_getdns_rr_type_name(item->data.n))) {
|
||||||
if (ldns_buffer_printf(
|
if (ldns_buffer_printf(
|
||||||
buf, " GETDNS_RRTYPE_%s", strval) < 0)
|
buf, " GETDNS_RRTYPE_%s", strval) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ((strcmp(item->node.key, "answer_type") == 0 ||
|
||||||
|
strcmp(item->node.key, "dnssec_status") == 0 ||
|
||||||
|
strcmp(item->node.key, "status") == 0) &&
|
||||||
|
(strval =
|
||||||
|
priv_getdns_get_const_info(item->data.n)->name)) {
|
||||||
|
if (ldns_buffer_printf(buf, " %s", strval) < 0)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (ldns_buffer_printf(buf, " %d", item->data.n) < 0)
|
if (ldns_buffer_printf(buf, " %d", item->data.n) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,7 +9,7 @@ cat > const-info.c << END_OF_HEAD
|
||||||
#include "const-info.h"
|
#include "const-info.h"
|
||||||
|
|
||||||
static struct const_info consts_info[] = {
|
static struct const_info consts_info[] = {
|
||||||
{ -1, "/* <unknown const value> */", "/* <unknown const value> */" },
|
{ -1, NULL, "/* <unknown getdns value> */" },
|
||||||
END_OF_HEAD
|
END_OF_HEAD
|
||||||
awk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ print "\t{ "$3", \""$1"\", "$1"_TEXT }," }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/_TEXT/{ print "\t{ "$3", \""$2"\", "$2"_TEXT },"}' getdns/getdns.h | sed 's/,,/,/g' >> const-info.c
|
awk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ print "\t{ "$3", \""$1"\", "$1"_TEXT }," }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/_TEXT/{ print "\t{ "$3", \""$2"\", "$2"_TEXT },"}' getdns/getdns.h | sed 's/,,/,/g' >> const-info.c
|
||||||
cat >> const-info.c << END_OF_TAIL
|
cat >> const-info.c << END_OF_TAIL
|
||||||
|
|
Loading…
Reference in New Issue