Moved guac -> libguac, moving towards pluggable protocols.

This commit is contained in:
Michael Jumper
2010-09-13 01:14:08 -07:00
parent 279266a67d
commit 5b66e05f8d
13 changed files with 63 additions and 50 deletions

View File

@@ -0,0 +1,46 @@
/*
* Guacamole - Clientless Remote Desktop
* Copyright (C) 2010 Michael Jumper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CLIENT_H
#define _CLIENT_H
#include <png.h>
#include "guacio.h"
typedef struct guac_client {
GUACIO* io;
void* data;
void (*handle_messages)(struct guac_client* client);
void (*mouse_handler)(struct guac_client* client, int x, int y, int button_mask);
void (*key_handler)(struct guac_client* client, int keysym, int pressed);
void (*clipboard_handler)(struct guac_client* client, char* copied);
void (*free_handler)(void* client);
} guac_client;
guac_client* guac_get_client(int client_fd, void (*client_init)(guac_client* client, const char* hostname, int port), const char* hostname, int port);
void guac_start_client(guac_client* client);
void guac_free_client(guac_client* client);
png_byte** guac_alloc_png_buffer(int w, int h, int bpp);
void guac_free_png_buffer(png_byte** png_buffer, int h);
#endif

View File

@@ -0,0 +1,54 @@
/*
* Guacamole - Clientless Remote Desktop
* Copyright (C) 2010 Michael Jumper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GUACIO_H
#define _GUACIO_H
#include <unistd.h>
typedef struct GUACIO {
int fd;
int ready;
int ready_buf[3];
int written;
char out_buf[8192];
int instructionbuf_size;
int instructionbuf_used_length;
char* instructionbuf;
/* Limit */
unsigned int transfer_limit; /* KB/sec */
} GUACIO;
GUACIO* guac_open(int fd);
ssize_t guac_write_int(GUACIO* io, unsigned int i);
ssize_t guac_write_string(GUACIO* io, const char* str);
ssize_t guac_write_base64(GUACIO* io, const void* buf, size_t count);
ssize_t guac_flush_base64(GUACIO* io);
ssize_t guac_flush(GUACIO* io);
int guac_select(GUACIO* io, int usec_timeout);
void guac_close(GUACIO* io);
#endif

View File

@@ -0,0 +1,52 @@
/*
* Guacamole - Clientless Remote Desktop
* Copyright (C) 2010 Michael Jumper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PROTOCOL_H
#define __PROTOCOL_H
#include <png.h>
#include "guacio.h"
typedef struct guac_instruction {
char* opcode;
int argc;
char** argv;
} guac_instruction;
void guac_free_instruction(guac_instruction* instruction);
char* guac_escape_string(const char* str);
char* guac_unescape_string_inplace(char* str);
void guac_send_name(GUACIO* io, const char* name);
void guac_send_error(GUACIO* io, const char* error);
void guac_send_clipboard(GUACIO* io, const char* data);
void guac_send_size(GUACIO* io, int w, int h);
void guac_send_copy(GUACIO* io, int srcx, int srcy, int w, int h, int dstx, int dsty);
void guac_send_png(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h);
void guac_send_cursor(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h);
int guac_instructions_waiting(GUACIO* io);
int guac_read_instruction(GUACIO* io, guac_instruction* parsed_instruction);
#endif