eyBuildLib API Reference : eyBuildLib
ebbuff - a high efficiency I/O buffer for CSP
ebBufTlvAdd( ) - add data to tlv buffer
ebBufReset( ) - reset the state to initialization state
ebBufCreate( ) - allocate a new tlv buffer then init it
ebBufDistroy( ) - free eybuild buffer
ebBufResize( ) - change tlv buffer size to new size
ebBufIsAutoFlush( ) - check allow auto flush or not
ebSetBufAutoFlush( ) - set allow auto flush or not
ebSetBufDeflat( ) - set allow gzip compress output or not
ebGetBufRemain( ) - get the remain size for data write to avaiable
ebBufFlush( ) - flush eybuild buffer
ebBufIsFlushed( ) - check buffer ever flushed or not
ebCheckBufSize( ) - check tlv buffer size
ebBufStringAdd( ) - add a const string to the eybuild buffer
ebprintf( ) - write a formatted string to the eybuild buffer
ebvprintf( ) - write a formatted string to the eybuild buffer
ebWriteBlock( ) - write binary data block
ebfwrite( ) - write binary data block into stream
This module provided a high efficiency I/O buffer. It will be used by CSP page to buffering data, which is outputed by ebprintf( ), ebEvaluate( ) ebBufStringAdd( ).
User can call ebBufIsAutoFlush( ), ebGetBufRemain( ), ebCheckBufSize( ) to get current buffer properties; User can call ebBufResize( ), ebSetBufAutoFlush( ), ebBufFlush( ), ebBufReset( ) to set buffer properties; User can call ebprintf( ), ebBufStringAdd( ), ebEvaluate( ) add data to buffer.
When you call ebHeader( ), ebRedirect( ), it will check the buffer state. If has data flushed before, they will return ERROR. Because those data should be output before CSP page data output.
Usually user needn't call ebBufCreate( ), ebBufDistroy( ) to create and distory a CSP page buffer.
ebbuff.h
snprintf( )
ebBufTlvAdd( ) - add data to tlv buffer
int ebBufTlvAdd ( void * ebfp, int type, int len, const char * pdata )
this routine will add data to tlv buffer and let current tlv pointer pointer to next tlv. Before call it, you should call ebCheckBufSize( ) to check the buffer size if longer enough.
OK/ERROR
ebBufReset( ) - reset the state to initialization state
int ebBufReset ( void * ebfp )
OK/ERROR
ebBufCreate( ) - allocate a new tlv buffer then init it
void * ebBufCreate ( int size )
the descriptor of new this new buffer, or NULL if error
ebBufDistroy( ) - free eybuild buffer
void ebBufDistroy ( void * ebfp )
this routine will not auto flush data in buffer, so before call function you shoud call ebBufFlush( ) manually to flush data.
NONE
ebBufResize( ) - change tlv buffer size to new size
int ebBufResize ( void * ebfp, int size )
this routine will not flush the original data, but copy to the new buffer if no enough dynamic memory will return ERROR
OK/ERROR
ebBufIsAutoFlush( ) - check allow auto flush or not
int ebBufIsAutoFlush ( void * ebfp )
TRUE/FALSE
ebSetBufAutoFlush( ) - set allow auto flush or not
int ebSetBufAutoFlush ( void * ebfp, /* eybuild buffer descriptor */ BOOL autoflush )
set allow auto flush or not
TRUE/FALSE
ebSetBufDeflat( ) - set allow gzip compress output or not
int ebSetBufDeflat ( void * ebfp, /* eybuild buffer descriptor */ BOOL blcompr )
set allow gzip compress output or not
TRUE/FALSE
ebGetBufRemain( ) - get the remain size for data write to avaiable
int ebGetBufRemain ( void * ebfp )
get the remain size for data write to avaiable
the size write avaiable, or <= 0 if buffer size not enough
ebBufFlush( ) - flush eybuild buffer
int ebBufFlush ( void * ebfp )
This routine writes data in eybuild buffer to stdout
OK/ERROR
ebBufIsFlushed( ) - check buffer ever flushed or not
BOOL ebBufIsFlushed ( void * ebfp )
TRUE/FALSE
ebCheckBufSize( ) - check tlv buffer size
int ebCheckBufSize ( void * ebfp )
if buffer is full, it will try to flush it and the retry check once
size avaiable write to, or ERROR when flush buffer error
ebBufStringAdd( ) - add a const string to the eybuild buffer
int ebBufStringAdd ( void * ebfp, /* eybuild buffer descriptor */ const char * pstr /* const string */ )
this routine let the value pointer of tlv pointer to that const string, but will not free it if is allocated by malloc( ), alloc( ), realloc( ), so the area parameter pstr pointer to should better be a const string.
After call ebBufFlush( ), that tlv will be set to zero.
OK/ERROR
ebprintf( ) - write a formatted string to the eybuild buffer
int ebprintf ( void * ebfp, /* eybuild buffer descriptor */ const char * fmt, /* format string to write */ ... /* optional arguments to format string */ )
This routine writes a formatted string to a specified file descriptor. Its function and syntax are otherwise identical to printf( ).
The number of characters output, or ERROR if there is an error during output.
ebbuff, printf( ), fprintf( )
ebvprintf( ) - write a formatted string to the eybuild buffer
int ebvprintf ( void * ebfp, /* eybuild buffer descriptor */ const char * fmt, /* format string to write */ va_list ar /* optional arguments to format string */ )
ebbuff, printf( ), fprintf( )
ebWriteBlock( ) - write binary data block
int ebWriteBlock ( void * ebfp, /* eybuild buffer descriptor */ void * data, /* data block */ size_t size )
This routine is to writes a write binary data block, it will force flush current buffer before write data.
block data will not be buffered by ebio buffer.
The number data output, or ERROR if output failure.
ebfwrite( ) - write binary data block into stream
int ebfwrite ( void * data, /* data block */ size_t size, /* size of data block */ size_t count, /* count of block */ void * ebfp /* eybuild buffer descriptor */ )
This routine is to write binary data block into stream, if compress output reqired, this routine will output compress data stream to stdout.
The number data output, or ERROR if output failure.
ebbuff, ebWriteBlock( )