1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-03 13:31:11 +03:00

fix ssh_callbacks_init() macro + documentation

ssh_callbacks_init should not zero' the struct because
it could be used on staticaly declared structures
This commit is contained in:
Aris Adamantiadis
2009-09-25 23:50:18 +02:00
parent e3bdc393cb
commit 5e76118512

View File

@@ -26,9 +26,8 @@
#ifndef _SSH_CALLBACK_H #ifndef _SSH_CALLBACK_H
#define _SSH_CALLBACK_H #define _SSH_CALLBACK_H
#include <string.h>
#include <libssh/libssh.h> #include <libssh/libssh.h>
#include <string.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -53,16 +52,29 @@ typedef void (*ssh_log_callback) (ssh_session session, int priority,
const char *message, void *userdata); const char *message, void *userdata);
struct ssh_callbacks_struct { struct ssh_callbacks_struct {
size_t size; /* size of this structure */ /** size of this structure. internal, shoud be set with ssh_callbacks_init()*/
void *userdata; /* User-provided data */ size_t size;
ssh_auth_callback auth_function; /* this functions will be called if e.g. a keyphrase is needed. */ /** User-provided data. User is free to set anything he wants here */
ssh_log_callback log_function; //log callback void *userdata;
void (*connect_status_function)(void *arg, float status); /* status callback function */ /** this functions will be called if e.g. a keyphrase is needed. */
ssh_auth_callback auth_function;
/** this function will be called each time a loggable event happens. */
ssh_log_callback log_function;
/** this function gets called during connection time to indicate the percentage
* of connection steps completed.
*/
void (*connect_status_function)(void *userdata, float status);
}; };
typedef struct ssh_callbacks_struct * ssh_callbacks; typedef struct ssh_callbacks_struct * ssh_callbacks;
/** Initializes an ssh_callbacks_struct
* A call to this macro is mandatory when you have set a new
* ssh_callback_struct structure. Its goal is to maintain the binary
* compatibility with future versions of libssh as the structure
* evolves with time.
*/
#define ssh_callbacks_init(p) do {\ #define ssh_callbacks_init(p) do {\
memset(p,'\0',sizeof(*p)); \
p->size=sizeof(*p); \ p->size=sizeof(*p); \
} while(0); } while(0);