📄 sip_protos.h
字号:
/* -*- C -*- * * This file is part of the Sofia-SIP package * * Copyright (C) 2005 Nokia Corporation. * * Contact: Pekka Pessi <pekka.pessi@nokia.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */#ifndef SIP_PROTOS_H /** Defined when sip_protos.h has been included. */#define SIP_PROTOS_H /**@file sip_protos.h * * SIP prototypes and macros for each header. * * This file is automatically generated from <sip.h> by msg_parser.awk. * * @author Pekka Pessi <Pekka.Pessi@nokia.com>. * */#include <sofia-sip/su_config.h>#ifndef SIP_HEADER_H#include <sofia-sip/sip_header.h>#endif#ifndef SIP_HCLASSES_H#include <sofia-sip/sip_hclasses.h>#endifSOFIA_BEGIN_DECLS#if SU_HAVE_INLINE/** Get SIP structure from msg. */su_inlinesip_t *sip_object(msg_t const *msg){ return (sip_t *)msg_public(msg, SIP_PROTOCOL_TAG);}/** Insert a (list of) header(s) to the header structure and fragment chain. * * The function @c sip_header_insert() inserts header or list of headers * into a SIP message. It also inserts them into the the message fragment * chain, if it exists. * * When inserting headers into the fragment chain, a request (or status) is * inserted first and replaces the existing request (or status). The Via * headers are inserted after the request or status, and rest of the headers * after request, status, or Via headers. * * If the header is a singleton, existing headers with the same class are * removed. * * @param msg message owning the fragment chain * @param sip SIP message structure to which header is added * @param h list of header(s) to be added */su_inlineint sip_header_insert(msg_t *msg, sip_t *sip, sip_header_t *h){ return msg_header_insert(msg, (msg_pub_t *)sip, (msg_header_t *)h);}/** Remove a header from a SIP message. */ su_inlineint sip_header_remove(msg_t *msg, sip_t *sip, sip_header_t *h){ return msg_header_remove(msg, (msg_pub_t *)sip, (msg_header_t *)h);}/** Return name of the header. */su_inlinechar const *sip_header_name(sip_header_t const *h, int compact){ if (compact && h->sh_class->hc_short[0]) return h->sh_class->hc_short; else return h->sh_class->hc_name;}/** Return data after header structure. */su_inlinevoid *sip_header_data(sip_header_t *h){ return h && h != SIP_NONE ? h->sh_class->hc_size + (char *)h : NULL;}#elsesip_t *sip_object(msg_t *msg);int sip_header_insert(msg_t *msg, sip_t *sip, sip_header_t *h);int sip_header_remove(msg_t *msg, sip_t *sip, sip_header_t *h);char const *sip_header_name(sip_header_t const *h, int compact);void *sip_header_data(sip_header_t *h);#endif/**@addtogroup sip_request * @{ *//** Parse a request line. @internal */int sip_request_d(su_home_t *home, msg_header_t *h, char *s, int slen);/** Print a request line. @internal */int sip_request_e(char b[], int bsiz, msg_header_t const *h, int flags);/**Access a sip_request_t from sip_t. * */#define sip_request(sip) \ ((sip_request_t *)msg_header_access((msg_pub_t*)(sip), sip_request_class))/**Initializer for structure sip_request_t. * * A static sip_request_t structure must be initialized. * The SIP_REQUEST_INIT() macro provides initialization value. * For instance, * @code * * sip_request_t sip_request = SIP_REQUEST_INIT; * * @endcode * @HI */#define SIP_REQUEST_INIT() SIP_HDR_INIT(request)/**Initialize a structure sip_request_t. * * An sip_request_t structure can be initialized with the * sip_request_init() function/macro. For instance, * @code * * sip_request_t sip_request; * * sip_request_init(&sip_request); * * @endcode * @HI */#if SU_HAVE_INLINEsu_inline sip_request_t *sip_request_init(sip_request_t x[1]){ return SIP_HEADER_INIT(x, sip_request_class, sizeof(sip_request_t));}#else#define sip_request_init(x) \ SIP_HEADER_INIT(x, sip_request_class, sizeof(sip_request_t))#endif/**Test if header object is instance of sip_request_t. * * The function sip_is_request() returns true (nonzero) if * the header class is an instance of request line * object and false (zero) otherwise. * * @param header pointer to the header structure to be tested * * @return * The function sip_is_request() returns true (nonzero) if * the header object is an instance of header request and * false (zero) otherwise. */#if SU_HAVE_INLINEsu_inline int sip_is_request(sip_header_t const *header){ return header && header->sh_class->hc_hash == sip_request_hash;}#elseint sip_is_request(sip_header_t const *header);#endif#define sip_request_p(h) sip_is_request((h))/**Duplicate (deep copy) @c sip_request_t. * * The function sip_request_dup() duplicates a header * structure @a hdr. If the header structure @a hdr * contains a reference (@c hdr->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 hdr 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 * * request = sip_request_dup(home, sip->sip_request); * * @endcode * * @return * The function sip_request_dup() returns a pointer to the * newly duplicated sip_request_t header structure, or NULL * upon an error. */#if SU_HAVE_INLINEsu_inline#endifsip_request_t *sip_request_dup(su_home_t *home, sip_request_t const *hdr) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinesip_request_t *sip_request_dup(su_home_t *home, sip_request_t const *hdr){ return (sip_request_t *) msg_header_dup_as(home, sip_request_class, (msg_header_t const *)hdr);}#endif/**Copy a sip_request_t header structure. * * The function sip_request_copy() copies a header structure @a * hdr. If the header structure @a hdr contains a reference (@c * hdr->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 hdr. * * @param home memory home used to allocate new structure * @param hdr pointer to the header structure to be copied * * 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 hdr header, including the encoding of the * old header, if present. * * @par Example * @code * * request = sip_request_copy(home, sip->sip_request); * * @endcode * * @return * The function sip_request_copy() returns a pointer to * newly copied header structure, or NULL upon an error. */#if SU_HAVE_INLINEsu_inline#endifsip_request_t *sip_request_copy(su_home_t *home, sip_request_t const *hdr) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinesip_request_t *sip_request_copy(su_home_t *home, sip_request_t const *hdr) { return (sip_request_t *) msg_header_copy_as(home, sip_request_class, (msg_header_t const *)hdr); }#endif/**Make a header structure sip_request_t. * * The function sip_request_make() makes a new * sip_request_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 * sip_header_make(). * * @return * The function sip_request_make() returns a pointer to * newly maked sip_request_t header structure, or NULL upon * an error. */#if SU_HAVE_INLINEsu_inline #endifsip_request_t *sip_request_make(su_home_t *home, char const *s) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inline sip_request_t *sip_request_make(su_home_t *home, char const *s){ return (sip_request_t *)sip_header_make(home, sip_request_class, s);}#endif/**Make a request line from formatting result. * * The function sip_request_format() makes a new * request line 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 sip_request_format() returns a pointer to newly * makes header structure, or NULL upon an error. * * @HIDE */#if SU_HAVE_INLINEsu_inline#endifsip_request_t *sip_request_format(su_home_t *home, char const *fmt, ...) __attribute__((__malloc__, __format__ (printf, 2, 3)));#if SU_HAVE_INLINEsu_inline sip_request_t *sip_request_format(su_home_t *home, char const *fmt, ...){ sip_header_t *h; va_list ap; va_start(ap, fmt); h = sip_header_vformat(home, sip_request_class, fmt, ap); va_end(ap); return (sip_request_t *)h;}#endif/** @} *//**@addtogroup sip_status * @{ *//** Parse a status line. @internal */int sip_status_d(su_home_t *home, msg_header_t *h, char *s, int slen);/** Print a status line. @internal */int sip_status_e(char b[], int bsiz, msg_header_t const *h, int flags);/**Access a sip_status_t from sip_t. * */#define sip_status(sip) \ ((sip_status_t *)msg_header_access((msg_pub_t*)(sip), sip_status_class))/**Initializer for structure sip_status_t. * * A static sip_status_t structure must be initialized. * The SIP_STATUS_INIT() macro provides initialization value. * For instance, * @code * * sip_status_t sip_status = SIP_STATUS_INIT; * * @endcode * @HI */#define SIP_STATUS_INIT() SIP_HDR_INIT(status)/**Initialize a structure sip_status_t. * * An sip_status_t structure can be initialized with the * sip_status_init() function/macro. For instance, * @code * * sip_status_t sip_status; * * sip_status_init(&sip_status); * * @endcode * @HI */#if SU_HAVE_INLINEsu_inline sip_status_t *sip_status_init(sip_status_t x[1]){ return SIP_HEADER_INIT(x, sip_status_class, sizeof(sip_status_t));}#else#define sip_status_init(x) \ SIP_HEADER_INIT(x, sip_status_class, sizeof(sip_status_t))#endif/**Test if header object is instance of sip_status_t. * * The function sip_is_status() returns true (nonzero) if * the header class is an instance of status line * object and false (zero) otherwise. * * @param header pointer to the header structure to be tested * * @return * The function sip_is_status() returns true (nonzero) if * the header object is an instance of header status and * false (zero) otherwise. */#if SU_HAVE_INLINEsu_inline int sip_is_status(sip_header_t const *header){ return header && header->sh_class->hc_hash == sip_status_hash;}#elseint sip_is_status(sip_header_t const *header);#endif#define sip_status_p(h) sip_is_status((h))/**Duplicate (deep copy) @c sip_status_t. * * The function sip_status_dup() duplicates a header * structure @a hdr. If the header structure @a hdr * contains a reference (@c hdr->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 hdr 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 * * status = sip_status_dup(home, sip->sip_status); * * @endcode * * @return * The function sip_status_dup() returns a pointer to the * newly duplicated sip_status_t header structure, or NULL * upon an error. */#if SU_HAVE_INLINEsu_inline#endifsip_status_t *sip_status_dup(su_home_t *home, sip_status_t const *hdr) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inline
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -