src/lib/ppc405lib/string_stream.c
// Write as much data as possible to a circular buffer.  Return -EAGAIN if the
// buffer would overflow.
Write as much data as possible to a circular buffer.  Return -EAGAIN if the
buffer would overflow.
Write as much data as possible to a circular buffer . Return - EAGAIN if the buffer would overflow .
static int
circular_swrite(FILE* stream, const void* buf, size_t size, size_t* written)
{
    StringStream *string = (StringStream *)stream;
    size_t wrote;
    int rc;
    if (string->flags & STRING_STREAM_FULL) {
        wrote = 0;
    } else {
        wrote = write_tail(string, buf, size);
        if (wrote != size) {
            wrote += write_head(string, buf + wrote, size - wrote);
        }
    }
    if ((wrote != 0) && (string->next_read == string->next_write)) {
        string->flags |= STRING_STREAM_FULL;
    }
    *written = wrote;
    if (wrote < size) {
        rc = -EAGAIN;
    } else {
        rc = 0;
    }
    return rc;
}
static int circular_swrite ( FILE * stream , const void * buf , size_t size , size_t * written ) { StringStream * string = ( StringStream * ) stream ; size_t wrote ; int rc ; if ( string -> flags & STRING_STREAM_FULL ) { wrote = 0 ; } else { wrote = write_tail ( string , buf , size ) ; if ( wrote != size ) { wrote += write_head ( string , buf + wrote , size - wrote ) ; } } if ( ( wrote != 0 ) && ( string -> next_read == string -> next_write ) ) { string -> flags |= STRING_STREAM_FULL ; } * written = wrote ; if ( wrote < size ) { rc = - EAGAIN ; } else { rc = 0 ; } return rc ; }
Write as much data as possible to a circular buffer.
Write as much data as possible to a circular buffer .