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 1067 of file gnutls.c.
1068{
1070 size_t sent = 0;
1071
1072 if (!data)
1073 {
1075 return -1;
1076 }
1077
1078 do
1079 {
1080 int rc;
1081 do
1082 {
1083 rc = gnutls_record_send(data->
session, buf + sent, count - sent);
1084 } while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
1085
1086 if (rc < 0)
1087 {
1088 mutt_error(
"tls_socket_write (%s)", gnutls_strerror(rc));
1089 return -1;
1090 }
1091
1092 sent += rc;
1093 } while (sent < count);
1094
1095 return sent;
1096}
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 1347 of file openssl.c.
1348{
1349 if (!conn || !conn->
sockdata || !buf || (count == 0))
1350 return -1;
1351
1352 int rc = SSL_write(
sockdata(conn)->ssl, buf, count);
1353 if ((rc <= 0) || (errno == EINTR))
1354 {
1355 if (errno == EINTR)
1356 {
1357 rc = -1;
1358 }
1360 }
1361
1362 return rc;
1363}
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 310 of file raw.c.
311{
312 int rc;
313 size_t sent = 0;
314
316 do
317 {
318 do
319 {
320 rc = write(conn->
fd, buf + sent, count - sent);
321 } while (rc < 0 && (errno == EINTR));
322
323 if (rc < 0)
324 {
327 return -1;
328 }
329
330 sent += rc;
331 }
while ((sent < count) && !
SigInt);
332
334 return sent;
335}
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 531 of file sasl.c.
532{
533 int rc;
534 const char *pbuf = NULL;
535 unsigned int olen, plen;
536
539
540
541 if (*sasldata->
ssf != 0)
542 {
543
544 do
545 {
547
548 rc = sasl_encode(sasldata->
saslconn,
buf, olen, &pbuf, &plen);
549 if (rc != SASL_OK)
550 {
552 goto fail;
553 }
554
555 rc = sasldata->
write(conn, pbuf, plen);
556 if (rc != plen)
557 goto fail;
558
559 count -= olen;
561 }
while (count > *sasldata->
pbufsize);
562 }
563 else
564 {
565
566 rc = sasldata->
write(conn,
buf, count);
567 }
568
570
571 return rc;
572
573fail:
575 return -1;
576}
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.
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 166 of file tunnel.c.
167{
169 int rc;
170 size_t sent = 0;
171
172 do
173 {
174 do
175 {
176 rc = write(tunnel->
fd_write, buf + sent, count - sent);
177 } while (rc < 0 && errno == EINTR);
178
179 if (rc < 0)
180 {
182 return -1;
183 }
184
185 sent += rc;
186 } while (sent < count);
187
188 return sent;
189}
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) |