⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msg_protos.h

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 H
📖 第 1 页 / 共 2 页
字号:
 */#if SU_HAVE_INLINEsu_inline#endifmsg_error_t *msg_error_format(su_home_t *home, char const *fmt, ...)     __attribute__((__malloc__, __format__ (printf, 2, 3)));#if SU_HAVE_INLINEsu_inline msg_error_t *msg_error_format(su_home_t *home, char const *fmt, ...){  msg_header_t *h;  va_list ap;    va_start(ap, fmt);  h = msg_header_vformat(home, msg_error_class, fmt, ap);  va_end(ap);   return (msg_error_t*)h;}#endif/** @} *//* Declare internal prototypes for separator line between headers and body *//**@addtogroup msg_separator  * @{  */enum {   /** Hash of separator line between headers and body. @internal */  msg_separator_hash = -5 };/** Parse a separator line between headers and body. @internal */MSG_DLL msg_parse_f msg_separator_d;/** Print a separator line between headers and body. @internal */MSG_DLL msg_print_f msg_separator_e;/**Header class for separator line between headers and body. *  * The header class msg_separator_class defines how a  * separator line between headers and body header is parsed and printed.  It also * contains methods used by message parser and other functions * to manipulate the msg_separator_t header structure. *  */MSG_DLL extern msg_hclass_t msg_separator_class[];/**Initializer for structure msg_separator_t. *  * A static msg_separator_t structure must be initialized * with the MSG_SEPARATOR_INIT() macro. For instance, * @code  *  *  msg_separator_t msg_separator = MSG_SEPARATOR_INIT; *  * @endcode * @HI */#define MSG_SEPARATOR_INIT() MSG_HDR_INIT(separator)/**Initialize a structure msg_separator_t. *  * An msg_separator_t structure can be initialized with the * msg_separator_init() function/macro. For instance, * @code *  *  msg_separator_t msg_separator; *  *  msg_separator_init(&msg_separator); *  * @endcode *  * @param x pointer to msg_separator_t structure  */#if SU_HAVE_INLINEsu_inline msg_separator_t *msg_separator_init(msg_separator_t x[1]){  return MSG_HEADER_INIT(x, msg_separator_class, sizeof(msg_separator_t));}#else#define msg_separator_init(x) \  MSG_HEADER_INIT(x, msg_separator_class, sizeof(msg_separator_t))#endif/**Test if header object is instance of msg_separator_t. *  * The function msg_is_separator() returns true (nonzero) if * the header class is an instance of separator line between headers and body * object and false (zero) otherwise. *  * @param header pointer to the header structure to be tested *  * @return * The function msg_is_separator() returns true (nonzero) if * the header object is an instance of header separator and * false (zero) otherwise. */#if SU_HAVE_INLINEsu_inline int msg_is_separator(msg_header_t const *header){  msg_generic_t const *h = (msg_generic_t *)header;  return h && h->g_common->h_class->hc_hash == msg_separator_hash;}#elseint msg_is_separator(msg_header_t const *header);#endif/**Duplicate (deep copy) @c msg_separator_t. *  * The function msg_separator_dup() duplicates a header structure @a * header. If the header structure @a header contains a reference * (@c header->x_next) to a list of headers, all the headers in the * list are duplicated, too. *  * @param home   memory home used to allocate new structure * @param header header structure to be duplicated *  * When duplicating, all parameter lists and non-constant strings * attached to the header are copied, too. The function uses given * memory @a home to allocate all the memory areas used to copy the * header. *  * @par Example * @code *  *   separator = msg_separator_dup(home, msg->msg_separator); *  * @endcode *  * @return * The function msg_separator_dup() returns a pointer to the * newly duplicated msg_separator_t header structure, or NULL * upon an error. */#if SU_HAVE_INLINEsu_inline#endifmsg_separator_t *msg_separator_dup(su_home_t *home, 				 msg_separator_t const *header)     __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinemsg_separator_t *msg_separator_dup(su_home_t *home, 				 msg_separator_t const *header){  return (msg_separator_t *)    msg_header_dup_as(home, msg_separator_class, (msg_header_t const *)header); }#endif/**Copy a msg_separator_t header structure. *  * The function msg_separator_copy() copies a header structure @a * header. If the header structure @a header contains a reference * (@c header->h_next) to a list of headers, all the headers in that * list are copied, too. The function uses given memory @a home to * allocate all the memory areas used to copy the header structure * @a header. *  * @param home    memory home used to allocate new structure * @param header  pointer to the header structure to be duplicated *  * When copying, only the header structure and parameter lists * attached to it are duplicated. The new header structure retains * all the references to the strings within the old @a header, * including the encoding of the old header, if present. *  * @par Example * @code *  *   separator = msg_separator_copy(home, msg->msg_separator); *  * @endcode *  * @return * The function msg_separator_copy() returns a pointer to * newly copied header structure, or NULL upon an error. */#if SU_HAVE_INLINEsu_inline#endifmsg_separator_t *msg_separator_copy(su_home_t *home, 				  msg_separator_t const *header)     __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinemsg_separator_t *msg_separator_copy(su_home_t *home, 				  msg_separator_t const *header){  return (msg_separator_t *)    msg_header_copy_as(home, msg_separator_class, (msg_header_t const *)header); }#endif/**Make a header structure msg_separator_t. *  * The function msg_separator_make() makes a new * msg_separator_t header structure.  It allocates a new * header structure, and decodes the string @a s as the * value of the structure. *  * @param home memory home used to allocate new header structure. * @param s    string to be decoded as value of the new header structure *  * @note This function is usually implemented as a macro calling * msg_header_make(). *  * @return * The function msg_separator_make() returns a pointer to * newly maked msg_separator_t header structure, or NULL upon * an error. */#if SU_HAVE_INLINEsu_inline msg_separator_t *msg_separator_make(su_home_t *home, char const *s){  return (msg_separator_t*)msg_header_make(home, msg_separator_class, s);}#elsemsg_separator_t *msg_separator_make(su_home_t *home, char const *s)     __attribute__((__malloc__));#endif/**Make a separator line between headers and body from formatting result. *  * The function msg_separator_format() makes a new * separator line between headers and body object using formatting result as its * value.  The function first prints the arguments according to * the format @a fmt specified.  Then it allocates a new header * structure, and uses the formatting result as the header * value. *  * @param home   memory home used to allocate new header structure. * @param fmt    string used as a printf()-style format * @param ...    argument list for format *  * @note This function is usually implemented as a macro calling * msg_header_format(). *  * @return * The function msg_separator_format() returns a pointer to newly * makes header structure, or NULL upon an error. *  * @HIDE */#if SU_HAVE_INLINEsu_inline#endifmsg_separator_t *msg_separator_format(su_home_t *home, char const *fmt, ...)     __attribute__((__malloc__, __format__ (printf, 2, 3)));#if SU_HAVE_INLINEsu_inline msg_separator_t *msg_separator_format(su_home_t *home, char const *fmt, ...){  msg_header_t *h;  va_list ap;    va_start(ap, fmt);  h = msg_header_vformat(home, msg_separator_class, fmt, ap);  va_end(ap);   return (msg_separator_t*)h;}#endif/** @} *//* Declare internal prototypes for message payload *//**@addtogroup msg_payload  * @{  */enum {   /** Hash of message payload. @internal */  msg_payload_hash = -6 };/** Parse a message payload. @internal */MSG_DLL msg_parse_f msg_payload_d;/** Print a message payload. @internal */MSG_DLL msg_print_f msg_payload_e;/**Header class for message payload. *  * The header class msg_payload_class defines how a  * message payload header is parsed and printed.  It also * contains methods used by message parser and other functions * to manipulate the msg_payload_t header structure. *  */MSG_DLL extern msg_hclass_t msg_payload_class[];/**Initializer for structure msg_payload_t. *  * A static msg_payload_t structure must be initialized * with the MSG_PAYLOAD_INIT() macro. For instance, * @code  *  *  msg_payload_t msg_payload = MSG_PAYLOAD_INIT; *  * @endcode * @HI */#define MSG_PAYLOAD_INIT() MSG_HDR_INIT(payload)/**Initialize a structure msg_payload_t. *  * An msg_payload_t structure can be initialized with the * msg_payload_init() function/macro. For instance, * @code *  *  msg_payload_t msg_payload; *  *  msg_payload_init(&msg_payload); *  * @endcode *  * @param x pointer to msg_payload_t structure  */#if SU_HAVE_INLINEsu_inline msg_payload_t *msg_payload_init(msg_payload_t x[1]){  return MSG_HEADER_INIT(x, msg_payload_class, sizeof(msg_payload_t));}#else#define msg_payload_init(x) \  MSG_HEADER_INIT(x, msg_payload_class, sizeof(msg_payload_t))#endif/**Test if header object is instance of msg_payload_t. *  * The function msg_is_payload() returns true (nonzero) if * the header class is an instance of message payload * object and false (zero) otherwise. *  * @param header pointer to the header structure to be tested *  * @return * The function msg_is_payload() returns true (nonzero) if * the header object is an instance of header payload and * false (zero) otherwise. */#if SU_HAVE_INLINEsu_inline int msg_is_payload(msg_header_t const *header){  msg_generic_t const *h = (msg_generic_t *)header;  return h && h->g_common->h_class->hc_hash == msg_payload_hash;}#elseint msg_is_payload(msg_header_t const *header);#endif/**Duplicate (deep copy) @c msg_payload_t. *  * The function msg_payload_dup() duplicates a header structure @a * header. If the header structure @a header contains a reference * (@c header->x_next) to a list of headers, all the headers in the * list are duplicated, too. *  * @param home   memory home used to allocate new structure * @param header header structure to be duplicated *  * When duplicating, all parameter lists and non-constant strings * attached to the header are copied, too. The function uses given * memory @a home to allocate all the memory areas used to copy the * header. *  * @par Example * @code *  *   payload = msg_payload_dup(home, msg->msg_payload); *  * @endcode *  * @return * The function msg_payload_dup() returns a pointer to the * newly duplicated msg_payload_t header structure, or NULL * upon an error. */#if SU_HAVE_INLINEsu_inline#endifmsg_payload_t *msg_payload_dup(su_home_t *home, 				 msg_payload_t const *header)     __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinemsg_payload_t *msg_payload_dup(su_home_t *home, 				 msg_payload_t const *header){  return (msg_payload_t *)    msg_header_dup_as(home, msg_payload_class, (msg_header_t const *)header); }#endif/**Copy a msg_payload_t header structure. *  * The function msg_payload_copy() copies a header structure @a * header. If the header structure @a header contains a reference * (@c header->h_next) to a list of headers, all the headers in that * list are copied, too. The function uses given memory @a home to * allocate all the memory areas used to copy the header structure * @a header. *  * @param home    memory home used to allocate new structure * @param header  pointer to the header structure to be duplicated *  * When copying, only the header structure and parameter lists * attached to it are duplicated. The new header structure retains * all the references to the strings within the old @a header, * including the encoding of the old header, if present. *  * @par Example * @code *  *   payload = msg_payload_copy(home, msg->msg_payload); *  * @endcode *  * @return * The function msg_payload_copy() returns a pointer to * newly copied header structure, or NULL upon an error. */#if SU_HAVE_INLINEsu_inline#endifmsg_payload_t *msg_payload_copy(su_home_t *home, 				  msg_payload_t const *header)     __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinemsg_payload_t *msg_payload_copy(su_home_t *home, 				  msg_payload_t const *header){  return (msg_payload_t *)    msg_header_copy_as(home, msg_payload_class, (msg_header_t const *)header); }#endif/**Make a header structure msg_payload_t. *  * The function msg_payload_make() makes a new * msg_payload_t header structure.  It allocates a new * header structure, and decodes the string @a s as the * value of the structure. *  * @param home memory home used to allocate new header structure. * @param s    string to be decoded as value of the new header structure *  * @note This function is usually implemented as a macro calling * msg_header_make(). *  * @return * The function msg_payload_make() returns a pointer to * newly maked msg_payload_t header structure, or NULL upon * an error. */#if SU_HAVE_INLINEsu_inline msg_payload_t *msg_payload_make(su_home_t *home, char const *s){  return (msg_payload_t*)msg_header_make(home, msg_payload_class, s);}#elsemsg_payload_t *msg_payload_make(su_home_t *home, char const *s)     __attribute__((__malloc__));#endif/**Make a message payload from formatting result. *  * The function msg_payload_format() makes a new * message payload object using formatting result as its * value.  The function first prints the arguments according to * the format @a fmt specified.  Then it allocates a new header * structure, and uses the formatting result as the header * value. *  * @param home   memory home used to allocate new header structure. * @param fmt    string used as a printf()-style format * @param ...    argument list for format *  * @note This function is usually implemented as a macro calling * msg_header_format(). *  * @return * The function msg_payload_format() returns a pointer to newly * makes header structure, or NULL upon an error. *  * @HIDE */#if SU_HAVE_INLINEsu_inline#endifmsg_payload_t *msg_payload_format(su_home_t *home, char const *fmt, ...)     __attribute__((__malloc__, __format__ (printf, 2, 3)));#if SU_HAVE_INLINEsu_inline msg_payload_t *msg_payload_format(su_home_t *home, char const *fmt, ...){  msg_header_t *h;  va_list ap;    va_start(ap, fmt);  h = msg_header_vformat(home, msg_payload_class, fmt, ap);  va_end(ap);   return (msg_payload_t*)h;}#endif/** @} */SOFIA_END_DECLS#endif /** !defined(MSG_PROTOS_H) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -