mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Moved client registry into own separate UUID-tree datatype, added client registry struct, migrated dependencies
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <png.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include "uuidtree.h"
|
||||
|
||||
#include "guacio.h"
|
||||
|
||||
@@ -32,7 +33,7 @@
|
||||
*/
|
||||
|
||||
typedef struct guac_client guac_client;
|
||||
typedef struct guac_client_registry_node guac_client_registry_node;
|
||||
typedef struct guac_client_registry guac_client_registry;
|
||||
|
||||
typedef void guac_client_handle_messages(guac_client* client);
|
||||
typedef void guac_client_mouse_handler(guac_client* client, int x, int y, int button_mask);
|
||||
@@ -188,7 +189,7 @@ typedef void guac_client_init_handler(guac_client* client, int argc, char** argv
|
||||
* @param argv The arguments being passed to this client.
|
||||
* @return A pointer to the newly initialized (or found) client.
|
||||
*/
|
||||
guac_client* guac_get_client(int client_fd, guac_client_registry_node* registry, guac_client_init_handler* client_init, int argc, char** argv);
|
||||
guac_client* guac_get_client(int client_fd, guac_client_registry* registry, guac_client_init_handler* client_init, int argc, char** argv);
|
||||
|
||||
/**
|
||||
* Enter the main network message handling loop for the given client.
|
||||
@@ -203,7 +204,7 @@ void guac_start_client(guac_client* client);
|
||||
* @param client The proxy client to free all reasources of.
|
||||
* @param registry The registry to remove this client from when freed.
|
||||
*/
|
||||
void guac_free_client(guac_client* client, guac_client_registry_node* registry);
|
||||
void guac_free_client(guac_client* client, guac_client_registry* registry);
|
||||
|
||||
/**
|
||||
* Allocate a libpng-compatible buffer to hold raw image data.
|
||||
@@ -226,66 +227,22 @@ void guac_free_png_buffer(png_byte** png_buffer, int h);
|
||||
|
||||
|
||||
/**
|
||||
* Represents a single node of the Guacamole client registry. The
|
||||
* Guacamole client registry contains references to all active clients,
|
||||
* indexed by client UUID.
|
||||
* Represent the Guacamole "client registry" in which all
|
||||
* currently connected clients are stored, indexed by UUID.
|
||||
*/
|
||||
struct guac_client_registry_node {
|
||||
struct guac_client_registry {
|
||||
|
||||
/**
|
||||
* The number of pointers used inside the next array.
|
||||
* Root of the uuid tree
|
||||
*/
|
||||
int used;
|
||||
|
||||
/**
|
||||
* The next guac_client_registry_node if currently looking at any byte
|
||||
* of the UUID except the last, or the guac_client if looking at the
|
||||
* last byte of the UUID.
|
||||
*/
|
||||
void* next[256];
|
||||
guac_uuid_tree_node* root;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers the given client in the client registry by that client's UUID.
|
||||
*
|
||||
* @param registry The registry to register the client within.
|
||||
* @param client The client to register.
|
||||
*/
|
||||
void guac_register_client(guac_client_registry_node* registry, guac_client* client);
|
||||
|
||||
/**
|
||||
* Returns the client from the client registry associated with the given UUID.
|
||||
*
|
||||
* @param registry The registry to search.
|
||||
* @param uuid The uuid of the client to lookup.
|
||||
* @return The client, if found, or NULL if no such client has been registered.
|
||||
*/
|
||||
guac_client* guac_find_client(guac_client_registry_node* registry, uuid_t uuid);
|
||||
|
||||
/**
|
||||
* Removes the given client from the client registry.
|
||||
*
|
||||
* @param registry The registry to remove the client from.
|
||||
* @param client The client to remove.
|
||||
*/
|
||||
void guac_remove_client(guac_client_registry_node* registry, guac_client* client);
|
||||
|
||||
/**
|
||||
* Creates a new client registry.
|
||||
*
|
||||
* @return The newly allocated and initialized registry.
|
||||
*/
|
||||
guac_client_registry_node* guac_create_client_registry();
|
||||
|
||||
/**
|
||||
* Frees all memory associated with the given client registry.
|
||||
*
|
||||
* @param registry The registry to clean up.
|
||||
*/
|
||||
void guac_cleanup_client_registry(guac_client_registry_node* registry);
|
||||
|
||||
|
||||
|
||||
guac_client_registry* guac_create_client_registry();
|
||||
void guac_register_client(guac_client_registry* registry, guac_client* client);
|
||||
guac_client* guac_find_client(guac_client_registry* registry, uuid_t uuid);
|
||||
void guac_remove_client(guac_client_registry* registry, uuid_t uuid);
|
||||
void guac_cleanup_registry(guac_client_registry* registry);
|
||||
|
||||
#endif
|
||||
|
52
guacamole/libguac/include/uuidtree.h
Normal file
52
guacamole/libguac/include/uuidtree.h
Normal 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 _UUIDTREE_H
|
||||
#define _UUIDTREE_H
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
typedef struct guac_uuid_tree_node guac_uuid_tree_node;
|
||||
|
||||
/**
|
||||
* Represents a single node of a tree storing objects by UUID.
|
||||
*/
|
||||
struct guac_uuid_tree_node {
|
||||
|
||||
/**
|
||||
* The number of pointers used inside the next array.
|
||||
*/
|
||||
int used;
|
||||
|
||||
/**
|
||||
* The next guac_uuid_tree_node if currently looking at any byte
|
||||
* of the UUID except the last, or the stored object if looking at the
|
||||
* last byte of the UUID.
|
||||
*/
|
||||
void* next[256];
|
||||
|
||||
};
|
||||
|
||||
guac_uuid_tree_node* guac_create_uuid_tree();
|
||||
void guac_uuid_tree_put(guac_uuid_tree_node* tree, uuid_t uuid, void* obj);
|
||||
void* guac_uuid_tree_get(guac_uuid_tree_node* tree, uuid_t uuid);
|
||||
void guac_uuid_tree_remove(guac_uuid_tree_node* tree, uuid_t uuid);
|
||||
void guac_cleanup_uuid_tree(guac_uuid_tree_node* tree);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user