eyBuildLib API Reference : eyBuildLib

ebbuff

NAME

ebbuff - a high efficiency I/O buffer for CSP

ROUTINES

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

DESCRIPTION

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.

INCLUDE

ebbuff.h

ALSO SEE

snprintf( )


eyBuildLib : Routines

ebBufTlvAdd( )

NAME

ebBufTlvAdd( ) - add data to tlv buffer

SYNOPSIS

int ebBufTlvAdd
    (
    void *       ebfp,
    int          type,
    int          len,
    const char * pdata
    )

DESCRIPTION

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.

RETURNS

OK/ERROR

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufReset( )

NAME

ebBufReset( ) - reset the state to initialization state

SYNOPSIS

int ebBufReset
    (
    void * ebfp
    )

DESCRIPTION

RETURNS

OK/ERROR

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufCreate( )

NAME

ebBufCreate( ) - allocate a new tlv buffer then init it

SYNOPSIS

void * ebBufCreate
    (
    int size
    )

DESCRIPTION

RETURNS

the descriptor of new this new buffer, or NULL if error

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufDistroy( )

NAME

ebBufDistroy( ) - free eybuild buffer

SYNOPSIS

void ebBufDistroy
    (
    void * ebfp
    )

DESCRIPTION

this routine will not auto flush data in buffer, so before call function you shoud call ebBufFlush( ) manually to flush data.

RETURNS

NONE

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufResize( )

NAME

ebBufResize( ) - change tlv buffer size to new size

SYNOPSIS

int ebBufResize
    (
    void * ebfp,
    int    size
    )

DESCRIPTION

this routine will not flush the original data, but copy to the new buffer if no enough dynamic memory will return ERROR

RETURNS

OK/ERROR

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufIsAutoFlush( )

NAME

ebBufIsAutoFlush( ) - check allow auto flush or not

SYNOPSIS

int ebBufIsAutoFlush
    (
    void * ebfp
    )

DESCRIPTION

RETURNS

TRUE/FALSE

SEE ALSO

ebbuff


eyBuildLib : Routines

ebSetBufAutoFlush( )

NAME

ebSetBufAutoFlush( ) - set allow auto flush or not

SYNOPSIS

int ebSetBufAutoFlush
    (
    void * ebfp,              /* eybuild buffer descriptor */
    BOOL   autoflush
    )

DESCRIPTION

set allow auto flush or not

RETURNS

TRUE/FALSE

SEE ALSO

ebbuff


eyBuildLib : Routines

ebSetBufDeflat( )

NAME

ebSetBufDeflat( ) - set allow gzip compress output or not

SYNOPSIS

int ebSetBufDeflat
    (
    void * ebfp,              /* eybuild buffer descriptor */
    BOOL   blcompr
    )

DESCRIPTION

set allow gzip compress output or not

RETURNS

TRUE/FALSE

SEE ALSO

ebbuff


eyBuildLib : Routines

ebGetBufRemain( )

NAME

ebGetBufRemain( ) - get the remain size for data write to avaiable

SYNOPSIS

int ebGetBufRemain
    (
    void * ebfp
    )

DESCRIPTION

get the remain size for data write to avaiable

RETURNS

the size write avaiable, or <= 0 if buffer size not enough

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufFlush( )

NAME

ebBufFlush( ) - flush eybuild buffer

SYNOPSIS

int ebBufFlush
    (
    void * ebfp
    )

DESCRIPTION

This routine writes data in eybuild buffer to stdout

RETURNS

OK/ERROR

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufIsFlushed( )

NAME

ebBufIsFlushed( ) - check buffer ever flushed or not

SYNOPSIS

BOOL ebBufIsFlushed
    (
    void * ebfp
    )

DESCRIPTION

RETURNS

TRUE/FALSE

SEE ALSO

ebbuff


eyBuildLib : Routines

ebCheckBufSize( )

NAME

ebCheckBufSize( ) - check tlv buffer size

SYNOPSIS

int ebCheckBufSize
    (
    void * ebfp
    )

DESCRIPTION

if buffer is full, it will try to flush it and the retry check once

RETURNS

size avaiable write to, or ERROR when flush buffer error

SEE ALSO

ebbuff


eyBuildLib : Routines

ebBufStringAdd( )

NAME

ebBufStringAdd( ) - add a const string to the eybuild buffer

SYNOPSIS

int ebBufStringAdd
    (
    void *       ebfp,        /* eybuild buffer descriptor */
    const char * pstr         /* const string */
    )

DESCRIPTION

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.

RETURNS

OK/ERROR

SEE ALSO

ebbuff


eyBuildLib : Routines

ebprintf( )

NAME

ebprintf( ) - write a formatted string to the eybuild buffer

SYNOPSIS

int ebprintf
    (
    void *       ebfp,        /* eybuild buffer descriptor */
    const char * fmt,         /* format string to write */
                 ...          /* optional arguments to format string */
    )

DESCRIPTION

This routine writes a formatted string to a specified file descriptor. Its function and syntax are otherwise identical to printf( ).

RETURNS

The number of characters output, or ERROR if there is an error during output.

SEE ALSO

ebbuff, printf( ), fprintf( )


eyBuildLib : Routines

ebvprintf( )

NAME

ebvprintf( ) - write a formatted string to the eybuild buffer

SYNOPSIS

int ebvprintf
    (
    void *       ebfp,        /* eybuild buffer descriptor */
    const char * fmt,         /* format string to write */
    va_list      ar           /* optional arguments to format string */
    )

DESCRIPTION

SEE ALSO

ebbuff, printf( ), fprintf( )


eyBuildLib : Routines

ebWriteBlock( )

NAME

ebWriteBlock( ) - write binary data block

SYNOPSIS

int ebWriteBlock
    (
    void * ebfp,              /* eybuild buffer descriptor */
    void * data,              /* data block */
    size_t size
    )

DESCRIPTION

This routine is to writes a write binary data block, it will force flush current buffer before write data.

NOTE

block data will not be buffered by ebio buffer.

RETURNS

The number data output, or ERROR if output failure.

SEE ALSO

ebbuff, ebprintf( )


eyBuildLib : Routines

ebfwrite( )

NAME

ebfwrite( ) - write binary data block into stream

SYNOPSIS

int ebfwrite
    (
    void * data,              /* data block */
    size_t size,              /* size of data block */
    size_t count,             /* count of block */
    void * ebfp               /* eybuild buffer descriptor */
    )

DESCRIPTION

This routine is to write binary data block into stream, if compress output reqired, this routine will output compress data stream to stdout.

RETURNS

The number data output, or ERROR if output failure.

SEE ALSO

ebbuff, ebWriteBlock( )