00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _rc_reader_h_
00033 #define _rc_reader_h_
00034
00035 #include <iostream>
00036 #include <string>
00037
00038 #include "Error.h"
00039 #include "util.h"
00040
00041 using namespace std;
00042
00051 class RCReader
00052 {
00053 private:
00054 string d_rc_file_path;
00055 string d_cache_root;
00056
00057 bool _dods_use_cache;
00058 unsigned int _dods_cache_max;
00059 unsigned int _dods_cached_obj;
00060 int _dods_ign_expires;
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 bool _dods_deflate;
00075
00076 int _dods_default_expires;
00077 int _dods_always_validate;
00078
00079
00080 string d_dods_proxy_server_protocol;
00081 string d_dods_proxy_server_host;
00082 int d_dods_proxy_server_port;
00083 string d_dods_proxy_server_userpw;
00084
00085
00086 int d_validate_ssl;
00087
00088 string _dods_proxy_server_host_url;
00089
00090
00091
00092 bool _dods_proxy_for;
00093 string _dods_proxy_for_regexp;
00094 string _dods_proxy_for_proxy_host_url;
00095 int _dods_proxy_for_regexp_flags;
00096
00097
00098 bool d_dods_no_proxy_for;
00099 string d_dods_no_proxy_for_protocol;
00100 string d_dods_no_proxy_for_host;
00101 int _dods_no_proxy_for_port;
00102
00103
00104
00105 string d_ais_database;
00106
00107 static RCReader* _instance;
00108
00109 RCReader() throw(Error);
00110 ~RCReader();
00111
00112
00113 bool write_rc_file(const string &pathname);
00114 bool read_rc_file(const string &pathname);
00115
00116
00117 string check_env_var(const string &variable_name);
00118 string check_string(string env_var);
00119
00120 static void initialize_instance();
00121 static void delete_instance();
00122
00123 friend class RCReaderTest;
00124 friend class HTTPConnectTest;
00125
00126 public:
00127 static RCReader* instance();
00128
00129
00130 const string get_dods_cache_root()
00131 {
00132 return d_cache_root;
00133 }
00134 const bool get_use_cache() throw()
00135 {
00136 return _dods_use_cache;
00137 }
00138 const int get_max_cache_size() throw()
00139 {
00140 return _dods_cache_max;
00141 }
00142 const unsigned int get_max_cached_obj() throw()
00143 {
00144 return _dods_cached_obj;
00145 }
00146 const int get_ignore_expires() throw()
00147 {
00148 return _dods_ign_expires;
00149 }
00150 const int get_default_expires() throw()
00151 {
00152 return _dods_default_expires;
00153 }
00154 const int get_always_validate() throw()
00155 {
00156 return _dods_always_validate;
00157 }
00158 int get_validate_ssl() const throw()
00159 {
00160 return d_validate_ssl;
00161 }
00162
00163 const bool get_deflate() throw()
00164 {
00165 return _dods_deflate;
00166 }
00167
00169 const string get_proxy_server_protocol() throw()
00170 {
00171 return d_dods_proxy_server_protocol;
00172 }
00174 const string get_proxy_server_host() throw()
00175 {
00176 return d_dods_proxy_server_host;
00177 }
00179 const int get_proxy_server_port() throw()
00180 {
00181 return d_dods_proxy_server_port;
00182 }
00184 const string get_proxy_server_userpw() throw()
00185 {
00186 return d_dods_proxy_server_userpw;
00187 }
00189 const string get_proxy_server_host_url() throw()
00190 {
00191 return (d_dods_proxy_server_userpw.empty() ? "" : d_dods_proxy_server_userpw + "@")
00192 + d_dods_proxy_server_host
00193 + ":" + long_to_string(d_dods_proxy_server_port);
00194 }
00195
00196
00197
00198
00199
00200
00201
00203 bool is_proxy_for_used() throw()
00204 {
00205 return _dods_proxy_for;
00206 }
00208 const string get_proxy_for_regexp() throw()
00209 {
00210 return _dods_proxy_for_regexp;
00211 }
00213 const string get_proxy_for_proxy_host_url() throw()
00214 {
00215 return _dods_proxy_for_proxy_host_url;
00216 }
00217
00219 const int get_proxy_for_regexp_flags() throw()
00220 {
00221 return _dods_proxy_for_regexp_flags;
00222 }
00223
00224
00225
00226
00227
00228
00229 bool is_no_proxy_for_used() throw()
00230 {
00231 return d_dods_no_proxy_for;
00232 }
00233 const string get_no_proxy_for_protocol() throw()
00234 {
00235 return d_dods_no_proxy_for_protocol;
00236 }
00237 const string get_no_proxy_for_host() throw()
00238 {
00239 return d_dods_no_proxy_for_host;
00240 }
00241
00243 const int get_no_proxy_for_port() throw()
00244 {
00245 return _dods_no_proxy_for_port;
00246 }
00247
00248 string get_ais_database() const throw()
00249 {
00250 return d_ais_database;
00251 }
00252
00253
00254 void set_use_cache(bool b) throw()
00255 {
00256 _dods_use_cache = b;
00257 }
00258 void set_max_cache_size(int i) throw()
00259 {
00260 _dods_cache_max = i;
00261 }
00262 void set_max_cached_obj(int i) throw()
00263 {
00264 _dods_cached_obj = i;
00265 }
00266 void set_ignore_expires(int i) throw()
00267 {
00268 _dods_ign_expires = i;
00269 }
00270 void set_default_expires(int i) throw()
00271 {
00272 _dods_default_expires = i;
00273 }
00274 void set_always_validate(int i) throw()
00275 {
00276 _dods_always_validate = i;
00277 }
00278 void set_validate_ssl(int i) throw()
00279 {
00280 d_validate_ssl = i;
00281 }
00282
00283 void set_deflate(bool b) throw()
00284 {
00285 _dods_deflate = b;
00286 }
00287
00288 void set_proxy_server_protocol(const string &s) throw()
00289 {
00290 d_dods_proxy_server_protocol = s;
00291 }
00292 void set_proxy_server_host(const string &s) throw()
00293 {
00294 d_dods_proxy_server_host = s;
00295 }
00296 void set_proxy_server_port(int l) throw()
00297 {
00298 d_dods_proxy_server_port = l;
00299 }
00300 void set_proxy_server_userpw(const string &s) throw()
00301 {
00302 d_dods_proxy_server_userpw = s;
00303 }
00304
00306 void set_proxy_server_host_url(const string &s) throw()
00307 {
00308 _dods_proxy_server_host_url = s;
00309 }
00310
00312 void set_proxy_for_regexp(const string &s) throw()
00313 {
00314 _dods_proxy_for_regexp = s;
00315 }
00317 void set_proxy_for_proxy_host_url(const string &s) throw()
00318 {
00319 _dods_proxy_for_proxy_host_url = s;
00320 }
00322 void set_proxy_for_regexp_flags(int i) throw()
00323 {
00324 _dods_proxy_for_regexp_flags = i;
00325 }
00326
00327 void set_no_proxy_for_protocol(const string &s) throw()
00328 {
00329 d_dods_no_proxy_for_protocol = s;
00330 }
00331 void set_no_proxy_for_host(const string &s) throw()
00332 {
00333 d_dods_no_proxy_for_host = s;
00334 }
00335
00337 void set_no_proxy_for_port(int i) throw()
00338 {
00339 _dods_no_proxy_for_port = i;
00340 }
00341
00342 void set_ais_database(const string &db) throw()
00343 {
00344 d_ais_database = db;
00345 }
00346 };
00347
00348 #endif // _RCReader_h_