msg  1.13.16
msg.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef MSG_H
27 #define MSG_H
37 #include <sofia-sip/msg_types.h>
38 #include <sofia-sip/su_alloc.h>
39 
40 SOFIA_BEGIN_DECLS
41 
42 SOFIAPUBFUN msg_t *msg_create(msg_mclass_t const *mc, int flags);
44 
46 SOFIAPUBFUN msg_t *msg_dup(msg_t const *);
47 
48 SOFIAPUBFUN msg_t *msg_make(msg_mclass_t const *mc, int flags,
49  void const *data, ssize_t len);
51  msg_t *msg, msg_pub_t *pub, int flags,
52  size_t *return_len);
53 
54 SOFIAPUBFUN void msg_set_parent(msg_t *kid, msg_t *dad);
55 
58 
59 SOFIAPUBFUN msg_pub_t *msg_public(msg_t const *msg, void *tag);
61 SOFIAPUBFUN msg_mclass_t const *msg_mclass(msg_t const *msg);
62 
63 SOFIAPUBFUN int msg_extract(msg_t *msg);
64 SOFIAPUBFUN unsigned msg_extract_errors(msg_t const *msg);
65 SOFIAPUBFUN int msg_is_complete(msg_t const *msg);
66 SOFIAPUBFUN int msg_has_error(msg_t const *msg);
68 
70 SOFIAPUBFUN int msg_prepare(msg_t *msg);
72 SOFIAPUBFUN int msg_is_prepared(msg_t const *msg);
73 
74 SOFIAPUBFUN usize_t msg_size(msg_t const *msg);
75 SOFIAPUBFUN usize_t msg_maxsize(msg_t *msg, usize_t maxsize);
76 
78 #define msg_home(h) ((su_home_t*)(h))
79 
86 };
87 
88 SOFIAPUBFUN int msg_is_streaming(msg_t const *msg);
90 
91 SOFIAPUBFUN unsigned msg_mark_as_complete(msg_t *msg, unsigned mask);
92 
93 SOFIAPUBFUN unsigned msg_get_flags(msg_t const *msg, unsigned mask);
94 SOFIAPUBFUN unsigned msg_set_flags(msg_t *msg, unsigned mask);
95 SOFIAPUBFUN unsigned msg_zap_flags(msg_t *msg, unsigned mask);
96 
100  MSG_FLG_COMPACT = (1<<0),
102  MSG_FLG_CANONIC = (1<<1),
107 
111  MSG_FLG_MAILBOX = (1<<4),
112 
115 
119 
121  MSG_FLG_THRDSAFE = (1<<15),
122 
123  MSG_FLG_USERMASK = (1<<16) - 1
124 };
125 
129  MSG_FLG_HEADERS = (1<<16),
131  MSG_FLG_BODY = (1<<17),
133  MSG_FLG_CHUNKS = (1<<18),
135  MSG_FLG_TRAILERS = (1<<19),
137  MSG_FLG_FRAGS = (1<<20),
139  MSG_FLG_COMPLETE = (1<<24),
140 
142  MSG_FLG_ERROR = (1<<25),
144  MSG_FLG_TOOLARGE = (1<<26),
146  MSG_FLG_TRUNC = (1<<27),
148  MSG_FLG_TIMEOUT = (1<<28),
149 
150  MSG_FLG_PARSERMASK = ((-1) ^ ((1<<16) - 1))
151 };
152 
153 #define MSG_DO_COMPACT MSG_FLG_COMPACT
154 #define MSG_DO_CANONIC MSG_FLG_CANONIC
155 #define MSG_DO_EXTRACT_COPY MSG_FLG_EXTRACT_COPY
156 
158 #define MSG_FLAGS(f, v) (((f) & (v)) == v)
159 
160 #define MSG_IS_COMPACT(f) MSG_FLAGS((f), MSG_FLG_COMPACT)
161 #define MSG_IS_CANONIC(f) MSG_FLAGS((f), MSG_FLG_CANONIC)
162 #define MSG_IS_EXTRACT_COPY(f) MSG_FLAGS((f), MSG_FLG_EXTRACT_COPY)
163 #define MSG_IS_COMMA_LISTS(f) MSG_FLAGS((f), MSG_FLG_COMMA_LISTS)
164 #define MSG_IS_MAILBOX(f) MSG_FLAGS((f), MSG_FLG_MAILBOX)
165 
166 #define MSG_HAS_COMPLETE(f) MSG_FLAGS((f), MSG_FLG_COMPLETE)
167 #define MSG_HAS_ERROR(f) MSG_FLAGS((f), MSG_FLG_ERROR)
168 
169 #define MSG_IS_COMPLETE(mo) (((mo)->msg_flags & MSG_FLG_COMPLETE) != 0)
170 
171 SOFIA_END_DECLS
172 
173 #endif /* MSG_H */
void msg_unprepare(msg_t *msg)
Clear 'prepared' flag.
Definition: msg_parser.c:1568
unsigned msg_set_flags(msg_t *msg, unsigned mask)
Set message flags.
Definition: msg_parser.c:96
msg_header_t ** msg_chain_head(msg_t const *msg)
Return head of the fragment chain.
Definition: msg_parser.c:1875
int msg_is_streaming(msg_t const *msg)
Test if streaming is in progress.
Definition: msg_parser.c:108
msg_streaming_status
Streaming state of a msg_t object.
Definition: msg.h:81
@ msg_start_streaming
Enable streaming.
Definition: msg.h:85
@ msg_stop_streaming
Disable streaming.
Definition: msg.h:83
int msg_is_prepared(msg_t const *msg)
Return true if message is prepared.
Definition: msg_parser.c:1574
void msg_set_streaming(msg_t *msg, enum msg_streaming_status what)
Enable/disable streaming.
Definition: msg_parser.c:114
char * msg_as_string(su_home_t *home, msg_t *msg, msg_pub_t *pub, int flags, size_t *return_len)
Convert a message to a string.
Definition: msg_parser.c:1788
msg_flg_user
Flags controlling parser/printer.
Definition: msg.h:98
@ MSG_FLG_EXTRACT_COPY
Cache a copy of headers when parsing.
Definition: msg.h:104
@ MSG_FLG_STREAMING
Enable streaming - parser gives completed message fragments when they are ready to upper layers.
Definition: msg.h:118
@ MSG_FLG_CHUNKING
Use multiple parts for message body.
Definition: msg.h:114
@ MSG_FLG_COMMA_LISTS
Print comma-separated lists instead of separate headers.
Definition: msg.h:106
@ MSG_FLG_COMPACT
Use compact form when printing.
Definition: msg.h:100
@ MSG_FLG_MAILBOX
Use mailbox format when parsing - in mailbox format message has no body unless Content-Length header ...
Definition: msg.h:111
@ MSG_FLG_THRDSAFE
Make messages threadsafe.
Definition: msg.h:121
@ MSG_FLG_CANONIC
Use canonic representation when printing.
Definition: msg.h:102
msg_flg_parser
Flags used by parser.
Definition: msg.h:127
@ MSG_FLG_COMPLETE
This message has been completely extracted.
Definition: msg.h:139
@ MSG_FLG_CHUNKS
Extract chunks for this message.
Definition: msg.h:133
@ MSG_FLG_TOOLARGE
This message is too large.
Definition: msg.h:144
@ MSG_FLG_TIMEOUT
This message has timeout.
Definition: msg.h:148
@ MSG_FLG_TRAILERS
Extract trailers for this message.
Definition: msg.h:135
@ MSG_FLG_FRAGS
Extract last component of this message.
Definition: msg.h:137
@ MSG_FLG_BODY
Extract body for this message.
Definition: msg.h:131
@ MSG_FLG_TRUNC
This message is truncated.
Definition: msg.h:146
@ MSG_FLG_ERROR
This message has parsing errors.
Definition: msg.h:142
@ MSG_FLG_HEADERS
Extract headers for this message.
Definition: msg.h:129
msg_pub_t * msg_object(msg_t const *msg)
Retrieve public message structure.
Definition: msg.c:183
unsigned msg_zap_flags(msg_t *msg, unsigned mask)
Clear message flags.
Definition: msg_parser.c:102
unsigned msg_get_flags(msg_t const *msg, unsigned mask)
Get message flags.
Definition: msg_parser.c:90
msg_t * msg_make(msg_mclass_t const *mc, int flags, void const *data, ssize_t len)
Parse a message.
Definition: msg_parser_util.c:1975
Types for messages and common headers.
MSG_HDR_T msg_header_t
Any protocol-specific header object.
Definition: msg_types.h:87
MSG_PUB_T msg_pub_t
Public protocol-specific message structure for accessing the message.
Definition: msg_types.h:81
Factory object for protocol messages.
Definition: msg_mclass.h:97
Message object.
Definition: msg_internal.h:59
msg_t * msg_create(msg_mclass_t const *mc, int flags)
Create a message.
Definition: msg.c:59
unsigned msg_mark_as_complete(msg_t *msg, unsigned mask)
Mark message as complete.
Definition: msg_parser.c:648
unsigned msg_extract_errors(msg_t const *msg)
Get error classification flags.
Definition: msg.c:379
void msg_destroy(msg_t *msg)
Deinitialize and free a message.
Definition: msg.c:154
usize_t msg_maxsize(msg_t *msg, usize_t maxsize)
Set the maximum size of a message.
Definition: msg_parser.c:697
msg_mclass_t const * msg_mclass(msg_t const *msg)
Retrieve message class.
Definition: msg.c:225
int msg_extract(msg_t *msg)
Extract and parse a message from internal buffer.
Definition: msg_parser.c:849
msg_t * msg_ref_create(msg_t *msg)
Increment a message reference count.
Definition: msg.c:102
msg_t * msg_dup(msg_t const *original)
Deep copy a message.
Definition: msg_header_copy.c:456
msg_t * msg_copy(msg_t *original)
Copy a message shallowly.
Definition: msg_header_copy.c:380
void msg_ref_destroy(msg_t *ref)
Destroy a reference to a message.
Definition: msg.c:143
int msg_has_error(msg_t const *msg)
Return true if message has parsing errors.
Definition: msg_parser.c:672
msg_pub_t * msg_public(msg_t const *msg, void *tag)
Retrieve public message structure of given type.
Definition: msg.c:205
void msg_set_parent(msg_t *kid, msg_t *dad)
Set a message parent.
Definition: msg.c:123
int msg_prepare(msg_t *msg)
Encode all message fragments.
Definition: msg_parser.c:1547
int msg_is_complete(msg_t const *msg)
Return true if message is complete.
Definition: msg_parser.c:663
usize_t msg_size(msg_t const *msg)
Total size of message.
Definition: msg_parser.c:681
int msg_serialize(msg_t *msg, msg_pub_t *pub)
Serialize headers into the fragment chain.
Definition: msg_parser.c:1904
SU_HOME_T su_home_t
#define SOFIAPUBFUN

Sofia-SIP 1.13.16 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.