1 /* 2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-) 3 Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 #ifndef _OSIP_TO_H_ 21 #define _OSIP_TO_H_ 22 23 #include <osipparser2/headers/osip_from.h> 24 25 /** 26 * @file osip_to.h 27 * @brief oSIP osip_to header definition. 28 */ 29 30 /** 31 * @defgroup oSIP_TO oSIP to header definition. 32 * @ingroup oSIP_HEADERS 33 * @{ 34 */ 35 36 /** 37 * Structure for To headers. 38 * @var osip_to_t 39 */ 40 typedef osip_from_t osip_to_t; 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 #ifndef MINISIZE 47 /** 48 * Allocate a To element. 49 * @param header The element to work on. 50 */ 51 int osip_to_init(osip_to_t **header); 52 /** 53 * Free a To element. 54 * @param header The element to work on. 55 */ 56 void osip_to_free(osip_to_t *header); 57 /** 58 * Parse a To element. 59 * @param header The element to work on. 60 * @param hvalue The string to parse. 61 */ 62 int osip_to_parse(osip_to_t *header, const char *hvalue); 63 /** 64 * Get a string representation of a To element. 65 * @param header The element to work on. 66 * @param dest A pointer on the new allocated string. 67 */ 68 int osip_to_to_str(const osip_to_t *header, char **dest); 69 /** 70 * Clone a To element. 71 * @param header The element to work on. 72 * @param dest A pointer on the copy of the element. 73 */ 74 int osip_to_clone(const osip_to_t *header, osip_to_t **dest); 75 /** 76 * Check if the tags in the To headers match. 77 * NOTE: THIS IS AN INTERNAL METHOD ONLY 78 * @param to1 The first To header. 79 * @param to2 The second To header. 80 */ 81 int osip_to_tag_match(osip_to_t *to1, osip_to_t *to2); 82 #else 83 #define osip_to_init osip_from_init 84 #define osip_to_free osip_from_free 85 #define osip_to_parse osip_from_parse 86 #define osip_to_to_str osip_from_to_str 87 #define osip_to_clone osip_from_clone 88 #define osip_to_tag_match osip_from_tag_match 89 #endif 90 /** 91 * Set the displayname in the To element. 92 * @param header The element to work on. 93 * @param value The value of the element. 94 */ 95 #define osip_to_set_displayname(header, value) osip_from_set_displayname((osip_from_t *) header, value) 96 /** 97 * Get the displayname from a To header. 98 * @param header The element to work on. 99 */ 100 #define osip_to_get_displayname(header) osip_from_get_displayname((osip_from_t *) header) 101 /** 102 * Set the url in the To element. 103 * @param header The element to work on. 104 * @param url The value of the element. 105 */ 106 #define osip_to_set_url(header, url) osip_from_set_url((osip_from_t *) header, url) 107 /** 108 * Get the url from a To header. 109 * @param header The element to work on. 110 */ 111 #define osip_to_get_url(header) osip_from_get_url((osip_from_t *) header) 112 /** 113 * Get a header parameter from a To element. 114 * @param header The element to work on. 115 * @param pos The index of the element to get. 116 * @param dest A pointer on the element found. 117 */ 118 #define osip_to_param_get(header, pos, dest) osip_from_param_get((osip_from_t *) header, pos, dest) 119 /** 120 * Find a header parameter in a To element. 121 * @param header The element to work on. 122 * @param name The token name to search. 123 * @param dest A pointer on the element found. 124 */ 125 #define osip_to_param_get_byname(header, name, dest) osip_generic_param_get_byname((&(header)->gen_params), name, dest) 126 /** 127 * Allocate and add a generic parameter element in a list. 128 * @param header The element to work on. 129 * @param name The token name. 130 * @param value The token value. 131 */ 132 #define osip_to_param_add(header, name, value) osip_generic_param_add((&(header)->gen_params), name, value) 133 134 /** 135 * Allocate and add a tag parameter element in a list. 136 * @param header The element to work on. 137 * @param value The token value. 138 */ 139 #define osip_to_set_tag(header, value) osip_generic_param_add((&(header)->gen_params), osip_strdup("tag"), value) 140 /** 141 * Find a tag parameter in a To element. 142 * @param header The element to work on. 143 * @param dest A pointer on the element found. 144 */ 145 #define osip_to_get_tag(header, dest) osip_generic_param_get_byname((&(header)->gen_params), "tag", dest) 146 147 #ifndef DOXYGEN /* avoid DOXYGEN warning */ 148 /* Compare the username, host and tag part of the two froms */ 149 #define osip_to_compare(header1, header2) osip_from_compare((osip_from_t *) header1, (osip_from_t *) header2) 150 #endif 151 152 #ifdef __cplusplus 153 } 154 #endif 155 156 /** @} */ 157 158 #endif 159