Skip to content

Commit

Permalink
Merge pull request #2276 from matt335672/xrdpapi_simple
Browse files Browse the repository at this point in the history
Update xrdpapi/simple.c example to work with new logging
  • Loading branch information
matt335672 authored May 19, 2022
2 parents 6c4bdf7 + dabd049 commit a64573b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
11 changes: 11 additions & 0 deletions xrdpapi/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ libxrdpapi_la_SOURCES = \

libxrdpapi_la_LIBADD = \
$(top_builddir)/common/libcommon.la

# Build the 'simple' example program, so it's added to the CI
noinst_PROGRAMS = xrdp-xrdpapi-simple

xrdp_xrdpapi_simple_SOURCES = \
simple.c

# If you change this, update the standalone build instructions in simple.c
xrdp_xrdpapi_simple_LDADD = \
libxrdpapi.la \
$(top_builddir)/common/libcommon.la
43 changes: 28 additions & 15 deletions xrdpapi/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -34,6 +35,8 @@
#endif

#include "xrdpapi.h"
#include "log.h"

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
Expand All @@ -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 <echo|tsmf>\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 <echo|tsmf>\n");
return 1;
result = 1;
}

if (lc != NULL)
{
log_config_free(lc);
log_end();
}

return result;
}

/**
Expand All @@ -89,18 +102,18 @@ run_echo_test(void)
int rv;
int count;
int pkt_count;
int i;
int bytes_written;
int bytes_read;
unsigned int i;
unsigned int bytes_written;
unsigned int bytes_read;

unsigned char c;
unsigned char *rd_ptr;
unsigned char *wr_ptr;
char *rd_ptr;
char *wr_ptr;

/* fill out_buf[] with incremental values */
for (i = 0, c = 0; i < 8192; i++, c++)
{
out_buf[i] = c;
out_buf[i] = (char)c;
}

/* open a virtual channel named ECHO */
Expand Down

0 comments on commit a64573b

Please sign in to comment.