datamap
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 30 Oct 2016 04:27:21 +0000 (06:27 +0200)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 30 Oct 2016 04:27:21 +0000 (06:27 +0200)
src/datamap.cc [new file with mode: 0644]
src/datamap.h [new file with mode: 0644]

diff --git a/src/datamap.cc b/src/datamap.cc
new file mode 100644 (file)
index 0000000..bf8854c
--- /dev/null
@@ -0,0 +1,44 @@
+#include <vector>
+#include <map>
+#include <string>
+#include "datamap.h"
+
+static std::vector<std::pair<std::string, std::string>> dmap;
+static std::map<std::string, std::string> 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<std::string, std::string> 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 (file)
index 0000000..4cbc44b
--- /dev/null
@@ -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_