aboutsummaryrefslogtreecommitdiffstats
path: root/misc/swig/pipe.cpp
blob: 2ccdd5dfdb1200fbf164a4eef817433c84053f70 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*************************************************
* SWIG Interface for Botan Pipe API              *
* (C) 1999-2003 The Botan Project                *
*************************************************/

#include "base.h"
#include <botan/pipe.h>

#include <stdio.h>

/*************************************************
* Write the contents of a file into a Pipe       *
*************************************************/
void Pipe::write_file(const char* filename)
   {
   Botan::DataSource_Stream in(filename);
   pipe->write(in);
   }

/*************************************************
* Write the contents of a string into a Pipe     *
*************************************************/
void Pipe::write_string(const char* string)
   {
   pipe->write(string);
   }

/*************************************************
* Read the contents of a Pipe into a buffer      *
*************************************************/
u32bit Pipe::read(byte* buf, u32bit length, u32bit msg)
   {
   printf("read %p %d\n", buf, length);
   return 0;
   //return pipe->read(buf, length, msg);
   }

/*************************************************
* Read the contents of a Pipe as a string        *
*************************************************/
std::string Pipe::read_all_as_string(u32bit msg)
   {
   return pipe->read_all_as_string(msg);
   }

/*************************************************
* Find out how much stuff the Pipe still has     *
*************************************************/
u32bit Pipe::remaining(u32bit msg)
   {
   return pipe->remaining();
   }

/*************************************************
* Start a new message                            *
*************************************************/
void Pipe::start_msg()
   {
   pipe->start_msg();
   }

/*************************************************
* End the current msessage                       *
*************************************************/
void Pipe::end_msg()
   {
   pipe->end_msg();
   }

/*************************************************
* Create a new Pipe                              *
*************************************************/
Pipe::Pipe(Filter* f1, Filter* f2, Filter* f3, Filter* f4)
   {
   pipe = new Botan::Pipe();

   if(f1) { pipe->append(f1->filter); f1->pipe_owns = true; }
   if(f2) { pipe->append(f2->filter); f2->pipe_owns = true; }
   if(f3) { pipe->append(f3->filter); f3->pipe_owns = true; }
   if(f4) { pipe->append(f4->filter); f4->pipe_owns = true; }
   }

/*************************************************
* Destroy this Pipe                              *
*************************************************/
Pipe::~Pipe()
   {
   delete pipe;
   }