Logo Search packages:      
Sourcecode: inkscape version File versions

enum CRStatus cr_input_seek_index ( CRInput a_this,
enum CRSeekPos  a_origin,
gint  a_pos 
)

Sets the "current byte index" of the current instance of CRInput. Next call to cr_input_get_byte() will return the byte next after the new "current byte index".

Parameters:
a_this the current instance of CRInput.
a_origin the origin to consider during the calculation of the absolute position of the new "current byte index".
a_pos the relative offset of the new "current byte index." This offset is relative to the origin a_origin.
Returns:
CR_OK upon successful completion otherwise returns
  • CR_BAD_PARAM_ERROR if at least one of the parameters is not valid
  • CR_OUT_BOUNDS_ERROR

Definition at line 881 of file cr-input.c.

{

        glong abs_offset = 0;

        g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR);

        switch (a_origin) {

        case CR_SEEK_CUR:
                abs_offset = PRIVATE (a_this)->next_byte_index - 1 + a_pos;
                break;

        case CR_SEEK_BEGIN:
                abs_offset = a_pos;
                break;

        case CR_SEEK_END:
                abs_offset = PRIVATE (a_this)->in_buf_size - 1 - a_pos;
                break;

        default:
                return CR_BAD_PARAM_ERROR;
        }

        if ((abs_offset > 0)
            && (gulong) abs_offset < PRIVATE (a_this)->nb_bytes) {

                /*update the input stream's internal state */
                PRIVATE (a_this)->next_byte_index = abs_offset + 1;

                return CR_OK;
        }

        return CR_OUT_OF_BOUNDS_ERROR;
}


Generated by  Doxygen 1.6.0   Back to index