2013-12-29 04:53:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Glyptodon LLC
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2012-09-04 01:16:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef _GUAC_PLUGIN_H
|
|
|
|
#define _GUAC_PLUGIN_H
|
|
|
|
|
2012-09-05 02:06:14 +00:00
|
|
|
#include "client.h"
|
|
|
|
|
2012-09-04 01:16:16 +00:00
|
|
|
/**
|
|
|
|
* Provides functions and structures required for handling a client plugin.
|
|
|
|
*
|
|
|
|
* @file plugin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* String prefix which begins the library filename of all client plugins.
|
|
|
|
*/
|
|
|
|
#define GUAC_PROTOCOL_LIBRARY_PREFIX "libguac-client-"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* String suffix which ends the library filename of all client plugins.
|
|
|
|
*/
|
|
|
|
#define GUAC_PROTOCOL_LIBRARY_SUFFIX ".so"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum number of characters (COUNTING NULL TERMINATOR) to allow
|
|
|
|
* for protocol names within the library filename of client plugins.
|
|
|
|
*/
|
|
|
|
#define GUAC_PROTOCOL_NAME_LIMIT 256
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum number of characters (INCLUDING NULL TERMINATOR) that a
|
|
|
|
* character array containing the concatenation of the library prefix,
|
|
|
|
* protocol name, and suffix can contain, assuming the protocol name is
|
|
|
|
* limited to GUAC_PROTOCOL_NAME_LIMIT characters.
|
|
|
|
*/
|
|
|
|
#define GUAC_PROTOCOL_LIBRARY_LIMIT ( \
|
|
|
|
\
|
|
|
|
sizeof(GUAC_PROTOCOL_LIBRARY_PREFIX) - 1 /* "libguac-client-" */ \
|
|
|
|
+ GUAC_PROTOCOL_NAME_LIMIT - 1 /* [up to 256 chars] */ \
|
|
|
|
+ sizeof(GUAC_PROTOCOL_LIBRARY_SUFFIX) - 1 /* ".so" */ \
|
|
|
|
+ 1 /* NULL terminator */ \
|
|
|
|
\
|
|
|
|
)
|
|
|
|
|
|
|
|
typedef struct guac_client_plugin guac_client_plugin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A handle to a client plugin, containing enough information about the
|
|
|
|
* plugin to complete the initial protocol handshake and instantiate a new
|
|
|
|
* client supporting the protocol provided by the client plugin.
|
|
|
|
*/
|
|
|
|
struct guac_client_plugin {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to dlopen'd client plugin.
|
|
|
|
*/
|
|
|
|
void* __client_plugin_handle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to the init handler of this client plugin. This
|
|
|
|
* function will be called when the client plugin is started.
|
|
|
|
*/
|
|
|
|
guac_client_init_handler* init_handler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NULL-terminated array of all arguments accepted by this client
|
|
|
|
* plugin, in order. The values of these arguments will be passed
|
|
|
|
* to the init_handler if the client plugin is started.
|
|
|
|
*/
|
|
|
|
const char** args;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the plugin which provides support for the given protocol, if it
|
|
|
|
* exists.
|
|
|
|
*
|
|
|
|
* @param protocol The name of the protocol to retrieve the client plugin
|
|
|
|
* for.
|
|
|
|
* @return The client plugin supporting the given protocol, or NULL if
|
|
|
|
* an error occurs or no such plugin exists.
|
|
|
|
*/
|
|
|
|
guac_client_plugin* guac_client_plugin_open(const char* protocol);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close the given plugin, releasing all associated resources. This function
|
|
|
|
* must be called after use of a client plugin is finished.
|
|
|
|
*
|
|
|
|
* @param plugin The client plugin to close.
|
|
|
|
* @return Zero on success, non-zero if an error occurred while releasing
|
|
|
|
* the resources associated with the plugin.
|
|
|
|
*/
|
|
|
|
int guac_client_plugin_close(guac_client_plugin* plugin);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the given guac_client using the initialization routine provided
|
|
|
|
* by the given guac_client_plugin.
|
|
|
|
*
|
|
|
|
* @param plugin The client plugin to use to initialize the new client.
|
|
|
|
* @param client The guac_client to initialize.
|
|
|
|
* @param argc The number of arguments being passed to the client.
|
|
|
|
* @param argv All arguments to be passed to the client.
|
|
|
|
* @return Zero if initialization was successful, non-zero otherwise.
|
|
|
|
*/
|
|
|
|
int guac_client_plugin_init_client(guac_client_plugin* plugin,
|
|
|
|
guac_client* client, int argc, char** argv);
|
|
|
|
|
|
|
|
#endif
|