aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-11-29 22:51:14 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2009-11-29 22:51:14 +0100
commit0bfb9d476c3dfc1ed74763665611891bcc277e9e (patch)
tree2ecbe008cbb309e57c818ca992a3154ed656a48b /libssh
parent91bb1b2de66a62723e0cbdda02e455f728522181 (diff)
downloadlibssh-0bfb9d476c3dfc1ed74763665611891bcc277e9e.tar.gz
libssh-0bfb9d476c3dfc1ed74763665611891bcc277e9e.tar.xz
libssh-0bfb9d476c3dfc1ed74763665611891bcc277e9e.zip
Standardize callbacks style and add documentation
Diffstat (limited to 'libssh')
-rw-r--r--libssh/channels.c10
-rw-r--r--libssh/packet.c4
-rw-r--r--libssh/session.c4
-rw-r--r--libssh/socket.c7
4 files changed, 13 insertions, 12 deletions
diff --git a/libssh/channels.c b/libssh/channels.c
index 8af3a037..afd17717 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -314,7 +314,7 @@ static ssh_channel channel_from_msg(ssh_session session) {
return channel;
}
-int channel_rcv_change_window(ssh_session session, void *user, u_int8_t type, ssh_buffer packet) {
+SSH_PACKET_CALLBACK(channel_rcv_change_window) {
ssh_channel channel;
uint32_t bytes;
int rc;
@@ -351,7 +351,7 @@ int channel_rcv_change_window(ssh_session session, void *user, u_int8_t type, ss
}
/* is_stderr is set to 1 if the data are extended, ie stderr */
-int channel_rcv_data(ssh_session session, void *user, u_int8_t type, ssh_buffer packet) {
+SSH_PACKET_CALLBACK(channel_rcv_data){
ssh_channel channel;
ssh_string str;
size_t len;
@@ -424,7 +424,7 @@ int channel_rcv_data(ssh_session session, void *user, u_int8_t type, ssh_buffer
return SSH_PACKET_USED;
}
-int channel_rcv_eof(ssh_session session, void *user, u_int8_t type, ssh_buffer packet) {
+SSH_PACKET_CALLBACK(channel_rcv_eof) {
ssh_channel channel;
(void)user;
(void)type;
@@ -449,7 +449,7 @@ int channel_rcv_eof(ssh_session session, void *user, u_int8_t type, ssh_buffer p
return SSH_PACKET_USED;
}
-int channel_rcv_close(ssh_session session, void *user, u_int8_t type, ssh_buffer packet) {
+SSH_PACKET_CALLBACK(channel_rcv_close) {
ssh_channel channel;
(void)user;
(void)type;
@@ -491,7 +491,7 @@ int channel_rcv_close(ssh_session session, void *user, u_int8_t type, ssh_buffer
return SSH_PACKET_USED;
}
-int channel_rcv_request(ssh_session session, void *user, u_int8_t type, ssh_buffer packet) {
+SSH_PACKET_CALLBACK(channel_rcv_request) {
ssh_channel channel;
ssh_string request_s;
char *request;
diff --git a/libssh/packet.c b/libssh/packet.c
index 0c023239..2a5f1b39 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -111,7 +111,7 @@ static int macsize=SHA_DIGEST_LEN;
* @len length of data received. It might not be enough for a complete packet
* @returns number of bytes read and processed.
*/
-int ssh_packet_socket_callback(void *user, const void *data, size_t receivedlen){
+int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user){
ssh_session session=(ssh_session) user;
unsigned int blocksize = (session->current_crypto ?
session->current_crypto->in_cipher->blocksize : 8);
@@ -331,7 +331,7 @@ void ssh_packet_process(ssh_session session, u_int8_t type){
continue;
if(cb->callbacks[type - cb->start]==NULL)
continue;
- r=cb->callbacks[type - cb->start](session,cb->user,type,session->in_buffer);
+ r=cb->callbacks[type - cb->start](session,type,session->in_buffer,cb->user);
if(r==SSH_PACKET_USED)
break;
}
diff --git a/libssh/session.c b/libssh/session.c
index ede83ebe..8145a3cf 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -369,7 +369,7 @@ int ssh_get_version(ssh_session session) {
* @internal
* @brief handles a SSH_DISCONNECT packet
*/
-int ssh_packet_disconnect_callback(ssh_session session, void *user, u_int8_t type, ssh_buffer packet){
+SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback){
u_int32_t code;
char *error;
ssh_string error_s;
@@ -396,7 +396,7 @@ int ssh_packet_disconnect_callback(ssh_session session, void *user, u_int8_t typ
* @internal
* @brief handles a SSH_IGNORE and SSH_DEBUG packet
*/
-int ssh_packet_ignore_callback(ssh_session session, void *user, u_int8_t type, ssh_buffer packet){
+SSH_PACKET_CALLBACK(ssh_packet_ignore_callback){
(void)user;
(void)type;
(void)packet;
diff --git a/libssh/socket.c b/libssh/socket.c
index cb96e8da..8acc76ce 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -153,8 +153,9 @@ int ssh_socket_pollcallback(ssh_poll_handle p, int fd, int revents, void *v_s){
/* Bufferize the data and then call the callback */
buffer_add_data(s->in_buffer,buffer,r);
if(s->callbacks){
- r= s->callbacks->data(s->callbacks->user,
- buffer_get_rest(s->in_buffer), buffer_get_rest_len(s->in_buffer));
+ r= s->callbacks->data(buffer_get_rest(s->in_buffer),
+ buffer_get_rest_len(s->in_buffer),
+ s->callbacks->user);
buffer_pass_bytes(s->in_buffer,r);
}
}
@@ -167,7 +168,7 @@ int ssh_socket_pollcallback(ssh_poll_handle p, int fd, int revents, void *v_s){
buffer_get_rest_len(s->out_buffer));
} else if(s->callbacks){
/* Otherwise advertise the upper level that write can be done */
- s->callbacks->controlflow(s->callbacks->user,SSH_SOCKET_FLOW_WRITEWONTBLOCK);
+ s->callbacks->controlflow(SSH_SOCKET_FLOW_WRITEWONTBLOCK,s->callbacks->user);
ssh_poll_set_events(p,ssh_poll_get_events(p) & ~POLLOUT);
/* TODO: Find a way to put back POLLOUT when buffering occurs */
}