openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glib-2.0/1_2.60.3-r0/glib-2.60.3/gio/goutputstream.c
gboolean g_output_stream_writev_all(GOutputStream* stream,
                                    GOutputVector* vectors, gsize n_vectors,
                                    gsize* bytes_written,
                                    GCancellable* cancellable, GError** error)
{
    gsize _bytes_written = 0;
    gsize i, to_be_written = 0;

    if (bytes_written)
        *bytes_written = 0;

    g_return_val_if_fail(G_IS_OUTPUT_STREAM(stream), FALSE);
    g_return_val_if_fail(vectors != NULL || n_vectors == 0, FALSE);
    g_return_val_if_fail(cancellable == NULL || G_IS_CANCELLABLE(cancellable),
                         FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);

    /* We can't write more than G_MAXSIZE bytes overall, otherwise we
     * would overflow the bytes_written counter */
    for (i = 0; i < n_vectors; i++)
    {
        if (to_be_written > G_MAXSIZE - vectors[i].size)
        {
            g_set_error(error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                        _("Sum of vectors passed to %s too large"), G_STRFUNC);
            return FALSE;
        }
        to_be_written += vectors[i].size;
    }

    _bytes_written = 0;
    while (n_vectors > 0 && to_be_written > 0)
    {
        gsize n_written = 0;
        gboolean res;

        res = g_output_stream_writev(stream, vectors, n_vectors, &n_written,
                                     cancellable, error);

        if (!res)
        {
            if (bytes_written)
                *bytes_written = _bytes_written;
            return FALSE;
        }

        g_return_val_if_fail(n_written > 0, FALSE);
        _bytes_written += n_written;

        /* skip vectors that have been written in full */
        while (n_vectors > 0 && n_written >= vectors[0].size)
        {
            n_written -= vectors[0].size;
            ++vectors;
            --n_vectors;
        }
        /* skip partially written vector data */
        if (n_written > 0 && n_vectors > 0)
        {
            vectors[0].size -= n_written;
            vectors[0].buffer = ((guint8*)vectors[0].buffer) + n_written;
        }
    }

    if (bytes_written)
        *bytes_written = _bytes_written;

    return TRUE;
}
/**
 * g_output_stream_writev_all:
 * @stream: a #GOutputStream.
 * @vectors: (array length=n_vectors): the buffer containing the #GOutputVectors
 * to write.
 * @n_vectors: the number of vectors to write
 * @bytes_written: (out) (optional): location to store the number of bytes that
 * were written to the stream
 * @cancellable: (nullable): optional #GCancellable object, %NULL to ignore.
 * @error: location to store the error occurring, or %NULL to ignore
 *
 * Tries to write the bytes contained in the @n_vectors @vectors into the
 * stream. Will block during the operation.
 *
 * This function is similar to g_output_stream_writev(), except it tries to
 * write as many bytes as requested, only stopping on an error.
 *
 * On a successful write of all @n_vectors vectors, %TRUE is returned, and
 * @bytes_written is set to the sum of all the sizes of @vectors.
 *
 * If there is an error during the operation %FALSE is returned and @error
 * is set to indicate the error status.
 *
 * As a special exception to the normal conventions for functions that
 * use #GError, if this function returns %FALSE (and sets @error) then
 * @bytes_written will be set to the number of bytes that were
 * successfully written before the error was encountered.  This
 * functionality is only available from C. If you need it from another
 * language then you must write your own loop around
 * g_output_stream_write().
 *
 * The content of the individual elements of @vectors might be changed by this
 * function.
 *
 * Returns: %TRUE on success, %FALSE if there was an error
 *
 * Since: 2.60
 */


Tries to write the bytes contained in the @n_vectors @vectors into the
stream. Will block during the operation.

This function is similar to g_output_stream_writev(), except it tries to
write as many bytes as requested, only stopping on an error.

On a successful write of all @n_vectors vectors, %TRUE is returned, and
@bytes_written is set to the sum of all the sizes of @vectors.

If there is an error during the operation %FALSE is returned and @error
is set to indicate the error status.

As a special exception to the normal conventions for functions that
use #GError, if this function returns %FALSE (and sets @error) then
@bytes_written will be set to the number of bytes that were
successfully written before the error was encountered.  This
functionality is only available from C. If you need it from another
language then you must write your own loop around
g_output_stream_write().

The content of the individual elements of @vectors might be changed by this
function.

%TRUE on success, %FALSE if there was an error


Tries to write the bytes contained in the @n_vectors @vectors into the stream . Will block during the operation . This function is similar to g_output_stream_writev () except it tries to write as many bytes as requested only stopping on an error . On a successful write of all @n_vectors vectors %TRUE is returned and @bytes_written is set to the sum of all the sizes of @vectors . If there is an error during the operation %FALSE is returned and @error is set to indicate the error status . As a special exception to the normal conventions for functions that use #GError if this function returns %FALSE ( and sets @error ) then @bytes_written will be set to the number of bytes that were successfully written before the error was encountered . This functionality is only available from C . If you need it from another language then you must write your own loop around g_output_stream_write () . The content of the individual elements of @vectors might be changed by this function . %TRUE on success %FALSE if there was an error
gboolean g_output_stream_writev_all(GOutputStream* stream,
                                    GOutputVector* vectors, gsize n_vectors,
                                    gsize* bytes_written,
                                    GCancellable* cancellable, GError** error)
{
    gsize _bytes_written = 0;
    gsize i, to_be_written = 0;
    if (bytes_written)
        *bytes_written = 0;
    g_return_val_if_fail(G_IS_OUTPUT_STREAM(stream), FALSE);
    g_return_val_if_fail(vectors != NULL || n_vectors == 0, FALSE);
    g_return_val_if_fail(cancellable == NULL || G_IS_CANCELLABLE(cancellable),
                         FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    for (i = 0; i < n_vectors; i++)
    {
        if (to_be_written > G_MAXSIZE - vectors[i].size)
        {
            g_set_error(error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                        _("Sum of vectors passed to %s too large"), G_STRFUNC);
            return FALSE;
        }
        to_be_written += vectors[i].size;
    }
    _bytes_written = 0;
    while (n_vectors > 0 && to_be_written > 0)
    {
        gsize n_written = 0;
        gboolean res;
        res = g_output_stream_writev(stream, vectors, n_vectors, &n_written,
                                     cancellable, error);
        if (!res)
        {
            if (bytes_written)
                *bytes_written = _bytes_written;
            return FALSE;
        }
        g_return_val_if_fail(n_written > 0, FALSE);
        _bytes_written += n_written;
        while (n_vectors > 0 && n_written >= vectors[0].size)
        {
            n_written -= vectors[0].size;
            ++vectors;
            --n_vectors;
        }
        if (n_written > 0 && n_vectors > 0)
        {
            vectors[0].size -= n_written;
            vectors[0].buffer = ((guint8*)vectors[0].buffer) + n_written;
        }
    }
    if (bytes_written)
        *bytes_written = _bytes_written;
    return TRUE;
}
gboolean g_output_stream_writev_all ( GOutputStream * stream , GOutputVector * vectors , gsize n_vectors , gsize * bytes_written , GCancellable * cancellable , GError * * error ) { gsize _bytes_written = 0 ; gsize i , to_be_written = 0 ; if ( bytes_written ) * bytes_written = 0 ; g_return_val_if_fail ( G_IS_OUTPUT_STREAM ( stream ) , FALSE ) ; g_return_val_if_fail ( vectors != NULL || n_vectors == 0 , FALSE ) ; g_return_val_if_fail ( cancellable == NULL || G_IS_CANCELLABLE ( cancellable ) , FALSE ) ; g_return_val_if_fail ( error == NULL || * error == NULL , FALSE ) ; for ( i = 0 ; i < n_vectors ; i ++ ) { if ( to_be_written > G_MAXSIZE - vectors [ i ] . size ) { g_set_error ( error , G_IO_ERROR , G_IO_ERROR_INVALID_ARGUMENT , _ ( " " ) , G_STRFUNC ) ; return FALSE ; } to_be_written += vectors [ i ] . size ; } _bytes_written = 0 ; while ( n_vectors > 0 && to_be_written > 0 ) { gsize n_written = 0 ; gboolean res ; res = g_output_stream_writev ( stream , vectors , n_vectors , & n_written , cancellable , error ) ; if ( ! res ) { if ( bytes_written ) * bytes_written = _bytes_written ; return FALSE ; } g_return_val_if_fail ( n_written > 0 , FALSE ) ; _bytes_written += n_written ; while ( n_vectors > 0 && n_written >= vectors [ 0 ] . size ) { n_written -= vectors [ 0 ] . size ; ++ vectors ; -- n_vectors ; } if ( n_written > 0 && n_vectors > 0 ) { vectors [ 0 ] . size -= n_written ; vectors [ 0 ] . buffer = ( ( guint8 * ) vectors [ 0 ] . buffer ) + n_written ; } } if ( bytes_written ) * bytes_written = _bytes_written ; return TRUE ; }
g_output_stream_writev_all:
 @stream: a #GOutputStream.
g_output_stream_writev_all : @stream : a #GOutputStream .
/* We can't write more than G_MAXSIZE bytes overall, otherwise we
     * would overflow the bytes_written counter */ /* skip vectors that have been written in full */ /* skip partially written vector data */