📄 sip_protos.h
字号:
__attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinesip_status_t *sip_status_dup(su_home_t *home, sip_status_t const *hdr){ return (sip_status_t *) msg_header_dup_as(home, sip_status_class, (msg_header_t const *)hdr);}#endif/**Copy a list of @ref sip_status "status line" header structures #sip_status_t. * * The function sip_status_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 list of 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 * * status = sip_status_copy(home, sip->sip_status); * * @endcode * * @return * A pointer to newly copied header structure, or NULL upon an error. * */#if SU_HAVE_INLINEsu_inline#endifsip_status_t *sip_status_copy(su_home_t *home, sip_status_t const *hdr) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinesip_status_t *sip_status_copy(su_home_t *home, sip_status_t const *hdr) { return (sip_status_t *) msg_header_copy_as(home, sip_status_class, (msg_header_t const *)hdr); }#endif/**Make a @ref sip_status "status line" structure #sip_status_t. * * The function sip_status_make() makes a new * #sip_status_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 * * @return * A pointer to newly maked #sip_status_t header structure, or NULL upon an * error. * */#if SU_HAVE_INLINEsu_inline #endifsip_status_t *sip_status_make(su_home_t *home, char const *s) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inline sip_status_t *sip_status_make(su_home_t *home, char const *s){ return (sip_status_t *)sip_header_make(home, sip_status_class, s);}#endif/**Make a @ref sip_status "status line" from formatting result. * * Make a new #sip_status_t 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 parses the * formatting result to the structure #sip_status_t. * * @param home memory home used to allocate new header structure. * @param fmt string used as a printf()-style format * @param ... argument list for format * * @return * A pointer to newly * makes header structure, or NULL upon an error. * * @HIDE * */#if SU_HAVE_INLINEsu_inline#endifsip_status_t *sip_status_format(su_home_t *home, char const *fmt, ...) __attribute__((__malloc__, __format__ (printf, 2, 3)));#if SU_HAVE_INLINEsu_inline sip_status_t *sip_status_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_status_class, fmt, ap); va_end(ap); return (sip_status_t *)h;}#endif/** @} *//**@addtogroup sip_via * @{ *//** Parse a SIP @ref sip_via "Via header". @internal */SOFIAPUBFUN issize_t sip_via_d(su_home_t *, msg_header_t *, char *s, isize_t slen);/** Print a SIP @ref sip_via "Via header". @internal */SOFIAPUBFUN issize_t sip_via_e(char b[], isize_t bsiz, msg_header_t const *h, int flags);/**Access a SIP @ref sip_via "Via header" * structure #sip_via_t from #sip_t. * */#define sip_via(sip) \ ((sip_via_t *)msg_header_access((msg_pub_t*)(sip), sip_via_class))/**Initializer for structure #sip_via_t. * * A static #sip_via_t structure for * @ref sip_via "Via header" must be initialized with * the SIP_VIA_INIT() macro. * For instance, * @code * * sip_via_t sip_via = SIP_VIA_INIT; * * @endcode * @HI * */#define SIP_VIA_INIT() SIP_HDR_INIT(via)/**Initialize a structure #sip_via_t. * * An #sip_via_t structure for * @ref sip_via "Via header" can be initialized with the * sip_via_init() function/macro. For instance, * @code * * sip_via_t sip_via; * * sip_via_init(&sip_via); * * @endcode * @HI * */#if SU_HAVE_INLINEsu_inline sip_via_t *sip_via_init(sip_via_t x[1]){ return SIP_HEADER_INIT(x, sip_via_class, sizeof(sip_via_t));}#else#define sip_via_init(x) \ SIP_HEADER_INIT(x, sip_via_class, sizeof(sip_via_t))#endif/**Test if header object is instance of #sip_via_t. * * Check if the header class is an instance of * @ref sip_via "Via header" object and return true (nonzero), * otherwise return false (zero). * * @param header pointer to the header structure to be tested * * @retval 1 (true) if the @a header is an instance of header via * @retval 0 (false) otherwise * */#if SU_HAVE_INLINEsu_inline int sip_is_via(sip_header_t const *header){ return header && header->sh_class->hc_hash == sip_via_hash;}#elseint sip_is_via(sip_header_t const *header);#endif#define sip_via_p(h) sip_is_via((h))/**Duplicate a list of @ref sip_via "Via header" header structures #sip_via_t. * * Duplicate 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 * * via = sip_via_dup(home, sip->sip_via); * * @endcode * * @return * A pointer to the * newly duplicated #sip_via_t header structure, or NULL * upon an error. * */#if SU_HAVE_INLINEsu_inline#endifsip_via_t *sip_via_dup(su_home_t *home, sip_via_t const *hdr) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinesip_via_t *sip_via_dup(su_home_t *home, sip_via_t const *hdr){ return (sip_via_t *) msg_header_dup_as(home, sip_via_class, (msg_header_t const *)hdr);}#endif/**Copy a list of @ref sip_via "Via header" header structures #sip_via_t. * * The function sip_via_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 list of 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 * * via = sip_via_copy(home, sip->sip_via); * * @endcode * * @return * A pointer to newly copied header structure, or NULL upon an error. * */#if SU_HAVE_INLINEsu_inline#endifsip_via_t *sip_via_copy(su_home_t *home, sip_via_t const *hdr) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inlinesip_via_t *sip_via_copy(su_home_t *home, sip_via_t const *hdr) { return (sip_via_t *) msg_header_copy_as(home, sip_via_class, (msg_header_t const *)hdr); }#endif/**Make a @ref sip_via "Via header" structure #sip_via_t. * * The function sip_via_make() makes a new * #sip_via_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 * * @return * A pointer to newly maked #sip_via_t header structure, or NULL upon an * error. * */#if SU_HAVE_INLINEsu_inline #endifsip_via_t *sip_via_make(su_home_t *home, char const *s) __attribute__((__malloc__));#if SU_HAVE_INLINEsu_inline sip_via_t *sip_via_make(su_home_t *home, char const *s){ return (sip_via_t *)sip_header_make(home, sip_via_class, s);}#endif/**Make a @ref sip_via "Via header" from formatting result. * * Make a new #sip_via_t 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 parses the * formatting result to the structure #sip_via_t. * * @param home memory home used to allocate new header structure. * @param fmt string used as a printf()-style format * @param ... argument list for format * * @return * A pointer to newly * makes header structure, or NULL upon an error. * * @HIDE * */#if SU_HAVE_INLINEsu_inline#endifsip_via_t *sip_via_format(su_home_t *home, char const *fmt, ...) __attribute__((__malloc__, __format__ (printf, 2, 3)));#if SU_HAVE_INLINEsu_inline sip_via_t *sip_via_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_via_class, fmt, ap); va_end(ap); return (sip_via_t *)h;}#endif/** @} *//**@addtogroup sip_route * @{ *//** Parse a SIP @ref sip_route "Route header". @internal */SOFIAPUBFUN issize_t sip_route_d(su_home_t *, msg_header_t *, char *s, isize_t slen);/** Print a SIP @ref sip_route "Route header". @internal */SOFIAPUBFUN issize_t sip_route_e(char b[], isize_t bsiz, msg_header_t const *h, int flags);/**Access a SIP @ref sip_route "Route header" * structure #sip_route_t from #sip_t. * */#define sip_route(sip) \ ((sip_route_t *)msg_header_access((msg_pub_t*)(sip), sip_route_class))/**Initializer for structure #sip_route_t. * * A static #sip_route_t structure for * @ref sip_route "Route header" must be initialized with * the SIP_ROUTE_INIT() macro. * For instance, * @code * * sip_route_t sip_route = SIP_ROUTE_INIT; * * @endcode * @HI * */#define SIP_ROUTE_INIT() SIP_HDR_INIT(route)/**Initialize a structure #sip_route_t. * * An #sip_route_t structure for * @ref sip_route "Route header" can be initialized with the * sip_route_init() function/macro. For instance, * @code * * sip_route_t sip_route; * * sip_route_init(&sip_route); * * @endcode * @HI * */#if SU_HAVE_INLINEsu_inline sip_route_t *sip_route_init(sip_route_t x[1]){ return SIP_HEADER_INIT(x, sip_route_class, sizeof(sip_route_t));}#else#define sip_route_init(x) \ SIP_HEADER_INIT(x, sip_route_class, sizeof(sip_route_t))#endif/**Test if header object is instance of #sip_route_t. * * Check if the header class is an instance of * @ref sip_route "Route header" object and return true (nonzero), * otherwise return false (zero). * * @param header pointer to the header structure to be tested * * @retval 1 (true) if the @a header is an instance of header route * @retval 0 (false) otherwise * */#if SU_HAVE_INLINEsu_inline int sip_is_route(sip_header_t const *header){ return header && header->sh_class->hc_hash == sip_route_hash;}#elseint sip_is_route(sip_header_t const *header);#endif#define sip_route_p(h) sip_is_route((h))/**Duplicate a list of @ref sip_route "Route header" header structures #sip_route_t. * * Duplicate 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 * * route = sip_route_dup(home, sip->sip_route); * * @endcode * * @return * A pointer to the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -