From 518903483d7a1123add420c5fb61b73ded433f97 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 Oct 2012 13:45:06 -0700 Subject: [PATCH] Add nest instruction. --- libguac/include/protocol.h | 16 ++++++++++++++++ libguac/src/protocol.c | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index 6c4fca8c..fc73394d 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -215,6 +215,22 @@ int guac_protocol_send_disconnect(guac_socket* socket); */ int guac_protocol_send_error(guac_socket* socket, const char* error); +/** + * Sends a nest instruction over the given guac_socket connection. + * + * If an error occurs sending the instruction, a non-zero value is + * returned, and guac_error is set appropriately. + * + * @param socket The guac_socket connection to use. + * @param index The integer index of the stram to send the protocol + * data over. + * @param data A string containing protocol data, which must be UTF-8 + * encoded and null-terminated. + * @return Zero on success, non-zero on error. + */ +int guac_protocol_send_nest(guac_socket* socket, int index, + const char* data); + /** * Sends a set instruction over the given guac_socket connection. * diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 84344470..eba527d7 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -715,6 +715,17 @@ int guac_protocol_send_name(guac_socket* socket, const char* name) { } +int guac_protocol_send_nest(guac_socket* socket, int index, + const char* data) { + + return + guac_socket_write_string(socket, "4.nest,") + || __guac_socket_write_length_int(socket, index) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_string(socket, data) + || guac_socket_write_string(socket, ";"); + +} int guac_protocol_send_png(guac_socket* socket, guac_composite_mode mode, const guac_layer* layer, int x, int y, cairo_surface_t* surface) {