diff --git a/libguac/include/client.h b/libguac/include/client.h index f4cb9e95..1f449f23 100644 --- a/libguac/include/client.h +++ b/libguac/include/client.h @@ -151,13 +151,13 @@ struct guac_client { * The time (in milliseconds) of receipt of the last sync message from * the client. */ - long last_received_timestamp; + guac_timestamp_t last_received_timestamp; /** * The time (in milliseconds) that the last sync message was sent to the * client. */ - long last_sent_timestamp; + guac_timestamp_t last_sent_timestamp; /** * Reference to dlopen'd client plugin. diff --git a/libguac/include/guacio.h b/libguac/include/guacio.h index ff3a1639..d21fea0c 100644 --- a/libguac/include/guacio.h +++ b/libguac/include/guacio.h @@ -123,7 +123,7 @@ GUACIO* guac_open(int fd); * @param i The unsigned int to write. * @return Zero on success, or non-zero if an error occurs while writing. */ -ssize_t guac_write_int(GUACIO* io, long i); +ssize_t guac_write_int(GUACIO* io, int64_t i); /** * Writes the given string to the given GUACIO object. The data diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index c0172efe..d7733cac 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -64,6 +64,7 @@ */ #define GUAC_USEC_TIMEOUT (GUAC_TIMEOUT*1000) +typedef int64_t guac_timestamp_t; /** * Composite modes used by Guacamole draw instructions. Each @@ -192,7 +193,7 @@ int guac_send_name(GUACIO* io, const char* name); * @param timestamp The current timestamp (in milliseconds). * @return Zero on success, non-zero on error. */ -int guac_send_sync(GUACIO* io, long timestamp); +int guac_send_sync(GUACIO* io, guac_timestamp_t timestamp); /** * Sends an error instruction over the given GUACIO connection. The @@ -298,7 +299,7 @@ int guac_instructions_waiting(GUACIO* io); */ int guac_read_instruction(GUACIO* io, guac_instruction* parsed_instruction); -long guac_current_timestamp(); +guac_timestamp_t guac_current_timestamp(); void guac_sleep(int millis); #endif diff --git a/libguac/src/client-handlers.c b/libguac/src/client-handlers.c index 380ad19a..83a9481f 100644 --- a/libguac/src/client-handlers.c +++ b/libguac/src/client-handlers.c @@ -55,7 +55,7 @@ __guac_instruction_handler_mapping __guac_instruction_handler_map[] = { /* Guacamole instruction handlers */ int __guac_handle_sync(guac_client* client, guac_instruction* instruction) { - long timestamp = atol(instruction->argv[0]); + guac_timestamp_t timestamp = atol(instruction->argv[0]); /* Error if timestamp is in future */ if (timestamp > client->last_sent_timestamp) diff --git a/libguac/src/client.c b/libguac/src/client.c index 47ed4636..cdc0cc43 100644 --- a/libguac/src/client.c +++ b/libguac/src/client.c @@ -267,7 +267,7 @@ void* __guac_client_output_thread(void* data) { while (client->state == RUNNING) { /* Occasionally ping client with sync */ - long timestamp = guac_current_timestamp(); + guac_timestamp_t timestamp = guac_current_timestamp(); if (timestamp - client->last_sent_timestamp > GUAC_SYNC_FREQUENCY) { client->last_sent_timestamp = timestamp; if ( diff --git a/libguac/src/guacio.c b/libguac/src/guacio.c index a160633e..3b06fff9 100644 --- a/libguac/src/guacio.c +++ b/libguac/src/guacio.c @@ -98,11 +98,11 @@ ssize_t __guac_write(GUACIO* io, const char* buf, int count) { return retval; } -ssize_t guac_write_int(GUACIO* io, long i) { +ssize_t guac_write_int(GUACIO* io, int64_t i) { char buffer[128]; char* ptr = &(buffer[127]); - long nonneg; + int64_t nonneg; /* Obtain non-negative value */ if (i < 0) nonneg = -i; diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index d2b3e91a..f0c9299f 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -263,7 +263,7 @@ int guac_send_error(GUACIO* io, const char* error) { } -int guac_send_sync(GUACIO* io, long timestamp) { +int guac_send_sync(GUACIO* io, guac_timestamp_t timestamp) { return guac_write_string(io, "sync:") @@ -503,7 +503,7 @@ int guac_instructions_waiting(GUACIO* io) { return guac_select(io, GUAC_USEC_TIMEOUT); } -long guac_current_timestamp() { +guac_timestamp_t guac_current_timestamp() { #ifdef HAVE_CLOCK_GETTIME @@ -513,7 +513,7 @@ long guac_current_timestamp() { clock_gettime(CLOCK_REALTIME, ¤t); /* Calculate milliseconds */ - return current.tv_sec * 1000 + current.tv_nsec / 1000000; + return (guac_timestamp_t) current.tv_sec * 1000 + current.tv_nsec / 1000000; #else @@ -523,7 +523,7 @@ long guac_current_timestamp() { gettimeofday(¤t, NULL); /* Calculate milliseconds */ - return current.tv_sec * 1000 + current.tv_usec / 1000; + return (guac_timestamp_t) current.tv_sec * 1000 + current.tv_usec / 1000; #endif