From 516e9be0443cfd7f844feb9b8299f909075b7c3c Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 30 Oct 2016 06:27:21 +0200 Subject: [PATCH] datamap --- src/datamap.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/datamap.h | 13 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/datamap.cc create mode 100644 src/datamap.h diff --git a/src/datamap.cc b/src/datamap.cc new file mode 100644 index 0000000..bf8854c --- /dev/null +++ b/src/datamap.cc @@ -0,0 +1,44 @@ +#include +#include +#include +#include "datamap.h" + +static std::vector> dmap; +static std::map cache; +static std::string root; + +void datmap_reset() +{ + root.clear(); + dmap.clear(); + cache.clear(); +} + +void datmap_set_path(const char *path) +{ + root = std::string(path); +} + +bool datmap_load_map(const char *fname) +{ + std::string path = root.empty() ? fname : root + std::string("/") + fname; + return false; // TODO cont... +} + +void datmap_map(const char *re, const char *path) +{ + std::pair mapping; + mapping.first = std::string(re); + mapping.second = std::string(path); + dmap.push_back(mapping); +} + +int datmap_lookup(const char *in, char *buf, int bsz) +{ + return -1; // TODO +} + +int datmap_path_size(const char *in) +{ + return datmap_lookup(in, 0, 0); +} diff --git a/src/datamap.h b/src/datamap.h new file mode 100644 index 0000000..4cbc44b --- /dev/null +++ b/src/datamap.h @@ -0,0 +1,13 @@ +#ifndef DATAMAP_H_ +#define DATAMAP_H_ + +void datmap_reset(); +void datmap_set_path(const char *path); + +bool datmap_load_map(const char *fname); +void datmap_map(const char *re, const char *path); + +int datmap_lookup(const char *in, char *buf, int bsz); +int datmap_path_size(const char *in); + +#endif // DATAMAP_H_ -- 1.7.10.4