781427da2de277aa1d84202faf3de57d5addbef2
[apps/madmutt.git] / lib-sys / mutt_socket.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1998 Brandon Long <blong@fiction.net>
4  * Copyright (C) 1999-2005 Brendan Cully <brendan@kublai.com>
5  *
6  * This file is part of mutt-ng, see http://www.muttng.org/.
7  * It's licensed under the GNU General Public License,
8  * please see the file GPL in the top level source directory.
9  */
10
11 #ifndef _MUTT_SOCKET_H_
12 #define _MUTT_SOCKET_H_ 1
13
14 #include "account.h"
15 #include "mutt.h"
16
17 /* logging levels */
18 #define M_SOCK_LOG_CMD  2
19 #define M_SOCK_LOG_HDR  3
20 #define M_SOCK_LOG_FULL 4
21
22 typedef struct _connection {
23   ACCOUNT account;
24   /* security strength factor, in bits */
25   unsigned int ssf;
26   void *data;
27
28   char inbuf[LONG_STRING];
29   int bufpos;
30
31   int fd;
32   int available;
33
34   struct _connection *next;
35
36   void *sockdata;
37   int (*conn_read) (struct _connection * conn, char *buf, ssize_t len);
38   int (*conn_write) (struct _connection * conn, const char *buf,
39                      ssize_t count);
40   int (*conn_open) (struct _connection * conn);
41   int (*conn_close) (struct _connection * conn);
42 } CONNECTION;
43
44 int mutt_socket_open (CONNECTION * conn);
45 int mutt_socket_close (CONNECTION * conn);
46 int mutt_socket_read (CONNECTION * conn, char *buf, ssize_t len);
47 int mutt_socket_readchar (CONNECTION * conn, char *c);
48
49 int mutt_socket_readln(char *buf, ssize_t buflen, CONNECTION * conn);
50 int mutt_socket_write(CONNECTION * conn, const char *buf);
51
52 int mutt_ssl_starttls (CONNECTION * conn);
53 int mutt_ssl_socket_setup (CONNECTION * conn);
54
55 /* stupid hack for imap_logout_all */
56 CONNECTION *mutt_socket_head (void);
57 void mutt_socket_free (CONNECTION * conn);
58 CONNECTION *mutt_conn_find (const CONNECTION * start,
59                             const ACCOUNT * account);
60
61 int raw_socket_read (CONNECTION * conn, char *buf, ssize_t len);
62 int raw_socket_write (CONNECTION * conn, const char *buf, ssize_t count);
63 int raw_socket_open (CONNECTION * conn);
64 int raw_socket_close (CONNECTION * conn);
65
66 #endif /* _MUTT_SOCKET_H_ */