GUACAMOLE-422: Rename new opcode handler function.

This commit is contained in:
Nick Couchman 2019-04-11 17:11:41 -04:00
parent c750b18f60
commit 379fce2d77
5 changed files with 42 additions and 6 deletions

View File

@ -544,6 +544,32 @@ void guac_user_free(guac_user* user);
*/ */
int guac_user_handle_connection(guac_user* user, int usec_timeout); int guac_user_handle_connection(guac_user* user, int usec_timeout);
/**
* Call the appropriate handler defined by the given user for the given
* instruction. A comparison is made between the instruction opcode and the
* initial handler lookup table defined in user-handlers.c. The initial handlers
* will in turn call the user's handler (if defined).
*
* @param user
* The user whose handlers should be called.
*
* @param opcode
* The opcode of the instruction to pass to the user via the appropriate
* handler.
*
* @param argc
* The number of arguments which are part of the instruction.
*
* @param argv
* An array of all arguments which are part of the instruction.
*
* @return
* Non-negative if the instruction was handled successfully, or negative
* if an error occurred.
*/
int guac_user_handle_instruction(guac_user* user, const char* opcode,
int argc, char** argv);
/** /**
* Allocates a new stream. An arbitrary index is automatically assigned * Allocates a new stream. An arbitrary index is automatically assigned
* if no previously-allocated stream is available for use. * if no previously-allocated stream is available for use.

View File

@ -693,7 +693,7 @@ void guac_free_mimetypes(char** mimetypes) {
} }
int guac_user_handle_instruction(__guac_instruction_handler_mapping* map, int __guac_user_call_opcode_handler(__guac_instruction_handler_mapping* map,
guac_user* user, const char* opcode, int argc, char** argv) { guac_user* user, const char* opcode, int argc, char** argv) {
/* For each defined instruction */ /* For each defined instruction */

View File

@ -261,8 +261,10 @@ char** guac_copy_mimetypes(char** mimetypes, int count);
/** /**
* Call the appropriate handler defined by the given user for the given * Call the appropriate handler defined by the given user for the given
* instruction. A comparison is made between the instruction opcode and the * instruction. A comparison is made between the instruction opcode and the
* initial handler lookup table defined in user-handlers.c. The intial handlers * initial handler lookup table defined in the map that is provided to this
* will in turn call the user's handler (if defined). * function. If an entry for the instruction is found in the provided map,
* the handler defined in that map will be called and the value returned. If
* no match is found, it is silently ignored.
* *
* @param map * @param map
* The array that holds the opcode to handler mappings. * The array that holds the opcode to handler mappings.
@ -284,7 +286,7 @@ char** guac_copy_mimetypes(char** mimetypes, int count);
* Non-negative if the instruction was handled successfully, or negative * Non-negative if the instruction was handled successfully, or negative
* if an error occurred. * if an error occurred.
*/ */
int guac_user_handle_instruction(__guac_instruction_handler_mapping* map, int __guac_user_call_opcode_handler(__guac_instruction_handler_mapping* map,
guac_user* user, const char* opcode, int argc, char** argv); guac_user* user, const char* opcode, int argc, char** argv);
#endif #endif

View File

@ -25,6 +25,7 @@
#include "guacamole/protocol.h" #include "guacamole/protocol.h"
#include "guacamole/socket.h" #include "guacamole/socket.h"
#include "guacamole/user.h" #include "guacamole/user.h"
#include "user-handlers.h"
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
@ -161,7 +162,7 @@ static void* guac_user_input_thread(void* data) {
guac_error_message = NULL; guac_error_message = NULL;
/* Call handler, stop on error */ /* Call handler, stop on error */
if (guac_user_handle_instruction(__guac_instruction_handler_map, if (__guac_user_call_opcode_handler(__guac_instruction_handler_map,
user, parser->opcode, parser->argc, parser->argv) < 0) { user, parser->opcode, parser->argc, parser->argv) < 0) {
/* Log error */ /* Log error */
@ -266,7 +267,7 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) {
parser->opcode); parser->opcode);
/* Run instruction handler for opcode with arguments. */ /* Run instruction handler for opcode with arguments. */
if (guac_user_handle_instruction(__guac_handshake_handler_map, user, if (__guac_user_call_opcode_handler(__guac_handshake_handler_map, user,
parser->opcode, parser->argc, parser->argv)) { parser->opcode, parser->argc, parser->argv)) {
guac_user_log_handshake_failure(user); guac_user_log_handshake_failure(user);

View File

@ -167,6 +167,13 @@ void guac_user_free_object(guac_user* user, guac_object* object) {
} }
int guac_user_handle_instruction(guac_user* user, const char* opcode, int argc, char** argv) {
return __guac_user_call_opcode_handler(__guac_instruction_handler_map,
user, opcode, argc, argv);
}
void guac_user_stop(guac_user* user) { void guac_user_stop(guac_user* user) {
user->active = 0; user->active = 0;
} }