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
, /*@only@ */ char *name
,
24 Pop3 pc
, const char *hostname
);
26 /* take a socket descriptor and bundle it into a connection
27 state structure for later communication */
29 struct connection_state
*initialize_unencrypted(int sd
, /*@only@ */
32 /* store a binding when connect() times out. these should be
33 skipped when trying to check mail so that other mailboxes
34 are checked responsively. I believe linux defaults to
35 around 90 seconds for a failed connect() attempt */
36 /* TODO: engineer an eventual retry scheme */
38 struct connection_state
*initialize_blacklist( /*@only@ */ char *name
);
39 int tlscomm_is_blacklisted(const struct connection_state
*scs
);
41 /* just like fprintf, only takes a connection state structure */
42 void tlscomm_printf(struct connection_state
*scs
, const char *format
, ...);
44 /* modeled after fgets; may not work exactly the same */
45 int tlscomm_gets( /*@out@ */ char *buf
,
46 int buflen
, struct connection_state
*scs
);
48 /* gobbles lines until it finds one starting with {prefix},
49 which is returned in buf */
50 int tlscomm_expect(struct connection_state
*scs
, const char *prefix
,
54 /* terminates the TLS association or just closes the socket,
55 and frees the connection state */
56 void tlscomm_close( /*@only@ */ struct connection_state
*scs
);
58 /* internal function exported for testing */
59 int getline_from_buffer(char *readbuffer
, char *linebuffer
,
62 #ifdef HAVE___ATTRIBUTE__
63 #define UNUSED(x) /*@unused@*/ x __attribute__((unused))