Signed-off-by: Alexey Kodanev <[email protected]>
---
include/test.h | 2 ++
lib/tst_res.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/include/test.h b/include/test.h
index e36ca38..17b8e39 100644
--- a/include/test.h
+++ b/include/test.h
@@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
__attribute__ ((format (printf, 3, 4)));
void tst_resm(int ttype, char *arg_fmt, ...)
__attribute__ ((format (printf, 2, 3)));
+void tst_resm_hexd(int ttype, const char *buf, size_t size, char *arg_fmt, ...)
+ __attribute__ ((format (printf, 4, 5)));
void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
__attribute__ ((format (printf, 4, 5)));
void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ffac6d7..e7c9d5d 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -675,6 +675,40 @@ void tst_resm(int ttype, char *arg_fmt, ...)
}
/*
+ * tst_resm_hexd() - Interface to tst_res(), with no filename.
+ * Also, dump specified buffer in hex.
+ */
+void tst_resm_hexd(int ttype, const char *buf, size_t size, char *arg_fmt, ...)
+{
+ char tmesg[USERMESG];
+
+#if DEBUG
+ printf("IN tst_resm_hexd\n");
+ fflush(stdout);
+ fflush(stdout);
+#endif
+
+ EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+
+ static const size_t symb_num = 3; /* space + xx */
+
+ size_t offset = strlen(tmesg);
+
+ if ((offset + symb_num * size + 1) >= USERMESG) {
+ printf("%s: %i: line too long\n", __func__, __LINE__);
+ abort();
+ }
+
+ size_t i;
+ for (i = 0; i < size; ++i) {
+ sprintf(tmesg + offset + i * symb_num,
+ " %02x", (unsigned char)buf[i]);
+ }
+
+ tst_res(ttype, NULL, "%s", tmesg);
+}
+
+/*
* tst_brkm() - Interface to tst_brk(), with no filename.
*/
void tst_brkm(int ttype, void (*func) (void), char *arg_fmt, ...)
--
1.7.1
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list