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
gssize g_output_stream_write(GOutputStream* stream, const void* buffer,
                             gsize count, GCancellable* cancellable,
                             GError** error)
{
    GOutputStreamClass* class;
    gssize res;

    g_return_val_if_fail(G_IS_OUTPUT_STREAM(stream), -1);
    g_return_val_if_fail(buffer != NULL, 0);

    if (count == 0)
        return 0;

    if (((gssize)count) < 0)
    {
        g_set_error(error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                    _("Too large count value passed to %s"), G_STRFUNC);
        return -1;
    }

    class = G_OUTPUT_STREAM_GET_CLASS(stream);

    if (class->write_fn == NULL)
    {
        g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                            _("Output stream doesn’t implement write"));
        return -1;
    }

    if (!g_output_stream_set_pending(stream, error))
        return -1;

    if (cancellable)
        g_cancellable_push_current(cancellable);

    res = class->write_fn(stream, buffer, count, cancellable, error);

    if (cancellable)
        g_cancellable_pop_current(cancellable);

    g_output_stream_clear_pending(stream);

    return res;
}
/**
 * g_output_stream_write:
 * @stream: a #GOutputStream.
 * @buffer: (array length=count) (element-type guint8): the buffer containing
 *the data to write.
 * @count: the number of bytes to write
 * @cancellable: (nullable): optional cancellable object
 * @error: location to store the error occurring, or %NULL to ignore
 *
 * Tries to write @count bytes from @buffer into the stream. Will block
 * during the operation.
 *
 * If count is 0, returns 0 and does nothing. A value of @count
 * larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
 *
 * On success, the number of bytes written to the stream is returned.
 * It is not an error if this is not the same as the requested size, as it
 * can happen e.g. on a partial I/O error, or if there is not enough
 * storage in the stream. All writes block until at least one byte
 * is written or an error occurs; 0 is never returned (unless
 * @count is 0).
 *
 * If @cancellable is not %NULL, then the operation can be cancelled by
 * triggering the cancellable object from another thread. If the operation
 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
 * operation was partially finished when the operation was cancelled the
 * partial result will be returned, without an error.
 *
 * On error -1 is returned and @error is set accordingly.
 *
 * Virtual: write_fn
 *
 * Returns: Number of bytes written, or -1 on error
 **/


Tries to write @count bytes from @buffer into the stream. Will block
during the operation.

If count is 0, returns 0 and does nothing. A value of @count
larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.

On success, the number of bytes written to the stream is returned.
It is not an error if this is not the same as the requested size, as it
can happen e.g. on a partial I/O error, or if there is not enough
storage in the stream. All writes block until at least one byte
is written or an error occurs; 0 is never returned (unless
@count is 0).

If @cancellable is not %NULL, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
operation was partially finished when the operation was cancelled the
partial result will be returned, without an error.

On error -1 is returned and @error is set accordingly.



Number of bytes written, or -1 on error
Tries to write @count bytes from @buffer into the stream . Will block during the operation . If count is 0 returns 0 and does nothing . A value of @count larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error . On success the number of bytes written to the stream is returned . It is not an error if this is not the same as the requested size as it can happen e . g . on a partial I / O error or if there is not enough storage in the stream . All writes block until at least one byte is written or an error occurs ; 0 is never returned ( unless @count is 0 ) . If @cancellable is not %NULL then the operation can be cancelled by triggering the cancellable object from another thread . If the operation was cancelled the error %G_IO_ERROR_CANCELLED will be returned . If an operation was partially finished when the operation was cancelled the partial result will be returned without an error . On error - 1 is returned and @error is set accordingly . Number of bytes written or - 1 on error
gssize g_output_stream_write(GOutputStream* stream, const void* buffer,
                             gsize count, GCancellable* cancellable,
                             GError** error)
{
    GOutputStreamClass* class;
    gssize res;
    g_return_val_if_fail(G_IS_OUTPUT_STREAM(stream), -1);
    g_return_val_if_fail(buffer != NULL, 0);
    if (count == 0)
        return 0;
    if (((gssize)count) < 0)
    {
        g_set_error(error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                    _("Too large count value passed to %s"), G_STRFUNC);
        return -1;
    }
    class = G_OUTPUT_STREAM_GET_CLASS(stream);
    if (class->write_fn == NULL)
    {
        g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                            _("Output stream doesn’t implement write"));
        return -1;
    }
    if (!g_output_stream_set_pending(stream, error))
        return -1;
    if (cancellable)
        g_cancellable_push_current(cancellable);
    res = class->write_fn(stream, buffer, count, cancellable, error);
    if (cancellable)
        g_cancellable_pop_current(cancellable);
    g_output_stream_clear_pending(stream);
    return res;
}
gssize g_output_stream_write ( GOutputStream * stream , const void * buffer , gsize count , GCancellable * cancellable , GError * * error ) { GOutputStreamClass * class ; gssize res ; g_return_val_if_fail ( G_IS_OUTPUT_STREAM ( stream ) , -1 ) ; g_return_val_if_fail ( buffer != NULL , 0 ) ; if ( count == 0 ) return 0 ; if ( ( ( gssize ) count ) < 0 ) { g_set_error ( error , G_IO_ERROR , G_IO_ERROR_INVALID_ARGUMENT , _ ( " " ) , G_STRFUNC ) ; return -1 ; } class = G_OUTPUT_STREAM_GET_CLASS ( stream ) ; if ( class -> write_fn == NULL ) { g_set_error_literal ( error , G_IO_ERROR , G_IO_ERROR_NOT_SUPPORTED , _ ( " ) ; return -1 ; } if ( ! g_output_stream_set_pending ( stream , error ) ) return -1 ; if ( cancellable ) g_cancellable_push_current ( cancellable ) ; res = class -> write_fn ( stream , buffer , count , cancellable , error ) ; if ( cancellable ) g_cancellable_pop_current ( cancellable ) ; g_output_stream_clear_pending ( stream ) ; return res ; }
g_output_stream_write:
 @stream: a #GOutputStream.
g_output_stream_write : @stream : a #GOutputStream .