Migrated guac_parse_int to __guac_parse_int, out of socket.h

This commit is contained in:
Michael Jumper 2011-11-25 13:18:00 -08:00
parent 6bd9c00fae
commit c4c30af6a4
3 changed files with 20 additions and 30 deletions

View File

@ -130,17 +130,6 @@ typedef struct guac_socket {
*/
guac_socket* guac_socket_open(int fd);
/**
* Parses the given string as a decimal number, returning the result as
* a 64-bit signed value. This value will be 64-bit regardless of platform.
*
* @param str The string to parse into a 64-bit integer.
* @return The 64-bit integer representation of the number in the given
* string, undefined if the string does not contain a properly
* formatted number.
*/
int64_t guac_parse_int(const char* str);
/**
* Writes the given unsigned int to the given guac_socket object. The data
* written may be buffered until the buffer is flushed automatically or

View File

@ -53,10 +53,29 @@ __guac_instruction_handler_mapping __guac_instruction_handler_map[] = {
{NULL, NULL}
};
int64_t __guac_parse_int(const char* str) {
int sign = 1;
int64_t num = 0;
for (; *str != '\0'; str++) {
if (*str == '-')
sign = -sign;
else
num = num * 10 + (*str - '0');
}
return num * sign;
}
/* Guacamole instruction handlers */
int __guac_handle_sync(guac_client* client, guac_instruction* instruction) {
guac_timestamp timestamp = guac_parse_int(instruction->argv[0]);
guac_timestamp timestamp = __guac_parse_int(instruction->argv[0]);
/* Error if timestamp is in future */
if (timestamp > client->last_sent_timestamp)

View File

@ -122,24 +122,6 @@ ssize_t __guac_socket_write(guac_socket* io, const char* buf, int count) {
return retval;
}
int64_t guac_parse_int(const char* str) {
int sign = 1;
int64_t num = 0;
for (; *str != '\0'; str++) {
if (*str == '-')
sign = -sign;
else
num = num * 10 + (*str - '0');
}
return num * sign;
}
ssize_t guac_socket_write_int(guac_socket* io, int64_t i) {
char buffer[128];