]> pilppa.com Git - libplp.git/commitdiff
added new helper function for getting byte array as hex-str.
authorMika Laitio <lamikr@pilppa.org>
Mon, 14 Feb 2011 20:30:02 +0000 (22:30 +0200)
committerMika Laitio <lamikr@pilppa.org>
Mon, 14 Feb 2011 20:30:02 +0000 (22:30 +0200)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
src/Makefile.am
src_test/test_config.c
src_test/test_logs.c

index 9697c8bacc2f1939a1e2090873fdabcbf2eb29aa..7ad0d5a88c40c1e80566753a9af0fbc9de408f3e 100644 (file)
@@ -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
index 13a1d53c590e2d99b2ee3b671f49f815b713f732..24716f3083dfbff84896e0a85b2754397cbfee6a 100644 (file)
@@ -8,7 +8,7 @@
 #include <stdio.h>
 #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;
 }
index 3d01b2ff319fce37c0e0d5d97335f0bb9c678879..1b0059c77fd3d26e780b2839755d076b797a43d5 100644 (file)
@@ -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;
 }