Added basic reporter/output registration

This commit is contained in:
Snaipe 2015-10-12 10:34:01 +01:00
parent 1928e161f7
commit 36543fb956

36
src/log/output.c Normal file
View file

@ -0,0 +1,36 @@
#include <stdio.h>
#include <string.h>
#include <khash.h>
#include "criterion/stats.h"
typedef void criterion_reporter(FILE *stream, struct criterion_global_stats *);
KHASH_MAP_INIT_STR(ht_str, criterion_reporter*)
KHASH_MAP_INIT_STR(ht_path, const char *)
static khash_t(ht_str) *reporters;
static khash_t(ht_path) *outputs;
void criterion_init_output(void) {
reporters = kh_init(ht_str);
outputs = kh_init(ht_path);
}
int criterion_register_output_provider(const char *name, criterion_reporter *reporter) {
int absent;
khint_t k = kh_put(ht_str, reporters, name, &absent);
kh_value(reporters, k) = reporter;
return absent;
}
int criterion_add_output(const char *provider, const char *path) {
int absent;
khint_t k = kh_put(ht_path, outputs, provider, &absent);
kh_value(outputs, k) = path;
return absent;
}
void criterion_free_output(void) {
kh_destroy(ht_str, reporters);
kh_destroy(ht_path, outputs);
}