commit 918f97c8c509762a389732efc05fe87ebc047d0a Author: Oswald Buddenhagen <o...@kde.org> Date: Sun Mar 13 13:40:39 2011 +0100
change socket_write() return code semantics instead of returning a write()-like result, return only a binary status code - write errors are handled internally anyway, so user code doesn't have to check the write length. src/drv_imap.c | 10 +++++----- src/socket.c | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 24c243a..7fbe3ac 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -253,15 +253,15 @@ v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd, else printf( ">>> %d LOGIN <user> <pass>\n", cmd->tag ); } - if (socket_write( &ctx->conn, buf, bufl ) != bufl) { + if (socket_write( &ctx->conn, buf, bufl ) < 0) { free( cmd->param.data ); goto bail; } if (litplus) { n = socket_write( &ctx->conn, cmd->param.data, cmd->param.data_len ); free( cmd->param.data ); - if (n != cmd->param.data_len || - (n = socket_write( &ctx->conn, "\r\n", 2 )) != 2) + if (n < 0 || + socket_write( &ctx->conn, "\r\n", 2 ) < 0) goto bail; cmd->param.data = 0; } else if (cmd->param.cont || cmd->param.data) { @@ -819,7 +819,7 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd ) n = socket_write( &ctx->conn, cmdp->param.data, cmdp->param.data_len ); free( cmdp->param.data ); cmdp->param.data = 0; - if (n != (int)cmdp->param.data_len) + if (n < 0) break; } else if (cmdp->param.cont) { if (cmdp->param.cont( ctx, cmdp, cmd )) @@ -828,7 +828,7 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd ) error( "IMAP error: unexpected command continuation request\n" ); break; } - if (socket_write( &ctx->conn, "\r\n", 2 ) != 2) + if (socket_write( &ctx->conn, "\r\n", 2 ) < 0) break; if (!cmdp->param.cont) ctx->literal_pending = 0; diff --git a/src/socket.c b/src/socket.c index 84210b9..5155d25 100644 --- a/src/socket.c +++ b/src/socket.c @@ -391,8 +391,9 @@ socket_write( conn_t *sock, char *buf, int len ) socket_perror( "write", sock, n ); close( sock->fd ); sock->fd = -1; + return -1; } - return n; + return 0; } int ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel