Rocco Rutte:
[apps/madmutt.git] / 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 "lib.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, size_t len);
38   int (*conn_write) (struct _connection * conn, const char *buf,
39                      size_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, size_t len);
47 int mutt_socket_readchar (CONNECTION * conn, char *c);
48
49 #define mutt_socket_readln(A,B,C) mutt_socket_readln_d(A,B,C,M_SOCK_LOG_CMD)
50 int mutt_socket_readln_d (char *buf, size_t buflen, CONNECTION * conn,
51                           int dbg);
52 #define mutt_socket_write(A,B) mutt_socket_write_d(A,B,M_SOCK_LOG_CMD);
53 int mutt_socket_write_d (CONNECTION * conn, const char *buf, int dbg);
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, size_t len);
62 int raw_socket_write (CONNECTION * conn, const char *buf, size_t count);
63 int raw_socket_open (CONNECTION * conn);
64 int raw_socket_close (CONNECTION * conn);
65
66 #endif /* _MUTT_SOCKET_H_ */