aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-10-09 22:24:23 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-10-09 22:24:23 +0200
commit98ff6fbbcefaa21a5bcc4c032fd7797fc2f8ca68 (patch)
tree1c9e717dd6e13ec428fed44989798b3783ad2dde
parent43e0d73b636c5ffe2bca2b180a0c5b243318784e (diff)
downloadlibssh-98ff6fbbcefaa21a5bcc4c032fd7797fc2f8ca68.tar.gz
libssh-98ff6fbbcefaa21a5bcc4c032fd7797fc2f8ca68.tar.xz
libssh-98ff6fbbcefaa21a5bcc4c032fd7797fc2f8ca68.zip
get rid of the option structure
-rw-r--r--include/libssh/libssh.h9
-rw-r--r--include/libssh/priv.h2
-rw-r--r--libssh/options.c50
-rw-r--r--libssh/session.c14
4 files changed, 30 insertions, 45 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index e7948937..523269fa 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -114,14 +114,14 @@ typedef struct ssh_agent_struct AGENT;
#endif
typedef struct ssh_message_struct SSH_MESSAGE;
-typedef struct ssh_session_struct SSH_OPTIONS;
+//typedef struct ssh_session_struct SSH_OPTIONS;
typedef struct ssh_session_struct SSH_SESSION;
typedef struct ssh_agent_struct* ssh_agent;
typedef struct ssh_buffer_struct* ssh_buffer;
typedef struct ssh_channel_struct* ssh_channel;
typedef struct ssh_message_struct *ssh_message;
-typedef struct ssh_session_struct* ssh_options;
+//typedef struct ssh_session_struct* ssh_options;
typedef struct ssh_private_key_struct* ssh_private_key;
typedef struct ssh_public_key_struct* ssh_public_key;
typedef struct ssh_scp_struct* ssh_scp;
@@ -384,8 +384,8 @@ LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
LIBSSH_API ssh_session ssh_new(void);
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
-LIBSSH_API int ssh_options_getopt(ssh_options options, int *argcptr, char **argv);
-LIBSSH_API int ssh_options_parse_config(ssh_options opt, const char *filename);
+LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv);
+LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename);
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
const void *value);
@@ -413,7 +413,6 @@ LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
LIBSSH_API void ssh_set_fd_except(ssh_session session);
LIBSSH_API void ssh_set_fd_toread(ssh_session session);
LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
-LIBSSH_API void ssh_set_options(ssh_session session, ssh_options options);
LIBSSH_API void ssh_silent_disconnect(ssh_session session);
#ifndef _WIN32
LIBSSH_API int ssh_userauth_agent_pubkey(ssh_session session, const char *username,
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index bea4c343..d30eb112 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -119,7 +119,7 @@ int ssh_send_banner(ssh_session session, int is_server);
char *ssh_get_banner(ssh_session session);
/* config.c */
-int ssh_config_parse_file(ssh_options opt, const char *filename);
+int ssh_config_parse_file(ssh_session session, const char *filename);
/* errors.c */
void ssh_set_error(void *error, int code, const char *descr, ...) PRINTF_ATTRIBUTE(3, 4);
diff --git a/libssh/options.c b/libssh/options.c
index c24c25fe..08b78f72 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -710,7 +710,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
* myssh -l user localhost\n
* The command wont set the hostname value of options to localhost.
*
- * @param options An empty option structure pointer.
+ * @param session The session to configure.
*
* @param argcptr The pointer to the argument count.
*
@@ -720,7 +720,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
*
* @see ssh_session_new()
*/
-int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
+int ssh_options_getopt(ssh_session session, int *argcptr, char **argv) {
char *user = NULL;
char *cipher = NULL;
char *localaddr = NULL;
@@ -751,7 +751,7 @@ int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
save = malloc(argc * sizeof(char *));
if (save == NULL) {
- ssh_set_error_oom(options);
+ ssh_set_error_oom(session);
return -1;
}
@@ -803,7 +803,7 @@ int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
save[current] = strdup(opt);
if (save[current] == NULL) {
SAFE_FREE(save);
- ssh_set_error_oom(options);
+ ssh_set_error_oom(session);
return -1;
}
current++;
@@ -819,11 +819,11 @@ int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
}
if (usersa && usedss) {
- ssh_set_error(options, SSH_FATAL, "Either RSA or DSS must be chosen");
+ ssh_set_error(session, SSH_FATAL, "Either RSA or DSS must be chosen");
cont = 0;
}
- ssh_options_set(options, SSH_OPTIONS_LOG_VERBOSITY, &debuglevel);
+ ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &debuglevel);
optind = saveoptind;
@@ -843,45 +843,45 @@ int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
/* set a new option struct */
if (compress) {
- if (ssh_options_set(options, SSH_OPTIONS_COMPRESSION_C_S, "zlib") < 0) {
+ if (ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib") < 0) {
cont = 0;
}
- if (ssh_options_set(options, SSH_OPTIONS_COMPRESSION_S_C, "zlib") < 0) {
+ if (ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib") < 0) {
cont = 0;
}
}
if (cont && cipher) {
- if (ssh_options_set(options, SSH_OPTIONS_CIPHERS_C_S, cipher) < 0) {
+ if (ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, cipher) < 0) {
cont = 0;
}
- if (cont && ssh_options_set(options, SSH_OPTIONS_CIPHERS_S_C, cipher) < 0) {
+ if (cont && ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, cipher) < 0) {
cont = 0;
}
}
if (cont && user) {
- if (ssh_options_set(options, SSH_OPTIONS_USER, user) < 0) {
+ if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
cont = 0;
}
}
if (cont && identity) {
- if (ssh_options_set(options, SSH_OPTIONS_IDENTITY, identity) < 0) {
+ if (ssh_options_set(session, SSH_OPTIONS_IDENTITY, identity) < 0) {
cont = 0;
}
}
- ssh_options_set(options, SSH_OPTIONS_PORT_STR, port);
+ ssh_options_set(session, SSH_OPTIONS_PORT_STR, port);
- ssh_options_set(options, SSH_OPTIONS_SSH1, &ssh1);
- ssh_options_set(options, SSH_OPTIONS_SSH2, &ssh2);
+ ssh_options_set(session, SSH_OPTIONS_SSH1, &ssh1);
+ ssh_options_set(session, SSH_OPTIONS_SSH2, &ssh2);
if (!cont) {
- return -1;
+ return SSH_ERROR;
}
- return 0;
+ return SSH_OK;
#endif
}
@@ -892,7 +892,7 @@ int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
* are already set. It requires that the host name is already set with
* ssh_options_set_host().
*
- * @param opt The options structure to use.
+ * @param session SSH session handle
*
* @param filename The options file to use, if NULL the default
* ~/.ssh/config will be used.
@@ -901,28 +901,28 @@ int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) {
*
* @see ssh_options_set_host()
*/
-int ssh_options_parse_config(ssh_options opt, const char *filename) {
+int ssh_options_parse_config(ssh_session session, const char *filename) {
char *expanded_filename;
int r;
- if (opt == NULL) {
+ if (session == NULL) {
return -1;
}
- if (opt->host == NULL) {
- ssh_set_error_invalid(opt, __FUNCTION__);
+ if (session->host == NULL) {
+ ssh_set_error_invalid(session, __FUNCTION__);
return -1;
}
/* set default filename */
if (filename == NULL) {
- expanded_filename = dir_expand_dup(opt, "SSH_DIR/config", 1);
+ expanded_filename = dir_expand_dup(session, "SSH_DIR/config", 1);
} else {
- expanded_filename = dir_expand_dup(opt, filename, 1);
+ expanded_filename = dir_expand_dup(session, filename, 1);
}
if (expanded_filename == NULL)
return -1;
- r = ssh_config_parse_file(opt, expanded_filename);
+ r = ssh_config_parse_file(session, expanded_filename);
free(expanded_filename);
return r;
}
diff --git a/libssh/session.c b/libssh/session.c
index 2ba628e0..a03b765f 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -185,20 +185,6 @@ void ssh_silent_disconnect(ssh_session session) {
/* FIXME: leave_function(); ??? */
}
-/** \brief set the options for the current session
- * \param session ssh session
- * \param options options structure
- * \see ssh_new()
- * \see ssh_options_new()
- */
-void ssh_set_options(ssh_session session, ssh_options options) {
- if (session == NULL || options == NULL) {
- return;
- }
-
- return;
-}
-
/** \brief set the session in blocking/nonblocking mode
* \param session ssh session
* \param blocking zero for nonblocking mode