| Libvirt-gobject Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Properties | ||||
struct GVirStream; struct GVirStreamClass; enum GVirStreamIOCondition; gboolean (*GVirStreamIOFunc) (GVirStream *stream,GVirStreamIOCondition cond,gpointer opaque); gint (*GVirStreamSinkFunc) (GVirStream *stream,const gchar *buf,gsize nbytes,gpointer user_data); gint (*GVirStreamSourceFunc) (GVirStream *stream,gchar *buf,gsize nbytes,gpointer user_data); guint gvir_stream_add_watch (GVirStream *stream,GVirStreamIOCondition cond,GVirStreamIOFunc func,gpointer opaque); guint gvir_stream_add_watch_full (GVirStream *stream,gint priority,GVirStreamIOCondition cond,GVirStreamIOFunc func,gpointer opaque,GDestroyNotify notify); gssize gvir_stream_receive (GVirStream *stream,gchar *buffer,gsize size,GCancellable *cancellable,GError **error); gssize gvir_stream_receive_all (GVirStream *stream,GCancellable *cancellable,GVirStreamSinkFunc func,gpointer user_data,GError **error); gssize gvir_stream_send (GVirStream *stream,const gchar *buffer,gsize size,GCancellable *cancellable,GError **error); gssize gvir_stream_send_all (GVirStream *stream,GCancellable *cancellable,GVirStreamSourceFunc func,gpointer user_data,GError **error);
struct GVirStreamClass {
GIOStreamClass parent_class;
gpointer padding[20];
};
typedef enum {
GVIR_STREAM_IO_CONDITION_READABLE = (1 << 0),
GVIR_STREAM_IO_CONDITION_WRITABLE = (1 << 1),
GVIR_STREAM_IO_CONDITION_HANGUP = (1 << 2),
GVIR_STREAM_IO_CONDITION_ERROR = (1 << 3),
} GVirStreamIOCondition;
gboolean (*GVirStreamIOFunc) (GVirStream *stream,GVirStreamIOCondition cond,gpointer opaque);
gint (*GVirStreamSinkFunc) (GVirStream *stream,const gchar *buf,gsize nbytes,gpointer user_data);
|
a GVirStream |
|
data pointer. [out][array length=nbytes][transfer none] |
|
data size |
|
user data passed to the function |
Returns : |
the number of bytes filled, 0 upon end of file, or -1 upon error |
gint (*GVirStreamSourceFunc) (GVirStream *stream,gchar *buf,gsize nbytes,gpointer user_data);
|
a GVirStream |
|
data pointer. [out][array length=nbytes][transfer none] |
|
data size |
|
user data passed to the function |
Returns : |
the number of bytes filled, 0 upon end of file, or -1 upon error |
guint gvir_stream_add_watch (GVirStream *stream,GVirStreamIOCondition cond,GVirStreamIOFunc func,gpointer opaque);
Adds a watch for stream to the mainloop
|
the stream |
|
the conditions to watch for (bitfield of GVirStreamIOCondition) |
|
the function to call when the condition is satisfied. [closure opaque] |
|
user data to pass to func. [closure]
|
Returns : |
the event source id |
guint gvir_stream_add_watch_full (GVirStream *stream,gint priority,GVirStreamIOCondition cond,GVirStreamIOFunc func,gpointer opaque,GDestroyNotify notify);
Adds a watch for stream to the mainloop
|
the stream |
|
the priority of the GVirStream source |
|
the conditions to watch for (bitfield of GVirStreamIOCondition) |
|
the function to call when the condition is satisfied. [closure opaque] |
|
user data to pass to func. [closure]
|
|
the function to call when the source is removed |
Returns : |
the event source id Rename to: gvir_stream_add_watch |
gssize gvir_stream_receive (GVirStream *stream,gchar *buffer,gsize size,GCancellable *cancellable,GError **error);
Receive data (up to size bytes) from a stream.
On error -1 is returned and error is set accordingly.
gvir_stream_receive() can return any number of bytes, up to
size. If more than size bytes have been received, the additional
data will be returned in future calls to gvir_stream_receive().
If there is no data available, a G_IO_ERROR_WOULD_BLOCK error will be
returned.
|
the stream |
|
a buffer to read data into (which should be at least size
bytes long). |
|
the number of bytes you want to read from the stream |
|
a GCancellable or NULL. [allow-none]
|
|
GError for error reporting, or NULL to ignore. |
Returns : |
Number of bytes read, or 0 if the end of stream reached, or -1 on error. |
gssize gvir_stream_receive_all (GVirStream *stream,GCancellable *cancellable,GVirStreamSinkFunc func,gpointer user_data,GError **error);
Receive the entire data stream, sending the data to the requested data sink. This is simply a convenient alternative to virStreamRecv, for apps that do blocking-I/o.
gssize gvir_stream_send (GVirStream *stream,const gchar *buffer,gsize size,GCancellable *cancellable,GError **error);
Send data (up to size bytes) from a stream.
On error -1 is returned and error is set accordingly.
gvir_stream_send() can return any number of bytes, up to
size. If more than size bytes have been sendd, the additional
data will be returned in future calls to gvir_stream_send().
If there is no data available, a G_IO_ERROR_WOULD_BLOCK error will be
returned.
|
the stream |
|
a buffer to write data from (which should be at least size
bytes long). |
|
the number of bytes you want to write to the stream |
|
a GCancellable or NULL. [allow-none]
|
|
GError for error reporting, or NULL to ignore. |
Returns : |
Number of bytes read, or 0 if the end of stream reached, or -1 on error. |
gssize gvir_stream_send_all (GVirStream *stream,GCancellable *cancellable,GVirStreamSourceFunc func,gpointer user_data,GError **error);
Send the entire data stream, sending the data to the requested data source. This is simply a convenient alternative to virStreamRecv, for apps that do blocking-I/o.