From 0e5a7bb5c2a54d587c6872c221e75cd7a82ec39d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 26 Feb 2016 18:35:15 -0800 Subject: [PATCH] GUAC-236: Add argument parsing stubs to instruction handlers. --- src/guacenc/instruction-blob.c | 20 ++++++++++++++++++++ src/guacenc/instruction-cfill.c | 23 +++++++++++++++++++++++ src/guacenc/instruction-copy.c | 27 +++++++++++++++++++++++++++ src/guacenc/instruction-cursor.c | 25 +++++++++++++++++++++++++ src/guacenc/instruction-dispose.c | 17 +++++++++++++++++ src/guacenc/instruction-end.c | 17 +++++++++++++++++ src/guacenc/instruction-img.c | 25 +++++++++++++++++++++++++ src/guacenc/instruction-move.c | 22 ++++++++++++++++++++++ src/guacenc/instruction-rect.c | 22 ++++++++++++++++++++++ src/guacenc/instruction-shade.c | 18 ++++++++++++++++++ src/guacenc/instruction-size.c | 19 +++++++++++++++++++ src/guacenc/instruction-transfer.c | 27 +++++++++++++++++++++++++++ 12 files changed, 262 insertions(+) diff --git a/src/guacenc/instruction-blob.c b/src/guacenc/instruction-blob.c index a3356414..e69fe491 100644 --- a/src/guacenc/instruction-blob.c +++ b/src/guacenc/instruction-blob.c @@ -21,9 +21,29 @@ */ #include "config.h" +#include "log.h" + +#include + +#include +#include int guacenc_handle_blob(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 2) { + guacenc_log(GUAC_LOG_DEBUG, "\"blob\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int index = atoi(argv[0]); + const char* data = argv[1]; + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "blob: stream=%i data=[%i chars]", + index, strlen(data)); return 0; + } diff --git a/src/guacenc/instruction-cfill.c b/src/guacenc/instruction-cfill.c index 419be042..2042173c 100644 --- a/src/guacenc/instruction-cfill.c +++ b/src/guacenc/instruction-cfill.c @@ -21,9 +21,32 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_cfill(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 6) { + guacenc_log(GUAC_LOG_DEBUG, "\"cfill\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int mask = atoi(argv[0]); + int index = atoi(argv[1]); + int r = atoi(argv[2]); + int g = atoi(argv[3]); + int b = atoi(argv[4]); + int a = atoi(argv[5]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "cfill: mask=0x%X layer=%i " + "rgba(%i, %i, %i, %i)", mask, index, r, g, b, a); return 0; + } diff --git a/src/guacenc/instruction-copy.c b/src/guacenc/instruction-copy.c index 22589111..ce82e82b 100644 --- a/src/guacenc/instruction-copy.c +++ b/src/guacenc/instruction-copy.c @@ -21,9 +21,36 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_copy(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 9) { + guacenc_log(GUAC_LOG_DEBUG, "\"copy\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int src_index = atoi(argv[0]); + int src_x = atoi(argv[1]); + int src_y = atoi(argv[2]); + int src_w = atoi(argv[3]); + int src_h = atoi(argv[4]); + int mask = atoi(argv[5]); + int dst_index = atoi(argv[6]); + int dst_x = atoi(argv[7]); + int dst_y = atoi(argv[8]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "copy: src_layer=%i (%i, %i) %ix%i mask=0x%X " + "dst_layer=%i (%i, %i)", src_index, src_x, src_y, src_w, src_h, + mask, dst_index, dst_x, dst_y); return 0; + } diff --git a/src/guacenc/instruction-cursor.c b/src/guacenc/instruction-cursor.c index 83a2f7f8..8d3a5b34 100644 --- a/src/guacenc/instruction-cursor.c +++ b/src/guacenc/instruction-cursor.c @@ -21,9 +21,34 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_cursor(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 7) { + guacenc_log(GUAC_LOG_DEBUG, "\"cursor\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int hotspot_x = atoi(argv[0]); + int hotspot_y = atoi(argv[1]); + int src_index = atoi(argv[2]); + int src_x = atoi(argv[3]); + int src_y = atoi(argv[4]); + int src_w = atoi(argv[5]); + int src_h = atoi(argv[6]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "cursor: hotspot (%i, %i) " + "src_layer=%i (%i, %i) %ix%i", hotspot_x, hotspot_y, + src_index, src_x, src_y, src_w, src_h); return 0; + } diff --git a/src/guacenc/instruction-dispose.c b/src/guacenc/instruction-dispose.c index f70319e6..0b280a0f 100644 --- a/src/guacenc/instruction-dispose.c +++ b/src/guacenc/instruction-dispose.c @@ -21,9 +21,26 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_dispose(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 1) { + guacenc_log(GUAC_LOG_DEBUG, "\"dispose\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int index = atoi(argv[0]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "dispose: layer=%i", index); return 0; + } diff --git a/src/guacenc/instruction-end.c b/src/guacenc/instruction-end.c index fe0aa74c..a99a0e45 100644 --- a/src/guacenc/instruction-end.c +++ b/src/guacenc/instruction-end.c @@ -21,9 +21,26 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_end(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 1) { + guacenc_log(GUAC_LOG_DEBUG, "\"end\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int index = atoi(argv[0]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "end: stream=%i", index); return 0; + } diff --git a/src/guacenc/instruction-img.c b/src/guacenc/instruction-img.c index 26a3d6d9..9e2dd312 100644 --- a/src/guacenc/instruction-img.c +++ b/src/guacenc/instruction-img.c @@ -21,9 +21,34 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_img(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 6) { + guacenc_log(GUAC_LOG_DEBUG, "\"img\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int stream_index = atoi(argv[0]); + int mask = atoi(argv[1]); + int layer_index = atoi(argv[2]); + const char* mimetype = argv[3]; + int x = atoi(argv[4]); + int y = atoi(argv[5]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "img: stream=%i mask=0x%X layer=%i " + "mimetype=%s (%i, %i)", stream_index, mask, layer_index, + mimetype, x, y); + return 0; + } diff --git a/src/guacenc/instruction-move.c b/src/guacenc/instruction-move.c index 5fab5715..2e916929 100644 --- a/src/guacenc/instruction-move.c +++ b/src/guacenc/instruction-move.c @@ -21,9 +21,31 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_move(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 5) { + guacenc_log(GUAC_LOG_DEBUG, "\"move\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int layer_index = atoi(argv[0]); + int parent_index = atoi(argv[1]); + int x = atoi(argv[2]); + int y = atoi(argv[3]); + int z = atoi(argv[4]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "move: layer=%i parent=%i (%i, %i) z=%i", + layer_index, parent_index, x, y, z); return 0; + } diff --git a/src/guacenc/instruction-rect.c b/src/guacenc/instruction-rect.c index 32fc45d6..85e229f0 100644 --- a/src/guacenc/instruction-rect.c +++ b/src/guacenc/instruction-rect.c @@ -21,9 +21,31 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_rect(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 5) { + guacenc_log(GUAC_LOG_DEBUG, "\"rect\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int index = atoi(argv[0]); + int x = atoi(argv[1]); + int y = atoi(argv[2]); + int width = atoi(argv[3]); + int height = atoi(argv[4]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "rect: layer=%i (%i, %i) %ix%i", + index, x, y, width, height); return 0; + } diff --git a/src/guacenc/instruction-shade.c b/src/guacenc/instruction-shade.c index 4d5eeb9c..48e6d7aa 100644 --- a/src/guacenc/instruction-shade.c +++ b/src/guacenc/instruction-shade.c @@ -21,9 +21,27 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_shade(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 2) { + guacenc_log(GUAC_LOG_DEBUG, "\"shade\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int index = atoi(argv[0]); + int opacity = atoi(argv[1]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "shade: layer=%i opacity=0x%X", index, opacity); return 0; + } diff --git a/src/guacenc/instruction-size.c b/src/guacenc/instruction-size.c index a4520f30..7057bcc4 100644 --- a/src/guacenc/instruction-size.c +++ b/src/guacenc/instruction-size.c @@ -21,9 +21,28 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_size(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 3) { + guacenc_log(GUAC_LOG_DEBUG, "\"size\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int index = atoi(argv[0]); + int width = atoi(argv[1]); + int height = atoi(argv[2]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "size: layer=%i %ix%i", index, width, height); return 0; + } diff --git a/src/guacenc/instruction-transfer.c b/src/guacenc/instruction-transfer.c index c2123985..ae0f4ea7 100644 --- a/src/guacenc/instruction-transfer.c +++ b/src/guacenc/instruction-transfer.c @@ -21,9 +21,36 @@ */ #include "config.h" +#include "log.h" + +#include + +#include int guacenc_handle_transfer(int argc, const char** argv) { + + /* Verify argument count */ + if (argc < 9) { + guacenc_log(GUAC_LOG_DEBUG, "\"transform\" instruction incomplete"); + return 1; + } + + /* Parse arguments */ + int src_index = atoi(argv[0]); + int src_x = atoi(argv[1]); + int src_y = atoi(argv[2]); + int src_w = atoi(argv[3]); + int src_h = atoi(argv[4]); + int function = atoi(argv[5]); + int dst_index = atoi(argv[6]); + int dst_x = atoi(argv[7]); + int dst_y = atoi(argv[8]); + /* STUB */ + guacenc_log(GUAC_LOG_DEBUG, "transform: src_layer=%i (%i, %i) %ix%i " + "function=0x%X dst_layer=%i (%i, %i)", src_index, src_x, src_y, + src_w, src_h, function, dst_index, dst_x, dst_y); return 0; + }