Squashed 'third_party/seasocks/' content from commit 016dc60
Change-Id: I195fa5bfd0c0e3cc66fbbefcc7b5170bafcf7a36
git-subtree-dir: third_party/seasocks
git-subtree-split: 016dc60b247e0d1d563aea6d22a9075e6884ab9f
diff --git a/scripts/gen_embedded.py b/scripts/gen_embedded.py
new file mode 100755
index 0000000..f715b1d
--- /dev/null
+++ b/scripts/gen_embedded.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import os, os.path, sys
+
+print """
+#include "internal/Embedded.h"
+
+#include <string>
+#include <unordered_map>
+
+namespace {
+
+std::unordered_map<std::string, EmbeddedContent> embedded = {
+"""
+
+for f in sys.argv[1:]:
+ bytes = open(f, 'rb').read()
+ print '{"/%s", {' % os.path.basename(f)
+ print '"' + "".join(['\\x%02x' % ord(x) for x in bytes]) + '"'
+ print ',%d }},' % len(bytes)
+
+print """
+};
+
+} // namespace
+
+const EmbeddedContent* findEmbeddedContent(const std::string& name) {
+ auto found = embedded.find(name);
+ if (found == embedded.end()) {
+ return NULL;
+ }
+ return &found->second;
+}
+"""
+