acl/lib_acl/include/stdlib/acl_iostuff.h

170 lines
4.6 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#ifndef ACL_IOSTUFF_INCLUDE_H
#define ACL_IOSTUFF_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "acl_define.h"
#include "acl_vstream.h"
#define ACL_CLOSE_ON_EXEC 1 /**< <20><>־λ, <20><><EFBFBD><EFBFBD> exec <20><><EFBFBD>Զ<EFBFBD><D4B6>رմ򿪵<D5B4><F2BFAAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#define ACL_PASS_ON_EXEC 0
#define ACL_BLOCKING 0 /**< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>־λ */
#define ACL_NON_BLOCKING 1 /**< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>־λ */
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽ӿ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} SOCKET <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param on {int} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ACL_BLOCKING <EFBFBD><EFBFBD> ACL_NON_BLOCKING
2016-05-10 21:58:47 +08:00
* @return {int} >= 0: <EFBFBD>ɹ<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ > 0 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD>ı<EFBFBD>־λ; -1: ʧ<EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
ACL_API int acl_non_blocking(ACL_SOCKET fd, int on);
2015-01-14 23:35:23 +08:00
/**
* <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
* @param fd {ACL_SOCKET} SOCKET <EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @return {int} -1 <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>֧<EFBFBD>֣<EFBFBD>1 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
* 0 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
*/
ACL_API int acl_is_blocking(ACL_SOCKET fd);
2014-11-19 00:25:21 +08:00
/**
* д<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֿ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param timeout {int} <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD>
* > 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* == 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* < 0 : ʱ<EFBFBD><EFBFBD>ʾֱ<EFBFBD>Ӹ<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֿɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ
* @return {int} 0: <EFBFBD><EFBFBD>д; -1: ʧ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD>ʱ
*/
ACL_API int acl_write_wait(ACL_SOCKET fd, int timeout);
/**
* <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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param timeout {int} <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD>
* > 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* == 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* < 0 : ʱ<EFBFBD><EFBFBD>ʾֱ<EFBFBD>Ӹ<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֿɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ
* @return {int} 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><EFBFBD><EFBFBD>; -1: ʧ<EFBFBD>ܻ<EFBFBD><EFBFBD><EFBFBD>ʱ
*/
ACL_API int acl_read_wait(ACL_SOCKET fd, int timeout);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>
* @param delay {unsigned} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
*/
ACL_API void acl_doze(unsigned delay);
/**
* ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɶ<EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-12-07 23:48:11 +08:00
* @return {int} 0: <EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>
2014-11-19 00:25:21 +08:00
*/
ACL_API int acl_readable(ACL_SOCKET fd);
/**
* <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><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param len {unsigned} buf <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
* @param timeout {int} <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD>
* > 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* == 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* < 0 : ʱ<EFBFBD><EFBFBD>ʾֱ<EFBFBD>Ӹ<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֿɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ
* @return {int} > 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_timed_read(ACL_SOCKET fd, void *buf, unsigned len,
int timeout, void *unused_context);
/**
* <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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param len {unsigned} <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD>ȴ<EFBFBD>С
* @param timeout {int} <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD>
* > 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* == 0 : <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* < 0 : ʱ<EFBFBD><EFBFBD>ʾֱ<EFBFBD>Ӹ<EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD>ֿɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊֹ
* @return {int} > 0 <EFBFBD>ɹ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; -1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_timed_write(ACL_SOCKET fd, void *buf, unsigned len,
int timeout, void *unused_context);
/**
* <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><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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @param len {unsigned} <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD>ȴ<EFBFBD>С
* @param timeout {int} <EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD>
* @param {int} <EFBFBD>ɹ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_write_buf(ACL_SOCKET fd, const char *buf, int len, int timeout);
/**
* ̽<EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
* @param fd {ACL_SOCKET} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_peekfd(ACL_SOCKET fd);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD>
* @param fds {ACL_FILE_HANDLE [2]} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: ok; -1: error
*/
ACL_API int acl_pipe(ACL_FILE_HANDLE fds[2]);
/**
* <EFBFBD>رչܵ<EFBFBD><EFBFBD><EFBFBD>
* @param fds {ACL_FILE_HANDLE[2]} <EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD>
* @return {int} 0: ok; -1: error
*/
ACL_API int acl_pipe_close(ACL_FILE_HANDLE fds[2]);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD>
* @param fds {ACL_FILE_HANDLE[2]} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺܵ<EFBFBD><EFBFBD>Ե<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* @return 0: ok; -1: error
*/
ACL_API int acl_duplex_pipe(ACL_FILE_HANDLE fds[2]);
#ifdef ACL_UNIX
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> exec <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
* @param fd {int} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param on {int} ACL_CLOSE_ON_EXEC <EFBFBD><EFBFBD> 0
* @return {int} 0: ok; -1: error
*/
ACL_API int acl_close_on_exec(int fd, int on);
/**
* <EFBFBD><EFBFBD>ij<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><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param lowfd {int} <EFBFBD><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_closefrom(int lowfd);
/**
* <EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
* @param limit {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
* @return {int} >=0: ok; -1: error
*/
ACL_API int acl_open_limit(int limit);
/**
* <EFBFBD>жϸ<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD>
* @param fd {int} <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} != 0: <EFBFBD><EFBFBD>; 0: <EFBFBD><EFBFBD>
*/
ACL_API int acl_issock(int fd);
#endif
#ifdef __cplusplus
}
#endif
#endif