File: parse_content.h

package info (click to toggle)
openser 1.1.0-9etch1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 9,828 kB
  • ctags: 11,809
  • sloc: ansic: 120,528; sh: 5,249; yacc: 1,716; makefile: 1,261; php: 656; perl: 205; sql: 190
file content (117 lines) | stat: -rw-r--r-- 3,210 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * $Id: parse_content.h,v 1.3 2006/03/17 10:39:17 bogdan_iancu Exp $
 *
 * Copyright (C) 2001-2003 FhG Fokus
 *
 * This file is part of openser, a free SIP server.
 *
 * openser is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version
 *
 * openser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _PARSE_CONTENT_H
#define _PARSE_CONTENT_H

#include "msg_parser.h"


struct mime_type {
	unsigned short type;
	unsigned short subtype;
};



/*
 * Mimes types/subtypes that are recognize
 */
#define TYPE_TEXT            1
#define TYPE_MESSAGE         2
#define TYPE_APPLICATION     3
#define TYPE_MULTIPART       4
#define TYPE_ALL             0xfe
#define TYPE_UNKNOWN         0xff

#define SUBTYPE_PLAIN        1
#define SUBTYPE_CPIM         2
#define SUBTYPE_SDP          3
#define SUBTYPE_CPLXML       4
#define SUBTYPE_PIDFXML      5
#define SUBTYPE_RLMIXML      6
#define SUBTYPE_RELATED      7
#define SUBTYPE_LPIDFXML     8
#define SUBTYPE_XPIDFXML     9
#define SUBTYPE_WATCHERINFOXML     10
#define SUBTYPE_EXTERNAL_BODY      11
#define SUBTYPE_XML_MSRTC_PIDF     12
#define SUBTYPE_ALL          0xfe
#define SUBTYPE_UNKNOWN      0xff


/*
 * Maximum number of mimes allowed in Accept header 
 */
#define MAX_MIMES_NR         128

/*
 * returns the content-length value of a sip_msg as an integer
 */
#define get_content_length(_msg_)   ((long)((_msg_)->content_length->parsed))


/*
 * returns the content-type value of a sip_msg as an integer
 */
#define get_content_type(_msg_)   ((int)(long)((_msg_)->content_type->parsed))


/*
 * returns the accept values of a sip_msg as an null-terminated array
 * of integer
 */
#define get_accept(_msg_) ((int*)((_msg_)->accept->parsed))

/*
 * parse the the body of the Content-Type header. It's value is also converted
 * as int.
 * Returns:   n (n>0)  : the found type
 *            0        : hdr not found
 *           -1        : error (parse error )
 */
int parse_content_type_hdr( struct sip_msg *msg);

/*
 * parse the the body of the Accept header. It's values are also converted
 * as an null-terminated array of ints.
 * Returns:   1 : OK
 *            0 : hdr not found
 *           -1 : error (parse error)
 */
int parse_accept_hdr( struct sip_msg *msg );


/*
 *  parse the body of a Content_-Length header. Also tries to recognize the
 *  type specified by this header (see th above defines).
 *  Returns the first chr after the end of the header.
 */
char* parse_content_length( char* buffer, char* end, int* len);


/*
 * parse a string containing a mime description
 */
char* decode_mime_type(char *start, char *end, unsigned int *mime_type);

#endif