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/
11 /* used to drill through per-mailbox debug keys */
15 /* opaque reference to the state associated with a
16 connection: may be just a file handle, or may include
18 struct connection_state
;
20 /* take a socket descriptor and negotiate a TLS connection
23 struct connection_state
*initialize_gnutls(intptr_t sd
,
24 /* @only@ */ char *name
,
26 const char *hostname
);
28 /* take a socket descriptor and bundle it into a connection
29 state structure for later communication */
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 */
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
,
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
,
64 #ifdef HAVE___ATTRIBUTE__
65 #define UNUSED(x) /*@unused@*/ x __attribute__((unused))