wmmixer: 1.9
[dockapps.git] / wmbiff / wmbiff / tlsComm.h
blob50a687e5488313d8880ff726f8b2108c77e5e269
1 /* tlsComm.h - interface for the thin layer that looks
2 sort of like fgets and fprintf, but might read or write
3 to a socket or a TLS association
5 Neil Spring (nspring@cs.washington.edu)
7 Comments in @'s are for lclint's benefit:
8 http://lclint.cs.virginia.edu/
9 */
11 /* used to drill through per-mailbox debug keys */
12 #include <stdint.h>
13 #include "Client.h"
15 /* opaque reference to the state associated with a
16 connection: may be just a file handle, or may include
17 encryption state */
18 struct connection_state;
20 /* take a socket descriptor and negotiate a TLS connection
21 over it */
22 /*@only@*/
23 struct connection_state *initialize_gnutls(intptr_t sd,
24 /* @only@ */ char *name,
25 Pop3 *pc,
26 const char *hostname);
28 /* take a socket descriptor and bundle it into a connection
29 state structure for later communication */
30 /*@only@*/
31 struct connection_state *initialize_unencrypted(int sd, /*@only@ */
32 char *name, Pop3 * pc);
34 /* store a binding when connect() times out. these should be
35 skipped when trying to check mail so that other mailboxes
36 are checked responsively. I believe linux defaults to
37 around 90 seconds for a failed connect() attempt */
38 /* TODO: engineer an eventual retry scheme */
39 /*@only@*/
40 struct connection_state *initialize_blacklist( /*@only@ */ char *name);
41 int tlscomm_is_blacklisted(const struct connection_state *scs);
43 /* just like fprintf, only takes a connection state structure */
44 void tlscomm_printf(struct connection_state *scs, const char *format, ...);
46 /* modeled after fgets; may not work exactly the same */
47 int tlscomm_gets( /*@out@ */ char *buf,
48 int buflen, struct connection_state *scs);
50 /* gobbles lines until it finds one starting with {prefix},
51 which is returned in buf */
52 int tlscomm_expect(struct connection_state *scs, const char *prefix,
53 /*@out@ */ char *buf,
54 int buflen);
56 /* terminates the TLS association or just closes the socket,
57 and frees the connection state */
58 void tlscomm_close( /*@only@ */ struct connection_state *scs);
60 /* internal function exported for testing */
61 int getline_from_buffer(char *readbuffer, char *linebuffer,
62 int linebuflen);
63 #ifndef UNUSED
64 #ifdef HAVE___ATTRIBUTE__
65 #define UNUSED(x) /*@unused@*/ x __attribute__((unused))
66 #else
67 #define UNUSED(x) x
68 #endif
69 #endif