GUAC-654: Fix namespace and style.

This commit is contained in:
Michael Jumper 2014-05-07 14:36:49 -07:00
parent 30a31d07cf
commit 6b33c8eeda
8 changed files with 48 additions and 54 deletions

View File

@ -21,7 +21,6 @@
*/
#include "config.h"
#include "client.h"
#include "clipboard.h"
#include "guac_handlers.h"
@ -79,7 +78,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_socket* socket = client->socket;
telnet_client_data* client_data = malloc(sizeof(telnet_client_data));
guac_telnet_client_data* client_data = malloc(sizeof(guac_telnet_client_data));
/* Init client data */
client->data = client_data;
@ -131,15 +130,15 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_socket_flush(socket);
/* Set basic handlers */
client->handle_messages = telnet_guac_client_handle_messages;
client->key_handler = telnet_guac_client_key_handler;
client->mouse_handler = telnet_guac_client_mouse_handler;
client->size_handler = telnet_guac_client_size_handler;
client->free_handler = telnet_guac_client_free_handler;
client->handle_messages = guac_telnet_client_handle_messages;
client->key_handler = guac_telnet_client_key_handler;
client->mouse_handler = guac_telnet_client_mouse_handler;
client->size_handler = guac_telnet_client_size_handler;
client->free_handler = guac_telnet_client_free_handler;
client->clipboard_handler = guac_telnet_clipboard_handler;
/* Start client thread */
if (pthread_create(&(client_data->client_thread), NULL, telnet_client_thread, (void*) client)) {
if (pthread_create(&(client_data->client_thread), NULL, guac_telnet_client_thread, (void*) client)) {
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Unable to start telnet client thread");
return -1;
}

View File

@ -20,12 +20,10 @@
* THE SOFTWARE.
*/
#ifndef _TELNET_GUAC_CLIENT_H
#define _TELNET_GUAC_CLIENT_H
#ifndef GUAC_TELNET__CLIENT_H
#define GUAC_TELNET__CLIENT_H
#include "config.h"
#include "terminal.h"
#include <pthread.h>
@ -34,7 +32,7 @@
/**
* Telnet-specific client data.
*/
typedef struct telnet_client_data {
typedef struct guac_telnet_client_data {
/**
* The hostname of the telnet server to connect to.
@ -82,7 +80,7 @@ typedef struct telnet_client_data {
*/
guac_terminal* term;
} telnet_client_data;
} guac_telnet_client_data;
#endif

View File

@ -23,12 +23,13 @@
#include "config.h"
#include "client.h"
#include "clipboard.h"
#include "terminal.h"
int guac_telnet_clipboard_handler(guac_client* client, guac_stream* stream,
char* mimetype) {
/* Clear clipboard and prepare for new data */
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
guac_terminal_clipboard_reset(client_data->term, mimetype);
/* Set handlers for clipboard stream */
@ -42,7 +43,7 @@ int guac_telnet_clipboard_blob_handler(guac_client* client, guac_stream* stream,
void* data, int length) {
/* Append new data */
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
guac_terminal_clipboard_append(client_data->term, data, length);
return 0;

View File

@ -20,8 +20,8 @@
* THE SOFTWARE.
*/
#ifndef _GUAC_TELNET_CLIPBOARD_H
#define _GUAC_TELNET_CLIPBOARD_H
#ifndef GUAC_TELNET__CLIPBOARD_H
#define GUAC_TELNET__CLIPBOARD_H
#include "config.h"

View File

@ -21,7 +21,6 @@
*/
#include "config.h"
#include "client.h"
#include "guac_handlers.h"
#include "terminal.h"
@ -33,23 +32,21 @@
#include <sys/select.h>
#include <sys/stat.h>
#include <cairo/cairo.h>
#include <guacamole/socket.h>
#include <guacamole/protocol.h>
#include <guacamole/client.h>
#include <libtelnet.h>
#include <pango/pangocairo.h>
int telnet_guac_client_handle_messages(guac_client* client) {
int guac_telnet_client_handle_messages(guac_client* client) {
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
return guac_terminal_render_frame(client_data->term);
}
int telnet_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) {
int guac_telnet_client_mouse_handler(guac_client* client, int x, int y, int mask) {
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
guac_terminal* term = client_data->term;
/* Send mouse event */
@ -58,9 +55,9 @@ int telnet_guac_client_mouse_handler(guac_client* client, int x, int y, int mask
}
int telnet_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
int guac_telnet_client_key_handler(guac_client* client, int keysym, int pressed) {
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
guac_terminal* term = client_data->term;
/* Send key */
@ -69,10 +66,10 @@ int telnet_guac_client_key_handler(guac_client* client, int keysym, int pressed)
}
int telnet_guac_client_size_handler(guac_client* client, int width, int height) {
int guac_telnet_client_size_handler(guac_client* client, int width, int height) {
/* Get terminal */
telnet_client_data* guac_client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* guac_client_data = (guac_telnet_client_data*) client->data;
guac_terminal* terminal = guac_client_data->term;
/* Resize terminal */
@ -85,9 +82,9 @@ int telnet_guac_client_size_handler(guac_client* client, int width, int height)
return 0;
}
int telnet_guac_client_free_handler(guac_client* client) {
int guac_telnet_client_free_handler(guac_client* client) {
telnet_client_data* guac_client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* guac_client_data = (guac_telnet_client_data*) client->data;
/* Close telnet connection */
if (guac_client_data->socket_fd != -1)

View File

@ -20,19 +20,18 @@
* THE SOFTWARE.
*/
#ifndef _TELNET_GUAC_HANDLERS_H
#define _TELNET_GUAC_HANDLERS_H
#ifndef GUAC_TELNET__GUAC_HANDLERS_H
#define GUAC_TELNET__GUAC_HANDLERS_H
#include "config.h"
#include <guacamole/client.h>
int telnet_guac_client_handle_messages(guac_client* client);
int telnet_guac_client_key_handler(guac_client* client, int keysym, int pressed);
int telnet_guac_client_mouse_handler(guac_client* client, int x, int y, int mask);
int telnet_guac_client_size_handler(guac_client* client, int width, int height);
int telnet_guac_client_free_handler(guac_client* client);
int guac_telnet_client_handle_messages(guac_client* client);
int guac_telnet_client_key_handler(guac_client* client, int keysym, int pressed);
int guac_telnet_client_mouse_handler(guac_client* client, int x, int y, int mask);
int guac_telnet_client_size_handler(guac_client* client, int width, int height);
int guac_telnet_client_free_handler(guac_client* client);
#endif

View File

@ -21,10 +21,10 @@
*/
#include "config.h"
#include "client.h"
#include "guac_handlers.h"
#include "telnet_client.h"
#include "terminal.h"
#include <errno.h>
#include <netdb.h>
@ -36,10 +36,10 @@
#include <sys/types.h>
#include <unistd.h>
#include <libtelnet.h>
#include <guacamole/client.h>
#include <guacamole/protocol.h>
#include <guacamole/socket.h>
#include <libtelnet.h>
static const telnet_telopt_t __telnet_options[] = {
{ TELNET_TELOPT_ECHO, TELNET_WONT, TELNET_DONT },
@ -50,7 +50,7 @@ static const telnet_telopt_t __telnet_options[] = {
{ -1, 0, 0 }
};
static int __write_all(int fd, const char* buffer, int size) {
static int __guac_telnet_write_all(int fd, const char* buffer, int size) {
int remaining = size;
while (remaining > 0) {
@ -73,7 +73,7 @@ static int __write_all(int fd, const char* buffer, int size) {
static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event, void* data) {
guac_client* client = (guac_client*) data;
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
switch (event->type) {
@ -84,7 +84,8 @@ static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event,
/* Data destined for remote end */
case TELNET_EV_SEND:
if (__write_all(client_data->socket_fd, event->data.buffer, event->data.size) != event->data.size)
if (__guac_telnet_write_all(client_data->socket_fd, event->data.buffer, event->data.size)
!= event->data.size)
guac_client_stop(client);
break;
@ -121,10 +122,10 @@ static void __guac_telnet_event_handler(telnet_t* telnet, telnet_event_t* event,
}
static void* telnet_input_thread(void* data) {
static void* __guac_telnet_input_thread(void* data) {
guac_client* client = (guac_client*) data;
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
char buffer[8192];
int bytes_read;
@ -148,7 +149,7 @@ static telnet_t* __guac_telnet_create_session(guac_client* client) {
char connected_address[1024];
char connected_port[64];
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
struct addrinfo hints = {
.ai_family = AF_UNSPEC,
@ -244,10 +245,10 @@ void guac_telnet_send_naws(telnet_t* telnet, uint16_t width, uint16_t height) {
telnet_finish_sb(telnet);
}
void* telnet_client_thread(void* data) {
void* guac_telnet_client_thread(void* data) {
guac_client* client = (guac_client*) data;
telnet_client_data* client_data = (telnet_client_data*) client->data;
guac_telnet_client_data* client_data = (guac_telnet_client_data*) client->data;
pthread_t input_thread;
char buffer[8192];
@ -264,7 +265,7 @@ void* telnet_client_thread(void* data) {
guac_client_log_info(client, "Telnet connection successful.");
/* Start input thread */
if (pthread_create(&(input_thread), NULL, telnet_input_thread, (void*) client)) {
if (pthread_create(&(input_thread), NULL, __guac_telnet_input_thread, (void*) client)) {
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, "Unable to start input thread");
return NULL;
}

View File

@ -20,9 +20,8 @@
* THE SOFTWARE.
*/
#ifndef __TELNET_CLIENT_H
#define __TELNET_CLIENT_H
#ifndef GUAC_TELNET__TELNET_CLIENT_H
#define GUAC_TELNET__TELNET_CLIENT_H
#include "config.h"
@ -31,7 +30,7 @@
/**
* Main telnet client thread, handling transfer of telnet output to STDOUT.
*/
void* telnet_client_thread(void* data);
void* guac_telnet_client_thread(void* data);
/**
* Send a telnet NAWS message indicating the given terminal window dimensions