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