From 1916f239c0e4cd558629b8dc887dbb1e6f779cdf Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Mon, 14 Feb 2011 22:30:02 +0200 Subject: [PATCH] added new helper function for getting byte array as hex-str. Signed-off-by: Mika Laitio --- src/Makefile.am | 10 ++++++---- src_test/test_config.c | 6 +++++- src_test/test_logs.c | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 9697c8b..7ad0d5a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,14 +1,16 @@ lib_LTLIBRARIES = libplp.la libplp_la_SOURCES = \ - retval.h \ + config.c config.h \ log.h \ log_config.c \ - config.c config.h + str_util.c str_util.h \ + retval.h libplp_la_LDFLAGS = $(SRC_LIBS) $(all_libraries) -version-info 1:0:0 -no-undefined AM_CPPFLAGS = $(SRC_CFLAGS) DISTCLEANFILES = Makefile.in libplpincludedir=$(includedir)/plp libplpinclude_HEADERS = \ - retval.h \ + config.h \ log.h \ - config.h + retval.h \ + str_util.h diff --git a/src_test/test_config.c b/src_test/test_config.c index 13a1d53..24716f3 100644 --- a/src_test/test_config.c +++ b/src_test/test_config.c @@ -8,7 +8,7 @@ #include #include "../src/config.h" -int main(int argc, char** argv) { +void test_config() { char work_dir[FILENAME_MAX]; getcwd(work_dir, sizeof(work_dir)); @@ -26,5 +26,9 @@ int main(int argc, char** argv) { "mysection_name", "myoption_name", "my_option_value2"); +} + +int main(int argc, char** argv) { + test_config(); return 0; } diff --git a/src_test/test_logs.c b/src_test/test_logs.c index 3d01b2f..1b0059c 100644 --- a/src_test/test_logs.c +++ b/src_test/test_logs.c @@ -13,8 +13,9 @@ #include "log.h" -int main(int argc, char** argv) -{ +#include "../src/str_util.h" + +void test_logging() { log_debug("debug"); log_debug("debug v%d\n", 2); log_info("info\n"); @@ -23,5 +24,20 @@ int main(int argc, char** argv) log_warning("warning v%d\n", 2); log_error("error\n"); log_error("error v%d\n", 2); +} + +void test_str_util() { + char *res_str; + char b_arr[] = {0x1, 0x11, 0x21, 0x31}; + + res_str = get_as_hex_str(b_arr, 4); + log_info("bytes: %s\n", res_str); + free(res_str); +} + +int main(int argc, char** argv) +{ + test_logging(); + test_str_util(); return 0; } -- 2.41.0