Read from a socket Connection.
More...
|
static int | tls_socket_read (struct Connection *conn, char *buf, size_t count) |
| Read data from a TLS socket - Implements Connection::read() -.
|
|
static int | ssl_socket_read (struct Connection *conn, char *buf, size_t count) |
| Read data from an SSL socket - Implements Connection::read() -.
|
|
int | raw_socket_read (struct Connection *conn, char *buf, size_t count) |
| Read data from a socket - Implements Connection::read() -.
|
|
static int | mutt_sasl_conn_read (struct Connection *conn, char *buf, size_t count) |
| Read data from an SASL connection - Implements Connection::read() -.
|
|
static int | tunnel_socket_read (struct Connection *conn, char *buf, size_t count) |
| Read data from a tunnel socket - Implements Connection::read() -.
|
|
static int | zstrm_read (struct Connection *conn, char *buf, size_t len) |
| Read compressed data from a socket - Implements Connection::read() -.
|
|
Read from a socket Connection.
- Parameters
-
conn | Connection to a server |
buf | Buffer to store the data |
count | Number of bytes to read |
- Return values
-
>0 | Success, number of bytes read |
-1 | Error, see errno |
◆ tls_socket_read()
static int tls_socket_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Read data from a TLS socket - Implements Connection::read() -.
Definition at line 1044 of file gnutls.c.
1045{
1047 if (!data)
1048 {
1050 return -1;
1051 }
1052
1053 int rc;
1054 do
1055 {
1056 rc = gnutls_record_recv(data->
session, buf, count);
1057 } while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
1058
1059 if (rc < 0)
1060 {
1061 mutt_error(
"tls_socket_read (%s)", gnutls_strerror(rc));
1062 return -1;
1063 }
1064
1065 return rc;
1066}
void * sockdata
Backend-specific socket data.
◆ ssl_socket_read()
static int ssl_socket_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Read data from an SSL socket - Implements Connection::read() -.
Definition at line 1332 of file openssl.c.
1333{
1334 struct SslSockData *data =
sockdata(conn);
1335 int rc;
1336
1337retry:
1338 rc = SSL_read(data->ssl, buf, count);
1339 if (rc > 0)
1340 return rc;
1341
1342
1343 if (
SigInt && (errno == EINTR))
1344 {
1345 rc = -1;
1346 }
1347 else if (BIO_should_retry(SSL_get_rbio(data->ssl)))
1348 {
1349
1350 goto retry;
1351 }
1352
1353 data->isopen = 0;
1355 return rc;
1356}
SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
static struct SslSockData * sockdata(struct Connection *conn)
Get a Connection's socket data.
static void ssl_err(struct SslSockData *data, int err)
Display an SSL error message.
◆ raw_socket_read()
int raw_socket_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
count |
|
) |
| |
Read data from a socket - Implements Connection::read() -.
Definition at line 277 of file raw.c.
278{
279 int rc;
280
282 do
283 {
284 rc = read(conn->
fd, buf, count);
285 } while (rc < 0 && (errno == EINTR));
286
287 if (rc < 0)
288 {
291 }
293
295 {
298 rc = -1;
299 }
300
301 return rc;
302}
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
char host[128]
Server to login to.
struct ConnAccount account
Account details: username, password, etc.
int fd
Socket file descriptor.
◆ mutt_sasl_conn_read()
static int mutt_sasl_conn_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Read data from an SASL connection - Implements Connection::read() -.
Definition at line 467 of file sasl.c.
468{
469 int rc;
470 unsigned int olen;
471
473
474
475 if (sasldata->
blen > sasldata->
bpos)
476 {
477 olen = ((sasldata->
blen - sasldata->
bpos) > count) ?
478 count :
480
481 memcpy(
buf, sasldata->
buf + sasldata->
bpos, olen);
482 sasldata->
bpos += olen;
483
484 return olen;
485 }
486
488
491
492
493 if (*sasldata->
ssf != 0)
494 {
495 do
496 {
497
498 rc = sasldata->
read(conn,
buf, count);
499 if (rc <= 0)
500 goto out;
501
503 if (rc != SASL_OK)
504 {
506 goto out;
507 }
508 }
while (sasldata->
blen == 0);
509
510 olen = ((sasldata->
blen - sasldata->
bpos) > count) ?
511 count :
513
514 memcpy(
buf, sasldata->
buf, olen);
515 sasldata->
bpos += olen;
516
517 rc = olen;
518 }
519 else
520 {
521 rc = sasldata->
read(conn,
buf, count);
522 }
523
524out:
526
527 return rc;
528}
int(* read)(struct Connection *conn, char *buf, size_t count)
Read from a socket Connection - Implements Connection::read() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
SASL authentication API -.
void * sockdata
Underlying socket data.
unsigned int blen
Size of the read buffer.
unsigned int bpos
Current read position.
const char * buf
Buffer for data read from the connection.
◆ tunnel_socket_read()
static int tunnel_socket_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Read data from a tunnel socket - Implements Connection::read() -.
Definition at line 145 of file tunnel.c.
146{
148 int rc;
149
150 do
151 {
152 rc = read(tunnel->
fd_read, buf, count);
153 } while (rc < 0 && errno == EINTR);
154
155 if (rc < 0)
156 {
158 return -1;
159 }
160
161 return rc;
162}
A network tunnel (pair of sockets)
int fd_read
File descriptor to read from.
◆ zstrm_read()
static int zstrm_read |
( |
struct Connection * |
conn, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Read compressed data from a socket - Implements Connection::read() -.
Definition at line 129 of file zstrm.c.
130{
132 int rc = 0;
133 int zrc = 0;
134
135retry:
137 return 0;
138
139
140
141
143 {
146 if (rc < 0)
147 return rc;
148 else if (rc == 0)
150 else
152 }
153
156 zctx->
read.
z.avail_out = (uInt) len;
157 zctx->
read.
z.next_out = (Bytef *) buf;
158
159 zrc = inflate(&zctx->
read.
z, Z_SYNC_FLUSH);
162 len - zctx->
read.
z.avail_out, len);
163
164
166 {
169 }
170
171 switch (zrc)
172 {
173 case Z_OK:
174 zrc = len - zctx->
read.
z.avail_out;
175 if (zrc == 0)
176 {
177
179 goto retry;
180 }
181 break;
182
183 case Z_STREAM_END:
185 zrc = len - zctx->
read.
z.avail_out;
187 break;
188
189 case Z_BUF_ERROR:
191 {
193 goto retry;
194 }
195 zrc = 0;
196 break;
197
198 default:
199
201 zrc = -1;
202 break;
203 }
204
205 return zrc;
206}
@ LL_DEBUG5
Log at debug level 5.
int(* read)(struct Connection *conn, char *buf, size_t count)
struct ZstrmDirection read
Data being read and de-compressed.
struct Connection next_conn
Underlying stream.
unsigned int pos
Current position.
bool conn_eof
Connection end-of-file reached.
unsigned int len
Length of data.
z_stream z
zlib compression handle
char * buf
Buffer for data being (de-)compressed.
bool stream_eof
Stream end-of-file reached.
◆ read
int(* SaslSockData::read) (struct Connection *conn, char *buf, size_t count) |