mutt stable branch with some hacks
1/*
2 * Copyright (C) 1998 Brandon Long <blong@fiction.net>
3 * Copyright (C) 1999-2005 Brendan Cully <brendan@kublai.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef _MUTT_SOCKET_H_
21#define _MUTT_SOCKET_H_ 1
22
23#include "account.h"
24#include "lib.h"
25
26/* logging levels */
27#define MUTT_SOCK_LOG_CMD 2
28#define MUTT_SOCK_LOG_HDR 3
29#define MUTT_SOCK_LOG_FULL 4
30
31typedef struct _connection
32{
33 ACCOUNT account;
34 /* security strength factor, in bits */
35 unsigned int ssf;
36 void *data;
37
38 char inbuf[LONG_STRING];
39 int bufpos;
40
41 int fd;
42 int available;
43
44 struct _connection *next;
45
46 void *sockdata;
47 int (*conn_read) (struct _connection* conn, char* buf, size_t len);
48 int (*conn_write) (struct _connection *conn, const char *buf, size_t count);
49 int (*conn_open) (struct _connection *conn);
50 int (*conn_close) (struct _connection *conn);
51 int (*conn_poll) (struct _connection *conn);
52} CONNECTION;
53
54int mutt_socket_open (CONNECTION* conn);
55int mutt_socket_close (CONNECTION* conn);
56int mutt_socket_read (CONNECTION* conn, char* buf, size_t len);
57int mutt_socket_poll (CONNECTION* conn);
58int mutt_socket_readchar (CONNECTION *conn, char *c);
59#define mutt_socket_readln(A,B,C) mutt_socket_readln_d(A,B,C,MUTT_SOCK_LOG_CMD)
60int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION *conn, int dbg);
61#define mutt_socket_write(A,B) mutt_socket_write_d(A,B,-1,MUTT_SOCK_LOG_CMD)
62#define mutt_socket_write_n(A,B,C) mutt_socket_write_d(A,B,C,MUTT_SOCK_LOG_CMD)
63int mutt_socket_write_d (CONNECTION *conn, const char *buf, int len, int dbg);
64
65/* stupid hack for imap_logout_all */
66CONNECTION* mutt_socket_head (void);
67void mutt_socket_free (CONNECTION* conn);
68CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account);
69
70int raw_socket_read (CONNECTION* conn, char* buf, size_t len);
71int raw_socket_write (CONNECTION* conn, const char* buf, size_t count);
72int raw_socket_open (CONNECTION *conn);
73int raw_socket_close (CONNECTION *conn);
74int raw_socket_poll (CONNECTION* conn);
75
76#endif /* _MUTT_SOCKET_H_ */