parse_content.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * $Id$
  3. *
  4. *
  5. * Copyright (C) 2001-2003 Fhg Fokus
  6. *
  7. * This file is part of ser, a free SIP server.
  8. *
  9. * ser 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. * For a license to use the ser software under conditions
  15. * other than those described here, or to purchase support for this
  16. * software, please contact iptel.org by e-mail at the following addresses:
  17. * [email protected]
  18. *
  19. * ser is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. */
  28. #ifndef _PARSE_CONTENT_H
  29. #define _PARSE_CONTENT_H
  30. #include "msg_parser.h"
  31. struct mime_type {
  32. unsigned short type;
  33. unsigned short subtype;
  34. };
  35. /*
  36. * Mimes types/subtypes that are recognize
  37. */
  38. #define TYPE_TEXT 1
  39. #define TYPE_MESSAGE 2
  40. #define TYPE_APPLICATION 3
  41. #define TYPE_ALL 0xfe
  42. #define TYPE_UNKNOWN 0xff
  43. #define SUBTYPE_PLAIN 1
  44. #define SUBTYPE_CPIM 2
  45. #define SUBTYPE_SDP 3
  46. #define SUBTYPE_CPLXML 4
  47. #define SUBTYPE_ALL 0xfe
  48. #define SUBTYPE_UNKNOWN 0xff
  49. /*
  50. * Maximum number of mimes allowed in Accept header
  51. */
  52. #define MAX_MIMES_NR 128
  53. /*
  54. * returns the content-length value of a sip_msg as an integer
  55. */
  56. #define get_content_length(_msg_) ((long)((_msg_)->content_length->parsed))
  57. /*
  58. * returns the content-type value of a sip_msg as an integer
  59. */
  60. #define get_content_type(_msg_) ((int)(long)((_msg_)->content_type->parsed))
  61. /*
  62. * returns the accept values of a sip_msg as an null-terminated array
  63. * of integer
  64. */
  65. #define get_accept(_msg_) ((int*)((_msg_)->accept->parsed))
  66. /*
  67. * parse the the body of the Content-Type header. It's value is also converted
  68. * as int.
  69. * Returns: n (n>0) : the found type
  70. * 0 : hdr not found
  71. * -1 : error (parse error )
  72. */
  73. int parse_content_type_hdr( struct sip_msg *msg);
  74. /*
  75. * parse the the body of the Accept header. It's values are also converted
  76. * as an null-terminated array of ints.
  77. * Returns: 1 : OK
  78. * 0 : hdr not found
  79. * -1 : error (parse error)
  80. */
  81. int parse_accept_hdr( struct sip_msg *msg );
  82. /*
  83. * parse the body of a Content_-Length header. Also tryes to recognize the
  84. * type specified by this header (see th above defines).
  85. * Returns the first chr after the end of the header.
  86. */
  87. char* parse_content_length( char* buffer, char* end, int* len);
  88. #endif