mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-12-04 14:46:31 -05:00
Feature: Allow asking objects for their error state
This commit is contained in:
parent
3c6c6c62b5
commit
76a9d1c756
@ -194,6 +194,10 @@ typedef enum {
|
||||
*/
|
||||
typedef igloo_ro_cr_t (*igloo_ro_compare_t)(igloo_ro_t a, igloo_ro_t b);
|
||||
|
||||
/* Type used for callback called when error value is requested from an object.
|
||||
*/
|
||||
typedef igloo_error_t (*igloo_ro_get_error_t)(igloo_ro_t self, igloo_error_t *result);
|
||||
|
||||
/* Meta type used to defined types.
|
||||
* DO NOT use any of the members in here directly!
|
||||
*/
|
||||
@ -232,6 +236,8 @@ struct igloo_ro_type_tag {
|
||||
igloo_ro_stringify_t type_stringifycb;
|
||||
/* Callback to be called by igloo_ro_compare() */
|
||||
igloo_ro_compare_t type_comparecb;
|
||||
/* Callback to be called by igloo_ro_get_error() */
|
||||
igloo_ro_get_error_t type_get_errorcb;
|
||||
};
|
||||
struct igloo_ro_base_tag {
|
||||
/* Type of the object */
|
||||
@ -392,6 +398,19 @@ char * igloo_ro_stringify(igloo_ro_t self, igloo_ro_sy_t flags);
|
||||
*/
|
||||
igloo_ro_cr_t igloo_ro_compare(igloo_ro_t a, igloo_ro_t b);
|
||||
|
||||
/* Get error value from a object.
|
||||
*
|
||||
* Parameters:
|
||||
* self
|
||||
* The Object to request error value from.
|
||||
* result
|
||||
* Pointer to the location the error value should be stored.
|
||||
* The value is only written if igloo_ERROR_NONE is returned.
|
||||
* Returns:
|
||||
* The result of the query.
|
||||
*/
|
||||
igloo_error_t igloo_ro_get_error(igloo_ro_t self, igloo_error_t *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
21
src/ro.c
21
src/ro.c
@ -26,6 +26,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <igloo/ro.h>
|
||||
#include <igloo/error.h>
|
||||
#include "private.h"
|
||||
|
||||
/* This is not static as it is used by igloo_RO_TYPEDECL_NEW_NOOP() */
|
||||
@ -512,3 +513,23 @@ igloo_ro_cr_t igloo_ro_compare(igloo_ro_t a, igloo_ro_t b)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
igloo_error_t igloo_ro_get_error(igloo_ro_t self, igloo_error_t *result)
|
||||
{
|
||||
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
|
||||
igloo_error_t ret = igloo_ERROR_GENERIC;
|
||||
igloo_error_t res = igloo_ERROR_GENERIC;
|
||||
|
||||
if (!base || !result)
|
||||
return igloo_ERROR_GENERIC;
|
||||
|
||||
igloo_thread_mutex_lock(&(base->lock));
|
||||
if (base->type->type_get_errorcb)
|
||||
ret = base->type->type_get_errorcb(self, &res);
|
||||
igloo_thread_mutex_unlock(&(base->lock));
|
||||
|
||||
if (ret == igloo_ERROR_NONE)
|
||||
*result = res;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user