diff --git a/io.cpp b/io.cpp index 6a304014c..42c55f9fe 100644 --- a/io.cpp +++ b/io.cpp @@ -51,6 +51,28 @@ Utilities for io redirection. #include "io.h" +void io_data_t::print() const +{ + switch (io_mode) + { + case IO_FILE: + fprintf(stderr, "file (%s)\n", filename_cstr); + break; + case IO_PIPE: + fprintf(stderr, "pipe {%d, %d}\n", param1.pipe_fd[0], param1.pipe_fd[1]); + break; + case IO_FD: + fprintf(stderr, "FD map %d -> %d\n", param1.old_fd, fd); + break; + case IO_BUFFER: + fprintf(stderr, "buffer %p (size %lu)\n", out_buffer_ptr(), out_buffer_size()); + break; + case IO_CLOSE: + fprintf(stderr, "close %d\n", fd); + break; + } +} + void io_buffer_read(io_data_t *d) { exec_close(d->param1.pipe_fd[1]); @@ -195,24 +217,7 @@ void io_print(const io_chain_t &chain) { const shared_ptr &io = chain.at(i); fprintf(stderr, "\t%lu: fd:%d, input:%s, ", (unsigned long)i, io->fd, io->is_input ? "yes" : "no"); - switch (io->io_mode) - { - case IO_FILE: - fprintf(stderr, "file (%s)\n", io->filename_cstr); - break; - case IO_PIPE: - fprintf(stderr, "pipe {%d, %d}\n", io->param1.pipe_fd[0], io->param1.pipe_fd[1]); - break; - case IO_FD: - fprintf(stderr, "FD map %d -> %d\n", io->param1.old_fd, io->fd); - break; - case IO_BUFFER: - fprintf(stderr, "buffer %p (size %lu)\n", io->out_buffer_ptr(), io->out_buffer_size()); - break; - case IO_CLOSE: - fprintf(stderr, "close %d\n", io->fd); - break; - } + io->print(); } } diff --git a/io.h b/io.h index 96f5cbaf4..da47abe07 100644 --- a/io.h +++ b/io.h @@ -94,6 +94,8 @@ public: return out_buffer->size(); } + virtual void print() const; + /** Set to true if this is an input io redirection */ bool is_input;