aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-10-10 16:25:40 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-10-10 16:25:40 +0200
commit399041180ffccd613119f2bd41cf7563e675600d (patch)
tree66e68229279be98e3c0212ef2722ebfd660740eb /examples
parent3f55fb5b22cbc296325b9280f0d61b49a6b7ba1c (diff)
downloadlibssh-399041180ffccd613119f2bd41cf7563e675600d.tar.gz
libssh-399041180ffccd613119f2bd41cf7563e675600d.tar.xz
libssh-399041180ffccd613119f2bd41cf7563e675600d.zip
resolve callback crash
Diffstat (limited to 'examples')
-rw-r--r--examples/sample.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/sample.c b/examples/sample.c
index 9ed2470..c0084c4 100644
--- a/examples/sample.c
+++ b/examples/sample.c
@@ -40,6 +40,7 @@ char *user;
int sftp;
char *cmds[MAXCMD];
struct termios terminal;
+
void do_sftp(ssh_session session);
static int auth_callback(const char *prompt, char *buf, size_t len,
@@ -68,6 +69,11 @@ static int auth_callback(const char *prompt, char *buf, size_t len,
return 0;
}
+struct ssh_callbacks_struct cb = {
+ .auth_function=auth_callback,
+ .userdata=NULL
+};
+
static void add_cmd(char *cmd){
int n;
for(n=0;cmds[n] && (n<MAXCMD);n++);
@@ -537,17 +543,10 @@ int main(int argc, char **argv){
char buf[10];
unsigned char *hash = NULL;
int hlen;
- ssh_callbacks cb;
-
session = ssh_new();
- cb = malloc(sizeof(ssh_callbacks));
-
- cb->auth_function = auth_callback;
- cb->userdata = NULL;
-
- ssh_callbacks_init(cb);
- ssh_set_callbacks(session, cb);
+ ssh_callbacks_init(&cb);
+ ssh_set_callbacks(session,&cb);
if(ssh_options_getopt(session, &argc, argv)) {
fprintf(stderr, "error parsing command line :%s\n",