Mask output in pipe

This commit is contained in:
Wilson Lin 2018-07-06 16:07:09 +12:00
parent 34d2d828be
commit b77f3dd03b
1 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ typedef struct hbu_pipe_s {
hbu_fstreamin_t input; hbu_fstreamin_t input;
void *output; void *output;
hbu_pipe_writer_cb_t writer; hbu_pipe_writer_cb_t writer;
int output_masked;
hbu_buffer_t buffer; hbu_buffer_t buffer;
@ -116,7 +117,9 @@ static void _hbu_pipe_assert_not_eoi(hbu_pipe_t pipe, hb_eod_char_t c) {
} }
static void _hbu_pipe_write_to_output(hbu_pipe_t pipe, hb_char_t c) { static void _hbu_pipe_write_to_output(hbu_pipe_t pipe, hb_char_t c) {
(*pipe->writer)(pipe->output, c); if (!pipe->output_masked) {
(*pipe->writer)(pipe->output, c);
}
} }
/* /*
@ -130,6 +133,7 @@ hbu_pipe_t hbu_pipe_create(hbu_fstreamin_t input, void *output, hbu_pipe_writer_
pipe->input = input; pipe->input = input;
pipe->output = output; pipe->output = output;
pipe->writer = writer; pipe->writer = writer;
pipe->output_masked = 0;
pipe->buffer = hbu_buffer_create(); pipe->buffer = hbu_buffer_create();
@ -146,6 +150,10 @@ void hbu_pipe_destroy(hbu_pipe_t pipe) {
free(pipe); free(pipe);
} }
void hbu_pipe_toggle_output_mask(hbu_pipe_t pipe, int output_masked) {
pipe->output_masked = output_masked;
}
/* /*
* *
* BUILDER FUNCTIONS * BUILDER FUNCTIONS