From d24aaeb614dcc1fe519463f167533cc21ece5490 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Apr 2014 12:56:06 -0700 Subject: [PATCH] GUAC-598: Bring up to compliance with POSIX standard claimed by source. --- configure.ac | 4 ++-- src/protocols/rdp/client.c | 2 -- src/protocols/vnc/client.c | 8 +++++++- src/protocols/vnc/vnc_handlers.c | 20 ++++++++++++++------ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index a6d66cee..5cc4e691 100644 --- a/configure.ac +++ b/configure.ac @@ -40,8 +40,8 @@ AC_PROG_LIBTOOL AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h time.h sys/time.h syslog.h unistd.h cairo/cairo.h pngstruct.h]) # Source characteristics -AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Uses POSIX APIs]) -AC_DEFINE([_BSD_SOURCE], [], [Uses BSD APIs]) +AC_DEFINE([_XOPEN_SOURCE], [700], [Uses X/Open and POSIX APIs]) +AC_DEFINE([_BSD_SOURCE], [], [Uses BSD APIs]) # libpng AC_CHECK_LIB([png], [png_write_png], [PNG_LIBS=-lpng], diff --git a/src/protocols/rdp/client.c b/src/protocols/rdp/client.c index 5d2bd998..a1199865 100644 --- a/src/protocols/rdp/client.c +++ b/src/protocols/rdp/client.c @@ -20,8 +20,6 @@ * THE SOFTWARE. */ -#define _XOPEN_SOURCE 500 - #include "config.h" #include "client.h" diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index 41a317ca..c13a50e3 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -280,12 +281,17 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* If unsuccessful, retry as many times as specified */ while (!rfb_client && retries_remaining > 0) { + struct timespec guac_vnc_connect_interval = { + .tv_sec = GUAC_VNC_CONNECT_INTERVAL/1000, + .tv_nsec = (GUAC_VNC_CONNECT_INTERVAL%1000)*1000000 + }; + guac_client_log_info(client, "Connect failed. Waiting %ims before retrying...", GUAC_VNC_CONNECT_INTERVAL); /* Wait for given interval then retry */ - usleep(GUAC_VNC_CONNECT_INTERVAL*1000); + nanosleep(&guac_vnc_connect_interval, NULL); rfb_client = __guac_vnc_get_client(client); retries_remaining--; diff --git a/src/protocols/vnc/vnc_handlers.c b/src/protocols/vnc/vnc_handlers.c index d202a261..368ab0bb 100644 --- a/src/protocols/vnc/vnc_handlers.c +++ b/src/protocols/vnc/vnc_handlers.c @@ -317,23 +317,31 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { void guac_vnc_client_log_info(const char* format, ...) { + char message[2048]; + + /* Copy log message into buffer */ va_list args; va_start(args, format); - - vsyslog(LOG_INFO, format, args); - + vsnprintf(message, sizeof(message), format, args); va_end(args); + /* Log to syslog */ + syslog(LOG_INFO, "%s", message); + } void guac_vnc_client_log_error(const char* format, ...) { + char message[2048]; + + /* Copy log message into buffer */ va_list args; va_start(args, format); - - vsyslog(LOG_ERR, format, args); - + vsnprintf(message, sizeof(message), format, args); va_end(args); + /* Log to syslog */ + syslog(LOG_ERR, "%s", message); + }