diff options
Diffstat (limited to 'hw_html/html.cpp')
| -rw-r--r-- | hw_html/html.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/hw_html/html.cpp b/hw_html/html.cpp new file mode 100644 index 0000000..dee58ce --- /dev/null +++ b/hw_html/html.cpp @@ -0,0 +1,43 @@ +#include "html.hpp" +#include <ctml.hpp> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +html::html() : + f(nullptr) +{ +} + +html::~html() +{ + if (f) + fclose(f); +} + +html::error html::open(const char *const path) +{ + if (!path) + return html::INVALID_PATH; + + f = fopen(path, "wb"); + + if (!f) + { + fprintf(stderr, "could not open %s for writing, reason: %s\n", path, + strerror(errno)); + return html::OPEN_ERR; + } + + CTML::Document doc; + + doc.AppendNodeToHead(CTML::Node("TITLE", "A9 register map")); + + if (fprintf(f, "%s\n", doc.ToString().c_str()) < 0) + { + fprintf(stderr, "HTML write error\n"); + return html::WRITE_ERR; + } + + return html::OK; +} |
