Low-level socket handling. More...
#include <time.h>Go to the source code of this file.
Macros | |
| #define | MUTT_SOCK_LOG_CMD 2 |
| Log commands only. | |
| #define | MUTT_SOCK_LOG_HDR 3 |
| Log commands and headers. | |
| #define | MUTT_SOCK_LOG_FULL 5 |
| Log everything including full protocol. | |
| #define | mutt_socket_readln(buf, buflen, conn) |
| #define | mutt_socket_send(conn, buf) |
| #define | mutt_socket_send_d(conn, buf, dbg) |
| #define | mutt_socket_write_n(conn, buf, len) |
| #define | mutt_socket_buffer_readln(buf, conn) |
Enumerations | |
| enum | ConnectionType { MUTT_CONNECTION_SIMPLE , MUTT_CONNECTION_TUNNEL , MUTT_CONNECTION_SSL } |
| Type of connection. More... | |
Functions | |
| int | mutt_socket_close (struct Connection *conn) |
| Close a socket. | |
| void | mutt_socket_empty (struct Connection *conn) |
| Clear out any queued data. | |
| struct Connection * | mutt_socket_new (enum ConnectionType type) |
| Allocate and initialise a new connection. | |
| int | mutt_socket_open (struct Connection *conn) |
| Simple wrapper. | |
| int | mutt_socket_poll (struct Connection *conn, time_t wait_secs) |
| Checks whether reads would block. | |
| int | mutt_socket_read (struct Connection *conn, char *buf, size_t len) |
| Read from a Connection. | |
| int | mutt_socket_readchar (struct Connection *conn, char *c) |
| Simple read buffering to speed things up. | |
| int | mutt_socket_readln_d (char *buf, size_t buflen, struct Connection *conn, int dbg) |
| Read a line from a socket. | |
| int | mutt_socket_write_d (struct Connection *conn, const char *buf, int len, int dbg) |
| Write data to a socket. | |
| int | mutt_socket_buffer_readln_d (struct Buffer *buf, struct Connection *conn, int dbg) |
| Read a line from a socket into a Buffer. | |
Low-level socket handling.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file socket.h.
| #define MUTT_SOCK_LOG_FULL 5 |
| #define mutt_socket_readln | ( | buf, | |
| buflen, | |||
| conn ) |
| #define mutt_socket_send | ( | conn, | |
| buf ) |
| #define mutt_socket_send_d | ( | conn, | |
| buf, | |||
| dbg ) |
| #define mutt_socket_write_n | ( | conn, | |
| buf, | |||
| len ) |
| #define mutt_socket_buffer_readln | ( | buf, | |
| conn ) |
| enum ConnectionType |
| int mutt_socket_close | ( | struct Connection * | conn | ) |
Close a socket.
| conn | Connection to a server |
| 0 | Success |
| -1 | Error |
Definition at line 100 of file socket.c.
| void mutt_socket_empty | ( | struct Connection * | conn | ) |
Clear out any queued data.
| conn | Connection to a server |
The internal buffer is emptied and any data that has already arrived at this machine (in kernel buffers) is read and dropped.
Definition at line 306 of file socket.c.
| struct Connection * mutt_socket_new | ( | enum ConnectionType | type | ) |
Allocate and initialise a new connection.
| type | Type of the new Connection |
| ptr | New Connection |
Definition at line 272 of file socket.c.
| int mutt_socket_open | ( | struct Connection * | conn | ) |
Simple wrapper.
| conn | Connection to a server |
| 0 | Success |
| -1 | Error |
Definition at line 76 of file socket.c.
| int mutt_socket_poll | ( | struct Connection * | conn, |
| time_t | wait_secs ) |
Checks whether reads would block.
| conn | Connection to a server |
| wait_secs | How long to wait for a response |
| >0 | There is data to read |
| 0 | Read would block |
| -1 | Connection doesn't support polling |
Definition at line 182 of file socket.c.
| int mutt_socket_read | ( | struct Connection * | conn, |
| char * | buf, | ||
| size_t | len ) |
Read from a Connection.
| conn | Connection a server |
| buf | Buffer to store read data |
| len | length of the buffer |
| >0 | Success, number of bytes read |
| -1 | Error, see errno |
Definition at line 128 of file socket.c.
| int mutt_socket_readchar | ( | struct Connection * | conn, |
| char * | c ) |
Simple read buffering to speed things up.
| [in] | conn | Connection to a server |
| [out] | c | Character that was read |
| 1 | Success |
| -1 | Error |
Definition at line 200 of file socket.c.
| int mutt_socket_readln_d | ( | char * | buf, |
| size_t | buflen, | ||
| struct Connection * | conn, | ||
| int | dbg ) |
Read a line from a socket.
| buf | Buffer to store the line |
| buflen | Length of data to write |
| conn | Connection to a server |
| dbg | Debug level for logging |
| >0 | Success, number of bytes read |
| -1 | Error |
Definition at line 238 of file socket.c.
| int mutt_socket_write_d | ( | struct Connection * | conn, |
| const char * | buf, | ||
| int | len, | ||
| int | dbg ) |
Write data to a socket.
| conn | Connection to a server |
| buf | Buffer with data to write |
| len | Length of data to write |
| dbg | Debug level for logging |
| >0 | Number of bytes written |
| -1 | Error |
Definition at line 142 of file socket.c.
| int mutt_socket_buffer_readln_d | ( | struct Buffer * | buf, |
| struct Connection * | conn, | ||
| int | dbg ) |
Read a line from a socket into a Buffer.
| buf | Buffer to store the line |
| conn | Connection to a server |
| dbg | Debug level for logging |
| >0 | Success, number of bytes read |
| -1 | Error |
Definition at line 328 of file socket.c.