From ed7028176632704c35c395c31c3534f30456d6c0 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 9 Jul 2015 12:05:57 -0700 Subject: [PATCH] GUAC-1171: Move SFTP functions to own header. --- src/common-ssh/Makefile.am | 2 ++ src/common-ssh/guac_sftp.c | 41 +++++++++++++++++++++++ src/common-ssh/guac_sftp.h | 67 ++++++++++++++++++++++++++++++++++++++ src/common-ssh/guac_ssh.c | 14 -------- src/common-ssh/guac_ssh.h | 37 --------------------- 5 files changed, 110 insertions(+), 51 deletions(-) create mode 100644 src/common-ssh/guac_sftp.c create mode 100644 src/common-ssh/guac_sftp.h diff --git a/src/common-ssh/Makefile.am b/src/common-ssh/Makefile.am index f389179a..79607a7c 100644 --- a/src/common-ssh/Makefile.am +++ b/src/common-ssh/Makefile.am @@ -26,9 +26,11 @@ ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libguac_common_ssh.la libguac_common_ssh_la_SOURCES = \ + guac_sftp.c \ guac_ssh.c noinst_HEADERS = \ + guac_sftp.h \ guac_ssh.h libguac_common_ssh_la_CFLAGS = \ diff --git a/src/common-ssh/guac_sftp.c b/src/common-ssh/guac_sftp.c new file mode 100644 index 00000000..a2524eaf --- /dev/null +++ b/src/common-ssh/guac_sftp.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "guac_ssh.h" + +#include +#include +#include + +guac_object* guac_common_ssh_create_sftp_filesystem(guac_client* client, + const char* name, LIBSSH2_SESSION* session) { + + /* STUB */ + return NULL; + +} + +void guac_common_ssh_destroy_sftp_filesystem(guac_client* client, + guac_object* filesystem) { + /* STUB */ +} + diff --git a/src/common-ssh/guac_sftp.h b/src/common-ssh/guac_sftp.h new file mode 100644 index 00000000..ee6f3885 --- /dev/null +++ b/src/common-ssh/guac_sftp.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2015 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef GUAC_COMMON_SSH_SFTP_H +#define GUAC_COMMON_SSH_SFTP_H + +#include +#include +#include + +/** + * Creates a new Guacamole filesystem object which provides access to files + * and directories via SFTP using the given SSH session. When the filesystem + * will no longer be used, it must be explicitly destroyed with + * guac_common_ssh_destroy_sftp_filesystem(). + * + * @param client + * The Guacamole client which will be associated with the new filesystem + * object. + * + * @param name + * The name to send as the name of the filesystem. + * + * @param session + * The session to use to provide SFTP. + * + * @return + * A new Guacamole filesystem object, already configured to use SFTP for + * uploading and downloading files. + */ +guac_object* guac_common_ssh_create_sftp_filesystem(guac_client* client, + const char* name, LIBSSH2_SESSION* session); + +/** + * Destroys the given filesystem object, disconnecting from SFTP and freeing + * and associated resources. + * + * @param client + * The client associated with the filesystem object. + * + * @param object + * The filesystem object to destroy. + */ +void guac_common_ssh_destroy_sftp_filesystem(guac_client* client, + guac_object* filesystem); + +#endif + diff --git a/src/common-ssh/guac_ssh.c b/src/common-ssh/guac_ssh.c index 6a85decd..105b9fcf 100644 --- a/src/common-ssh/guac_ssh.c +++ b/src/common-ssh/guac_ssh.c @@ -23,7 +23,6 @@ #include "guac_ssh.h" #include -#include #include #ifdef LIBSSH2_USES_GCRYPT @@ -147,16 +146,3 @@ LIBSSH2_SESSION* guac_common_ssh_connect_private_key(const char* hostname, } -guac_object* guac_common_ssh_create_sftp_filesystem(guac_client* client, - const char* name, LIBSSH2_SESSION* session) { - - /* STUB */ - return NULL; - -} - -void guac_common_ssh_destroy_sftp_filesystem(guac_client* client, - guac_object* filesystem) { - /* STUB */ -} - diff --git a/src/common-ssh/guac_ssh.h b/src/common-ssh/guac_ssh.h index 302d6f0e..44af5905 100644 --- a/src/common-ssh/guac_ssh.h +++ b/src/common-ssh/guac_ssh.h @@ -24,7 +24,6 @@ #define GUAC_COMMON_SSH_H #include -#include #include /** @@ -98,41 +97,5 @@ LIBSSH2_SESSION* guac_common_ssh_connect_private_key(const char* hostname, int port, const char* username, const char* private_key, const char* passphrase); -/** - * Creates a new Guacamole filesystem object which provides access to files - * and directories via SFTP using the given SSH session. When the filesystem - * will no longer be used, it must be explicitly destroyed with - * guac_common_ssh_destroy_sftp_filesystem(). - * - * @param client - * The Guacamole client which will be associated with the new filesystem - * object. - * - * @param name - * The name to send as the name of the filesystem. - * - * @param session - * The session to use to provide SFTP. - * - * @return - * A new Guacamole filesystem object, already configured to use SFTP for - * uploading and downloading files. - */ -guac_object* guac_common_ssh_create_sftp_filesystem(guac_client* client, - const char* name, LIBSSH2_SESSION* session); - -/** - * Destroys the given filesystem object, disconnecting from SFTP and freeing - * and associated resources. - * - * @param client - * The client associated with the filesystem object. - * - * @param object - * The filesystem object to destroy. - */ -void guac_common_ssh_destroy_sftp_filesystem(guac_client* client, - guac_object* filesystem); - #endif