aboutsummaryrefslogtreecommitdiff
path: root/hw_html/html.cpp
blob: 9f2b3f464a5e83201722b3575d3888161d87ca12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <html.hpp>
#include <mcubase.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;
}

html::error html::add(const mcubase &reg)
{
    return html::OK;
}