From 78bb8cd9be1d21c3de747a7e4bb2f4d30d86595f Mon Sep 17 00:00:00 2001 From: kpl Date: Wed, 4 Mar 2020 14:25:59 -0500 Subject: [PATCH] dns_sd/rpt.h/cpp : Initial commit. --- dns_sd/rpt.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ dns_sd/rpt.h | 10 +++++++++ 2 files changed, 71 insertions(+) create mode 100644 dns_sd/rpt.cpp create mode 100644 dns_sd/rpt.h diff --git a/dns_sd/rpt.cpp b/dns_sd/rpt.cpp new file mode 100644 index 0000000..719ce4e --- /dev/null +++ b/dns_sd/rpt.cpp @@ -0,0 +1,61 @@ +#include +#include + +#include "rpt.h" + +void vrpt( printCallback_t printCbFunc, const char* fmt, va_list vl ) +{ + if( printCbFunc != nullptr ) + { + const int bufN = 32; + char buf[bufN]; + vsnprintf(buf,bufN,fmt,vl); + buf[bufN-1] = '\0'; + printCbFunc(buf); + } +} + +void rpt( printCallback_t printCbFunc, const char* fmt, ... ) +{ + va_list vl; + va_start(vl,fmt); + vrpt(printCbFunc,fmt,vl); + va_end(vl); +} + + +void rptHex( printCallback_t printCbFunc, const void* buf, unsigned bufByteN, const char* label, bool asciiFl ) +{ + const unsigned char* data = static_cast(buf); + const unsigned colN = 8; + unsigned ci = 0; + + if( label != nullptr ) + rpt(printCbFunc,"%s\n",label); + + for(unsigned i=0; i