msg
1.12.11
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef MSG_H 00026 00027 #define MSG_H 00028 00037 #include <sofia-sip/msg_types.h> 00038 #include <sofia-sip/su_alloc.h> 00039 00040 SOFIA_BEGIN_DECLS 00041 00042 SOFIAPUBFUN msg_t *msg_create(msg_mclass_t const *mc, int flags); 00043 SOFIAPUBFUN void msg_destroy(msg_t *); 00044 00045 SOFIAPUBFUN msg_t *msg_copy(msg_t *); 00046 SOFIAPUBFUN msg_t *msg_dup(msg_t const *); 00047 00048 SOFIAPUBFUN msg_t *msg_make(msg_mclass_t const *mc, int flags, 00049 void const *data, ssize_t len); 00050 SOFIAPUBFUN char *msg_as_string(su_home_t *home, 00051 msg_t *msg, msg_pub_t *pub, int flags, 00052 size_t *return_len); 00053 00054 SOFIAPUBFUN void msg_set_parent(msg_t *kid, msg_t *dad); 00055 00056 SOFIAPUBFUN msg_t *msg_ref_create(msg_t *); 00057 SOFIAPUBFUN void msg_ref_destroy(msg_t *); 00058 00059 SOFIAPUBFUN msg_pub_t *msg_public(msg_t const *msg, void *tag); 00060 SOFIAPUBFUN msg_pub_t *msg_object(msg_t const *msg); 00061 SOFIAPUBFUN msg_mclass_t const *msg_mclass(msg_t const *msg); 00062 00063 SOFIAPUBFUN int msg_extract(msg_t *msg); 00064 SOFIAPUBFUN unsigned msg_extract_errors(msg_t const *msg); 00065 SOFIAPUBFUN int msg_is_complete(msg_t const *msg); 00066 SOFIAPUBFUN int msg_has_error(msg_t const *msg); 00067 SOFIAPUBFUN msg_header_t **msg_chain_head(msg_t const *msg); 00068 00069 SOFIAPUBFUN int msg_serialize(msg_t *msg, msg_pub_t *mo); 00070 SOFIAPUBFUN int msg_prepare(msg_t *msg); 00071 SOFIAPUBFUN void msg_unprepare(msg_t *msg); 00072 SOFIAPUBFUN int msg_is_prepared(msg_t const *msg); 00073 00074 SOFIAPUBFUN usize_t msg_size(msg_t const *msg); 00075 SOFIAPUBFUN usize_t msg_maxsize(msg_t *msg, usize_t maxsize); 00076 00078 #define msg_home(h) ((su_home_t*)(h)) 00079 00081 enum msg_streaming_status { 00083 msg_stop_streaming = 0, 00085 msg_start_streaming = 1 00086 }; 00087 00088 SOFIAPUBFUN int msg_is_streaming(msg_t const *msg); 00089 SOFIAPUBFUN void msg_set_streaming(msg_t *msg, enum msg_streaming_status what); 00090 00091 SOFIAPUBFUN unsigned msg_mark_as_complete(msg_t *msg, unsigned mask); 00092 00093 SOFIAPUBFUN unsigned msg_get_flags(msg_t const *msg, unsigned mask); 00094 SOFIAPUBFUN unsigned msg_set_flags(msg_t *msg, unsigned mask); 00095 SOFIAPUBFUN unsigned msg_zap_flags(msg_t *msg, unsigned mask); 00096 00098 enum msg_flg_user { 00100 MSG_FLG_COMPACT = (1<<0), 00102 MSG_FLG_CANONIC = (1<<1), 00104 MSG_FLG_EXTRACT_COPY = (1<<2), 00106 MSG_FLG_COMMA_LISTS = (1<<3), 00107 00111 MSG_FLG_MAILBOX = (1<<4), 00112 00114 MSG_FLG_CHUNKING = (1<<5), 00115 00118 MSG_FLG_STREAMING = (1<<6), 00119 00121 MSG_FLG_THRDSAFE = (1<<15), 00122 00123 MSG_FLG_USERMASK = (1<<16) - 1 00124 }; 00125 00127 enum msg_flg_parser { 00129 MSG_FLG_HEADERS = (1<<16), 00131 MSG_FLG_BODY = (1<<17), 00133 MSG_FLG_CHUNKS = (1<<18), 00135 MSG_FLG_TRAILERS = (1<<19), 00137 MSG_FLG_FRAGS = (1<<20), 00139 MSG_FLG_COMPLETE = (1<<24), 00140 00142 MSG_FLG_ERROR = (1<<25), 00144 MSG_FLG_TOOLARGE = (1<<26), 00146 MSG_FLG_TRUNC = (1<<27), 00148 MSG_FLG_TIMEOUT = (1<<28), 00149 00150 MSG_FLG_PARSERMASK = ((-1) ^ ((1<<16) - 1)) 00151 }; 00152 00153 #define MSG_DO_COMPACT MSG_FLG_COMPACT 00154 #define MSG_DO_CANONIC MSG_FLG_CANONIC 00155 #define MSG_DO_EXTRACT_COPY MSG_FLG_EXTRACT_COPY 00156 00158 #define MSG_FLAGS(f, v) (((f) & (v)) == v) 00159 00160 #define MSG_IS_COMPACT(f) MSG_FLAGS((f), MSG_FLG_COMPACT) 00161 #define MSG_IS_CANONIC(f) MSG_FLAGS((f), MSG_FLG_CANONIC) 00162 #define MSG_IS_EXTRACT_COPY(f) MSG_FLAGS((f), MSG_FLG_EXTRACT_COPY) 00163 #define MSG_IS_COMMA_LISTS(f) MSG_FLAGS((f), MSG_FLG_COMMA_LISTS) 00164 #define MSG_IS_MAILBOX(f) MSG_FLAGS((f), MSG_FLG_MAILBOX) 00165 00166 #define MSG_HAS_COMPLETE(f) MSG_FLAGS((f), MSG_FLG_COMPLETE) 00167 #define MSG_HAS_ERROR(f) MSG_FLAGS((f), MSG_FLG_ERROR) 00168 00169 #define MSG_IS_COMPLETE(mo) (((mo)->msg_flags & MSG_FLG_COMPLETE) != 0) 00170 00171 SOFIA_END_DECLS 00172 00173 #endif /* MSG_H */