Botan  1.10.9
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 */
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 */
50  {
51  public:
52  size_t read(byte[], size_t);
53  size_t peek(byte[], size_t, size_t) const;
54  bool end_of_data() const;
55  std::string id() const;
56 
57  int fd() const;
58 
59  DataSource_Command(const std::string&,
60  const std::vector<std::string>& paths);
62  private:
63  void create_pipe(const std::vector<std::string>&);
64  void shutdown_pipe();
65 
66  const size_t MAX_BLOCK_USECS, KILL_WAIT;
67 
68  std::vector<std::string> arg_list;
69  struct pipe_wrapper* pipe;
70  };
71 
72 }
73 
74 #endif
BigInt n
Definition: numthry.cpp:26
size_t read(byte[], size_t)
Definition: unix_cmd.cpp:63
unsigned char byte
Definition: types.h:22
size_t peek(byte[], size_t, size_t) const
Definition: unix_cmd.cpp:95
Unix_Program(const char *n, size_t p)
Definition: unix_cmd.h:27
bool end_of_data() const
Definition: unix_cmd.cpp:105
std::string id() const
Definition: unix_cmd.cpp:123
std::string name_and_args
Definition: unix_cmd.h:33
DataSource_Command(const std::string &, const std::vector< std::string > &paths)
Definition: unix_cmd.cpp:215