mirror of https://github.com/getdnsapi/getdns.git
Re-enable printing of json with getdns_query
This commit is contained in:
parent
b26f09d1aa
commit
84c5b67ee0
|
@ -125,7 +125,6 @@ print_usage(FILE *out, const char *progname)
|
||||||
fprintf(out, "\t-U\tSet transport to UDP only\n");
|
fprintf(out, "\t-U\tSet transport to UDP only\n");
|
||||||
fprintf(out, "\t-B\tBatch mode. Schedule all messages before processing responses.\n");
|
fprintf(out, "\t-B\tBatch mode. Schedule all messages before processing responses.\n");
|
||||||
fprintf(out, "\t-q\tQuiet mode - don't print response\n");
|
fprintf(out, "\t-q\tQuiet mode - don't print response\n");
|
||||||
fprintf(out, "\t+sit[=cookie]\tSet edns cookie\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void callback(getdns_context *context, getdns_callback_type_t callback_type,
|
void callback(getdns_context *context, getdns_callback_type_t callback_type,
|
||||||
|
@ -135,14 +134,12 @@ void callback(getdns_context *context, getdns_callback_type_t callback_type,
|
||||||
|
|
||||||
if (callback_type == GETDNS_CALLBACK_COMPLETE) {
|
if (callback_type == GETDNS_CALLBACK_COMPLETE) {
|
||||||
/* This is a callback with data */;
|
/* This is a callback with data */;
|
||||||
if (!quiet) {
|
if (!quiet && (response_str = json ?
|
||||||
if (json)
|
getdns_print_json_dict(response, json == 1)
|
||||||
response_str = getdns_print_json_dict(
|
: getdns_pretty_print_dict(response))) {
|
||||||
response, json == 1);
|
|
||||||
else if ((response_str = getdns_pretty_print_dict(response))) {
|
fprintf(stdout, "ASYNC response:\n%s\n", response_str);
|
||||||
fprintf(stdout, "ASYNC response:\n%s\n", response_str);
|
free(response_str);
|
||||||
free(response_str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"The callback with ID %llu was successfull.\n",
|
"The callback with ID %llu was successfull.\n",
|
||||||
|
@ -156,6 +153,7 @@ void callback(getdns_context *context, getdns_callback_type_t callback_type,
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"The callback got a callback_type of %d. Exiting.\n",
|
"The callback got a callback_type of %d. Exiting.\n",
|
||||||
callback_type);
|
callback_type);
|
||||||
|
|
||||||
getdns_dict_destroy(response);
|
getdns_dict_destroy(response);
|
||||||
response = NULL;
|
response = NULL;
|
||||||
}
|
}
|
||||||
|
@ -527,15 +525,17 @@ main(int argc, char **argv)
|
||||||
if (r)
|
if (r)
|
||||||
goto done_destroy_extensions;
|
goto done_destroy_extensions;
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
if (json)
|
if ((response_str = json ?
|
||||||
response_str = getdns_print_json_dict(
|
getdns_print_json_dict(response, json == 1)
|
||||||
response, json == 1);
|
: getdns_pretty_print_dict(response))) {
|
||||||
else if ((response_str = getdns_pretty_print_dict(response))) {
|
|
||||||
fprintf(stdout, "SYNC response:\n%s\n", response_str);
|
fprintf( stdout, "SYNC response:\n%s\n"
|
||||||
|
, response_str);
|
||||||
free(response_str);
|
free(response_str);
|
||||||
} else {
|
} else {
|
||||||
r = GETDNS_RETURN_MEMORY_ERROR;
|
r = GETDNS_RETURN_MEMORY_ERROR;
|
||||||
fprintf(stderr, "Could not print response\n");
|
fprintf( stderr
|
||||||
|
, "Could not print response\n");
|
||||||
}
|
}
|
||||||
} else if (r == GETDNS_RETURN_GOOD)
|
} else if (r == GETDNS_RETURN_GOOD)
|
||||||
fprintf(stdout, "Response code was: GOOD\n");
|
fprintf(stdout, "Response code was: GOOD\n");
|
||||||
|
|
Loading…
Reference in New Issue