1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

Feature: Implement __flush() and __set_backend()

This commit is contained in:
Philipp Schafft 2019-07-14 14:13:45 +00:00
parent 92ce939b1d
commit ac4f5eee2e

View File

@ -231,10 +231,42 @@ static igloo_filter_result_t __handle(igloo_INTERFACE_BASIC_ARGS, igloo_ro_t obj
return igloo_FILTER_RESULT_PASS; return igloo_FILTER_RESULT_PASS;
} }
static int __flush(igloo_INTERFACE_BASIC_ARGS)
{
igloo_io_t *io = igloo_RO_TO_TYPE(*backend_object, igloo_io_t);
if (!io)
return 0;
return igloo_io_flush(io, igloo_IO_OPFLAG_DEFAULTS|igloo_IO_OPFLAG_FULL);
}
static int __set_backend(igloo_INTERFACE_BASIC_ARGS, igloo_ro_t backend)
{
int ret;
if (!igloo_RO_IS_NULL(backend)) {
if (!igloo_RO_IS_VALID(backend, igloo_io_t))
return -1;
ret = igloo_ro_ref(backend);
if (ret != 0)
return ret;
}
igloo_ro_unref(*backend_object);
*backend_object = backend;
return 0;
}
static const igloo_objecthandler_ifdesc_t igloo_logmsg_formarter_ifdesc = { static const igloo_objecthandler_ifdesc_t igloo_logmsg_formarter_ifdesc = {
igloo_INTERFACE_DESCRIPTION_BASE(igloo_objecthandler_ifdesc_t), igloo_INTERFACE_DESCRIPTION_BASE(igloo_objecthandler_ifdesc_t),
.is_thread_safe = 1, .is_thread_safe = 1,
.handle = __handle .handle = __handle,
.flush = __flush,
.set_backend = __set_backend
}; };
igloo_objecthandler_t * igloo_logmsg_formarter(igloo_ro_t backend, const char *subformat, const char *name, igloo_ro_t associated) igloo_objecthandler_t * igloo_logmsg_formarter(igloo_ro_t backend, const char *subformat, const char *name, igloo_ro_t associated)
@ -242,9 +274,6 @@ igloo_objecthandler_t * igloo_logmsg_formarter(igloo_ro_t backend, const char
igloo_logmsg_formarter_subtype_t *sf = NULL; igloo_logmsg_formarter_subtype_t *sf = NULL;
igloo_objecthandler_t *objecthandler; igloo_objecthandler_t *objecthandler;
if (!igloo_RO_IS_VALID(backend, igloo_io_t))
return NULL;
if (!subformat || strcmp(subformat, "default") == 0) if (!subformat || strcmp(subformat, "default") == 0)
subformat = "normal"; subformat = "normal";
@ -263,11 +292,16 @@ igloo_objecthandler_t * igloo_logmsg_formarter(igloo_ro_t backend, const char
return NULL; return NULL;
} }
objecthandler = igloo_objecthandler_new(&igloo_logmsg_formarter_ifdesc, backend, sf, name, associated); objecthandler = igloo_objecthandler_new(&igloo_logmsg_formarter_ifdesc, NULL, sf, name, associated);
if (!objecthandler) { if (!objecthandler) {
free(sf); free(sf);
} }
if (igloo_objecthandler_set_backend(objecthandler, backend) != 0) {
igloo_ro_unref(objecthandler);
return NULL;
}
return objecthandler; return objecthandler;
} }