summaryrefslogtreecommitdiffstats
path: root/libssh/options.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-02 11:56:13 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-02 11:56:13 +0000
commit4373fc64e345a994d2a207ddc7f1a11859ec7176 (patch)
tree777204c3a234a7947e7febb18a51420d573832ca /libssh/options.c
parentb6fbe97f24f8f8cffdb467f90a2c42d0f36cedfb (diff)
downloadlibssh-4373fc64e345a994d2a207ddc7f1a11859ec7176.tar.gz
libssh-4373fc64e345a994d2a207ddc7f1a11859ec7176.tar.xz
libssh-4373fc64e345a994d2a207ddc7f1a11859ec7176.zip
Improve ssh_options_set_bind().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@353 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/options.c')
-rw-r--r--libssh/options.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/libssh/options.c b/libssh/options.c
index 74a4d319..77f44a7f 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -326,18 +326,33 @@ int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd) {
return 0;
}
-/** In case your client has multiple IP adresses, select the local address
- * and port to use for the socket.\n
- * If the address or port is not bindable, it may be impossible to
- * connect.
- * \brief set the local address and port binding
- * \param opt options structure
- * \param bindaddr bind address in form of hostname or ip address
- * \param port port number to bind
+/**
+ * @brief Set the local address and port binding.
+ *
+ * In case your client has multiple IP adresses, select the local address and
+ * port to use for the socket.\n
+ * If the address or port is not bindable, it may be impossible to connect.
+ *
+ * @param opt The options structure to use.
+ *
+ * @param bindaddr The bind address in form of hostname or ip address.
+ *
+ * @param port The port number to bind.
+ *
+ * @return 0 on success, < 0 on error.
*/
-void ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port){
- opt->bindaddr=strdup(bindaddr);
- opt->bindport=port;
+int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) {
+ if (opt == NULL || bindaddr == NULL) {
+ return -1;
+ }
+
+ opt->bindaddr = strdup(bindaddr);
+ if (opt->bindaddr == NULL) {
+ return -1;
+ }
+ opt->bindport = port;
+
+ return 0;
}
/** the ssh directory is used for files like known_hosts and