debug function now returns string instead of directly printing to stdout

This commit is contained in:
Mylloon 2023-06-19 20:31:27 +02:00
parent 10347ad517
commit 7cfb6f83ac
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,7 +1,7 @@
let print_dns_header (header : Types.dns_header) = let dns_header (header : Types.dns_header) =
Printf.printf Printf.sprintf
"{ id = %d; flags = %d; num_questions = %d; num_answers = %d; num_authorities = %d; \ "{ id = %d; flags = %d; num_questions = %d; num_answers = %d; num_authorities = %d; \
num_additionals = %d }\n" num_additionals = %d }"
header.id header.id
header.flags header.flags
header.num_questions header.num_questions
@ -10,17 +10,17 @@ let print_dns_header (header : Types.dns_header) =
header.num_additionals header.num_additionals
;; ;;
let print_dns_question (question : Types.dns_question) = let dns_question (question : Types.dns_question) =
Printf.printf Printf.sprintf
"{ name = '%s'; type_ = %d; class_ = %d }\n" "{ name = '%s'; type_ = %d; class_ = %d }"
(Bytes.to_string question.name) (Bytes.to_string question.name)
question.type_ question.type_
question.class_ question.class_
;; ;;
let print_dns_record (record : Types.dns_record) = let dns_record (record : Types.dns_record) =
Printf.printf Printf.sprintf
"{ name = '%s'; type_ = %d; class_ = %d; ttl = %d; data = '%s' }\n" "{ name = '%s'; type_ = %d; class_ = %d; ttl = %d; data = '%s' }"
(Bytes.to_string record.name) (Bytes.to_string record.name)
record.type_ record.type_
record.class_ record.class_