* Return the value for the requested Trace2 setting from these sources: * the system config, the global config, and the environment. */
| 101 | * the system config, the global config, and the environment. |
| 102 | */ |
| 103 | const char *tr2_sysenv_get(enum tr2_sysenv_variable var) |
| 104 | { |
| 105 | if (var >= TR2_SYSENV_MUST_BE_LAST) |
| 106 | BUG("tr2_sysenv_get invalid var '%d'", var); |
| 107 | |
| 108 | if (!tr2_sysenv_settings[var].getenv_called) { |
| 109 | const char *v = getenv(tr2_sysenv_settings[var].env_var_name); |
| 110 | if (v && *v) { |
| 111 | free(tr2_sysenv_settings[var].value); |
| 112 | tr2_sysenv_settings[var].value = xstrdup(v); |
| 113 | } |
| 114 | tr2_sysenv_settings[var].getenv_called = 1; |
| 115 | } |
| 116 | |
| 117 | return tr2_sysenv_settings[var].value; |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * Return a friendly name for this setting that is suitable for printing |
no test coverage detected