libssh 0.4.8

include/libssh/callbacks.h

00001 /*
00002  * This file is part of the SSH Library
00003  *
00004  * Copyright (c) 2009 Aris Adamantiadis <aris@0xbadc0de.be>
00005  *
00006  * The SSH Library is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2.1 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * The SSH Library is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00014  * License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with the SSH Library; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00019  * MA 02111-1307, USA.
00020  */
00021 
00022 /* callback.h
00023  * This file includes the public declarations for the libssh callback mechanism
00024  */
00025 
00026 #ifndef _SSH_CALLBACK_H
00027 #define _SSH_CALLBACK_H
00028 
00029 #include <libssh/libssh.h>
00030 #include <string.h>
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00049 typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
00050     int echo, int verify, void *userdata);
00051 typedef void (*ssh_log_callback) (ssh_session session, int priority,
00052     const char *message, void *userdata);
00055 typedef void (*ssh_status_callback) (ssh_session session, float status,
00056     void *userdata);
00057 
00058 struct ssh_callbacks_struct {
00060   size_t size;
00062   void *userdata;
00064   ssh_auth_callback auth_function;
00066   ssh_log_callback log_function;
00070   void (*connect_status_function)(void *userdata, float status);
00071 };
00072 
00073 typedef struct ssh_callbacks_struct * ssh_callbacks;
00074 
00081 #define ssh_callbacks_init(p) do {\
00082   (p)->size=sizeof(*(p)); \
00083 } while(0);
00084 
00107 LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);
00108 
00109 #ifdef __cplusplus
00110 }
00111 #endif
00112 
00113 #endif /*_SSH_CALLBACK_H */