Skip to content

Commit a9bcf46

Browse files
authored
Merge pull request #878 from evoskuil/master
Add embedded site defines, macros and web service simple resources.
2 parents 2a90e1d + e03537d commit a9bcf46

29 files changed

+708
-108
lines changed

Makefile.am

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,18 @@ console_bn_SOURCES = \
133133
console/localize.hpp \
134134
console/main.cpp \
135135
console/stack_trace.cpp \
136-
console/stack_trace.hpp
136+
console/stack_trace.hpp \
137+
console/embedded/embedded.hpp \
138+
console/embedded/explore_css.cpp \
139+
console/embedded/explore_ecma.cpp \
140+
console/embedded/explore_font.cpp \
141+
console/embedded/explore_html.cpp \
142+
console/embedded/explore_icon.cpp \
143+
console/embedded/web_css.cpp \
144+
console/embedded/web_ecma.cpp \
145+
console/embedded/web_font.cpp \
146+
console/embedded/web_html.cpp \
147+
console/embedded/web_icon.cpp
137148

138149
endif WITH_CONSOLE
139150

builds/cmake/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,18 @@ if (with-console)
391391
"../../console/localize.hpp"
392392
"../../console/main.cpp"
393393
"../../console/stack_trace.cpp"
394-
"../../console/stack_trace.hpp" )
394+
"../../console/stack_trace.hpp"
395+
"../../console/embedded/embedded.hpp"
396+
"../../console/embedded/explore_css.cpp"
397+
"../../console/embedded/explore_ecma.cpp"
398+
"../../console/embedded/explore_font.cpp"
399+
"../../console/embedded/explore_html.cpp"
400+
"../../console/embedded/explore_icon.cpp"
401+
"../../console/embedded/web_css.cpp"
402+
"../../console/embedded/web_ecma.cpp"
403+
"../../console/embedded/web_font.cpp"
404+
"../../console/embedded/web_html.cpp"
405+
"../../console/embedded/web_icon.cpp" )
395406

396407
# bn project specific include directories.
397408
#------------------------------------------------------------------------------

builds/msvc/vs2022/bn/bn.vcxproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@
118118
<Import Project="$(ProjectDir)$(ProjectName).props" />
119119
</ImportGroup>
120120
<ItemGroup>
121+
<ClCompile Include="..\..\..\..\console\embedded\explore_css.cpp" />
122+
<ClCompile Include="..\..\..\..\console\embedded\explore_ecma.cpp" />
123+
<ClCompile Include="..\..\..\..\console\embedded\explore_font.cpp" />
124+
<ClCompile Include="..\..\..\..\console\embedded\explore_html.cpp" />
125+
<ClCompile Include="..\..\..\..\console\embedded\explore_icon.cpp" />
126+
<ClCompile Include="..\..\..\..\console\embedded\web_css.cpp" />
127+
<ClCompile Include="..\..\..\..\console\embedded\web_ecma.cpp" />
128+
<ClCompile Include="..\..\..\..\console\embedded\web_font.cpp" />
129+
<ClCompile Include="..\..\..\..\console\embedded\web_html.cpp" />
130+
<ClCompile Include="..\..\..\..\console\embedded\web_icon.cpp" />
121131
<ClCompile Include="..\..\..\..\console\executor.cpp" />
122132
<ClCompile Include="..\..\..\..\console\executor_commands.cpp" />
123133
<ClCompile Include="..\..\..\..\console\executor_dumps.cpp" />
@@ -133,6 +143,7 @@
133143
<ClCompile Include="..\..\..\..\console\stack_trace.cpp" />
134144
</ItemGroup>
135145
<ItemGroup>
146+
<ClInclude Include="..\..\..\..\console\embedded\embedded.hpp" />
136147
<ClInclude Include="..\..\..\..\console\executor.hpp" />
137148
<ClInclude Include="..\..\..\..\console\localize.hpp" />
138149
<ClInclude Include="..\..\..\..\console\stack_trace.hpp" />

builds/msvc/vs2022/bn/bn.vcxproj.filters

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,46 @@
88
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
99
<ItemGroup>
1010
<Filter Include="resource">
11-
<UniqueIdentifier>{D3404804-C83F-46CE-0000-000000000001}</UniqueIdentifier>
11+
<UniqueIdentifier>{D3404804-C83F-46CE-0000-000000000002}</UniqueIdentifier>
1212
</Filter>
1313
<Filter Include="src">
1414
<UniqueIdentifier>{D3404804-C83F-46CE-0000-000000000000}</UniqueIdentifier>
1515
</Filter>
16+
<Filter Include="src\embedded">
17+
<UniqueIdentifier>{D3404804-C83F-46CE-0000-000000000001}</UniqueIdentifier>
18+
</Filter>
1619
</ItemGroup>
1720
<ItemGroup>
21+
<ClCompile Include="..\..\..\..\console\embedded\explore_css.cpp">
22+
<Filter>src\embedded</Filter>
23+
</ClCompile>
24+
<ClCompile Include="..\..\..\..\console\embedded\explore_ecma.cpp">
25+
<Filter>src\embedded</Filter>
26+
</ClCompile>
27+
<ClCompile Include="..\..\..\..\console\embedded\explore_font.cpp">
28+
<Filter>src\embedded</Filter>
29+
</ClCompile>
30+
<ClCompile Include="..\..\..\..\console\embedded\explore_html.cpp">
31+
<Filter>src\embedded</Filter>
32+
</ClCompile>
33+
<ClCompile Include="..\..\..\..\console\embedded\explore_icon.cpp">
34+
<Filter>src\embedded</Filter>
35+
</ClCompile>
36+
<ClCompile Include="..\..\..\..\console\embedded\web_css.cpp">
37+
<Filter>src\embedded</Filter>
38+
</ClCompile>
39+
<ClCompile Include="..\..\..\..\console\embedded\web_ecma.cpp">
40+
<Filter>src\embedded</Filter>
41+
</ClCompile>
42+
<ClCompile Include="..\..\..\..\console\embedded\web_font.cpp">
43+
<Filter>src\embedded</Filter>
44+
</ClCompile>
45+
<ClCompile Include="..\..\..\..\console\embedded\web_html.cpp">
46+
<Filter>src\embedded</Filter>
47+
</ClCompile>
48+
<ClCompile Include="..\..\..\..\console\embedded\web_icon.cpp">
49+
<Filter>src\embedded</Filter>
50+
</ClCompile>
1851
<ClCompile Include="..\..\..\..\console\executor.cpp">
1952
<Filter>src</Filter>
2053
</ClCompile>
@@ -56,6 +89,9 @@
5689
</ClCompile>
5790
</ItemGroup>
5891
<ItemGroup>
92+
<ClInclude Include="..\..\..\..\console\embedded\embedded.hpp">
93+
<Filter>src\embedded</Filter>
94+
</ClInclude>
5995
<ClInclude Include="..\..\..\..\console\executor.hpp">
6096
<Filter>src</Filter>
6197
</ClInclude>

console/embedded/embedded.hpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#ifndef LIBBITCOIN_BN_EMBEDDED_HPP
20+
#define LIBBITCOIN_BN_EMBEDDED_HPP
21+
22+
#include "../executor.hpp"
23+
24+
#include <iterator>
25+
#include <bitcoin/node.hpp>
26+
27+
#define DECLARE_EMBEDDED_PAGE(page) \
28+
span_value page() const NOEXCEPT override
29+
30+
#define DECLARE_EMBEDDED_PAGES(container) \
31+
struct container : public server::settings::embedded_pages \
32+
{ \
33+
DECLARE_EMBEDDED_PAGE(css); \
34+
DECLARE_EMBEDDED_PAGE(html); \
35+
DECLARE_EMBEDDED_PAGE(ecma); \
36+
DECLARE_EMBEDDED_PAGE(font); \
37+
DECLARE_EMBEDDED_PAGE(icon); \
38+
}
39+
40+
#define DEFINE_EMBEDDED_PAGE(container, type, name, ...) \
41+
span_value container::name() const NOEXCEPT \
42+
{ \
43+
static constexpr type name##_[] = __VA_ARGS__; \
44+
static const span_value out \
45+
( \
46+
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(&name##_[0])), \
47+
literal_length(name##_) \
48+
); \
49+
return out; \
50+
}
51+
52+
namespace libbitcoin {
53+
namespace server {
54+
55+
DECLARE_EMBEDDED_PAGES(web_pages);
56+
DECLARE_EMBEDDED_PAGES(explore_pages);
57+
58+
} // namespace server
59+
} // namespace libbitcoin
60+
61+
#endif

console/embedded/explore_css.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#include "../embedded/embedded.hpp"
20+
21+
namespace libbitcoin {
22+
namespace server {
23+
24+
DEFINE_EMBEDDED_PAGE(explore_pages, char, css, "")
25+
26+
} // namespace server
27+
} // namespace libbitcoin

console/embedded/explore_ecma.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#include "../embedded/embedded.hpp"
20+
21+
namespace libbitcoin {
22+
namespace server {
23+
24+
DEFINE_EMBEDDED_PAGE(explore_pages, char, ecma, "")
25+
26+
} // namespace server
27+
} // namespace libbitcoin

console/embedded/explore_font.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#include "../embedded/embedded.hpp"
20+
21+
namespace libbitcoin {
22+
namespace server {
23+
24+
DEFINE_EMBEDDED_PAGE(explore_pages, char, font, "")
25+
26+
} // namespace server
27+
} // namespace libbitcoin

console/embedded/explore_html.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#include "../embedded/embedded.hpp"
20+
21+
namespace libbitcoin {
22+
namespace server {
23+
24+
// Empty page disabled embedded size.
25+
DEFINE_EMBEDDED_PAGE(explore_pages, char, html, "")
26+
27+
} // namespace server
28+
} // namespace libbitcoin

console/embedded/explore_icon.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#include "../embedded/embedded.hpp"
20+
21+
namespace libbitcoin {
22+
namespace server {
23+
24+
DEFINE_EMBEDDED_PAGE(explore_pages, char, icon, "")
25+
26+
} // namespace server
27+
} // namespace libbitcoin

0 commit comments

Comments
 (0)