Write to a socket Connection.
More...
|
static int | tls_socket_write (struct Connection *conn, const char *buf, size_t count) |
| Write data to a TLS socket - Implements Connection::write() -. More...
|
|
static int | ssl_socket_write (struct Connection *conn, const char *buf, size_t count) |
| Write data to an SSL socket - Implements Connection::write() -. More...
|
|
int | raw_socket_write (struct Connection *conn, const char *buf, size_t count) |
| Write data to a socket - Implements Connection::write() -. More...
|
|
static int | mutt_sasl_conn_write (struct Connection *conn, const char *buf, size_t count) |
| Write to an SASL connection - Implements Connection::write() -. More...
|
|
static int | tunnel_socket_write (struct Connection *conn, const char *buf, size_t count) |
| Write data to a tunnel socket - Implements Connection::write() -. More...
|
|
static int | zstrm_write (struct Connection *conn, const char *buf, size_t count) |
| Write compressed data to a socket - Implements Connection::write() -. More...
|
|
Write to a socket Connection.
- Parameters
-
- Return values
-
>0 | Success, number of bytes written |
-1 | Error, see errno |
◆ tls_socket_write()
static int tls_socket_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Write data to a TLS socket - Implements Connection::write() -.
Definition at line 1070 of file gnutls.c.
1071{
1073 size_t sent = 0;
1074
1075 if (!data)
1076 {
1078 return -1;
1079 }
1080
1081 do
1082 {
1083 int rc;
1084 do
1085 {
1086 rc = gnutls_record_send(data->
state, buf + sent, count - sent);
1087 } while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
1088
1089 if (rc < 0)
1090 {
1091 mutt_error(
"tls_socket_write (%s)", gnutls_strerror(rc));
1092 return -1;
1093 }
1094
1095 sent += rc;
1096 } while (sent < count);
1097
1098 return sent;
1099}
void * sockdata
Backend-specific socket data.
◆ ssl_socket_write()
static int ssl_socket_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Write data to an SSL socket - Implements Connection::write() -.
Definition at line 1348 of file openssl.c.
1349{
1350 if (!conn || !conn->
sockdata || !buf || (count == 0))
1351 return -1;
1352
1353 int rc = SSL_write(
sockdata(conn)->ssl, buf, count);
1354 if ((rc <= 0) || (errno == EINTR))
1355 {
1356 if (errno == EINTR)
1357 {
1358 rc = -1;
1359 }
1361 }
1362
1363 return rc;
1364}
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_write()
int raw_socket_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
Write data to a socket - Implements Connection::write() -.
Definition at line 294 of file raw.c.
295{
296 int rc;
297 size_t sent = 0;
298
300 do
301 {
302 do
303 {
304 rc = write(conn->
fd, buf + sent, count - sent);
305 } while (rc < 0 && (errno == EINTR));
306
307 if (rc < 0)
308 {
311 return -1;
312 }
313
314 sent += rc;
315 }
while ((sent < count) && !
SigInt);
316
318 return sent;
319}
SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
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_write()
static int mutt_sasl_conn_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Write to an SASL connection - Implements Connection::write() -.
Definition at line 527 of file sasl.c.
528{
529 int rc;
530 const char *
pbuf = NULL;
531 unsigned int olen,
plen;
532
535
536
537 if (*sasldata->
ssf != 0)
538 {
539
540 do
541 {
543
545 if (rc != SASL_OK)
546 {
548 goto fail;
549 }
550
553 goto fail;
554
555 count -= olen;
557 }
while (count > *sasldata->
pbufsize);
558 }
559 else
560 {
561
562 rc = sasldata->
write(conn,
buf, count);
563 }
564
566
567 return rc;
568
569fail:
571 return -1;
572}
int(* write)(struct Connection *conn, const char *buf, size_t count)
Write to a socket Connection - Implements Connection::write() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
static unsigned char * pbuf
Cached PGP data packet.
static size_t plen
Length of cached packet.
SASL authentication API -.
void * sockdata
Underlying socket data.
const unsigned int * pbufsize
const char * buf
Buffer for data read from the connection.
◆ tunnel_socket_write()
static int tunnel_socket_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Write data to a tunnel socket - Implements Connection::write() -.
Definition at line 159 of file tunnel.c.
160{
162 int rc;
163 size_t sent = 0;
164
165 do
166 {
167 do
168 {
169 rc = write(tunnel->
fd_write, buf + sent, count - sent);
170 } while (rc < 0 && errno == EINTR);
171
172 if (rc < 0)
173 {
175 return -1;
176 }
177
178 sent += rc;
179 } while (sent < count);
180
181 return sent;
182}
A network tunnel (pair of sockets)
int fd_write
File descriptor to write to.
◆ zstrm_write()
static int zstrm_write |
( |
struct Connection * |
conn, |
|
|
const char * |
buf, |
|
|
size_t |
count |
|
) |
| |
|
static |
Write compressed data to a socket - Implements Connection::write() -.
Definition at line 228 of file zstrm.c.
229{
231 int rc;
232
233 zctx->
write.
z.avail_in = (uInt) count;
234 zctx->
write.
z.next_in = (Bytef *) buf;
237
238 do
239 {
240 int zrc = deflate(&zctx->
write.
z, Z_PARTIAL_FLUSH);
241 if (zrc == Z_OK)
242 {
243
247 count - zctx->
write.
z.avail_in, count);
249 {
252 if (rc < 0)
253 return -1;
254
255 wbufp += rc;
257 }
258
259
260
261
262 if ((zctx->
write.
z.avail_out != 0) && (zctx->
write.
z.avail_in == 0))
263 break;
264
267 }
268 else
269 {
270
271
272 return -1;
273 }
274 } while (true);
275
276 rc = (int) count;
277 return (rc <= 0) ? 1 : rc;
278}
@ LL_DEBUG5
Log at debug level 5.
int(* write)(struct Connection *conn, const char *buf, size_t count)
struct ZstrmDirection write
Data being compressed and written.
struct Connection next_conn
Underlying stream.
unsigned int pos
Current position.
unsigned int len
Length of data.
z_stream z
zlib compression handle
char * buf
Buffer for data being (de-)compressed.
◆ write
int(* SaslSockData::write) (struct Connection *conn, const char *buf, size_t count) |