1 /* 2 * Copyright (C) 2006 iptego GmbH 3 * 4 * This file is part of SEMS, a free SIP media server. 5 * 6 * SEMS is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. This program is released under 10 * the GPL with the additional exemption that compiling, linking, 11 * and/or using OpenSSL is allowed. 12 * 13 * For a license to use the SEMS software under conditions 14 * other than those described here, or to purchase support for this 15 * software, please contact iptel.org by e-mail at the following addresses: 16 * info@iptel.org 17 * 18 * SEMS is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 */ 27 #ifndef _AmUriParser_h_ 28 #define _AmUriParser_h_ 29 30 #include <string> 31 #include <map> 32 using std::map; 33 using std::string; 34 35 struct AmUriParser { 36 string display_name; 37 string uri; 38 39 string uri_user; 40 string uri_host; 41 string uri_port; 42 string uri_headers; 43 string uri_param; // <sip:user@host;uri_param> 44 // <sip:user;user_param@host> 45 46 map<string, string> params; // <sip:user;@host>;params 47 48 bool isEqual(const AmUriParser& c) const; 49 /** parse nameaddr from pos 50 @return true on success 51 @return end of current nameaddr */ 52 bool parse_contact(const string& line, size_t pos, size_t& end); 53 /** parse a name-addr @return true on success */ 54 bool parse_nameaddr(const string& line); 55 56 /** @return true on success */ 57 bool parse_uri(); 58 bool parse_params(const string& line, int& pos); 59 60 /** param_string is semicolon separated list of parameters with or without value. 61 * method can be used to add/replace param for uri and user parameters */ 62 static string add_param_to_param_list(const string& param_name, 63 const string& param_value, const string& param_list); 64 65 void dump() const; 66 string uri_str() const; 67 string canon_uri_str() const; 68 string nameaddr_str() const; 69 AmUriParserAmUriParser70 AmUriParser() { } 71 72 string print() const; 73 }; 74 75 #endif 76