wmbiff: Fix cast to pointer from integer of different size compiler warning.
[dockapps.git] / wmbiff / wmbiff / tlsComm.h
blob15ffa4af343f74e4c2bba8105797ab3268e775e7
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, /*@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 */
28 /*@only@*/
29 struct connection_state *initialize_unencrypted(int sd, /*@only@ */
30 char *name, Pop3 pc);
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 */
37 /*@only@*/
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,
51 /*@out@ */ char *buf,
52 int buflen);
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,
60 int linebuflen);
61 #ifndef UNUSED
62 #ifdef HAVE___ATTRIBUTE__
63 #define UNUSED(x) /*@unused@*/ x __attribute__((unused))
64 #else
65 #define UNUSED(x) x
66 #endif
67 #endif