Strip off version numbers from dir name
[dockapps.git] / wmbiff / wmbiff / tlsComm.h
blob38911dd409a801dab9cf19362854f68e00af7a69
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 "Client.h"
14 /* opaque reference to the state associated with a
15 connection: may be just a file handle, or may include
16 encryption state */
17 struct connection_state;
19 /* take a socket descriptor and negotiate a TLS connection
20 over it */
21 /*@only@*/
22 struct connection_state *initialize_gnutls(int sd, /*@only@ */ char *name,
23 Pop3 pc, const char *hostname);
25 /* take a socket descriptor and bundle it into a connection
26 state structure for later communication */
27 /*@only@*/
28 struct connection_state *initialize_unencrypted(int sd, /*@only@ */
29 char *name, Pop3 pc);
31 /* store a binding when connect() times out. these should be
32 skipped when trying to check mail so that other mailboxes
33 are checked responsively. I believe linux defaults to
34 around 90 seconds for a failed connect() attempt */
35 /* TODO: engineer an eventual retry scheme */
36 /*@only@*/
37 struct connection_state *initialize_blacklist( /*@only@ */ char *name);
38 int tlscomm_is_blacklisted(const struct connection_state *scs);
40 /* just like fprintf, only takes a connection state structure */
41 void tlscomm_printf(struct connection_state *scs, const char *format, ...);
43 /* modeled after fgets; may not work exactly the same */
44 int tlscomm_gets( /*@out@ */ char *buf,
45 int buflen, struct connection_state *scs);
47 /* gobbles lines until it finds one starting with {prefix},
48 which is returned in buf */
49 int tlscomm_expect(struct connection_state *scs, const char *prefix,
50 /*@out@ */ char *buf,
51 int buflen);
53 /* terminates the TLS association or just closes the socket,
54 and frees the connection state */
55 void tlscomm_close( /*@only@ */ struct connection_state *scs);
57 /* internal function exported for testing */
58 int getline_from_buffer(char *readbuffer, char *linebuffer,
59 int linebuflen);
60 #ifndef UNUSED
61 #ifdef HAVE___ATTRIBUTE__
62 #define UNUSED(x) /*@unused@*/ x __attribute__((unused))
63 #else
64 #define UNUSED(x) x
65 #endif
66 #endif