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
52 static int getVerbosity(){
53 int loglevel = VERBOSITY;
54 char *envpara = getenv(
"VERBOSITY" );
56 loglevel = atoi( envpara );
58 if( loglevel < 0 ) loglevel = 0;
64 static std::string getLogFile(){
65 char* envpara = getenv(
"LOGFILE" );
66 if( envpara )
return std::string( envpara );
71 static float getMaxImageCacheSize(){
72 float max_image_cache_size = MAX_IMAGE_CACHE_SIZE;
73 char* envpara = getenv(
"MAX_IMAGE_CACHE_SIZE" );
75 max_image_cache_size = atof( envpara );
77 return max_image_cache_size;
81 static std::string getFileNamePattern(){
82 char* envpara = getenv(
"FILENAME_PATTERN" );
83 std::string filename_pattern;
85 filename_pattern = std::string( envpara );
87 else filename_pattern = FILENAME_PATTERN;
89 return filename_pattern;
93 static int getJPEGQuality(){
94 char* envpara = getenv(
"JPEG_QUALITY" );
97 jpeg_quality = atoi( envpara );
98 if( jpeg_quality > 100 ) jpeg_quality = 100;
99 if( jpeg_quality < 1 ) jpeg_quality = 1;
101 else jpeg_quality = JPEG_QUALITY;
107 static int getMaxCVT(){
108 char* envpara = getenv(
"MAX_CVT" );
111 max_CVT = atoi( envpara );
112 if( max_CVT < 64 ) max_CVT = 64;
113 if( max_CVT == -1 ) max_CVT = -1;
115 else max_CVT = MAX_CVT;
121 static int getMaxLayers(){
122 char* envpara = getenv(
"MAX_LAYERS" );
124 if( envpara ) layers = atoi( envpara );
125 else layers = MAX_LAYERS;
131 static std::string getFileSystemPrefix(){
132 char* envpara = getenv(
"FILESYSTEM_PREFIX" );
133 std::string filesystem_prefix;
135 filesystem_prefix = std::string( envpara );
137 else filesystem_prefix = FILESYSTEM_PREFIX;
139 return filesystem_prefix;
143 static std::string getWatermark(){
144 char* envpara = getenv(
"WATERMARK" );
145 std::string watermark;
147 watermark = std::string( envpara );
149 else watermark = WATERMARK;
155 static float getWatermarkProbability(){
156 float watermark_probability = WATERMARK_PROBABILITY;
157 char* envpara = getenv(
"WATERMARK_PROBABILITY" );
160 watermark_probability = atof( envpara );
161 if( watermark_probability > 1.0 ) watermark_probability = 1.0;
162 if( watermark_probability < 0 ) watermark_probability = 0.0;
165 return watermark_probability;
169 static float getWatermarkOpacity(){
170 float watermark_opacity = WATERMARK_OPACITY;
171 char* envpara = getenv(
"WATERMARK_OPACITY" );
174 watermark_opacity = atof( envpara );
175 if( watermark_opacity > 1.0 ) watermark_opacity = 1.0;
176 if( watermark_opacity < 0 ) watermark_opacity = 0.0;
179 return watermark_opacity;
183 static std::string getMemcachedServers(){
184 char* envpara = getenv(
"MEMCACHED_SERVERS" );
185 std::string memcached_servers;
187 memcached_servers = std::string( envpara );
189 else memcached_servers = LIBMEMCACHED_SERVERS;
191 return memcached_servers;
195 static unsigned int getMemcachedTimeout(){
196 char* envpara = getenv(
"MEMCACHED_TIMEOUT" );
197 unsigned int memcached_timeout;
198 if( envpara ) memcached_timeout = atoi( envpara );
199 else memcached_timeout = LIBMEMCACHED_TIMEOUT;
201 return memcached_timeout;