GUAC-598: Bring up to compliance with POSIX standard claimed by source.

This commit is contained in:
Michael Jumper 2014-04-11 12:56:06 -07:00
parent 20222beaed
commit d24aaeb614
4 changed files with 23 additions and 11 deletions

View File

@ -40,7 +40,7 @@ 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]) 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 # Source characteristics
AC_DEFINE([_POSIX_C_SOURCE], [200809L], [Uses POSIX APIs]) AC_DEFINE([_XOPEN_SOURCE], [700], [Uses X/Open and POSIX APIs])
AC_DEFINE([_BSD_SOURCE], [], [Uses BSD APIs]) AC_DEFINE([_BSD_SOURCE], [], [Uses BSD APIs])
# libpng # libpng

View File

@ -20,8 +20,6 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#define _XOPEN_SOURCE 500
#include "config.h" #include "config.h"
#include "client.h" #include "client.h"

View File

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <rfb/rfbclient.h> #include <rfb/rfbclient.h>
#include <guacamole/audio.h> #include <guacamole/audio.h>
@ -280,12 +281,17 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* If unsuccessful, retry as many times as specified */ /* If unsuccessful, retry as many times as specified */
while (!rfb_client && retries_remaining > 0) { 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, guac_client_log_info(client,
"Connect failed. Waiting %ims before retrying...", "Connect failed. Waiting %ims before retrying...",
GUAC_VNC_CONNECT_INTERVAL); GUAC_VNC_CONNECT_INTERVAL);
/* Wait for given interval then retry */ /* 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); rfb_client = __guac_vnc_get_client(client);
retries_remaining--; retries_remaining--;

View File

@ -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, ...) { void guac_vnc_client_log_info(const char* format, ...) {
char message[2048];
/* Copy log message into buffer */
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vsnprintf(message, sizeof(message), format, args);
vsyslog(LOG_INFO, format, args);
va_end(args); va_end(args);
/* Log to syslog */
syslog(LOG_INFO, "%s", message);
} }
void guac_vnc_client_log_error(const char* format, ...) { void guac_vnc_client_log_error(const char* format, ...) {
char message[2048];
/* Copy log message into buffer */
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vsnprintf(message, sizeof(message), format, args);
vsyslog(LOG_ERR, format, args);
va_end(args); va_end(args);
/* Log to syslog */
syslog(LOG_ERR, "%s", message);
} }