Logo Search packages:      
Sourcecode: librasterlite version File versions  Download package

local int terminate_header ( unsigned char *  buf,
int  buf_size,
int  n_fields 
)

Terminate block header

This function replaces n_fields -th occurence of ; symbol with 0. In other words, this function zero-terminates header.

Parameters:
bufData buffer
buf_sizeBuffer size
n_fieldsNumber of header fields
Returns:
Either EPS_OK or EPS_FORMAT_ERROR

Definition at line 132 of file libmain.c.

References EPS_FORMAT_ERROR, and EPS_OK.

Referenced by eps_read_block_header(), read_gs_header(), and read_tc_header().

{
    int field, i;

    /* Report an error if data contains at least one zero byte */
    for (i = 0; i < buf_size; i++) {
        if (!buf[i]) {
            return EPS_FORMAT_ERROR;
        }
    }

    /* Find n-th occurence of ';' symbol and replace it with zero */
    for (i = 0, field = 1; i < buf_size; i++) {
        if (buf[i] == ';') {
            if (field == n_fields) {
                buf[i] = 0;
                return EPS_OK;
            }

            field++;
        }
    }

    return EPS_FORMAT_ERROR;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index