diff options
Diffstat (limited to 'linden/indra/test/llpipeutil.h')
-rw-r--r-- | linden/indra/test/llpipeutil.h | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/linden/indra/test/llpipeutil.h b/linden/indra/test/llpipeutil.h new file mode 100644 index 0000000..7fda905 --- /dev/null +++ b/linden/indra/test/llpipeutil.h | |||
@@ -0,0 +1,144 @@ | |||
1 | /** | ||
2 | * @file llpipeutil.h | ||
3 | * @date 2006-05-18 | ||
4 | * @brief Utility pipe fittings for injecting and extracting strings | ||
5 | * | ||
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLPIPEUTIL_H | ||
30 | #define LL_LLPIPEUTIL_H | ||
31 | |||
32 | #include "lliopipe.h" | ||
33 | |||
34 | |||
35 | /** | ||
36 | * @brief Simple function which pumps for the specified time. | ||
37 | */ | ||
38 | F32 pump_loop(LLPumpIO* pump, F32 seconds); | ||
39 | |||
40 | /** | ||
41 | * @brief Simple class which writes a string and then marks the stream | ||
42 | * as done. | ||
43 | */ | ||
44 | class LLPipeStringInjector : public LLIOPipe | ||
45 | { | ||
46 | public: | ||
47 | LLPipeStringInjector(const std::string& string) | ||
48 | : mString(string) | ||
49 | { } | ||
50 | |||
51 | protected: | ||
52 | virtual EStatus process_impl( | ||
53 | const LLChannelDescriptors& channels, | ||
54 | buffer_ptr_t& buffer, | ||
55 | bool& eos, | ||
56 | LLSD& context, | ||
57 | LLPumpIO* pump); | ||
58 | |||
59 | private: | ||
60 | std::string mString; | ||
61 | }; | ||
62 | |||
63 | |||
64 | class LLPipeStringExtractor : public LLIOPipe | ||
65 | { | ||
66 | public: | ||
67 | LLPipeStringExtractor() : mDone(false) { } | ||
68 | |||
69 | bool done() { return mDone; } | ||
70 | std::string string() { return mString; } | ||
71 | |||
72 | protected: | ||
73 | // LLIOPipe API implementation. | ||
74 | virtual EStatus process_impl( | ||
75 | const LLChannelDescriptors& channels, | ||
76 | LLIOPipe::buffer_ptr_t& buffer, | ||
77 | bool& eos, | ||
78 | LLSD& context, | ||
79 | LLPumpIO* pump); | ||
80 | |||
81 | private: | ||
82 | bool mDone; | ||
83 | std::string mString; | ||
84 | }; | ||
85 | |||
86 | /** | ||
87 | * @brief Generate a specified number of bytes of random data | ||
88 | */ | ||
89 | class LLIOFuzz : public LLIOPipe | ||
90 | { | ||
91 | public: | ||
92 | LLIOFuzz(int byte_count) : mByteCount(byte_count) {} | ||
93 | |||
94 | protected: | ||
95 | virtual EStatus process_impl( | ||
96 | const LLChannelDescriptors& channels, | ||
97 | buffer_ptr_t& buffer, | ||
98 | bool& eos, | ||
99 | LLSD& context, | ||
100 | LLPumpIO* pump); | ||
101 | |||
102 | private: | ||
103 | int mByteCount; | ||
104 | }; | ||
105 | |||
106 | /** | ||
107 | * @brief Generate some ascii fuz | ||
108 | */ | ||
109 | class LLIOASCIIFuzz : public LLIOPipe | ||
110 | { | ||
111 | public: | ||
112 | LLIOASCIIFuzz(int byte_count) : mByteCount(byte_count) {} | ||
113 | |||
114 | protected: | ||
115 | virtual EStatus process_impl( | ||
116 | const LLChannelDescriptors& channels, | ||
117 | buffer_ptr_t& buffer, | ||
118 | bool& eos, | ||
119 | LLSD& context, | ||
120 | LLPumpIO* pump); | ||
121 | |||
122 | private: | ||
123 | int mByteCount; | ||
124 | }; | ||
125 | |||
126 | |||
127 | /** | ||
128 | * @brief Pipe that does nothing except return STATUS_OK | ||
129 | */ | ||
130 | class LLIONull : public LLIOPipe | ||
131 | { | ||
132 | public: | ||
133 | LLIONull() {} | ||
134 | |||
135 | protected: | ||
136 | virtual EStatus process_impl( | ||
137 | const LLChannelDescriptors& channels, | ||
138 | buffer_ptr_t& buffer, | ||
139 | bool& eos, | ||
140 | LLSD& context, | ||
141 | LLPumpIO* pump); | ||
142 | }; | ||
143 | |||
144 | #endif // LL_LLPIPEUTIL_H | ||