From 7cfb6f83acecf4d7b74264382ab3c2dfeb0e75ed Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 19 Jun 2023 20:31:27 +0200 Subject: [PATCH] debug function now returns string instead of directly printing to stdout --- lib/debug.ml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/debug.ml b/lib/debug.ml index ce2a62e..2c70401 100644 --- a/lib/debug.ml +++ b/lib/debug.ml @@ -1,7 +1,7 @@ -let print_dns_header (header : Types.dns_header) = - Printf.printf +let dns_header (header : Types.dns_header) = + Printf.sprintf "{ id = %d; flags = %d; num_questions = %d; num_answers = %d; num_authorities = %d; \ - num_additionals = %d }\n" + num_additionals = %d }" header.id header.flags header.num_questions @@ -10,17 +10,17 @@ let print_dns_header (header : Types.dns_header) = header.num_additionals ;; -let print_dns_question (question : Types.dns_question) = - Printf.printf - "{ name = '%s'; type_ = %d; class_ = %d }\n" +let dns_question (question : Types.dns_question) = + Printf.sprintf + "{ name = '%s'; type_ = %d; class_ = %d }" (Bytes.to_string question.name) question.type_ question.class_ ;; -let print_dns_record (record : Types.dns_record) = - Printf.printf - "{ name = '%s'; type_ = %d; class_ = %d; ttl = %d; data = '%s' }\n" +let dns_record (record : Types.dns_record) = + Printf.sprintf + "{ name = '%s'; type_ = %d; class_ = %d; ttl = %d; data = '%s' }" (Bytes.to_string record.name) record.type_ record.class_