case_cont.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Contact, Content-Type, Content-Length, Content-Disposition, Content-Encoding
  3. * Header Field Name Parsing Macros
  4. *
  5. * Copyright (C) 2001-2003 FhG Fokus
  6. *
  7. * This file is part of SIP-router, a free SIP server.
  8. *
  9. * SIP-router is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * SIP-router is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * History:
  24. * ----------
  25. * 2003-02-28 scratchpad compatibility abandoned (jiri)
  26. * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
  27. */
  28. /*! \file
  29. * \brief Parser :: Contact, Content-Type, Content-Length, Content-Disposition, Content-Encoding
  30. * Header Field Name Parsing Macros
  31. *
  32. * \ingroup parser
  33. */
  34. #ifndef CASE_CONT_H
  35. #define CASE_CONT_H
  36. #include "../comp_defs.h"
  37. #define TH_CASE \
  38. switch(LOWER_DWORD(val)) { \
  39. case _th12_: \
  40. hdr->type = HDR_CONTENTLENGTH_T; \
  41. hdr->name.len = 14; \
  42. return (p + 4); \
  43. } \
  44. \
  45. if (LOWER_BYTE(*p) == 't') { \
  46. p++; \
  47. if (LOWER_BYTE(*p) == 'h') { \
  48. hdr->type = HDR_CONTENTLENGTH_T;\
  49. p++; \
  50. goto dc_end; \
  51. } \
  52. }
  53. #define ion_CASE \
  54. switch(LOWER_DWORD(val)) { \
  55. case _ion1_: \
  56. hdr->type = HDR_CONTENTDISPOSITION_T; \
  57. hdr->name.len = 19; \
  58. return (p + 4); \
  59. \
  60. case _ion2_: \
  61. hdr->type = HDR_CONTENTDISPOSITION_T; \
  62. p += 4; \
  63. goto dc_end; \
  64. }
  65. #define DISPOSITION_CASE \
  66. switch(LOWER_DWORD(val)) { \
  67. case _osit_: \
  68. p += 4; \
  69. val = READ(p); \
  70. ion_CASE; \
  71. goto other; \
  72. }
  73. #define ENCODING_CASE \
  74. switch(LOWER_DWORD(val)) { \
  75. case _ding_: \
  76. p += 4; \
  77. hdr->type = HDR_CONTENTENCODING_T; \
  78. goto dc_end; \
  79. }
  80. #define CONTENT_CASE \
  81. switch(LOWER_DWORD(val)) { \
  82. case _leng_: \
  83. p += 4; \
  84. val = READ(p); \
  85. TH_CASE; \
  86. goto other; \
  87. \
  88. case _type_: \
  89. hdr->type = HDR_CONTENTTYPE_T; \
  90. p += 4; \
  91. goto dc_end; \
  92. \
  93. case _disp_: \
  94. p += 4; \
  95. val = READ(p); \
  96. DISPOSITION_CASE; \
  97. goto other; \
  98. case _enco_: \
  99. p += 4; \
  100. val = READ(p); \
  101. ENCODING_CASE; \
  102. goto other; \
  103. }
  104. #define ACT_ENT_CASE \
  105. switch(LOWER_DWORD(val)) { \
  106. case _act1_: \
  107. hdr->type = HDR_CONTACT_T; \
  108. hdr->name.len = 7; \
  109. return (p + 4); \
  110. \
  111. case _act2_: \
  112. hdr->type = HDR_CONTACT_T; \
  113. p += 4; \
  114. goto dc_end; \
  115. \
  116. case _ent__: \
  117. p += 4; \
  118. val = READ(p); \
  119. CONTENT_CASE; \
  120. goto other; \
  121. }
  122. #define cont_CASE \
  123. p += 4; \
  124. val = READ(p); \
  125. ACT_ENT_CASE; \
  126. goto other;
  127. #endif /* CASE_CONT_H */