Skip to content
Snippets Groups Projects
Commit ca492e52 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

tests/libzsanner: add optional output spliting

parent d1b919a2
No related branches found
No related tags found
1 merge request!1238SVCB/HTTPS rrtype support
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -79,7 +79,11 @@ void debug_process_record(zs_scanner_t *s)
printf(" \\# %u ", s->r_data_length);
int block = *((int *)(s->process.data));
for (i = 0; i < s->r_data_length; i++) {
if (block > 0 && i > 0 && (i % block) == 0) {
printf(" ");
}
printf("%02X", (s->r_data)[i]);
}
printf("\n");
......
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -44,6 +44,7 @@ static void help(void)
" 0 Empty output.\n"
" 1 Debug output (DEFAULT).\n"
" 2 Test output.\n"
" -b <num> Divide hex string to blocks of length <num>.\n"
" -s State parsing mode.\n"
" -t Launch unit tests.\n"
" -h Print this help.\n");
......@@ -139,11 +140,12 @@ static int include(zs_scanner_t *s)
int main(int argc, char *argv[])
{
int mode = DEFAULT_MODE, state = 0, test = 0;
int mode = DEFAULT_MODE, block = 0, state = 0, test = 0;
// Command line long options.
struct option opts[] = {
{ "mode", required_argument, NULL, 'm' },
{ "block", required_argument, NULL, 'b' },
{ "state", no_argument, NULL, 's' },
{ "test", no_argument, NULL, 't' },
{ "help", no_argument, NULL, 'h' },
......@@ -152,11 +154,14 @@ int main(int argc, char *argv[])
// Parsed command line arguments.
int opt = 0, li = 0;
while ((opt = getopt_long(argc, argv, "m:sth", opts, &li)) != -1) {
while ((opt = getopt_long(argc, argv, "m:b:sth", opts, &li)) != -1) {
switch (opt) {
case 'm':
mode = atoi(optarg);
break;
case 'b':
block = atoi(optarg);
break;
case 's':
state = 1;
break;
......@@ -210,7 +215,7 @@ int main(int argc, char *argv[])
ret = 0;
break;
case 1:
ret = zs_set_processing(s, debug_process_record, debug_process_error, NULL);
ret = zs_set_processing(s, debug_process_record, debug_process_error, &block);
ret += zs_set_processing_comment(s, debug_process_comment);
break;
case 2:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment