Botan: src/entropy/unix_procs/unix_cmd.h Source File

Botan 1.10.17

unix_cmd.h
Go to the documentation of this file.
1 /*
2 * Unix Command Execution
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_UNIX_CMD_H__
9 #define BOTAN_UNIX_CMD_H__
10
11 #include <botan/types.h>
12 #include <botan/data_src.h>
13 #include <string>
14 #include <vector>
15
16 namespace Botan {
17
18 /**
19 * Unix Program Info
20 */
21 struct Unix_Program
22 {
23 /**
24 * @param n is the name and arguments of what we are going run
25 * @param p is the priority level (lower prio numbers get polled first)
26 */
27 Unix_Program(const char* n, size_t p)
28 { name_and_args = n; priority = p; working = true; }
29
30 /**
31 * The name and arguments for this command
32 */
33 std::string name_and_args;
34
35 /**
36 * Priority: we scan from low to high
37 */
38 size_t priority;
39
40 /**
41 * Does this source seem to be working?
42 */
43 bool working;
44 };
45
46 /**
47 * Command Output DataSource
48 */
49 class DataSource_Command : public DataSource
50 {
51 public:
52 size_t read(byte[], size_t);
53 size_t peek(byte[], size_t, size_t) const;
54 bool check_available(size_t n);
55 bool end_of_data() const;
56 std::string id() const;
57
58 int fd() const;
59
60 DataSource_Command(const std::string&,
61 const std::vector<std::string>& paths);
62 ~DataSource_Command();
63 private:
64 void create_pipe(const std::vector<std::string>&);
65 void shutdown_pipe();
66
67 const size_t MAX_BLOCK_USECS, KILL_WAIT;
68
69 std::vector<std::string> arg_list;
70 struct pipe_wrapper* pipe;
71 };
72
73 }
74
75 #endif
Botan::DataSource_Command::~DataSource_Command
~DataSource_Command()
Definition: unix_cmd.cpp:238
Botan::DataSource_Command::read
size_t read(byte[], size_t)
Definition: unix_cmd.cpp:63
Botan::DataSource
Definition: data_src.h:20
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Unix_Program
Definition: unix_cmd.h:21
Botan::Unix_Program::Unix_Program
Unix_Program(const char *n, size_t p)
Definition: unix_cmd.h:27
Botan::DataSource_Command
Definition: unix_cmd.h:49
Botan::DataSource_Command::check_available
bool check_available(size_t n)
Definition: unix_cmd.cpp:102
Botan::DataSource_Command::id
std::string id() const
Definition: unix_cmd.cpp:128
Botan
Definition: algo_base.h:14
Botan::DataSource_Command::peek
size_t peek(byte[], size_t, size_t) const
Definition: unix_cmd.cpp:95
Botan::Unix_Program::priority
size_t priority
Definition: unix_cmd.h:38
Botan::Unix_Program::name_and_args
std::string name_and_args
Definition: unix_cmd.h:33
Botan::DataSource_Command::end_of_data
bool end_of_data() const
Definition: unix_cmd.cpp:110
Botan::Unix_Program::working
bool working
Definition: unix_cmd.h:43
Botan::DataSource_Command::DataSource_Command
DataSource_Command(const std::string &, const std::vector< std::string > &paths)
Definition: unix_cmd.cpp:220
Botan::DataSource_Command::fd
int fd() const
Definition: unix_cmd.cpp:118