~zooko/cryptopp/trunk

1 by weidai
Initial revision
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
		assert(false);	\
14
	}
15
16
#define FILTER_END_NO_MESSAGE_END	\
17
	FILTER_END_NO_MESSAGE_END_NO_RETURN	\
18
	return 0;
19
24 by weidai
fixed FILTER_END bug
20
/*
1 by weidai
Initial revision
21
#define FILTER_END	\
22
	case -1:	\
24 by weidai
fixed FILTER_END bug
23
		if (messageEnd && Output(-1, NULL, 0, messageEnd, blocking))	\
1 by weidai
Initial revision
24
			return 1;	\
25
	FILTER_END_NO_MESSAGE_END
24 by weidai
fixed FILTER_END bug
26
*/
1 by weidai
Initial revision
27
28
#define FILTER_OUTPUT2(site, statement, output, length, messageEnd)	\
29
	{\
30
	case site:	\
31
	statement;	\
32
	if (Output(site, output, length, messageEnd, blocking))	\
33
		return STDMAX(1U, (unsigned int)length-m_inputPosition);\
34
	}
35
36
#define FILTER_OUTPUT(site, output, length, messageEnd)	\
37
	FILTER_OUTPUT2(site, 0, output, length, messageEnd)
38
39
#define FILTER_OUTPUT_BYTE(site, output)	\
40
	FILTER_OUTPUT(site, &(const byte &)(byte)output, 1, 0)
41
64 by weidai
sync with private branch
42
#define FILTER_OUTPUT2_MODIFIABLE(site, statement, output, length, messageEnd)	\
43
	{\
44
	case site:	\
45
	statement;	\
46
	if (OutputModifiable(site, output, length, messageEnd, blocking))	\
47
		return STDMAX(1U, (unsigned int)length-m_inputPosition);\
48
	}
49
50
#define FILTER_OUTPUT_MODIFIABLE(site, output, length, messageEnd)	\
51
	FILTER_OUTPUT2_MODIFIABLE(site, 0, output, length, messageEnd)
52
1 by weidai
Initial revision
53
#endif