]> Pileus Git - ~andy/fetchmail/blob - socket.h
Compiler warnings fixes, preprocessor and minor general cleanup.
[~andy/fetchmail] / socket.h
1 /*
2  * socket.h -- declarations for socket library functions
3  *
4  * For license terms, see the file COPYING in this directory.
5  */
6
7 #ifndef SOCKET__
8 #define SOCKET__
9
10 /* Create a new client socket; returns (FILE *)NULL on error */
11 #ifdef INET6_ENABLE
12 int SockOpen(const char *host, const char *service, const char *options,
13              const char *plugin);
14 #else /* INET6_ENABLE */
15 int SockOpen(const char *host, int clientPort, const char *options,
16              const char *plugin);
17 #endif /* INET6_ENABLE */
18
19 /* Returns 1 if this socket is OK, 0 if it isn't select()able
20  * on - probably because it's been closed. You should
21  * always check this function before passing stuff to the
22  * select()-based waiter, as otherwise it may loop. 
23  */
24 int SockCheckOpen(int fd);
25
26 /* 
27 Get a string terminated by an '\n' (matches interface of fgets).
28 Pass it a valid socket, a buffer for the string, and
29 the length of the buffer (including the trailing \0)
30 returns length of buffer on success, -1 on failure. 
31 */
32 int SockRead(int sock, char *buf, int len);
33
34 /*
35  * Peek at the next socket character without actually reading it.
36  */
37 int SockPeek(int sock);
38
39 /*
40 Write a chunk of bytes to the socket (matches interface of fwrite).
41 Returns number of bytes successfully written.
42 */
43 int SockWrite(int sock, char *buf, int size);
44
45 /* 
46 Send formatted output to the socket (matches interface of fprintf).
47 Returns number of bytes successfully written.
48 */
49 #if defined(HAVE_STDARG_H)
50 int SockPrintf(int sock, const char *format, ...) ;
51 #else
52 int SockPrintf();
53 #endif
54  
55 /*
56 Close a socket previously opened by SockOpen.  This allows for some
57 additional clean-up if necessary.
58 */
59 int SockClose(int sock);
60
61 /*
62 FIXME: document this
63 */
64 int UnixOpen(const char *path);
65
66 #ifdef SSL_ENABLE
67 int SSLOpen(int sock, char *mycert, char *mykey, char *myproto, int certck, char *certpath,
68     char *fingerprint, char *servercname, char *label);
69 #endif /* SSL_ENABLE */
70
71 #endif /* SOCKET__ */