Example #1
0
File: odr_mem.c Project: nla/yaz
int odr_write(ODR o, unsigned char *buf, int bytes)
{
    if (o->pos + bytes >= o->size && odr_grow_block(o, bytes))
    {
        odr_seterror(o, OSPACE, 40);
        return -1;
    }
    memcpy(o->buf + o->pos, buf, bytes);
    o->pos += bytes;
    if (o->pos > o->top)
        o->top = o->pos;
    return 0;
}
Example #2
0
File: odr_mem.c Project: nla/yaz
int odr_seek(ODR o, int whence, int offset)
{
    if (whence == ODR_S_CUR)
        offset += o->pos;
    else if (whence == ODR_S_END)
        offset += o->top;
    if (offset > o->size && odr_grow_block(o, offset - o->size))
    {
        odr_seterror(o, OSPACE, 41);
        return -1;
    }
    o->pos = offset;
    return 0;
}
Example #3
0
int odr_write(ODR o, const char *buf, int bytes)
{
    if (bytes < 0 || o->op->pos > INT_MAX - bytes)
    {
        odr_seterror(o, OSPACE, 40);
        return -1;
    }
    if (o->op->pos + bytes >= o->op->size && odr_grow_block(o, bytes))
    {
        odr_seterror(o, OSPACE, 40);
        return -1;
    }
    memcpy(o->op->buf + o->op->pos, buf, bytes);
    o->op->pos += bytes;
    if (o->op->pos > o->op->top)
        o->op->top = o->op->pos;
    return 0;
}