src/lib/ppc405lib/string_stream.c
// Read as much data as possible from a circular buffer.  Return -EAGAIN if the
// buffer would underflow.
Read as much data as possible from a circular buffer.  Return -EAGAIN if the
buffer would underflow.
Read as much data as possible from a circular buffer . Return - EAGAIN if the buffer would underflow .
static int
string_stream_sread(FILE* stream, void* buf, size_t size, size_t* read)
{
    StringStream *string = (StringStream *)stream;
    size_t were_read;
    int rc;
    if ((string->next_read == string->next_write) &&
        !(string->flags & STRING_STREAM_FULL)) {
        were_read = 0;
    } else {
        were_read = read_tail(string, buf, size);
        if (were_read != size) {
            were_read += read_head(string, buf + were_read, size - were_read);
        }
    }
    if (were_read != 0) {
        string->flags &= ~STRING_STREAM_FULL;
    }
    *read = were_read;
    if (were_read < size) {
        rc = -EAGAIN;
    } else {
        rc = 0;
    }
    return rc;
}
static int string_stream_sread ( FILE * stream , void * buf , size_t size , size_t * read ) { StringStream * string = ( StringStream * ) stream ; size_t were_read ; int rc ; if ( ( string -> next_read == string -> next_write ) && ! ( string -> flags & STRING_STREAM_FULL ) ) { were_read = 0 ; } else { were_read = read_tail ( string , buf , size ) ; if ( were_read != size ) { were_read += read_head ( string , buf + were_read , size - were_read ) ; } } if ( were_read != 0 ) { string -> flags &= ~ STRING_STREAM_FULL ; } * read = were_read ; if ( were_read < size ) { rc = - EAGAIN ; } else { rc = 0 ; } return rc ; }
Read as much data as possible from a circular buffer.
Read as much data as possible from a circular buffer .