fltrimpl.h 2.0 KB

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