You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/01/30 19:08:37 UTC
[09/11] guacamole-server git commit: GUACAMOLE-313: Include unknown
keys within log.
GUACAMOLE-313: Include unknown keys within log.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/b7257d9a
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/b7257d9a
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/b7257d9a
Branch: refs/heads/master
Commit: b7257d9ae45287a8a9e1b80920c677d75863698c
Parents: 5e5f1fc
Author: Michael Jumper <mj...@apache.org>
Authored: Fri Dec 8 13:10:32 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Jan 26 16:24:45 2018 -0800
----------------------------------------------------------------------
src/guaclog/keydef.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/b7257d9a/src/guaclog/keydef.c
----------------------------------------------------------------------
diff --git a/src/guaclog/keydef.c b/src/guaclog/keydef.c
index 427e3ca..6b979fa 100644
--- a/src/guaclog/keydef.c
+++ b/src/guaclog/keydef.c
@@ -21,6 +21,7 @@
#include "keydef.h"
#include "log.h"
+#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -169,6 +170,36 @@ static guaclog_keydef* guaclog_get_known_key(int keysym) {
}
/**
+ * Returns a statically-allocated guaclog_keydef representing an unknown key,
+ * deriving the name of the key from the hexadecimal value of the keysym.
+ *
+ * @param keysym
+ * The X11 keysym of the key.
+ *
+ * @return
+ * A statically-allocated guaclog_keydef representing the key associated
+ * with the given keysym.
+ */
+static guaclog_keydef* guaclog_get_unknown_key(int keysym) {
+
+ static char unknown_keydef_name[64];
+ static guaclog_keydef unknown_keydef;
+
+ /* Write keysym as hex */
+ int size = snprintf(unknown_keydef_name, sizeof(unknown_keydef_name),
+ "0x%X", keysym);
+
+ /* Hex string is guaranteed to fit within the provided 64 bytes */
+ assert(size < sizeof(unknown_keydef_name));
+
+ /* Return static key definition */
+ unknown_keydef.keysym = keysym;
+ unknown_keydef.name = unknown_keydef_name;
+ return &unknown_keydef;
+
+}
+
+/**
* Returns a statically-allocated guaclog_keydef representing the key
* associated with the given keysym, deriving the name and value of the key
* using its corresponding Unicode character.
@@ -286,7 +317,7 @@ guaclog_keydef* guaclog_keydef_alloc(int keysym) {
/* Key not known */
guaclog_log(GUAC_LOG_DEBUG, "Definition not found for key 0x%X.", keysym);
- return NULL;
+ return guaclog_copy_key(guaclog_get_unknown_key(keysym));
}