aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbarenblat@galois.com>2014-01-27 19:07:30 -0800
committerGravatar Benjamin Barenblat <bbarenblat@galois.com>2014-01-27 19:07:30 -0800
commitb9dfb8d03b457844fbcab5ad20d744971569f0d7 (patch)
tree385f470f4faa64399995403664da0b3f807b8aac /src
parentbb3a3a61fe7b971ad8ef326ec7e4d5903e6860ee (diff)
Add 'ppaml_tracer_init_from_env'
This new API function is similar to 'ppaml_tracer_init', but instead of accepting the report base name as an argument, it pulls it from the 'PPAMLTRACER_TRACE_BASE' environment variable. This is useful for users who want to be able to vary the locations of trace reports but do not want to build tracing into their configuration file / command-line argument parsers.
Diffstat (limited to 'src')
-rw-r--r--src/tracer.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tracer.c b/src/tracer.c
index be2f3cc..3b39759 100644
--- a/src/tracer.c
+++ b/src/tracer.c
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
#include <otf.h>
@@ -59,6 +60,23 @@ int ppaml_tracer_init(
done: return r;
}
+int ppaml_tracer_init_from_env(ppaml_tracer_t *const tracer)
+{
+ int r = 0;
+ // Figure out where to put the trace.
+ const char *const report_name_base = getenv("PPAMLTRACER_TRACE_BASE");
+ require_nonnull(report_name_base, 5);
+ if (report_name_base[0] == '\0') {
+ /* The variable exists, but it's empty, so we can't do anything
+ * with it. */
+ r = 5;
+ goto done;
+ }
+ // Create the trace.
+ r = ppaml_tracer_init(tracer, report_name_base);
+done: return r;
+}
+
int ppaml_tracer_done(ppaml_tracer_t *const tracer)
{
int r = 0;