]> Pileus Git - ~andy/fetchmail/blob - socket.h
Remove port/service dualism and make everything a service.
[~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 -1 on error */
11 int SockOpen(const char *host, const char *service, const char *plugin);
12
13 /* Returns 1 if this socket is OK, 0 if it isn't select()able
14  * on - probably because it's been closed. You should
15  * always check this function before passing stuff to the
16  * select()-based waiter, as otherwise it may loop. 
17  */
18 int SockCheckOpen(int fd);
19
20 /* 
21 Get a string terminated by an '\n' (matches interface of fgets).
22 Pass it a valid socket, a buffer for the string, and
23 the length of the buffer (including the trailing \0)
24 returns length of buffer on success, -1 on failure. 
25 */
26 int SockRead(int sock, char *buf, int len);
27
28 /*
29  * Peek at the next socket character without actually reading it.
30  */
31 int SockPeek(int sock);
32
33 /*
34 Write a chunk of bytes to the socket (matches interface of fwrite).
35 Returns number of bytes successfully written.
36 */
37 int SockWrite(int sock, char *buf, int size);
38
39 /* 
40 Send formatted output to the socket (matches interface of fprintf).
41 Returns number of bytes successfully written.
42 */
43 #if defined(HAVE_STDARG_H)
44 int SockPrintf(int sock, const char *format, ...) ;
45 #else
46 int SockPrintf();
47 #endif
48  
49 /*
50 Close a socket previously opened by SockOpen.  This allows for some
51 additional clean-up if necessary.
52 */
53 int SockClose(int sock);
54
55 /*
56 FIXME: document this
57 */
58 int UnixOpen(const char *path);
59
60 #ifdef SSL_ENABLE
61 int SSLOpen(int sock, char *mycert, char *mykey, char *myproto, int certck, char *certpath,
62     char *fingerprint, char *servercname, char *label);
63 #endif /* SSL_ENABLE */
64
65 #endif /* SOCKET__ */