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 string d_cookie_jar;
00111
00112 static RCReader* _instance;
00113
00114 RCReader() throw(Error);
00115 ~RCReader();
00116
00117
00118 bool write_rc_file(const string &pathname);
00119 bool read_rc_file(const string &pathname);
00120
00121
00122 string check_env_var(const string &variable_name);
00123 string check_string(string env_var);
00124
00125 static void initialize_instance();
00126 static void delete_instance();
00127
00128 friend class RCReaderTest;
00129 friend class HTTPConnectTest;
00130
00131 public:
00132 static RCReader* instance();
00133
00134
00135 string get_dods_cache_root() const throw()
00136 {
00137 return d_cache_root;
00138 }
00139 bool get_use_cache() const throw()
00140 {
00141 return _dods_use_cache;
00142 }
00143 int get_max_cache_size() const throw()
00144 {
00145 return _dods_cache_max;
00146 }
00147 unsigned int get_max_cached_obj() const throw()
00148 {
00149 return _dods_cached_obj;
00150 }
00151 int get_ignore_expires() const throw()
00152 {
00153 return _dods_ign_expires;
00154 }
00155 int get_default_expires() const throw()
00156 {
00157 return _dods_default_expires;
00158 }
00159 int get_always_validate() const throw()
00160 {
00161 return _dods_always_validate;
00162 }
00163 int get_validate_ssl() const throw()
00164 {
00165 return d_validate_ssl;
00166 }
00167
00168 bool get_deflate() const throw()
00169 {
00170 return _dods_deflate;
00171 }
00172
00174 string get_proxy_server_protocol() const throw()
00175 {
00176 return d_dods_proxy_server_protocol;
00177 }
00179 string get_proxy_server_host() const throw()
00180 {
00181 return d_dods_proxy_server_host;
00182 }
00184 int get_proxy_server_port() const throw()
00185 {
00186 return d_dods_proxy_server_port;
00187 }
00189 string get_proxy_server_userpw() const throw()
00190 {
00191 return d_dods_proxy_server_userpw;
00192 }
00194 string get_proxy_server_host_url() const throw()
00195 {
00196 return (d_dods_proxy_server_userpw.empty() ? "" : d_dods_proxy_server_userpw + "@")
00197 + d_dods_proxy_server_host
00198 + ":" + long_to_string(d_dods_proxy_server_port);
00199 }
00200
00201
00202
00203
00204
00205
00206
00208 bool is_proxy_for_used() throw()
00209 {
00210 return _dods_proxy_for;
00211 }
00213 string get_proxy_for_regexp() const throw()
00214 {
00215 return _dods_proxy_for_regexp;
00216 }
00218 string get_proxy_for_proxy_host_url() const throw()
00219 {
00220 return _dods_proxy_for_proxy_host_url;
00221 }
00222
00224 int get_proxy_for_regexp_flags() const throw()
00225 {
00226 return _dods_proxy_for_regexp_flags;
00227 }
00228
00229
00230
00231
00232
00233
00234 bool is_no_proxy_for_used() throw()
00235 {
00236 return d_dods_no_proxy_for;
00237 }
00238 string get_no_proxy_for_protocol() const throw()
00239 {
00240 return d_dods_no_proxy_for_protocol;
00241 }
00242 string get_no_proxy_for_host() const throw()
00243 {
00244 return d_dods_no_proxy_for_host;
00245 }
00246
00248 int get_no_proxy_for_port() const throw()
00249 {
00250 return _dods_no_proxy_for_port;
00251 }
00252
00253 string get_ais_database() const throw()
00254 {
00255 return d_ais_database;
00256 }
00257
00258 string get_cookie_jar() const throw()
00259 {
00260 return d_cookie_jar;
00261 }
00262
00263
00264 void set_use_cache(bool b) throw()
00265 {
00266 _dods_use_cache = b;
00267 }
00268 void set_max_cache_size(int i) throw()
00269 {
00270 _dods_cache_max = i;
00271 }
00272 void set_max_cached_obj(int i) throw()
00273 {
00274 _dods_cached_obj = i;
00275 }
00276 void set_ignore_expires(int i) throw()
00277 {
00278 _dods_ign_expires = i;
00279 }
00280 void set_default_expires(int i) throw()
00281 {
00282 _dods_default_expires = i;
00283 }
00284 void set_always_validate(int i) throw()
00285 {
00286 _dods_always_validate = i;
00287 }
00288 void set_validate_ssl(int i) throw()
00289 {
00290 d_validate_ssl = i;
00291 }
00292
00293 void set_deflate(bool b) throw()
00294 {
00295 _dods_deflate = b;
00296 }
00297
00298 void set_proxy_server_protocol(const string &s) throw()
00299 {
00300 d_dods_proxy_server_protocol = s;
00301 }
00302 void set_proxy_server_host(const string &s) throw()
00303 {
00304 d_dods_proxy_server_host = s;
00305 }
00306 void set_proxy_server_port(int l) throw()
00307 {
00308 d_dods_proxy_server_port = l;
00309 }
00310 void set_proxy_server_userpw(const string &s) throw()
00311 {
00312 d_dods_proxy_server_userpw = s;
00313 }
00314
00316 void set_proxy_server_host_url(const string &s) throw()
00317 {
00318 _dods_proxy_server_host_url = s;
00319 }
00320
00322 void set_proxy_for_regexp(const string &s) throw()
00323 {
00324 _dods_proxy_for_regexp = s;
00325 }
00327 void set_proxy_for_proxy_host_url(const string &s) throw()
00328 {
00329 _dods_proxy_for_proxy_host_url = s;
00330 }
00332 void set_proxy_for_regexp_flags(int i) throw()
00333 {
00334 _dods_proxy_for_regexp_flags = i;
00335 }
00336
00337 void set_no_proxy_for_protocol(const string &s) throw()
00338 {
00339 d_dods_no_proxy_for_protocol = s;
00340 }
00341 void set_no_proxy_for_host(const string &s) throw()
00342 {
00343 d_dods_no_proxy_for_host = s;
00344 }
00345
00347 void set_no_proxy_for_port(int i) throw()
00348 {
00349 _dods_no_proxy_for_port = i;
00350 }
00351
00352 void set_ais_database(const string &db) throw()
00353 {
00354 d_ais_database = db;
00355 }
00356 };
00357
00358 }
00359
00360 #endif // _RCReader_h_