aboutsummaryrefslogtreecommitdiff
path: root/libssh/socket.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-14 14:02:37 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-14 14:02:37 +0000
commitf2788c9866371fc2ff325f90504ce2be49fb16a9 (patch)
tree4652a5004f701d85b73fc984278b0629ae56cefa /libssh/socket.c
parente29ef25cdd608a0e73639e3ec9e6800ab1e898f0 (diff)
downloadlibssh-f2788c9866371fc2ff325f90504ce2be49fb16a9.tar.gz
libssh-f2788c9866371fc2ff325f90504ce2be49fb16a9.tar.xz
libssh-f2788c9866371fc2ff325f90504ce2be49fb16a9.zip
Reformat ssh_socket_completewrite() and use const for buffer.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@465 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/socket.c')
-rw-r--r--libssh/socket.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/libssh/socket.c b/libssh/socket.c
index ff5ef6d..d791714 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -301,27 +301,29 @@ int ssh_socket_completeread(struct socket *s, void *buffer, u32 len) {
/** \internal
* \brief Blocking write of len bytes
*/
+int ssh_socket_completewrite(struct socket *s, const void *buffer, u32 len) {
+ SSH_SESSION *session = s->session;
+ int written = -1;
-int ssh_socket_completewrite(struct socket *s, void *buffer, u32 len){
- SSH_SESSION *session=s->session;
- int written;
+ enter_function();
- enter_function();
- if(!ssh_socket_is_open(s)){
- leave_function();
- return SSH_ERROR;
- }
- while(len >0) {
- written=ssh_socket_unbuffered_write(s,buffer,len);
- if(written==0 || written==-1){
- leave_function();
- return SSH_ERROR;
- }
- len-=written;
- buffer+=written;
- }
+ if(! ssh_socket_is_open(s)) {
leave_function();
- return SSH_OK;
+ return SSH_ERROR;
+ }
+
+ while (len >0) {
+ written = ssh_socket_unbuffered_write(s, buffer, len);
+ if (written == 0 || written == -1) {
+ leave_function();
+ return SSH_ERROR;
+ }
+ len -= written;
+ buffer += written;
+ }
+
+ leave_function();
+ return SSH_OK;
}
/** \internal