21 #ifndef _ENVIRONMENT_H 22 #define _ENVIRONMENT_H 28 #define LOGFILE "/tmp/iipsrv.log" 29 #define MAX_IMAGE_CACHE_SIZE 10.0 30 #define FILENAME_PATTERN "_pyr_" 31 #define JPEG_QUALITY 75 34 #define FILESYSTEM_PREFIX "" 36 #define WATERMARK_PROBABILITY 1.0 37 #define WATERMARK_OPACITY 1.0 38 #define LIBMEMCACHED_SERVERS "localhost" 39 #define LIBMEMCACHED_TIMEOUT 86400 // 24 hours 40 #define INTERPOLATION 1 43 #define CACHE_CONTROL "max-age=86400"; // 24 hours 55 static int getVerbosity(){
56 int loglevel = VERBOSITY;
57 char *envpara = getenv(
"VERBOSITY" );
59 loglevel = atoi( envpara );
61 if( loglevel < 0 ) loglevel = 0;
67 static std::string getLogFile(){
68 char* envpara = getenv(
"LOGFILE" );
69 if( envpara )
return std::string( envpara );
74 static float getMaxImageCacheSize(){
75 float max_image_cache_size = MAX_IMAGE_CACHE_SIZE;
76 char* envpara = getenv(
"MAX_IMAGE_CACHE_SIZE" );
78 max_image_cache_size = atof( envpara );
80 return max_image_cache_size;
84 static std::string getFileNamePattern(){
85 char* envpara = getenv(
"FILENAME_PATTERN" );
86 std::string filename_pattern;
88 filename_pattern = std::string( envpara );
90 else filename_pattern = FILENAME_PATTERN;
92 return filename_pattern;
96 static int getJPEGQuality(){
97 char* envpara = getenv(
"JPEG_QUALITY" );
100 jpeg_quality = atoi( envpara );
101 if( jpeg_quality > 100 ) jpeg_quality = 100;
102 if( jpeg_quality < 1 ) jpeg_quality = 1;
104 else jpeg_quality = JPEG_QUALITY;
110 static int getMaxCVT(){
111 char* envpara = getenv(
"MAX_CVT" );
114 max_CVT = atoi( envpara );
115 if( max_CVT < 64 ) max_CVT = 64;
117 else max_CVT = MAX_CVT;
123 static int getMaxLayers(){
124 char* envpara = getenv(
"MAX_LAYERS" );
126 if( envpara ) layers = atoi( envpara );
127 else layers = MAX_LAYERS;
133 static std::string getFileSystemPrefix(){
134 char* envpara = getenv(
"FILESYSTEM_PREFIX" );
135 std::string filesystem_prefix;
137 filesystem_prefix = std::string( envpara );
139 else filesystem_prefix = FILESYSTEM_PREFIX;
141 return filesystem_prefix;
145 static std::string getWatermark(){
146 char* envpara = getenv(
"WATERMARK" );
147 std::string watermark;
149 watermark = std::string( envpara );
151 else watermark = WATERMARK;
157 static float getWatermarkProbability(){
158 float watermark_probability = WATERMARK_PROBABILITY;
159 char* envpara = getenv(
"WATERMARK_PROBABILITY" );
162 watermark_probability = atof( envpara );
163 if( watermark_probability > 1.0 ) watermark_probability = 1.0;
164 if( watermark_probability < 0 ) watermark_probability = 0.0;
167 return watermark_probability;
171 static float getWatermarkOpacity(){
172 float watermark_opacity = WATERMARK_OPACITY;
173 char* envpara = getenv(
"WATERMARK_OPACITY" );
176 watermark_opacity = atof( envpara );
177 if( watermark_opacity > 1.0 ) watermark_opacity = 1.0;
178 if( watermark_opacity < 0 ) watermark_opacity = 0.0;
181 return watermark_opacity;
185 static std::string getMemcachedServers(){
186 char* envpara = getenv(
"MEMCACHED_SERVERS" );
187 std::string memcached_servers;
189 memcached_servers = std::string( envpara );
191 else memcached_servers = LIBMEMCACHED_SERVERS;
193 return memcached_servers;
197 static unsigned int getMemcachedTimeout(){
198 char* envpara = getenv(
"MEMCACHED_TIMEOUT" );
199 unsigned int memcached_timeout;
200 if( envpara ) memcached_timeout = atoi( envpara );
201 else memcached_timeout = LIBMEMCACHED_TIMEOUT;
203 return memcached_timeout;
207 static unsigned int getInterpolation(){
208 char* envpara = getenv(
"INTERPOLATION" );
209 unsigned int interpolation;
210 if( envpara ) interpolation = atoi( envpara );
211 else interpolation = INTERPOLATION;
213 return interpolation;
217 static std::string getCORS(){
218 char* envpara = getenv(
"CORS" );
220 if( envpara ) cors = std::string( envpara );
226 static std::string getBaseURL(){
227 char* envpara = getenv(
"BASE_URL" );
228 std::string base_url;
229 if( envpara ) base_url = std::string( envpara );
230 else base_url = BASE_URL;
235 static std::string getCacheControl(){
236 char* envpara = getenv(
"CACHE_CONTROL" );
237 std::string cache_control;
238 if( envpara ) cache_control = std::string( envpara );
239 else cache_control = CACHE_CONTROL;
240 return cache_control;
Class to obtain environment variables.
Definition: Environment.h:50