aboutsummaryrefslogtreecommitdiffstats
path: root/modules/es_unix/unix_cmd.h
blob: b073eb59d971d4f43b27cf3f7bd427ba484c6a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*************************************************
* Unix Command Execution Header File             *
* (C) 1999-2008 The Botan Project                *
*************************************************/

#ifndef BOTAN_EXT_UNIX_CMD_H__
#define BOTAN_EXT_UNIX_CMD_H__

#include <botan/types.h>
#include <botan/data_src.h>
#include <string>
#include <vector>

namespace Botan {

/*************************************************
* Unix Program Info                              *
*************************************************/
struct Unix_Program
   {
   Unix_Program(const char* n, u32bit p)
      { name_and_args = n; priority = p; working = true; }

   std::string name_and_args;
   u32bit priority;
   bool working;
   };

/*************************************************
* Command Output DataSource                      *
*************************************************/
class DataSource_Command : public DataSource
   {
   public:
      u32bit read(byte[], u32bit);
      u32bit peek(byte[], u32bit, u32bit) const;
      bool end_of_data() const;
      std::string id() const;

      int fd() const;

      DataSource_Command(const std::string&, const std::string&);
      ~DataSource_Command();
   private:
      void create_pipe(const std::string&);
      void shutdown_pipe();

      const u32bit MAX_BLOCK_USECS, KILL_WAIT;

      std::vector<std::string> arg_list;
      struct pipe_wrapper* pipe;
   };

}

#endif