From 58573c4110e4349865d977139949458a745df478 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 8 Feb 2022 10:08:05 +0000 Subject: [PATCH] Update xrdpapi/simple.c for new logging --- xrdpapi/simple.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/xrdpapi/simple.c b/xrdpapi/simple.c index 47e3d00e..0599b350 100644 --- a/xrdpapi/simple.c +++ b/xrdpapi/simple.c @@ -22,7 +22,8 @@ /* * build instructions: - * gcc simple.c -o simple -L./.libs -lxrdpapi + * gcc simple.c -o simple -I.. -I../common -L./.libs -L../common/.libs \ + * -DHAVE_CONFIG_H -lxrdpapi -lcommon */ #if defined(HAVE_CONFIG_H) @@ -34,6 +35,8 @@ #endif #include "xrdpapi.h" +#include "log.h" + #include #include #include @@ -47,25 +50,35 @@ int run_tsmf_test(void); int main(int argc, char **argv) { - if (argc < 2) + int result; + struct log_config *lc; + + if ((lc = log_config_init_for_console(LOG_LEVEL_DEBUG, NULL)) != NULL) { - printf("usage: simple \n"); - return 1; + log_start_from_param(lc); } - if (strcasecmp(argv[1], "echo") == 0) + if (argc > 1 && strcasecmp(argv[1], "echo") == 0) { - return run_echo_test(); + result = run_echo_test(); } - else if (strcasecmp(argv[1], "tsmf") == 0) + else if (argc > 1 && strcasecmp(argv[1], "tsmf") == 0) { - return run_tsmf_test(); + result = run_tsmf_test(); } else { printf("usage: simple \n"); - return 1; + result = 1; } + + if (lc != NULL) + { + log_config_free(lc); + log_end(); + } + + return result; } /**