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