Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Kral <vojtech@kral.hk>2018-04-19 11:35:47 +0300
committerVojtech Kral <vojtech@kral.hk>2018-05-21 19:58:20 +0300
commit11a00b025fc4ec0b81b09cc3caac3e156f313cda (patch)
tree41e04dd06a55dc114304f1196a2b97e0fc2efe4d /xs/src/avrdude/avrdude-slic3r.cpp
parent1caeab913bdbd8c8940dcb96c5ce29c46bb51cd5 (diff)
avrdude integration basics (WIP)
Diffstat (limited to 'xs/src/avrdude/avrdude-slic3r.cpp')
-rw-r--r--xs/src/avrdude/avrdude-slic3r.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/xs/src/avrdude/avrdude-slic3r.cpp b/xs/src/avrdude/avrdude-slic3r.cpp
new file mode 100644
index 000000000..37da0a530
--- /dev/null
+++ b/xs/src/avrdude/avrdude-slic3r.cpp
@@ -0,0 +1,34 @@
+#include "avrdude-slic3r.hpp"
+
+extern "C" {
+#include "ac_cfg.h"
+#include "avrdude.h"
+}
+
+namespace Slic3r {
+
+namespace AvrDude {
+
+static void avrdude_message_handler_ostream(const char *msg, unsigned size, void *user_p)
+{
+ (void)size;
+ std::ostream &os = *reinterpret_cast<std::ostream*>(user_p);
+ os << msg;
+}
+
+int main(std::vector<std::string> args, std::string sys_config, std::ostream &stderr)
+{
+ std::vector<char *> c_args {{ const_cast<char*>(PACKAGE_NAME) }};
+ for (const auto &arg : args) {
+ c_args.push_back(const_cast<char*>(arg.data()));
+ }
+
+ ::avrdude_message_handler_set(avrdude_message_handler_ostream, reinterpret_cast<void*>(&stderr));
+ const auto res = ::avrdude_main(static_cast<int>(c_args.size()), c_args.data(), sys_config.c_str());
+ ::avrdude_message_handler_set(nullptr, nullptr);
+ return res;
+}
+
+}
+
+}