# HG changeset patch # User reimar # Date 1104605216 0 # Node ID 12239a0d54082cac08bbb2d0135cc3a14affc8cc # Parent f4b8d6abce2289a27a82deecf8d7d2ebe7f7ef80 Make af_control_any_rev return the matching filter diff -r f4b8d6abce22 -r 12239a0d5408 libaf/af.c --- a/libaf/af.c Sat Jan 01 14:45:11 2005 +0000 +++ b/libaf/af.c Sat Jan 01 18:46:56 2005 +0000 @@ -615,16 +615,21 @@ return AF_OK; } -// send control to all filters, starting with the last until -// one responds with AF_OK -int af_control_any_rev (af_stream_t* s, int cmd, void* arg) { +/** + * \brief send control to all filters, starting with the last, until + * one responds with AF_OK + * \return The instance that accepted the command or NULL if none did. + */ +af_instance_t *af_control_any_rev (af_stream_t* s, int cmd, void* arg) { int res = AF_UNKNOWN; af_instance_t* filt = s->last; - while (filt && res != AF_OK) { + while (filt) { res = filt->control(filt, cmd, arg); + if (res == AF_OK) + return filt; filt = filt->prev; } - return (res == AF_OK); + return NULL; } void af_help (void) { diff -r f4b8d6abce22 -r 12239a0d5408 libaf/af.h --- a/libaf/af.h Sat Jan 01 14:45:11 2005 +0000 +++ b/libaf/af.h Sat Jan 01 18:46:56 2005 +0000 @@ -153,8 +153,8 @@ // send control to all filters, starting with the last until // one accepts the command with AF_OK. -// Returns true if accepting filter was found. -int af_control_any_rev (af_stream_t* s, int cmd, void* arg); +// Returns the accepting filter or NULL if none was found. +af_instance_t *af_control_any_rev (af_stream_t* s, int cmd, void* arg); /* Calculate how long the output from the filters will be given the input length "len". The calculated length is >= the actual