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 1046 of file gnutls.c.
1047{
1049 if (!data)
1050 {
1052 return -1;
1053 }
1054
1055 int rc;
1056 do
1057 {
1058 rc = gnutls_record_recv(data->
session, buf, count);
1059 } while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
1060
1061 if (rc < 0)
1062 {
1063 mutt_error(
"tls_socket_read (%s)", gnutls_strerror(rc));
1064 return -1;
1065 }
1066
1067 return rc;
1068}
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 1337 of file openssl.c.
1338{
1339 struct SslSockData *data =
sockdata(conn);
1340 int rc;
1341
1342retry:
1343 rc = SSL_read(data->ssl, buf, count);
1344 if (rc > 0)
1345 return rc;
1346
1347
1348 if (
SigInt && (errno == EINTR))
1349 {
1350 rc = -1;
1351 }
1352 else if (BIO_should_retry(SSL_get_rbio(data->ssl)))
1353 {
1354
1355 goto retry;
1356 }
1357
1358 data->isopen = 0;
1360 return rc;
1361}
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.
volatile sig_atomic_t SigInt
true after SIGINT is received
◆ 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 295 of file raw.c.
296{
297 int rc;
298
300 do
301 {
302 rc = read(conn->
fd, buf, count);
303 } while (rc < 0 && (errno == EINTR));
304
305 if (rc < 0)
306 {
309 }
311
313 {
316 rc = -1;
317 }
318
319 return rc;
320}
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 468 of file sasl.c.
469{
470 int rc;
471 unsigned int olen;
472
474
475
476 if (sasldata->
blen > sasldata->
bpos)
477 {
478 olen = ((sasldata->
blen - sasldata->
bpos) > count) ?
479 count :
481
482 memcpy(
buf, sasldata->
buf + sasldata->
bpos, olen);
483 sasldata->
bpos += olen;
484
485 return olen;
486 }
487
489
492
493
494 if (*sasldata->
ssf != 0)
495 {
496 do
497 {
498
499 rc = sasldata->
read(conn,
buf, count);
500 if (rc <= 0)
501 goto out;
502
504 if (rc != SASL_OK)
505 {
507 goto out;
508 }
509 }
while (sasldata->
blen == 0);
510
511 olen = ((sasldata->
blen - sasldata->
bpos) > count) ?
512 count :
514
515 memcpy(
buf, sasldata->
buf, olen);
516 sasldata->
bpos += olen;
517
518 rc = olen;
519 }
520 else
521 {
522 rc = sasldata->
read(conn,
buf, count);
523 }
524
525out:
527
528 return rc;
529}
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 146 of file tunnel.c.
147{
149 int rc;
150
151 do
152 {
153 rc = read(tunnel->
fd_read, buf, count);
154 } while (rc < 0 && errno == EINTR);
155
156 if (rc < 0)
157 {
159 return -1;
160 }
161
162 return rc;
163}
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 132 of file zstrm.c.
133{
135 int rc = 0;
136 int zrc = 0;
137
138retry:
140 return 0;
141
142
143
144
146 {
149 if (rc < 0)
150 return rc;
151 else if (rc == 0)
153 else
155 }
156
159 zctx->
read.
z.avail_out = (uInt) len;
160 zctx->
read.
z.next_out = (Bytef *) buf;
161
162 zrc = inflate(&zctx->
read.
z, Z_SYNC_FLUSH);
165 len - zctx->
read.
z.avail_out, len);
166
167
169 {
172 }
173
174 switch (zrc)
175 {
176 case Z_OK:
177 zrc = len - zctx->
read.
z.avail_out;
178 if (zrc == 0)
179 {
180
182 goto retry;
183 }
184 break;
185
186 case Z_STREAM_END:
188 zrc = len - zctx->
read.
z.avail_out;
190 break;
191
192 case Z_BUF_ERROR:
194 {
196 goto retry;
197 }
198 zrc = 0;
199 break;
200
201 default:
202
204 zrc = -1;
205 break;
206 }
207
208 return zrc;
209}
@ 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) |