drop account-hooks for now.
[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 <lib-lua/lib-lua.h>
15 #include "account.h"
16 #include "mutt_ssl.li"
17
18 /* logging levels */
19 #define M_SOCK_LOG_CMD  2
20 #define M_SOCK_LOG_HDR  3
21 #define M_SOCK_LOG_FULL 4
22
23 typedef struct _connection {
24   ACCOUNT account;
25   /* security strength factor, in bits */
26   unsigned int ssf;
27   void *data;
28
29   char inbuf[LONG_STRING];
30   int bufpos;
31
32   int fd;
33   int available;
34
35   struct _connection *next;
36
37   void *sockdata;
38   int (*conn_read) (struct _connection * conn, char *buf, ssize_t len);
39   int (*conn_write) (struct _connection * conn, const char *buf,
40                      ssize_t count);
41   int (*conn_open) (struct _connection * conn);
42   int (*conn_close) (struct _connection * conn);
43 } CONNECTION;
44
45 int mutt_socket_open (CONNECTION * conn);
46 int mutt_socket_close (CONNECTION * conn);
47 int mutt_socket_read (CONNECTION * conn, char *buf, ssize_t len);
48 int mutt_socket_readchar (CONNECTION * conn, char *c);
49
50 int mutt_socket_readln(char *buf, ssize_t buflen, CONNECTION * conn);
51 int mutt_socket_write(CONNECTION * conn, const char *buf);
52
53 int mutt_socket_readln2(buffer_t *buf, CONNECTION *conn);
54
55 int mutt_ssl_starttls (CONNECTION * conn);
56 int mutt_ssl_socket_setup (CONNECTION * conn);
57
58 /* stupid hack for imap_logout_all */
59 CONNECTION *mutt_socket_head (void);
60 void mutt_socket_free (CONNECTION * conn);
61 CONNECTION *mutt_conn_find (const CONNECTION * start,
62                             const ACCOUNT * account);
63
64 int raw_socket_read (CONNECTION * conn, char *buf, ssize_t len);
65 int raw_socket_write (CONNECTION * conn, const char *buf, ssize_t count);
66 int raw_socket_open (CONNECTION * conn);
67 int raw_socket_close (CONNECTION * conn);
68
69 #endif /* _MUTT_SOCKET_H_ */