dinit-env.cc 775 B

123456789101112131415161718192021222324
  1. #include <iostream>
  2. #include <fstream>
  3. #include "dinit-log.h"
  4. #include "dinit-env.h"
  5. environment main_env;
  6. // Log a parse error when reading the environment file.
  7. static void log_bad_env(int linenum)
  8. {
  9. log(loglevel_t::ERROR, "Invalid environment variable setting in environment file (line ", linenum, ")");
  10. }
  11. static void log_bad_env_cmd(int linenum)
  12. {
  13. log(loglevel_t::ERROR, "Unknown command in environment file (line ", linenum, ")");
  14. }
  15. // Read and set environment variables from a file. May throw std::bad_alloc, std::system_error.
  16. void read_env_file(const char *env_file_path, bool log_warnings, environment &env, bool throw_on_open_failure)
  17. {
  18. read_env_file_inline(env_file_path, log_warnings, env, throw_on_open_failure, log_bad_env, log_bad_env_cmd);
  19. }