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 // 1: Bilinear 43 #define CACHE_CONTROL "max-age=86400"; // 24 hours 44 #define ALLOW_UPSCALING true 46 #define EMBED_ICC true 47 #define KAKADU_READMODE 0 59 static int getVerbosity(){
60 int loglevel = VERBOSITY;
61 char *envpara = getenv(
"VERBOSITY" );
63 loglevel = atoi( envpara );
65 if( loglevel < 0 ) loglevel = 0;
71 static std::string getLogFile(){
72 char* envpara = getenv(
"LOGFILE" );
73 if( envpara )
return std::string( envpara );
78 static float getMaxImageCacheSize(){
79 float max_image_cache_size = MAX_IMAGE_CACHE_SIZE;
80 char* envpara = getenv(
"MAX_IMAGE_CACHE_SIZE" );
82 max_image_cache_size = atof( envpara );
84 return max_image_cache_size;
88 static std::string getFileNamePattern(){
89 char* envpara = getenv(
"FILENAME_PATTERN" );
90 std::string filename_pattern;
92 filename_pattern = std::string( envpara );
94 else filename_pattern = FILENAME_PATTERN;
96 return filename_pattern;
100 static int getJPEGQuality(){
101 char* envpara = getenv(
"JPEG_QUALITY" );
104 jpeg_quality = atoi( envpara );
105 if( jpeg_quality > 100 ) jpeg_quality = 100;
106 if( jpeg_quality < 1 ) jpeg_quality = 1;
108 else jpeg_quality = JPEG_QUALITY;
114 static int getMaxCVT(){
115 char* envpara = getenv(
"MAX_CVT" );
118 max_CVT = atoi( envpara );
119 if( max_CVT < 64 ) max_CVT = 64;
121 else max_CVT = MAX_CVT;
127 static int getMaxLayers(){
128 char* envpara = getenv(
"MAX_LAYERS" );
130 if( envpara ) layers = atoi( envpara );
131 else layers = MAX_LAYERS;
137 static std::string getFileSystemPrefix(){
138 char* envpara = getenv(
"FILESYSTEM_PREFIX" );
139 std::string filesystem_prefix;
141 filesystem_prefix = std::string( envpara );
143 else filesystem_prefix = FILESYSTEM_PREFIX;
145 return filesystem_prefix;
149 static std::string getWatermark(){
150 char* envpara = getenv(
"WATERMARK" );
151 std::string watermark;
153 watermark = std::string( envpara );
155 else watermark = WATERMARK;
161 static float getWatermarkProbability(){
162 float watermark_probability = WATERMARK_PROBABILITY;
163 char* envpara = getenv(
"WATERMARK_PROBABILITY" );
166 watermark_probability = atof( envpara );
167 if( watermark_probability > 1.0 ) watermark_probability = 1.0;
168 if( watermark_probability < 0 ) watermark_probability = 0.0;
171 return watermark_probability;
175 static float getWatermarkOpacity(){
176 float watermark_opacity = WATERMARK_OPACITY;
177 char* envpara = getenv(
"WATERMARK_OPACITY" );
180 watermark_opacity = atof( envpara );
181 if( watermark_opacity > 1.0 ) watermark_opacity = 1.0;
182 if( watermark_opacity < 0 ) watermark_opacity = 0.0;
185 return watermark_opacity;
189 static std::string getMemcachedServers(){
190 char* envpara = getenv(
"MEMCACHED_SERVERS" );
191 std::string memcached_servers;
193 memcached_servers = std::string( envpara );
195 else memcached_servers = LIBMEMCACHED_SERVERS;
197 return memcached_servers;
201 static unsigned int getMemcachedTimeout(){
202 char* envpara = getenv(
"MEMCACHED_TIMEOUT" );
203 unsigned int memcached_timeout;
204 if( envpara ) memcached_timeout = atoi( envpara );
205 else memcached_timeout = LIBMEMCACHED_TIMEOUT;
207 return memcached_timeout;
211 static unsigned int getInterpolation(){
212 char* envpara = getenv(
"INTERPOLATION" );
213 unsigned int interpolation;
214 if( envpara ) interpolation = atoi( envpara );
215 else interpolation = INTERPOLATION;
217 return interpolation;
221 static std::string getCORS(){
222 char* envpara = getenv(
"CORS" );
224 if( envpara ) cors = std::string( envpara );
230 static std::string getBaseURL(){
231 char* envpara = getenv(
"BASE_URL" );
232 std::string base_url;
233 if( envpara ) base_url = std::string( envpara );
234 else base_url = BASE_URL;
239 static std::string getCacheControl(){
240 char* envpara = getenv(
"CACHE_CONTROL" );
241 std::string cache_control;
242 if( envpara ) cache_control = std::string( envpara );
243 else cache_control = CACHE_CONTROL;
244 return cache_control;
248 static bool getAllowUpscaling(){
249 char* envpara = getenv(
"ALLOW_UPSCALING" );
250 bool allow_upscaling;
251 if( envpara ) allow_upscaling = atoi( envpara );
252 else allow_upscaling = ALLOW_UPSCALING;
253 return allow_upscaling;
257 static std::string getURIMap(){
258 char* envpara = getenv(
"URI_MAP" );
260 if( envpara ) uri_map = std::string( envpara );
261 else uri_map = URI_MAP;
266 static unsigned int getEmbedICC(){
267 char* envpara = getenv(
"EMBED_ICC" );
269 if( envpara ) embed = atoi( envpara );
270 else embed = EMBED_ICC;
275 static unsigned int getKduReadMode(){
276 unsigned int readmode;
277 char* envpara = getenv(
"KAKADU_READMODE" );
279 readmode = atoi( envpara );
280 if( readmode > 2 ) readmode = 2;
282 else readmode = KAKADU_READMODE;
Class to obtain environment variables.
Definition: Environment.h:54