From: Richard Russon Date: Sat, 29 Sep 2018 21:44:21 +0000 (+0100) Subject: doxy: comment remaining connection functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a92d4abcc9c0da8e92b9548d79f31f51b7e29d87;p=neomutt doxy: comment remaining connection functions --- diff --git a/conn/conn_raw.c b/conn/conn_raw.c index 05324d77f..325561798 100644 --- a/conn/conn_raw.c +++ b/conn/conn_raw.c @@ -262,12 +262,12 @@ int raw_socket_open(struct Connection *conn) /** * raw_socket_read - Read data from a socket - Implements Connection::conn_read() */ -int raw_socket_read(struct Connection *conn, char *buf, size_t len) +int raw_socket_read(struct Connection *conn, char *buf, size_t count) { int rc; mutt_sig_allow_interrupt(1); - rc = read(conn->fd, buf, len); + rc = read(conn->fd, buf, count); if (rc == -1) { mutt_error(_("Error talking to %s (%s)"), conn->account.host, strerror(errno)); diff --git a/conn/connection.h b/conn/connection.h index c41232527..e397ef5bb 100644 --- a/conn/connection.h +++ b/conn/connection.h @@ -57,18 +57,18 @@ struct Connection int (*conn_open) (struct Connection *conn); /** * conn_read - Read from a socket Connection - * @param conn Connection to a server - * @param buf Buffer to store the data - * @param len Number of bytes to read + * @param conn Connection to a server + * @param buf Buffer to store the data + * @param count Number of bytes to read * @retval >0 Success, number of bytes read * @retval -1 Error, see errno */ - int (*conn_read) (struct Connection *conn, char *buf, size_t len); + int (*conn_read) (struct Connection *conn, char *buf, size_t count); /** * conn_write - Write to a socket Connection - * @param conn Connection to a server - * @param buf Buffer to read into - * @param len Number of bytes to read + * @param conn Connection to a server + * @param buf Buffer to read into + * @param count Number of bytes to read * @retval >0 Success, number of bytes written * @retval -1 Error, see errno */ diff --git a/conn/sasl.c b/conn/sasl.c index 32209f1af..e241d9bcb 100644 --- a/conn/sasl.c +++ b/conn/sasl.c @@ -320,10 +320,7 @@ static sasl_callback_t *mutt_sasl_get_callbacks(struct ConnAccount *account) } /** - * mutt_sasl_conn_open - empty wrapper for underlying open function - * @param conn Connection to the server - * @retval 0 Success - * @retval -1 Error + * mutt_sasl_conn_open - empty wrapper for underlying open function - Implements Connection::conn_open() * * We don't know in advance that a connection will use SASL, so we replace * conn's methods with sasl methods when authentication is successful, using @@ -340,10 +337,7 @@ static int mutt_sasl_conn_open(struct Connection *conn) } /** - * mutt_sasl_conn_close - close SASL connection - * @param conn Connection to a server - * @retval 0 Success - * @retval -1 Error + * mutt_sasl_conn_close - close SASL connection - Implements Connection::conn_close() * * Calls underlying close function and disposes of the sasl_conn_t object, then * restores connection to pre-sasl state @@ -371,14 +365,9 @@ static int mutt_sasl_conn_close(struct Connection *conn) } /** - * mutt_sasl_conn_read - Read data from an SASL connection - * @param conn Connection to a server - * @param buf Buffer to store the data - * @param buflen Number of bytes to read - * @retval >0 Success, number of bytes read - * @retval -1 Error, see errno + * mutt_sasl_conn_read - Read data from an SASL connection - Implements Connection::conn_read() */ -static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t buflen) +static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t count) { int rc; unsigned int olen; @@ -388,8 +377,8 @@ static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t buflen /* if we still have data in our read buffer, copy it into buf */ if (sasldata->blen > sasldata->bpos) { - olen = (sasldata->blen - sasldata->bpos > buflen) ? - buflen : + olen = (sasldata->blen - sasldata->bpos > count) ? + count : sasldata->blen - sasldata->bpos; memcpy(buf, sasldata->buf + sasldata->bpos, olen); @@ -409,7 +398,7 @@ static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t buflen do { /* call the underlying read function to fill the buffer */ - rc = (sasldata->msasl_read)(conn, buf, buflen); + rc = (sasldata->msasl_read)(conn, buf, count); if (rc <= 0) goto out; @@ -421,8 +410,8 @@ static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t buflen } } while (sasldata->blen == 0); - olen = (sasldata->blen - sasldata->bpos > buflen) ? - buflen : + olen = (sasldata->blen - sasldata->bpos > count) ? + count : sasldata->blen - sasldata->bpos; memcpy(buf, sasldata->buf, olen); @@ -431,7 +420,7 @@ static int mutt_sasl_conn_read(struct Connection *conn, char *buf, size_t buflen rc = olen; } else - rc = (sasldata->msasl_read)(conn, buf, buflen); + rc = (sasldata->msasl_read)(conn, buf, count); out: conn->sockdata = sasldata; @@ -440,14 +429,9 @@ out: } /** - * mutt_sasl_conn_write - Write to an SASL connection - * @param conn Connection to a server - * @param buf Buffer to store the data - * @param buflen Number of bytes to read - * @retval >0 Success, number of bytes read - * @retval -1 Error, see errno + * mutt_sasl_conn_write - Write to an SASL connection - Implements Connection::conn_write() */ -static int mutt_sasl_conn_write(struct Connection *conn, const char *buf, size_t buflen) +static int mutt_sasl_conn_write(struct Connection *conn, const char *buf, size_t count) { int rc; const char *pbuf = NULL; @@ -462,7 +446,7 @@ static int mutt_sasl_conn_write(struct Connection *conn, const char *buf, size_t /* handle data larger than MAXOUTBUF */ do { - olen = (buflen > *sasldata->pbufsize) ? *sasldata->pbufsize : buflen; + olen = (count > *sasldata->pbufsize) ? *sasldata->pbufsize : count; rc = sasl_encode(sasldata->saslconn, buf, olen, &pbuf, &plen); if (rc != SASL_OK) @@ -475,14 +459,14 @@ static int mutt_sasl_conn_write(struct Connection *conn, const char *buf, size_t if (rc != plen) goto fail; - buflen -= olen; + count -= olen; buf += olen; - } while (buflen > *sasldata->pbufsize); + } while (count > *sasldata->pbufsize); } else { /* just write using the underlying socket function */ - rc = (sasldata->msasl_write)(conn, buf, buflen); + rc = (sasldata->msasl_write)(conn, buf, count); } conn->sockdata = sasldata; @@ -495,12 +479,7 @@ fail: } /** - * mutt_sasl_conn_poll - Check an SASL connection for data - * @param conn Connection to a server - * @param wait_secs How long to wait for a response - * @retval >0 There is data to read - * @retval 0 Read would block - * @retval -1 Connection doesn't support polling + * mutt_sasl_conn_poll - Check an SASL connection for data - Implements Connection::conn_poll() */ static int mutt_sasl_conn_poll(struct Connection *conn, time_t wait_secs) { diff --git a/conn/ssl.c b/conn/ssl.c index 338bed8e3..b33fa5a7f 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -362,8 +362,7 @@ static int ssl_passwd_cb(char *buf, int buflen, int rwflag, void *userdata) } /** - * ssl_socket_open_err - Error callback for opening an SSL connection - * @param conn Connection to a server + * ssl_socket_open_err - Error callback for opening an SSL connection - Implements Connection::conn_open() * @retval -1 Always */ static int ssl_socket_open_err(struct Connection *conn) @@ -625,10 +624,7 @@ static void ssl_get_client_cert(struct SslSockData *ssldata, struct Connection * } /** - * ssl_socket_close_and_restore - Close an SSL Connection and restore Connnection callbacks - * @param conn Connection to a server - * @retval 0 Success - * @retval -1 Error, see errno + * ssl_socket_close_and_restore - Close an SSL Connection and restore Connnection callbacks - Implements Connection::conn_close() */ static int ssl_socket_close_and_restore(struct Connection *conn) { @@ -1338,12 +1334,12 @@ static int ssl_socket_open(struct Connection *conn) /** * ssl_socket_read - Read data from an SSL socket - Implements Connection::conn_read() */ -static int ssl_socket_read(struct Connection *conn, char *buf, size_t len) +static int ssl_socket_read(struct Connection *conn, char *buf, size_t count) { struct SslSockData *data = conn->sockdata; int rc; - rc = SSL_read(data->ssl, buf, len); + rc = SSL_read(data->ssl, buf, count); if (rc <= 0 || errno == EINTR) { if (errno == EINTR) @@ -1360,12 +1356,12 @@ static int ssl_socket_read(struct Connection *conn, char *buf, size_t len) /** * ssl_socket_write - Write data to an SSL socket - Implements Connection::conn_write() */ -static int ssl_socket_write(struct Connection *conn, const char *buf, size_t len) +static int ssl_socket_write(struct Connection *conn, const char *buf, size_t count) { struct SslSockData *data = conn->sockdata; int rc; - rc = SSL_write(data->ssl, buf, len); + rc = SSL_write(data->ssl, buf, count); if (rc <= 0 || errno == EINTR) { if (errno == EINTR) diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index 42ccb811b..dfbb61557 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -99,10 +99,7 @@ static int tls_init(void) } /** - * tls_starttls_close - Close a TLS connection - * @param conn Connection to a server - * @retval 0 Success - * @retval -1 Error, see errno + * tls_starttls_close - Close a TLS connection - Implements Connection::conn_close() */ static int tls_starttls_close(struct Connection *conn) { @@ -1157,7 +1154,7 @@ static int tls_socket_open(struct Connection *conn) /** * tls_socket_read - Read data from a TLS socket - Implements Connection::conn_read() */ -static int tls_socket_read(struct Connection *conn, char *buf, size_t len) +static int tls_socket_read(struct Connection *conn, char *buf, size_t count) { struct TlsSockData *data = conn->sockdata; int rc; @@ -1170,7 +1167,7 @@ static int tls_socket_read(struct Connection *conn, char *buf, size_t len) do { - rc = gnutls_record_recv(data->state, buf, len); + rc = gnutls_record_recv(data->state, buf, count); if ((rc < 0 && gnutls_error_is_fatal(rc) == 1) || rc == GNUTLS_E_INTERRUPTED) { mutt_error("tls_socket_read (%s)", gnutls_strerror(rc)); @@ -1184,7 +1181,7 @@ static int tls_socket_read(struct Connection *conn, char *buf, size_t len) /** * tls_socket_write - Write data to a TLS socket - Implements Connection::conn_write() */ -static int tls_socket_write(struct Connection *conn, const char *buf, size_t len) +static int tls_socket_write(struct Connection *conn, const char *buf, size_t count) { struct TlsSockData *data = conn->sockdata; size_t sent = 0; @@ -1197,7 +1194,7 @@ static int tls_socket_write(struct Connection *conn, const char *buf, size_t len do { - const int ret = gnutls_record_send(data->state, buf + sent, len - sent); + const int ret = gnutls_record_send(data->state, buf + sent, count - sent); if (ret < 0) { if (gnutls_error_is_fatal(ret) == 1 || ret == GNUTLS_E_INTERRUPTED) @@ -1208,7 +1205,7 @@ static int tls_socket_write(struct Connection *conn, const char *buf, size_t len return ret; } sent += ret; - } while (sent < len); + } while (sent < count); return sent; } diff --git a/conn/tunnel.c b/conn/tunnel.c index fb15e99cb..72ae5b353 100644 --- a/conn/tunnel.c +++ b/conn/tunnel.c @@ -134,12 +134,12 @@ static int tunnel_socket_open(struct Connection *conn) /** * tunnel_socket_read - Read data from a tunnel socket - Implements Connection::conn_read() */ -static int tunnel_socket_read(struct Connection *conn, char *buf, size_t len) +static int tunnel_socket_read(struct Connection *conn, char *buf, size_t count) { struct TunnelSockData *tunnel = conn->sockdata; int rc; - rc = read(tunnel->readfd, buf, len); + rc = read(tunnel->readfd, buf, count); if (rc == -1) { mutt_error(_("Tunnel error talking to %s: %s"), conn->account.host, strerror(errno)); @@ -151,12 +151,12 @@ static int tunnel_socket_read(struct Connection *conn, char *buf, size_t len) /** * tunnel_socket_write - Write data to a tunnel socket - Implements Connection::conn_write() */ -static int tunnel_socket_write(struct Connection *conn, const char *buf, size_t len) +static int tunnel_socket_write(struct Connection *conn, const char *buf, size_t count) { struct TunnelSockData *tunnel = conn->sockdata; int rc; - rc = write(tunnel->writefd, buf, len); + rc = write(tunnel->writefd, buf, count); if (rc == -1) { mutt_error(_("Tunnel error talking to %s: %s"), conn->account.host, strerror(errno));