r e a d e n v Goes to read directly the environment variables from the operating system on Windows and provides a stub for UNIX.
| 276 | // Goes to read directly the environment variables from the operating system on Windows |
| 277 | // and provides a stub for UNIX. |
| 278 | bool readenv(const char* env_name, Firebird::string& env_value) |
| 279 | { |
| 280 | #ifdef WIN_NT |
| 281 | const DWORD rc = GetEnvironmentVariable(env_name, NULL, 0); |
| 282 | if (rc) |
| 283 | { |
| 284 | env_value.reserve(rc - 1); |
| 285 | DWORD rc2 = GetEnvironmentVariable(env_name, env_value.begin(), rc); |
| 286 | if (rc2 < rc && rc2 != 0) |
| 287 | { |
| 288 | env_value.recalculate_length(); |
| 289 | return true; |
| 290 | } |
| 291 | } |
| 292 | #else |
| 293 | const char* p = getenv(env_name); |
| 294 | if (p) |
| 295 | return env_value.assign(p).length() != 0; |
| 296 | #endif |
| 297 | // Not found, clear the output var. |
| 298 | env_value.begin()[0] = 0; |
| 299 | env_value.recalculate_length(); |
| 300 | return false; |
| 301 | } |
| 302 | |
| 303 | |
| 304 | bool readenv(const char* env_name, Firebird::PathName& env_value) |
no test coverage detected