25
|
1 |
#ifndef __CONNWRAP_H__ |
|
2 |
#define __CONNWRAP_H__ |
|
3 |
|
|
4 |
#ifdef __cplusplus |
|
5 |
extern "C" { |
|
6 |
#endif |
|
7 |
|
|
8 |
#include <sys/types.h> |
|
9 |
#include <sys/socket.h> |
|
10 |
|
|
11 |
int cw_connect(int sockfd, const struct sockaddr *serv_addr, int addrlen, int ssl); |
|
12 |
|
|
13 |
#define CW_CONNECT_STARTED 0x1 |
|
14 |
#define CW_CONNECT_SSL 0x2 |
|
15 |
#define CW_CONNECT_WANT_READ 0x4 |
|
16 |
#define CW_CONNECT_WANT_WRITE 0x8 |
|
17 |
#define CW_CONNECT_WANT_SOMETHING 0xC |
|
18 |
#define CW_CONNECT_BLOCKING 0x10 |
|
19 |
|
|
20 |
/* non-blocking socket |
|
21 |
state should be initialized with 0, subsequent calls should keep the modified state (state is a bitwise OR between CW_CONNECT_XXX) |
|
22 |
returns 0 for OK, or if it wants subsequent calls |
|
23 |
-1 for a fatal error |
|
24 |
*/ |
|
25 |
int cw_nb_connect(int sockfd, const struct sockaddr *serv_addr, int addrlen, int ssl, int *state); |
|
26 |
int cw_accept(int s, struct sockaddr *addr, int *addrlen, int ssl); |
|
27 |
|
|
28 |
int cw_write(int fd, const void *buf, int count, int ssl); |
|
29 |
int cw_read(int fd, void *buf, int count, int ssl); |
|
30 |
|
|
31 |
int cw_close(int fd); |
|
32 |
|
|
33 |
void cw_setproxy(const char *aproxyhost, int aproxyport, const char *aproxyuser, const char *aproxypass); |
|
34 |
void cw_setbind(const char *abindaddr); |
|
35 |
|
|
36 |
char *cw_base64_encode(const char *in); |
|
37 |
|
|
38 |
#ifdef __cplusplus |
|
39 |
} |
|
40 |
#endif |
|
41 |
|
|
42 |
#endif |