2012-09-24 16:27:47 +10:00
|
|
|
#ifndef __UTIL_H__
|
|
|
|
#define __UTIL_H__
|
|
|
|
|
|
|
|
#if defined(unix) || defined(__APPLE__)
|
2012-09-24 16:50:04 +10:00
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2012-09-24 16:27:47 +10:00
|
|
|
#define SOCKETTYPE int
|
|
|
|
#define SOCKETFAIL(a) ((a) < 0)
|
|
|
|
#define INVSOCK -1
|
|
|
|
#define INVINETADDR -1
|
|
|
|
#define CLOSESOCKET close
|
|
|
|
|
|
|
|
#define SOCKERRMSG strerror(errno)
|
|
|
|
#elif defined WIN32
|
2012-09-24 16:50:04 +10:00
|
|
|
#include <ws2tcpip.h>
|
|
|
|
#include <winsock2.h>
|
|
|
|
|
2012-09-24 16:27:47 +10:00
|
|
|
#define SOCKETTYPE SOCKET
|
|
|
|
#define SOCKETFAIL(a) ((a) == SOCKET_ERROR)
|
|
|
|
#define INVSOCK INVALID_SOCKET
|
|
|
|
#define INVINETADDR INADDR_NONE
|
|
|
|
#define CLOSESOCKET closesocket
|
|
|
|
|
2012-10-04 15:35:28 +10:00
|
|
|
extern char *WSAErrorMsg(void);
|
2012-09-24 16:27:47 +10:00
|
|
|
#define SOCKERRMSG WSAErrorMsg()
|
|
|
|
|
|
|
|
#ifndef SHUT_RDWR
|
|
|
|
#define SHUT_RDWR SD_BOTH
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef in_addr_t
|
|
|
|
#define in_addr_t uint32_t
|
|
|
|
#endif
|
|
|
|
#endif
|
2012-09-30 20:24:24 +10:00
|
|
|
|
|
|
|
#if JANSSON_MAJOR_VERSION >= 2
|
|
|
|
#define JSON_LOADS(str, err_ptr) json_loads((str), 0, (err_ptr))
|
|
|
|
#else
|
|
|
|
#define JSON_LOADS(str, err_ptr) json_loads((str), (err_ptr))
|
|
|
|
#endif
|
|
|
|
|
2012-09-25 05:46:07 +10:00
|
|
|
struct pool;
|
2012-09-30 23:10:43 +10:00
|
|
|
bool stratum_send(struct pool *pool, char *s, ssize_t len);
|
2012-10-04 23:18:33 +10:00
|
|
|
char *recv_line(struct pool *pool);
|
2012-09-30 19:19:46 +10:00
|
|
|
bool parse_method(struct pool *pool, char *s);
|
2012-09-25 20:23:59 +10:00
|
|
|
bool extract_sockaddr(struct pool *pool, char *url);
|
2012-09-28 04:35:16 +10:00
|
|
|
bool auth_stratum(struct pool *pool);
|
2012-09-26 15:23:01 +10:00
|
|
|
bool initiate_stratum(struct pool *pool);
|
2012-09-24 16:27:47 +10:00
|
|
|
|
|
|
|
#endif /* __UTIL_H__ */
|