Buff.h

xiaoxiao2021-04-03  223

#ifdef __cplusplusextern "c" {#ENDIF

#ifdef B_SFIO -------------------- This macro is defined unknown #include "sfio.h" #ENDIF

#include

/ * Reading is buffered * / # define b_rd (1) / * Writing is buffered * / # define b_wr (2) #define b_rdwr (3) / * at end of file, or close, stream; no further input limited * / # Define B_EOF (4) / * no further output possible * / # define b_eout (8) / * a read error HAS Occurred * / # define b_rderr (16) / * a write error HAS Occurred * / # define b_wrerr (32) # IFDEF B_ERROR / * IN SVR4: Sometimes Defined In /USR/include/sys/buf.h * / # undef B_ERROR # ENDIF # define b_error (48) / * Use chunked Writing * / # define b_chunk (64) / * bflush ( ) if a read would block * / # define B_SAFEREAD (128) / * buffer is a socket * / # define B_SOCKET (256) #ifdef CHARSET_EBCDIC # define B_ASCII2EBCDIC 0x40000000 / * Enable conversion for this buffer * / # define B_EBCDIC2ASCII 0x80000000 / * Enable conversion for this buffer * / # Endif / * charset_ebcdic * /

Typedef struct buff_struct buff;

struct buff_struct {int flags; / * flags * / unsigned char * inptr; / * pointer to next location to read * / int incnt; / * number of bytes left to read from input buffer; * always 0 if had a read error * / int outchunk; / * location of chunk header when chunking * / int outcnt; / * number of byte put in output buffer * / unsigned char * inbase; unsigned char * outbase; int bufsiz; void (* error) (BUFF * fb , INT OP, VOID * DATA); void * error_data; long int Bytes_sent; / * number of bytes actually write * /

AP_POOL * POOL;

/ * Could Also Putines Here * / Int fd; / * The file descriptor * / int fd_in; / * input file descriptor, if Different * / # ifdef Win32 Handle Hfh; / * Windows FileHandle * / # Endif / * Transport Handle, for rpc binding handle or some such * / void * t_handle;

#ifdef B_SFIO SFIO_T * SF_IN; SFIO_T * SF_OUT; #ENDIF};

#ifdef b_sfiotypedef struct {sfdisc_t disc; buff * buff;} apache_sfio;

Extern sfdisc_t * bsfio_new (pool * p, buff * b); # Endif

/ * Options to bset / getopt * / # define bo_Bytect (1)

/ * Stream creation and modification * / API_EXPORT (BUFF *) ap_bcreate (pool * p, int flags); API_EXPORT (void) ap_bpushfd (BUFF * fb, int fd_in, int fd_out); # ifdef WIN32API_EXPORT (void) ap_bpushh (BUFF * fb, HANDLE hFH); # endifAPI_EXPORT (int) ap_bsetopt (BUFF * fb, int optname, const void * optval); API_EXPORT (int) ap_bgetopt (BUFF * fb, int optname, void * optval); API_EXPORT (int) ap_bsetflag ( BUFF * FB, INT flag, int value; API_EXPORT (int) ap_bclose (buff * fb);

#define ap_bgetflag (FB, FLAG) ((FB) -> Flags & (FLAG))

/ * Error Handling * / API_EXPORT (VOID) AP_BONERROR (Buff * FB, Void (* Error) (buff *, int, void *), void * data);

/ * I / o * / api_export (int) ap_bread (buff * fb, void * buf, int nbyte); API_EXPORT (int) ap_bgets (char * s, int N, buff * fb); API_EXPORT (INT) AP_BLOOKC (charr) * buff, BUFF * fb); API_EXPORT (int) ap_bskiplf (BUFF * fb); API_EXPORT (int) ap_bwrite (BUFF * fb, const void * buf, int nbyte); API_EXPORT (int) ap_bflush (BUFF * fb); API_EXPORT (int) ap_bputs (const char * x, buff * fb); API_EXPORT (int) ap_bvputs (buff * fb, ...); api_export_nonstd (int) ap_bprintf (buff * fb, const char * fmt, ...) __ATTRIBUTE__ (Format (Printf, 2, 3)); API_EXPORT (INT) AP_VBPRINTF (Buff * FB, Const Char * FMT, VA_LIST VLIST);

/ * INTERNAL ROUTINES * / API_EXPORT (INT) AP_BFLSBUF (INT C, BUFF * FB); API_EXPORT (INT) AP_BFILBUF (Buff * FB); # iFNDef Charset_EBCDIC -------------------------------- ------ What definition and meaning unknown

#define ap_bgetc ((fb) ((fb) -> incnt == 0)? AP_BFILBUF (FB): / ((fb) -> Incnt--, * ((fb) -> inptr ))))))

#define ap_bputc (((((((fb) -> flags & (b_eout | b_wrerr | b_wr))! = b_wr || / (fb) -> OUTCNT == (FB) -> bufsiz)? AP_BFLSBUF C, (fb)): / ((fb) -> OUTBASE [(FB) -> OUTCNT ] = (c), 0))

#ELSE / * charset_ebcdic * /

#define ap_bgetc ((fb) -> incnt == 0)? AP_BFILBUF (FB): / ((fb) -> incnt -, (fb-> flags & b_ascii2ebcdic) /? os_toebcdic [(unsigned char ) * ((fb) -> INPTR )]: * ((fb) -> inptr )))))))))

#define ap_bputc (((((((fb) -> flags & (b_eout | b_wrerr | b_wr))! = b_wr || / (fb) -> OUTCNT == (FB) -> bufsiz)? AP_BFLSBUF C, (FB)): / ((fb) -> OUTBASE [(FB) -> OUTCNT ] = (fb-> flags & b_ebcdic2ascii) /? OS_TOASCII [(unsigned char) C] :( c), 0))

#endif / * CHARSET_EBCDIC * / struct child_info {#ifdef WIN32 / * * These handles are used by ap_call_exec to call * create process with pipe handles * / HANDLE hPipeInputRead;. HANDLE hPipeOutputWrite; HANDLE hPipeErrorWrite; #else / * * We need to put a dummy member in here to avoid compilation * errors under certain Unix compilers, like SGI's and HPUX's, * which fail to compile a zero-sized struct. Of course * it would be much nicer if there was actually a use for this * structure Under unix. Aah the JOYS OF X-Platform Code. * / Int Dummy; #ENDIF}; API_EXPORT (INT) AP_BSPAWN_CHILD (POOL *, INT (*) (Void *, Child_INFO *), VOID *, ENUM KILL_CONDITIONS, BUFF * * PIPE_IN, BUFF ** PIPE_OUT, BUFF ** PIPE_ERR); / * Enable non-blocking operations * / api_export (int) ap_bnonblock (buff * fb, int direction); / * and get an fd to select () on * / API_EXPORT (int) ap_bfileno (buff * fb, int direction);

/ * bflush () if a read count 10 n '@ eXport (void) ap_bhalfduplex (buff * fb);

#ifdef __cplusplus} #ENDIF

This file is mainly based on memory management, and the file read cache structure and API interface of the Apache application layer are defined based on memory management.

转载请注明原文地址:https://www.9cbs.com/read-131479.html

New Post(0)