]> Pileus Git - ~andy/fetchmail/blob - socket.h
Comment fix.
[~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 #if INET6
12 int SockOpen(const char *host, const char *service, const char *options,
13              const char *plugin);
14 #else /* INET6 */
15 int SockOpen(const char *host, int clientPort, const char *options,
16              const char *plugin);
17 #endif /* INET6 */
18
19 /* 
20 Get a string terminated by an '\n' (matches interface of fgets).
21 Pass it a valid socket, a buffer for the string, and
22 the length of the buffer (including the trailing \0)
23 returns length of buffer on success, -1 on failure. 
24 */
25 int SockRead(int sock, char *buf, int len);
26
27 /*
28  * Peek at the next socket character without actually reading it.
29  */
30 int SockPeek(int sock);
31
32 /*
33 Write a chunk of bytes to the socket (matches interface of fwrite).
34 Returns number of bytes successfully written.
35 */
36 int SockWrite(int sock, char *buf, int size);
37
38 /* 
39 Send formatted output to the socket (matches interface of fprintf).
40 Returns number of bytes successfully written.
41 */
42 #if defined(HAVE_STDARG_H)
43 int SockPrintf(int sock, const char *format, ...) ;
44 #else
45 int SockPrintf();
46 #endif
47  
48 /*
49 Close a socket previously opened by SockOpen.  This allows for some
50 additional clean-up if necessary.
51 */
52 int SockClose(int sock);
53
54 #endif /* SOCKET__ */