]> Pileus Git - ~andy/fetchmail/blob - socket.h
Initial revision
[~andy/fetchmail] / socket.h
1 /*
2  * socket.h -- declarations for socket library functions
3  *
4  * Design and implementation by Carl Harris <ceharris@mal.com>
5  *
6  * For license terms, see the file COPYING in this directory.
7  */
8
9 #ifndef SOCKET__
10 #define SOCKET__
11
12 #ifndef  INADDR_NONE
13 #ifdef   INADDR_BROADCAST
14 #define  INADDR_NONE    INADDR_BROADCAST
15 #else
16 #define  INADDR_NONE    -1
17 #endif
18 #endif
19
20 #if defined(HAVE_PROTOTYPES)
21 /*
22 Create a new client socket 
23 returns < 0 on error 
24 */
25 int Socket(char *host, int clientPort);
26
27 /* 
28 Get a string terminated by an '\n', delete any '\r' and the '\n'.
29 Pass it a valid socket, a buffer for the string, and
30 the length of the buffer (including the trailing \0)
31 returns 0 for success. 
32 */
33 int SockGets(int socket, char *buf, int len);
34
35 /*
36 Send a nul terminated string to the socket, followed by 
37 a CR-LF.  Returns 0 for success.
38 */
39 int SockPuts(int socket, char *buf);
40
41 /*
42 Write a chunk of bytes to the socket.
43 Returns 0 for success.
44 */
45 int SockWrite(int socket, char *buf, int len);
46
47 /*
48 Read a chunk of bytes from the socket.
49 Returns 0 for success.
50 */
51 int SockRead(int socket, char *buf, int len);
52
53 /* 
54 Send formatted output to the socket, followed
55 by a CR-LF.
56 Returns 0 for success.
57 */
58 #if defined(HAVE_STDARG_H)
59 int SockPrintf(int socket, char *format, ...) ;
60 #else
61 int SockPrintf();
62 #endif
63 /*
64 Check socket for readability.  return 0 for not readable,
65 >0 for readable.
66 */
67 int SockStatus(int socket, int seconds);
68  
69 #endif /* defined(HAVE_PROTOTYPES) */
70
71 #endif /* SOCKET__ */