/** * gvir_storage_pool_get_info: * @pool: the storage_pool * @err: Place-holder for possible errors * * Returns: (transfer full): the info. The returned pointer should be * freed using #g_boxed_free() when no longer needed. */ GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, GError **err) { GVirStoragePoolPrivate *priv; virStoragePoolInfo info; GVirStoragePoolInfo *ret; g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), NULL); g_return_val_if_fail(err == NULL || *err == NULL, NULL); priv = pool->priv; if (virStoragePoolGetInfo(priv->handle, &info) < 0) { if (err) *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, 0, "Unable to get storage pool info"); return NULL; } ret = g_slice_new(GVirStoragePoolInfo); ret->state = info.state; ret->capacity = info.capacity; ret->allocation = info.allocation; ret->available = info.available; return ret; }
/** * gvir_set_error_literal: * @error: pointer to error location * @domain: error domain * @code: error code * @message: error message * * If @error is NULL this does nothing. Otherwise it * creates a new #GError and stores it in @error; unlike * gvir_set_error(), @message is not a printf()-style * format string. Use this function if @message contains * text you don't have control over, that could include * printf() escape sequences. */ void gvir_set_error_literal(GError **error, GQuark domain, gint code, const gchar *message) { if (!error) return; *error = gvir_error_new_literal(domain, code, message); }
/** * gvir_set_error_valist: * @error: pointer to error location * @domain: error domain * @code: error code * @format: printf()-style format for error message * @args: #va_list of parameters for the message format * * If @error is NULL this does nothing. Otherwise it * creates a new #GError with the given @domain and @code, * and a message formatted with @format, and stores it * in @error. */ void gvir_set_error_valist(GError **error, GQuark domain, gint code, const gchar *format, va_list args) { gchar *message; if (!error) return; message = g_strdup_vprintf(format, args); *error = gvir_error_new_literal(domain, code, message); g_free(message); }
/** * gvir_error_new_valist: * @domain: error domain * @code: error code * @format: printf()-style format for error message * @args: #va_list of parameters for the message format * * Creates a new #GError with the given @domain and @code, * and a message formatted with @format. * * Returns: a new #GError */ GError *gvir_error_new_valist(GQuark domain, gint code, const gchar *format, va_list args) { GError *err; gchar *message; message = g_strdup_vprintf(format, args); err = gvir_error_new_literal(domain, code, message); g_free(message); return err; }
/** * gvir_error_new: * @domain: error domain * @code: error code * @format: printf()-style format for error message * @...: parameters for message format * * Creates a new #GError with the given @domain and @code, * and a message formatted with @format. * * Returns: a new #GError */ GError *gvir_error_new(GQuark domain, gint code, const gchar *format, ...) { GError *err; va_list args; gchar *message; va_start(args, format); message = g_strdup_vprintf(format, args); va_end(args); err = gvir_error_new_literal(domain, code, message); g_free(message); return err; }
/** * gvir_set_error: * @error: pointer to error location * @domain: error domain * @code: error code * @format: printf()-style format for error message * @...: parameters for message format * * If @error is NULL this does nothing. Otherwise it * creates a new #GError with the given @domain and @code, * and a message formatted with @format, and stores it * in @error. */ void gvir_set_error(GError **error, GQuark domain, gint code, const gchar *format, ...) { va_list args; gchar *message; if (!error) return; va_start(args, format); message = g_strdup_vprintf(format, args); va_end(args); *error = gvir_error_new_literal(domain, code, message); g_free(message); }