8 #include <botan/pipe.h>
9 #include <botan/internal/out_buf.h>
10 #include <botan/secqueue.h>
11 #include <botan/parsing.h>
20 class Null_Filter :
public Filter
23 void write(
const byte input[],
size_t length)
24 { send(input, length); }
26 std::string name()
const {
return "Null"; }
50 for(
auto i = args.begin(); i != args.end(); ++i)
87 void Pipe::destruct(
Filter* to_kill)
89 if(!to_kill || dynamic_cast<SecureQueue*>(to_kill))
91 for(
size_t j = 0; j != to_kill->total_ports(); ++j)
92 destruct(to_kill->next[j]);
120 write(input, length);
142 process_msg(reinterpret_cast<const byte*>(input.data()), input.length());
161 throw Invalid_State(
"Pipe::start_msg: Message was already started");
163 pipe =
new Null_Filter;
164 find_endpoints(pipe);
175 throw Invalid_State(
"Pipe::end_msg: Message was already ended");
177 clear_endpoints(pipe);
178 if(dynamic_cast<Null_Filter*>(pipe))
191 void Pipe::find_endpoints(
Filter* f)
193 for(
size_t j = 0; j != f->total_ports(); ++j)
194 if(f->next[j] && !dynamic_cast<SecureQueue*>(f->next[j]))
195 find_endpoints(f->next[j]);
207 void Pipe::clear_endpoints(Filter* f)
210 for(
size_t j = 0; j != f->total_ports(); ++j)
212 if(f->next[j] && dynamic_cast<SecureQueue*>(f->next[j]))
213 f->next[j] =
nullptr;
214 clear_endpoints(f->next[j]);
224 throw Invalid_State(
"Cannot append to a Pipe while it is processing");
227 if(dynamic_cast<SecureQueue*>(filter))
232 filter->owned =
true;
234 if(!pipe) pipe = filter;
235 else pipe->attach(filter);
244 throw Invalid_State(
"Cannot prepend to a Pipe while it is processing");
247 if(dynamic_cast<SecureQueue*>(filter))
252 filter->owned =
true;
254 if(pipe) filter->attach(pipe);
264 throw Invalid_State(
"Cannot pop off a Pipe while it is processing");
269 if(pipe->total_ports() > 1)
270 throw Invalid_State(
"Cannot pop off a Filter with multiple ports");
273 size_t owns = f->owns();
274 pipe = pipe->next[0];
280 pipe = pipe->next[0];