/* * Unix Command Execution * (C) 1999-2007 Jack Lloyd * 2012 Markus Wanner * * Distributed under the terms of the Botan license */ #ifndef BOTAN_UNIX_CMD_H__ #define BOTAN_UNIX_CMD_H__ #include #include #include #include namespace Botan { /** * Unix Program Info */ struct Unix_Program { /** * @param n is the name and arguments of what we are going run * @param p is the priority level (lower prio numbers get polled first) */ Unix_Program(const char* n, size_t p) { name_and_args = n; priority = p; working = true; } /** * The name and arguments for this command */ std::string name_and_args; /** * Priority: we scan from low to high */ size_t priority; /** * Does this source seem to be working? */ bool working; }; /** * Command Output DataSource */ class DataSource_Command : public DataSource { public: size_t read(byte[], size_t); size_t peek(byte[], size_t, size_t) const; bool end_of_data() const; std::string id() const; size_t get_bytes_read() const; int fd() const; DataSource_Command(const std::string&, const std::vector& paths); ~DataSource_Command(); private: void create_pipe(const std::vector&); void shutdown_pipe(); const size_t MAX_BLOCK_USECS, KILL_WAIT; std::vector arg_list; struct pipe_wrapper* pipe; size_t bytes_read; }; } #endif