GUAC-236: Allow instruction handlers to touch the argument values.
This commit is contained in:
parent
0e5a7bb5c2
commit
91197ffad2
@ -60,8 +60,7 @@ static int guacenc_read_instructions(const char* path, guac_socket* socket) {
|
|||||||
|
|
||||||
/* Continuously read and handle all instructions */
|
/* Continuously read and handle all instructions */
|
||||||
while (!guac_parser_read(parser, socket, -1)) {
|
while (!guac_parser_read(parser, socket, -1)) {
|
||||||
guacenc_handle_instruction(parser->opcode, parser->argc,
|
guacenc_handle_instruction(parser->opcode, parser->argc, parser->argv);
|
||||||
(const char**) parser->argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fail on read/parse error */
|
/* Fail on read/parse error */
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int guacenc_handle_blob(int argc, const char** argv) {
|
int guacenc_handle_blob(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
@ -38,7 +38,7 @@ int guacenc_handle_blob(int argc, const char** argv) {
|
|||||||
|
|
||||||
/* Parse arguments */
|
/* Parse arguments */
|
||||||
int index = atoi(argv[0]);
|
int index = atoi(argv[0]);
|
||||||
const char* data = argv[1];
|
char* data = argv[1];
|
||||||
|
|
||||||
/* STUB */
|
/* STUB */
|
||||||
guacenc_log(GUAC_LOG_DEBUG, "blob: stream=%i data=[%i chars]",
|
guacenc_log(GUAC_LOG_DEBUG, "blob: stream=%i data=[%i chars]",
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_cfill(int argc, const char** argv) {
|
int guacenc_handle_cfill(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 6) {
|
if (argc < 6) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_copy(int argc, const char** argv) {
|
int guacenc_handle_copy(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 9) {
|
if (argc < 9) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_cursor(int argc, const char** argv) {
|
int guacenc_handle_cursor(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 7) {
|
if (argc < 7) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_dispose(int argc, const char** argv) {
|
int guacenc_handle_dispose(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_end(int argc, const char** argv) {
|
int guacenc_handle_end(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_img(int argc, const char** argv) {
|
int guacenc_handle_img(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 6) {
|
if (argc < 6) {
|
||||||
@ -39,7 +39,7 @@ int guacenc_handle_img(int argc, const char** argv) {
|
|||||||
int stream_index = atoi(argv[0]);
|
int stream_index = atoi(argv[0]);
|
||||||
int mask = atoi(argv[1]);
|
int mask = atoi(argv[1]);
|
||||||
int layer_index = atoi(argv[2]);
|
int layer_index = atoi(argv[2]);
|
||||||
const char* mimetype = argv[3];
|
char* mimetype = argv[3];
|
||||||
int x = atoi(argv[4]);
|
int x = atoi(argv[4]);
|
||||||
int y = atoi(argv[5]);
|
int y = atoi(argv[5]);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_move(int argc, const char** argv) {
|
int guacenc_handle_move(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_rect(int argc, const char** argv) {
|
int guacenc_handle_rect(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_shade(int argc, const char** argv) {
|
int guacenc_handle_shade(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_size(int argc, const char** argv) {
|
int guacenc_handle_size(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int guacenc_handle_transfer(int argc, const char** argv) {
|
int guacenc_handle_transfer(int argc, char** argv) {
|
||||||
|
|
||||||
/* Verify argument count */
|
/* Verify argument count */
|
||||||
if (argc < 9) {
|
if (argc < 9) {
|
||||||
|
@ -45,7 +45,7 @@ guacenc_instruction_handler_mapping guacenc_instruction_handler_map[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int guacenc_handle_instruction(const char* opcode,
|
int guacenc_handle_instruction(const char* opcode,
|
||||||
int argc, const char** argv) {
|
int argc, char** argv) {
|
||||||
|
|
||||||
/* Search through mapping for instruction handler having given opcode */
|
/* Search through mapping for instruction handler having given opcode */
|
||||||
guacenc_instruction_handler_mapping* current = guacenc_instruction_handler_map;
|
guacenc_instruction_handler_mapping* current = guacenc_instruction_handler_map;
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
* Zero if the instruction was handled successfully, non-zero if an error
|
* Zero if the instruction was handled successfully, non-zero if an error
|
||||||
* occurs.
|
* occurs.
|
||||||
*/
|
*/
|
||||||
typedef int guacenc_instruction_handler(int argc, const char** argv);
|
typedef int guacenc_instruction_handler(int argc, char** argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping of instruction opcode to corresponding handler function.
|
* Mapping of instruction opcode to corresponding handler function.
|
||||||
@ -91,8 +91,7 @@ extern guacenc_instruction_handler_mapping guacenc_instruction_handler_map[];
|
|||||||
* Zero if the instruction was handled successfully, non-zero if an error
|
* Zero if the instruction was handled successfully, non-zero if an error
|
||||||
* occurs.
|
* occurs.
|
||||||
*/
|
*/
|
||||||
int guacenc_handle_instruction(const char* opcode, int argc,
|
int guacenc_handle_instruction(const char* opcode, int argc, char** argv);
|
||||||
const char** argv);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the Guacamole "blob" instruction.
|
* Handler for the Guacamole "blob" instruction.
|
||||||
|
Loading…
Reference in New Issue
Block a user