|
reSIProcate/repro
9694
|
00001 #include "ProxyConfig.hxx" 00002 00003 #include <iostream> 00004 #include <fstream> 00005 #include <iterator> 00006 00007 //#include <rutil/DnsUtil.hxx> 00008 #include <resip/stack/NameAddr.hxx> 00009 #include <rutil/Log.hxx> 00010 #include <rutil/Logger.hxx> 00011 #include <rutil/WinLeakCheck.hxx> 00012 00013 using namespace repro; 00014 using namespace resip; 00015 using namespace std; 00016 00017 #define RESIPROCATE_SUBSYSTEM Subsystem::REPRO 00018 00019 namespace repro 00020 { 00021 00022 ProxyConfig::ProxyConfig(int argc, char** argv, const resip::Data& defaultConfigFilename) : ConfigParse(argc, argv, defaultConfigFilename), mStore(0) 00023 { 00024 } 00025 00026 ProxyConfig::ProxyConfig() : mStore(0) 00027 { 00028 } 00029 00030 ProxyConfig::~ProxyConfig() 00031 { 00032 delete mStore; 00033 mStore=0; 00034 } 00035 00036 bool 00037 ProxyConfig::getConfigValue(const resip::Data& name, resip::Uri &value) 00038 { 00039 Data lowerName(name); lowerName.lowercase(); 00040 ConfigValuesMap::iterator it = mConfigValues.find(lowerName); 00041 if(it != mConfigValues.end()) 00042 { 00043 try 00044 { 00045 if(!it->second.empty()) 00046 { 00047 NameAddr tempNameAddr(it->second); 00048 value = tempNameAddr.uri(); 00049 return true; 00050 } 00051 else 00052 { 00053 value = Uri(); // return an empty Uri 00054 return true; 00055 } 00056 } 00057 catch(resip::BaseException& e) 00058 { 00059 // Try adding sip: to value to see if it will be valid 00060 try 00061 { 00062 NameAddr tempNameAddr(Data("sip:" + it->second)); 00063 value = tempNameAddr.uri(); 00064 return true; 00065 } 00066 catch(resip::BaseException&) 00067 { 00068 cerr << "Invalid Uri setting: " << name << " = " << it->second << ": " << e << endl; 00069 return false; 00070 } 00071 } 00072 } 00073 // Not found 00074 return false; 00075 } 00076 00077 resip::Uri 00078 ProxyConfig::getConfigUri(const resip::Data& name, const resip::Uri defaultValue, bool useDefaultIfEmpty) 00079 { 00080 Uri ret(defaultValue); 00081 if(getConfigValue(name, ret) && ret.host().empty() && useDefaultIfEmpty) 00082 { 00083 return defaultValue; 00084 } 00085 return ret; 00086 } 00087 00088 void 00089 ProxyConfig::printHelpText(int argc, char **argv) 00090 { 00091 cout << "Command line format is:" << endl; 00092 cout << " " << argv[0] << " [<ConfigFilename>] [--<ConfigValueName>=<ConfigValue>] [--<ConfigValueName>=<ConfigValue>] ..." << endl; 00093 cout << "Sample Command lines:" << endl; 00094 cout << " " << argv[0] << "repro.config --RecordRouteUri=sip:proxy.sipdomain.com --ForceRecordRouting=true" << endl; 00095 cout << " " << argv[0] << "repro.config /RecordRouteUri:sip:proxy.sipdomain.com /ForceRecordRouting:true" << endl; 00096 } 00097 00098 void 00099 ProxyConfig::createDataStore(AbstractDb* db) 00100 { 00101 assert(db); 00102 mStore = new Store(*db); 00103 } 00104 00105 } 00106 00107 /* ==================================================================== 00108 * The Vovida Software License, Version 1.0 00109 * 00110 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00111 * 00112 * Redistribution and use in source and binary forms, with or without 00113 * modification, are permitted provided that the following conditions 00114 * are met: 00115 * 00116 * 1. Redistributions of source code must retain the above copyright 00117 * notice, this list of conditions and the following disclaimer. 00118 * 00119 * 2. Redistributions in binary form must reproduce the above copyright 00120 * notice, this list of conditions and the following disclaimer in 00121 * the documentation and/or other materials provided with the 00122 * distribution. 00123 * 00124 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00125 * and "Vovida Open Communication Application Library (VOCAL)" must 00126 * not be used to endorse or promote products derived from this 00127 * software without prior written permission. For written 00128 * permission, please contact vocal@vovida.org. 00129 * 00130 * 4. Products derived from this software may not be called "VOCAL", nor 00131 * may "VOCAL" appear in their name, without prior written 00132 * permission of Vovida Networks, Inc. 00133 * 00134 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00135 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00136 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00137 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00138 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00139 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00140 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00141 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00142 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00143 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00145 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00146 * DAMAGE. 00147 * 00148 * ==================================================================== 00149 * 00150 * This software consists of voluntary contributions made by Vovida 00151 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00152 * Inc. For more information on Vovida Networks, Inc., please see 00153 * <http://www.vovida.org/>. 00154 * 00155 */
1.7.5.1