acl/lib_acl/include/stdlib/acl_sys_patch.h

202 lines
5.9 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#ifndef ACL_SYS_PATCH_INCLUDE_H
#define ACL_SYS_PATCH_INCLUDE_H
# ifdef __cplusplus
extern "C" {
# endif
#include "acl_define.h"
#include "acl_vstream.h"
#if defined(_WIN32) || defined(_WIN64)
2014-11-19 00:25:21 +08:00
struct iovec {
void *iov_base; /**< Starting address */
size_t iov_len; /**< Number of bytes */
};
#ifdef HAVE_NO_TIMEVAL
struct timeval {
long tv_sec; /**< seconds */
long tv_usec; /**< microseconds */
};
#endif
struct timezone {
int tz_minuteswest; /**< minutes W of Greenwich */
int tz_dsttime; /**< type of dst correction */
};
/**
* ˯<EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD>
* @param sec {int} ˯<EFBFBD>ߵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API void sleep(int sec);
/**
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰʱ<EFBFBD><EFBFBD>
* @param tv {struct timeval*} <EFBFBD><EFBFBD><EFBFBD>ǰʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param tz {struct timezone*} ʱ<EFBFBD><EFBFBD>
*/
ACL_API int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif /* _WIN32 */
2014-11-19 00:25:21 +08:00
#ifdef ACL_UNIX
# include <sys/uio.h>
#endif
/**
* <EFBFBD>׽<EFBFBD><EFBFBD>ֳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_WIN32ƽ̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>WSAStartup<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>SOCKET<EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UNIXƽ̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͨ<EFBFBD><EFBFBD> signal(SIGPIPE, SIG_IGN) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
* @return {int} 0: OK; -1: error
*/
ACL_API int acl_socket_init(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>_WIN32<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
* @return {int} 0: OK; -1: error
*/
ACL_API int acl_socket_end(void);
/**
* <EFBFBD>ر<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: OK; -1: error
*/
ACL_API int acl_socket_close(ACL_SOCKET fd);
/**
* <EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param buf {void*} <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param size {size_t} buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param timeout {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻص<EFBFBD><EFBFBD><EFBFBD>ʽʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: OK; -1: error
*/
ACL_API int acl_socket_read(ACL_SOCKET fd, void *buf, size_t size,
int timeout, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param buf {void*} <EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
* @param size {size_t} buf <EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
* @param timeout {int} д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻص<EFBFBD><EFBFBD><EFBFBD>ʽʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: OK; -1: error
*/
ACL_API int acl_socket_write(ACL_SOCKET fd, const void *buf,
size_t size, int timeout, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param vec {const struct iovec*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param count {int} vec <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param timeout {int} д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻص<EFBFBD><EFBFBD><EFBFBD>ʽʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: OK; -1: error
*/
ACL_API int acl_socket_writev(ACL_SOCKET fd, const struct iovec *vec,
int count, int timeout, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param filepath {cosnt char*} <EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
* @param flags {int} <EFBFBD>򿪱<EFBFBD>־λ, O_RDONLY | O_WRONLY | O_RDWR,
* O_CREAT | O_EXCL | O_TRUNC, O_APPEND(for UNIX)
* @param mode {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD>λ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>UNIX<EFBFBD><EFBFBD>Ч, <EFBFBD>0700, 0755
* @return {ACL_FILE_HANDLE} <EFBFBD>򿪵<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_FILE_INVALID <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
*/
ACL_API ACL_FILE_HANDLE acl_file_open(const char *filepath, int flags, int mode);
/**
* <EFBFBD>رմ򿪵<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: ok; -1: error
*/
ACL_API int acl_file_close(ACL_FILE_HANDLE fh);
/**
* <EFBFBD><EFBFBD>λ<EFBFBD>ļ<EFBFBD>λ<EFBFBD><EFBFBD>
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param offset {acl_off_t} ƫ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
* @param whence {int} λ<EFBFBD>ñ<EFBFBD>־λ<EFBFBD><EFBFBD>SEEK_CUR, SEEK_SET, SEEK_END
* @return {acl_off_t} <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ƫ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
*/
ACL_API acl_off_t acl_lseek(ACL_FILE_HANDLE fh, acl_off_t offset, int whence);
/**
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param buf {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param size {size_t} buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>Իص<EFBFBD><EFBFBD><EFBFBD>ʽʹ<EFBFBD><EFBFBD>ʱ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_VSTREAM_EOF <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_file_read(ACL_FILE_HANDLE fh, void *buf, size_t size,
int timeout, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param buf {void*} <EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param size {size_t} buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD>ȴ<EFBFBD>С
* @param timeout {int} д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>Իص<EFBFBD><EFBFBD><EFBFBD>ʽʹ<EFBFBD><EFBFBD>ʱ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
* @return {int} <EFBFBD>ɹ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_VSTREAM_EOF <EFBFBD><EFBFBD>ʾд<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_file_write(ACL_FILE_HANDLE fh, const void *buf, size_t size,
int timeout, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>дһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param vec {const struct iovec*} <EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param count {int} vec <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>
* @param timeout {int} д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>Իص<EFBFBD><EFBFBD><EFBFBD>ʽʹ<EFBFBD><EFBFBD>ʱ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
* @return {int} <EFBFBD>ɹ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_VSTREAM_EOF <EFBFBD><EFBFBD>ʾд<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_file_writev(ACL_FILE_HANDLE fh, const struct iovec *vec,
int count, int timeout, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD>
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>Իص<EFBFBD><EFBFBD><EFBFBD>ʽʹ<EFBFBD><EFBFBD>ʱ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
* @return {int} 0: ok; -1: error
*/
ACL_API int acl_file_fflush(ACL_FILE_HANDLE fh, ACL_VSTREAM *fp, void *arg);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ø<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>Ĵ<EFBFBD>С
* @param filename {const char*} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @return {acl_int64} >= 0: ok; -1: error
*/
ACL_API acl_int64 acl_file_size(const char *filename);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ø<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>Ĵ<EFBFBD>С
* @param fh {ACL_FILE_HANDLE} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fp {ACL_VSTREAM*} <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>Իص<EFBFBD><EFBFBD><EFBFBD>ʽʹ<EFBFBD><EFBFBD>ʱ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
* @return {acl_int64} >= 0: ok; -1: error
*/
ACL_API acl_int64 acl_file_fsize(ACL_FILE_HANDLE fh, ACL_VSTREAM *fp, void *arg);
# ifdef __cplusplus
}
# endif
#endif