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
00043 namespace libdap
00044 {
00045
00054 class RCReader
00055 {
00056 private:
00057 string d_rc_file_path;
00058 string d_cache_root;
00059
00060 bool _dods_use_cache;
00061 unsigned int _dods_cache_max;
00062 unsigned int _dods_cached_obj;
00063 int _dods_ign_expires;
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 bool _dods_deflate;
00078
00079 int _dods_default_expires;
00080 int _dods_always_validate;
00081
00082
00083 string d_dods_proxy_server_protocol;
00084 string d_dods_proxy_server_host;
00085 int d_dods_proxy_server_port;
00086 string d_dods_proxy_server_userpw;
00087
00088
00089 int d_validate_ssl;
00090
00091 string _dods_proxy_server_host_url;
00092
00093
00094
00095 bool _dods_proxy_for;
00096 string _dods_proxy_for_regexp;
00097 string _dods_proxy_for_proxy_host_url;
00098 int _dods_proxy_for_regexp_flags;
00099
00100
00101 bool d_dods_no_proxy_for;
00102 string d_dods_no_proxy_for_protocol;
00103 string d_dods_no_proxy_for_host;
00104 int _dods_no_proxy_for_port;
00105
00106
00107
00108 string d_ais_database;
00109
00110 static RCReader* _instance;
00111
00112 RCReader() throw(Error);
00113 ~RCReader();
00114
00115
00116 bool write_rc_file(const string &pathname);
00117 bool read_rc_file(const string &pathname);
00118
00119
00120 string check_env_var(const string &variable_name);
00121 string check_string(string env_var);
00122
00123 static void initialize_instance();
00124 static void delete_instance();
00125
00126 friend class RCReaderTest;
00127 friend class HTTPConnectTest;
00128
00129 public:
00130 static RCReader* instance();
00131
00132
00133 const string get_dods_cache_root()
00134 {
00135 return d_cache_root;
00136 }
00137 const bool get_use_cache() throw()
00138 {
00139 return _dods_use_cache;
00140 }
00141 const int get_max_cache_size() throw()
00142 {
00143 return _dods_cache_max;
00144 }
00145 const unsigned int get_max_cached_obj() throw()
00146 {
00147 return _dods_cached_obj;
00148 }
00149 const int get_ignore_expires() throw()
00150 {
00151 return _dods_ign_expires;
00152 }
00153 const int get_default_expires() throw()
00154 {
00155 return _dods_default_expires;
00156 }
00157 const int get_always_validate() throw()
00158 {
00159 return _dods_always_validate;
00160 }
00161 int get_validate_ssl() const throw()
00162 {
00163 return d_validate_ssl;
00164 }
00165
00166 const bool get_deflate() throw()
00167 {
00168 return _dods_deflate;
00169 }
00170
00172 const string get_proxy_server_protocol() throw()
00173 {
00174 return d_dods_proxy_server_protocol;
00175 }
00177 const string get_proxy_server_host() throw()
00178 {
00179 return d_dods_proxy_server_host;
00180 }
00182 const int get_proxy_server_port() throw()
00183 {
00184 return d_dods_proxy_server_port;
00185 }
00187 const string get_proxy_server_userpw() throw()
00188 {
00189 return d_dods_proxy_server_userpw;
00190 }
00192 const string get_proxy_server_host_url() throw()
00193 {
00194 return (d_dods_proxy_server_userpw.empty() ? "" : d_dods_proxy_server_userpw + "@")
00195 + d_dods_proxy_server_host
00196 + ":" + long_to_string(d_dods_proxy_server_port);
00197 }
00198
00199
00200
00201
00202
00203
00204
00206 bool is_proxy_for_used() throw()
00207 {
00208 return _dods_proxy_for;
00209 }
00211 const string get_proxy_for_regexp() throw()
00212 {
00213 return _dods_proxy_for_regexp;
00214 }
00216 const string get_proxy_for_proxy_host_url() throw()
00217 {
00218 return _dods_proxy_for_proxy_host_url;
00219 }
00220
00222 const int get_proxy_for_regexp_flags() throw()
00223 {
00224 return _dods_proxy_for_regexp_flags;
00225 }
00226
00227
00228
00229
00230
00231
00232 bool is_no_proxy_for_used() throw()
00233 {
00234 return d_dods_no_proxy_for;
00235 }
00236 const string get_no_proxy_for_protocol() throw()
00237 {
00238 return d_dods_no_proxy_for_protocol;
00239 }
00240 const string get_no_proxy_for_host() throw()
00241 {
00242 return d_dods_no_proxy_for_host;
00243 }
00244
00246 const int get_no_proxy_for_port() throw()
00247 {
00248 return _dods_no_proxy_for_port;
00249 }
00250
00251 string get_ais_database() const throw()
00252 {
00253 return d_ais_database;
00254 }
00255
00256
00257 void set_use_cache(bool b) throw()
00258 {
00259 _dods_use_cache = b;
00260 }
00261 void set_max_cache_size(int i) throw()
00262 {
00263 _dods_cache_max = i;
00264 }
00265 void set_max_cached_obj(int i) throw()
00266 {
00267 _dods_cached_obj = i;
00268 }
00269 void set_ignore_expires(int i) throw()
00270 {
00271 _dods_ign_expires = i;
00272 }
00273 void set_default_expires(int i) throw()
00274 {
00275 _dods_default_expires = i;
00276 }
00277 void set_always_validate(int i) throw()
00278 {
00279 _dods_always_validate = i;
00280 }
00281 void set_validate_ssl(int i) throw()
00282 {
00283 d_validate_ssl = i;
00284 }
00285
00286 void set_deflate(bool b) throw()
00287 {
00288 _dods_deflate = b;
00289 }
00290
00291 void set_proxy_server_protocol(const string &s) throw()
00292 {
00293 d_dods_proxy_server_protocol = s;
00294 }
00295 void set_proxy_server_host(const string &s) throw()
00296 {
00297 d_dods_proxy_server_host = s;
00298 }
00299 void set_proxy_server_port(int l) throw()
00300 {
00301 d_dods_proxy_server_port = l;
00302 }
00303 void set_proxy_server_userpw(const string &s) throw()
00304 {
00305 d_dods_proxy_server_userpw = s;
00306 }
00307
00309 void set_proxy_server_host_url(const string &s) throw()
00310 {
00311 _dods_proxy_server_host_url = s;
00312 }
00313
00315 void set_proxy_for_regexp(const string &s) throw()
00316 {
00317 _dods_proxy_for_regexp = s;
00318 }
00320 void set_proxy_for_proxy_host_url(const string &s) throw()
00321 {
00322 _dods_proxy_for_proxy_host_url = s;
00323 }
00325 void set_proxy_for_regexp_flags(int i) throw()
00326 {
00327 _dods_proxy_for_regexp_flags = i;
00328 }
00329
00330 void set_no_proxy_for_protocol(const string &s) throw()
00331 {
00332 d_dods_no_proxy_for_protocol = s;
00333 }
00334 void set_no_proxy_for_host(const string &s) throw()
00335 {
00336 d_dods_no_proxy_for_host = s;
00337 }
00338
00340 void set_no_proxy_for_port(int i) throw()
00341 {
00342 _dods_no_proxy_for_port = i;
00343 }
00344
00345 void set_ais_database(const string &db) throw()
00346 {
00347 d_ais_database = db;
00348 }
00349 };
00350
00351 }
00352
00353 #endif // _RCReader_h_