Skip to content

Commit 9677358

Browse files
committed
read_env_file[_inline]: documentation comment
1 parent 2797c27 commit 9677358

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/dinit-env.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ static void log_bad_env_cmd(int linenum)
1717
log(loglevel_t::ERROR, "Unknown command in environment file (line ", linenum, ")");
1818
}
1919

20-
// Read and set environment variables from a file. May throw std::bad_alloc, std::system_error.
20+
// Read and set environment variables (encapsulated in an 'environment' object) from a file.
21+
// File contains "VAR=VALUE" assignments (line by line) and "!" meta-commands.
22+
// Parameters:
23+
// env_file_path - the path to the environment file to process
24+
// log_warnings - whether warnings should be logged (eg about invalid embedded commands)
25+
// env - the environment to modify
26+
// throw_on_open_failure - whether to throw an exception on failure to open the specified
27+
// file. If false, returns instead (without logging failure).
28+
// Throws:
29+
// std::bad_alloc, std::system_error
2130
void read_env_file(const char *env_file_path, bool log_warnings, environment &env, bool throw_on_open_failure)
2231
{
2332
read_env_file_inline(env_file_path, log_warnings, env, throw_on_open_failure, log_bad_env, log_bad_env_cmd);

src/includes/dinit-env.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,18 @@ class environment
353353
}
354354
};
355355

356-
// Read and set environment variables from a file. May throw std::bad_alloc, std::system_error.
356+
// Read and set environment variables (encapsulated in an 'environment' object) from a file.
357+
// File contains "VAR=VALUE" assignments (line by line) and "!" meta-commands.
358+
// Parameters:
359+
// env_file_path - the path to the environment file to process
360+
// log_warnings - whether warnings should be logged (eg about invalid embedded commands)
361+
// env - the environment to modify
362+
// throw_on_open_failure - whether to throw an exception on failure to open the specified
363+
// file. If false, returns instead (without logging failure).
364+
// log_inv_setting - function/functor to log invalid lines
365+
// log_bad_cmd - function/functor to log bad meta commands
366+
// Throws:
367+
// std::bad_alloc, std::system_error
357368
template <typename LOG_INV_SETTING, typename LOG_BAD_COMMAND>
358369
inline void read_env_file_inline(const char *env_file_path, bool log_warnings, environment &env,
359370
bool throw_on_open_failure, LOG_INV_SETTING &log_inv_setting, LOG_BAD_COMMAND &log_bad_cmd)

0 commit comments

Comments
 (0)