e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen#ifndef ISTREAM_TRY_H
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen#define ISTREAM_TRY_H
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen/* Read from the first input stream that doesn't fail with EINVAL. If any of
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen the streams fail with non-EINVAL, it's treated as a fatal failure and the
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen error is immediately returned. If a stream returns 0, more data is waited
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen for before continuing to the next stream. This allows the last stream to
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen be a fallback stream that always succeeds.
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen Once the stream is detected, all the other streams are unreferenced.
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen The streams should usually be children of the same parent tee-istream. */
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainenstruct istream *istream_try_create(struct istream *const input[]);
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen
e9fe799e27b5a3b67c256766d4bafd388e560684Timo Sirainen#endif