From 373cab0be6db3aedfeda93237f2c81dc236c48d3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 3 Sep 2012 17:58:43 -0700 Subject: [PATCH] Refactor layer struct and functions into layer.h --- libguac/include/client.h | 36 ------------ libguac/include/layer.h | 116 +++++++++++++++++++++++++++++++++++++ libguac/include/protocol.h | 32 ---------- 3 files changed, 116 insertions(+), 68 deletions(-) create mode 100644 libguac/include/layer.h diff --git a/libguac/include/client.h b/libguac/include/client.h index 9dc650f1..a7fa9d61 100644 --- a/libguac/include/client.h +++ b/libguac/include/client.h @@ -509,42 +509,6 @@ void guac_client_free(guac_client* client); */ int guac_client_handle_instruction(guac_client* client, guac_instruction* instruction); -/** - * Allocates a new buffer (invisible layer). An arbitrary index is - * automatically assigned if no existing buffer is available for use. - * - * @param client The proxy client to allocate the buffer for. - * @return The next available buffer, or a newly allocated buffer. - */ -guac_layer* guac_client_alloc_buffer(guac_client* client); - -/** - * Allocates a new layer. An arbitrary index is automatically assigned - * if no existing layer is available for use. - * - * @param client The proxy client to allocate the layer buffer for. - * @return The next available layer, or a newly allocated layer. - */ -guac_layer* guac_client_alloc_layer(guac_client* client); - -/** - * Returns the given buffer to the pool of available buffers, such that it - * can be reused by any subsequent call to guac_client_allow_buffer(). - * - * @param client The proxy client to return the buffer to. - * @param layer The buffer to return to the pool of available buffers. - */ -void guac_client_free_buffer(guac_client* client, guac_layer* layer); - -/** - * Returns the given layer to the pool of available layers, such that it - * can be reused by any subsequent call to guac_client_allow_layer(). - * - * @param client The proxy client to return the layer to. - * @param layer The buffer to return to the pool of available layer. - */ -void guac_client_free_layer(guac_client* client, guac_layer* layer); - /** * Logs an informational message in the log used by the given client. The * logger used will normally be defined by guacd (or whichever program loads diff --git a/libguac/include/layer.h b/libguac/include/layer.h new file mode 100644 index 00000000..732b53ee --- /dev/null +++ b/libguac/include/layer.h @@ -0,0 +1,116 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _GUAC_LAYER_H +#define _GUAC_LAYER_H + +/** + * Provides functions and structures required for allocating and using layers. + * + * @file layer.h + */ + +typedef struct guac_layer guac_layer; + +/** + * Represents a single layer within the Guacamole protocol. + */ +struct guac_layer { + + /** + * The index of this layer. + */ + int index; + + /** + * The URI which must be passed via a resource instruction to denote + * a resource related to this layer. This value is automatically set + * upon allocation. + */ + char* uri; + + /** + * The next allocated layer in the list of all layers. + */ + guac_layer* __next; + + /** + * The next available (unused) layer in the list of + * allocated but free'd layers. + */ + guac_layer* __next_available; + +}; + +/** + * Allocates a new buffer (invisible layer). An arbitrary index is + * automatically assigned if no existing buffer is available for use. + * + * @param client The proxy client to allocate the buffer for. + * @return The next available buffer, or a newly allocated buffer. + */ +guac_layer* guac_client_alloc_buffer(guac_client* client); + +/** + * Allocates a new layer. An arbitrary index is automatically assigned + * if no existing layer is available for use. + * + * @param client The proxy client to allocate the layer buffer for. + * @return The next available layer, or a newly allocated layer. + */ +guac_layer* guac_client_alloc_layer(guac_client* client); + +/** + * Returns the given buffer to the pool of available buffers, such that it + * can be reused by any subsequent call to guac_client_allow_buffer(). + * + * @param client The proxy client to return the buffer to. + * @param layer The buffer to return to the pool of available buffers. + */ +void guac_client_free_buffer(guac_client* client, guac_layer* layer); + +/** + * Returns the given layer to the pool of available layers, such that it + * can be reused by any subsequent call to guac_client_allow_layer(). + * + * @param client The proxy client to return the layer to. + * @param layer The buffer to return to the pool of available layer. + */ +void guac_client_free_layer(guac_client* client, guac_layer* layer); + +#endif + diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index 6d77107d..b4c571e6 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -170,38 +170,6 @@ typedef enum guac_line_join_style { GUAC_LINE_JOIN_ROUND = 0x2 } guac_line_join_style; -typedef struct guac_layer guac_layer; - -/** - * Represents a single layer within the Guacamole protocol. - */ -struct guac_layer { - - /** - * The index of this layer. - */ - int index; - - /** - * The URI which must be passed via a resource instruction to denote - * a resource related to this layer. This value is automatically set - * upon allocation. - */ - char* uri; - - /** - * The next allocated layer in the list of all layers. - */ - guac_layer* __next; - - /** - * The next available (unused) layer in the list of - * allocated but free'd layers. - */ - guac_layer* __next_available; - -}; - /** * Represents a single instruction within the Guacamole protocol. */