NeoMutt  2024-03-23-142-g2b2e76
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1
23#ifndef MUTT_CONN_SOCKET_H
24#define MUTT_CONN_SOCKET_H
25
26#include <time.h>
27
28struct Buffer;
29struct Connection;
30
35{
39};
40
41int mutt_socket_close (struct Connection *conn);
42void mutt_socket_empty (struct Connection *conn);
43struct Connection *mutt_socket_new (enum ConnectionType type);
44int mutt_socket_open (struct Connection *conn);
45int mutt_socket_poll (struct Connection *conn, time_t wait_secs);
46int mutt_socket_read (struct Connection *conn, char *buf, size_t len);
47int mutt_socket_readchar(struct Connection *conn, char *c);
48int mutt_socket_readln_d(char *buf, size_t buflen, struct Connection *conn, int dbg);
49int mutt_socket_write_d (struct Connection *conn, const char *buf, int len, int dbg);
50
51/* logging levels */
52#define MUTT_SOCK_LOG_CMD 2
53#define MUTT_SOCK_LOG_HDR 3
54#define MUTT_SOCK_LOG_FULL 5
55
56#define mutt_socket_readln(buf, buflen, conn) mutt_socket_readln_d(buf, buflen, conn, MUTT_SOCK_LOG_CMD)
57#define mutt_socket_send(conn, buf) mutt_socket_send_d(conn, buf, MUTT_SOCK_LOG_CMD)
58#define mutt_socket_send_d(conn, buf, dbg) mutt_socket_write_d(conn, buf, mutt_str_len(buf), dbg)
59#define mutt_socket_write_n(conn, buf, len) mutt_socket_write_d(conn, buf, len, MUTT_SOCK_LOG_CMD)
60
61#define mutt_socket_buffer_readln(buf, conn) mutt_socket_buffer_readln_d(buf, conn, MUTT_SOCK_LOG_CMD)
62int mutt_socket_buffer_readln_d(struct Buffer *buf, struct Connection *conn, int dbg);
63
64#endif /* MUTT_CONN_SOCKET_H */
int mutt_socket_close(struct Connection *conn)
Close a socket.
Definition: socket.c:100
int mutt_socket_poll(struct Connection *conn, time_t wait_secs)
Checks whether reads would block.
Definition: socket.c:182
int mutt_socket_buffer_readln_d(struct Buffer *buf, struct Connection *conn, int dbg)
Read a line from a socket into a Buffer.
Definition: socket.c:328
int mutt_socket_write_d(struct Connection *conn, const char *buf, int len, int dbg)
Write data to a socket.
Definition: socket.c:142
struct Connection * mutt_socket_new(enum ConnectionType type)
Allocate and initialise a new connection.
Definition: socket.c:272
int mutt_socket_readchar(struct Connection *conn, char *c)
Simple read buffering to speed things up.
Definition: socket.c:200
void mutt_socket_empty(struct Connection *conn)
Clear out any queued data.
Definition: socket.c:306
ConnectionType
Type of connection.
Definition: socket.h:35
@ MUTT_CONNECTION_SSL
SSL/TLS-encrypted connection.
Definition: socket.h:38
@ MUTT_CONNECTION_SIMPLE
Simple TCP socket connection.
Definition: socket.h:36
@ MUTT_CONNECTION_TUNNEL
Tunnelled connection.
Definition: socket.h:37
int mutt_socket_read(struct Connection *conn, char *buf, size_t len)
Read from a Connection.
Definition: socket.c:128
int mutt_socket_open(struct Connection *conn)
Simple wrapper.
Definition: socket.c:76
int mutt_socket_readln_d(char *buf, size_t buflen, struct Connection *conn, int dbg)
Read a line from a socket.
Definition: socket.c:238
String manipulation buffer.
Definition: buffer.h:36