Crypto++ 8.9
Free C++ class library of cryptographic schemes
fltrimpl.h
1#ifndef CRYPTOPP_FLTRIMPL_H
2#define CRYPTOPP_FLTRIMPL_H
3
4#define FILTER_BEGIN \
5 switch (m_continueAt) \
6 { \
7 case 0: \
8 m_inputPosition = 0;
9
10#define FILTER_END_NO_MESSAGE_END_NO_RETURN \
11 break; \
12 default: \
13 CRYPTOPP_ASSERT(false); \
14 }
15
16#define FILTER_END_NO_MESSAGE_END \
17 FILTER_END_NO_MESSAGE_END_NO_RETURN \
18 return 0;
19
20/*
21#define FILTER_END \
22 case -1: \
23 if (messageEnd && Output(-1, NULLPTR, 0, messageEnd, blocking)) \
24 return 1; \
25 FILTER_END_NO_MESSAGE_END
26*/
27
28#define FILTER_OUTPUT3(site, statement, output, length, messageEnd, channel) \
29 {\
30 case site: \
31 (void) statement; \
32 if (Output(site, output, length, messageEnd, blocking, channel)) \
33 return STDMAX(size_t(1), length-m_inputPosition);\
34 }
35
36#define FILTER_OUTPUT2(site, statement, output, length, messageEnd) \
37 FILTER_OUTPUT3(site, statement, output, length, messageEnd, DEFAULT_CHANNEL)
38
39#define FILTER_OUTPUT(site, output, length, messageEnd) \
40 FILTER_OUTPUT2(site, 0, output, length, messageEnd)
41
42#define FILTER_OUTPUT_BYTE(site, output) \
43 FILTER_OUTPUT(site, &(const byte &)(byte)output, 1, 0)
44
45#define FILTER_OUTPUT2_MODIFIABLE(site, statement, output, length, messageEnd) \
46 {\
47 /* fall through */ \
48 case site: \
49 (void) statement; \
50 if (OutputModifiable(site, output, length, messageEnd, blocking)) \
51 return STDMAX(size_t(1), length-m_inputPosition);\
52 }
53
54#define FILTER_OUTPUT_MODIFIABLE(site, output, length, messageEnd) \
55 FILTER_OUTPUT2_MODIFIABLE(site, 0, output, length, messageEnd)
56
57#define FILTER_OUTPUT2_MAYBE_MODIFIABLE(site, statement, output, length, messageEnd, modifiable) \
58 {\
59 /* fall through */ \
60 case site: \
61 (void) statement; \
62 if (modifiable ? OutputModifiable(site, output, length, messageEnd, blocking) : Output(site, output, length, messageEnd, blocking)) \
63 return STDMAX(size_t(1), length-m_inputPosition);\
64 }
65
66#define FILTER_OUTPUT_MAYBE_MODIFIABLE(site, output, length, messageEnd, modifiable) \
67 FILTER_OUTPUT2_MAYBE_MODIFIABLE(site, 0, output, length, messageEnd, modifiable)
68
69#endif