Squashed 'third_party/seasocks/' changes from 016dc60..bac7d40
bac7d40 Merge pull request #118 from iwanders/allow-disabling-example-apps
5656c43 Allow disabling the example applications.
44c1aff Clang 8 CI build added.
64f5912 Usages of 'using namespace std' removed.
9d273db Usages of std::endl replaced with '\n'.
82d3e24 Code improvements.
8fb923f Naming of some C API variables improved.
9e1e9e3 Braces added.
0e936b7 Parameter names unified.
e519edc Iterator made const and braces added.
21f9e17 Merge branch 'offa/unit_tests'
0633d1f Merge pull request #116 from iwanders/provide_cmake_config
1c758a9 Tests for the trimWhitespace function added.
125dd89 Catch v2.6.0 update.
27ab414 Provide SeasocksConfig.cmake files when installed.
6e76ab2 Travis updated to Xenial.
7c2e3f2 Merge pull request #115 from twanas/master
7782925 Updated return type as per @offa suggestion.
f58cba2 Resolved ignoring return value error
c3eb2da CI builds changed to Release build type (#114).
1c7a038 Tests for the split function added.
bf00af7 Tests for the replace function added.
673cc4b String utils comparison test added.
2984f41 Calls to c_str() cleaned up.
da0d091 Calls to atoi() replaced with the safer stoi().
cfc3a46 Some code improvements; static access, size() replaced by empty() and loop variable made const-Ref.
766ccef Merge pull request #107 from mattgodbolt/102-clangformat
bbc3bd1 Code formatted by clang-format (#102).
79ee9a0 Ctor initializer indention improved (#107, #102).
4ee3d51 Clang-Format CMake support added (#102).
7daedf9 Clang-Format config added (#102).
7fa6e89 Rename log levels to not be ALL CAPS to avoid clashing with commonly-defined macros. Fixes #111
0008558 Merge pull request #110 from iwanders/allow-embedding-as-subproject
2fa6b27 Use current binary directory and provide aliases.
0c42700 Embedded data made const and indention fixed.
c185a6e Missing overrides added.
a10ddcb Merge pull request #108 from iwanders/add-export-fix-zlib-link-interface
12edb16 Export zlib to link interface for static library.
6fdd5f7 Export targets to allow using the build tree.
33f6537 Typo in the test case fixed.
8bce5c0 Merge pull request #106 from offa/105-non_ascii_escape
143d167 Test for the json handling of ascii strings added.
f568cd2 Escaping for non-ascii characters (#105).
6ec0bf4 Unit test execution target added and integrated into the ci build (#104).
eb54d16 Catch updated to v2.5.0.
bb1bbeb Merge pull request #100 from membar/patch-2
79a963d Deprecated travis setting removed.
23995dd Merge pull request #99 from membar/patch-1
a611a87 Return errbuf
4d9dc6f Add byteswap.h
8742bd7 Version fixed.
f6373e2 Fix typo in CMakeLists.txt
3d8653d Fix path to Config.h.in
5b31bf0 Catch updated to v2.4.1.
544541c Clang 7 CI build added.
70f072d Some travis yml cleanup.
12f0f0f Merge pull request #97 from nkowdley/master
a51be5d Update CMakeLists.txt to work on CMake 3.12
afeb46c RaiiFd extracted (#95).
4daa1e3 Merge pull request #92 from offa/python3_support
6dd4574 Old style cast replaced with static_cast<>().
9ee6e9b Parameter named as in the header.
9d0dffc Overrides added.
fe933b2 Accessing npos through std::string and braces added.
27f9781 Consts added.
5cb9a27 Constant moved to anonymous namespace.
62711b0 Function paramters named consistent.
5d34845 Single argument Ctor made explicit.
9e6f08e Braces added and formatting.
ff62ce6 Parameter made const-ref.
11f658c Single argument ctor made explicit.
c777c22 Braces added.
8108180 Naming fixed and override added.
5aaf62a Ctor made explicit.
925ac0b Formatting improved and braces added.
ab1c956 Missing override added.
9206ea3 Private dependencies for tests.
0a06a52 Unused variable and directory removed from the travis ci config.
e6d8684 License file of Catch added.
b11fd3f Catch updated to latest v2.3.0.
c5ef750 Scope of the output file reduced.
99e2046 No longer needed parameter removed.
4b78344 Embedded generator script improved. The structure of the generated source code is now more maintainable.
1694ad5 Script gen_embedded.py refactored to reflect the structure of the generated file better.
c7022d5 Using the default python installation again. This can either be python2 or python3 - whatever the caller has set default.
050a801 Call of the gen_embedded.py script updated to the new arguments.
fafe609 Refactoring of the gen_embedded.py script. The scripts takes arguments for the input files and the destination files now. The result is written directly to the output file instead of stdout.
f1b0404 Workaround for the python 2/3 compatibility.
127c329 Support for python3 only as python2 is incompatible now.
46f8a91 Const added in the generated code.
8193732 Tabs replaced with spaces in the generated code.
82648cf Embedded content generator updated to support python3.
9ef2bcd GCC 8 CI build added.
a1bc19e CMake file with the compiler settings renamed.
0f4c576 Catch updated to v2.2.2.
ba8d7cb Clang 6.0 CI build added.
3f40182 Catch updated to v2.2.1.
648b5fa Support (in a very primitive way), the protocols. See bug #81
12bedeb Catch updated to v2.1.2.
7d9b0bb Catch updated to v2.1.1.
b9f5a21 Catch updated to latest v2.1.0 release.
c56265c GCC 4.8 CI build removed. This version does not provide enough C++14 support.
735eb1f SHA1 doesn't need a (virtual) dtor. Accidentally cleaned up some Whitespaces.
fd8d431 Deleted member functions made public.
8b77076 Modernization of some loops; range-based loops instead of manual iterator loops.
1c30fe1 Old typedef syntax replaced.
aebd693 Resetting unique ptr improved.
caa0e1f Deprecated C headers replaced with their C++ equivalent.
5fd3e30 Empty braces replaced by '= default' for default implementation.
00b5a66 Add coverage bage
1f3f1cc Installation of CMake no longer necessary as the recent build image update ships CMake 3.9 now.
8e8c2b8 Actually disable coverage for clang 3.9
7274f79 Build debug, coverage off for clang 3.9 where it doesn't seem to work
2e0b1d9 Coverage take two
b86ce89 Enable coverage
a1a71f4 Catch has removed the matchers in v2, instead operators are used.
4c195e3 Missing include added.
d4cd9ad Catch updated to v2.0.1 release.
41a75a8 Whoops :)
823f197 Add new CLion stuff
2833512 Include all files in CMakeLists.txt
de8c718 Naked new's replaced and formatting.
f26fc41 Naked new's replaced.
edf08a3 Tests for all concrete response factory functions added.
8c28510 Small fix.
a34114a Some more naked news used with shared_ptr replaced with make_unique(). Some cleanup.
ef1c909 Some naked new's in context of shared_ptr replaced with make_shared().
ca9d0ea GCC 4.7 CI build removed since it has no C++14 support.
cc9523f Moved to C++14.
612dce6 Release v1.3.2.
0cfa345 Inclusion of Catch improved.
896662b Cleanup of the main CMakeLists.txt.
72bf82b Setting the C++ Standard using CMAKE_CXX_STANDARD and let CMake figure out which flag is necessary for the used compiler.
3203132 Using add_compile_options().
9cd2c8d Clang 5 CI build added.
c382014 Catch updated to v1.10.0. Thanks to some performance related improvements of catch, unit tests should run notably faster now.
96b163d Merge pull request #78 from dhouck/soname
9a275ee Add SONAME versioning to shared library
0ba3d9c Merge pull request #75 from offa/catch_1.9.6
5ceed7e Catch updated to latest release (v1.9.6) and some updates accordingly.
bc32e79 Merge pull request #73 from offa/ci_gcc7
4a71b69 Gcc7 CI Build added.
1368d33 Release v1.3.1.
ea54b6c Version corrected.
be6e5a0 Typo fixed.
524a984 Update copyright
29f9d5c Try another approach
da0e29d Make static to hopefully prevent some older G++ warnings
5a88f4f Ahem sources for travis
2cf5eef WAG at testing in travis
68dca58 Support configurable dependency on deflate. On by default.
a098b9b Merge pull request #70 from caffinatedmonkey/streaming-response
7d4844e Added StreamingResponse
3d94f43 Merge pull request #71 from offa/zlib_dependency_fix
865c116 Forward declaration instead of include to break dependency to an internal header.
c1e3d5d Merge pull request #69 from offa/install_path_fix
6f26211 Install path fixed for runtime targets (= executables).
6488d1a Merge pull request #67 from offa/issue66/type_deduction_fix
cdb3c9b Type deduction fixed (#66).
ea485c5 Merge pull request #65 from offa/ci/clang40
9a28644 Missing override added.
a3b1373 Fix wrong compiler used.
8eec2d2 Clang 4.0 clang build added.
4480081 Merge pull request #64 from offa/ci_clang39
9124c42 Clang 3.9 has finally been whitelisted by travis ci.
1061092 Merge pull request #63 from offa/issue62-static_lib
dff594a Fix for the static library target not including the embedded content object correctly (#62).
749726a Merge pull request #60 from hoytech/permessage-deflate
027afb7 Per-message deflate as described in RFC 7692
cc1c68a Merge pull request #61 from offa/gitignore_cleanup
5694418 Obsolete gitignore file removed.
1c2ca3e Merge pull request #59 from offa/issue57
db8c1c0 Debug flag removed (see #57).
042a476 Merge pull request #58 from offa/compiler_checks_cleanup
24c390f Compiler checks removed as the tested features should be supported by any C++11 compiler.
54de807 Merge pull request #56 from offa/cmake_python_search
468d95c Search and check python executable instead of hardcoding it.
df9173a Merge pull request #52 from offa/version_fix
ae6866e Merge pull request #54 from offa/missing_override
c3e531a Missing include for bswap64 added.
48d295a Missing include added.
0f95aec Missing override added (#53).
ab6d881 Using pragma once.
851c4a7 Compile definition of the version removed.
68bc86f Obsolute template file removed.
aad7edf Version.h removed as it is no longer needed.
728f0ef Braces unified.
d655c57 Version made a constant.
d1074e6 Version fixed for all targets.
5cdd0f4 Merge pull request #51 from offa/shadow_fixes
a99c79b Fixes for shadowed variables.
51f3826 Rev to 1.2.6
636b057 Rev to 1.2.5
3d78946 Make client buffer size configurable
0f496f9 Merge pull request #50 from offa/embedded_content_test
d7ff2fd Some more tests added.
5f2d2ed Merge pull request #49 from offa/cmake_include_cleanup
25cacaa Unit Test for checking the embedded content generation added.
b76bd9f Cleanup (see #48).
cd5652c Merge pull request #48 from offa/some_fixes
34d13ca Broken generation of embedded content fixed. CMake warning according add_library() fixed.
6fcdc6a Replaced source file globbing as this is not recommended by cmake.
0c17838 Merge pull request #46 from dascandy/master
faadb44 Aargh travis
03152e7 More travis
92ec5f8 Travis...
892e653 Travis tweaks
2db009e Big travis refactor
a8bae23 More travis attempts
f584a79 Dump cmake version in travis
809257a Remove some do-nothing commands
693dcc0 Merge branch 'master' of https://github.com/mattgodbolt/seasocks
2d7b1e1 Moved the embedded logic into its own subfolder with cleaned up CMakeLists; made use more of target-specific properties rather than global ones; made library build only once instead of twice. One cmake warning left sadly.
ee19673 Arg
eed081b Use suppressions. Fixes #44
be0ecf1 Fix compile error #45
c5823d6 Merge pull request #43 from offa/scoped_enums
158c09e Logger Level converted to scoped enums.
572e4f9 Request Verb converted to scoped enum.
0e7661e Connection State converted to scoped enum.
3b356c7 Merge pull request #42 from offa/scoped_enum
bb9ee7c Enum changed to scoped enum.
306b460 Merge pull request #41 from hoytech/master
1cd4ceb Support listening on AF_UNIX sockets
0beca0c Handle PONG frames. Should fix #40
39b458f Updates for CLion
934116b Merge pull request #38 from offa/ci
6400c5a Clang 3.9 added to Ci builds.
3993599 Ci builds for more compilers added. There are builds for Gcc 4.7 - 6 and Clang 3.6 - 3.8.
c5a975b Merge pull request #37 from offa/version_fix
bd8c981 Version fixed.
c5bea26 Merge pull request #36 from seeekr/patch-1
fed61b7 fix typo in async_test.cpp
b95be51 Merge pull request #35 from offa/constants_constexpr
f3bdd0f Constants made constexpr.
5d17e7b Merge pull request #32 from offa/to_string
f8c7d3b Workaround for CI failure.
a791e03 toString() for integral types implemented using std::to_string().
e5488c6 Fix the tests for toString so they really show bug 28 was fixed. Closes #28
b11439e Really fix #28
1e924a1 Set a default C locale before formatting things in toString. Fixes #28
f9a46d4 Remove emplace from chatroom example
353f870 Add a chatroom example
229e15b Merge pull request #27 from offa/some_fixes
35967b6 Ctors made explicit.
e421542 Missing init of member variabled added.
c7dc05e Fix for 1.2.3
f6b4dc9 Rev to 1.2.3
48713f3 Use c++1y if available
f72d695 Upgrade DRW compiler version
30071e9 New CLion; add a shared library build
8dfd835 Couple more server tests
4a4a9a4 Use std::ostringstream instead of printf/%x. Portable solution. Fixes #25 again
1fe8f1e Fix size_t printf using C99/GNU %z
495a5b5 Bump to 1.2.2
8294c91 Fix error documents
40a89b7 Add Transfer Encoding
d7bf183 Bump to 1.2.0
3e6784c Bump to 1.1.7
4340303 Merge branch 'master' into async
2b22fbc Merge pull request #24 from offa/minor_fix
4d91214 Tidying up of CMakeLists
97be762 Ensure async test files are copied
a0ab831 Remove unused declaration
fc3cf05 Merge branch 'master' into async
66c57c8 Improve documentation
9b45d96 Greatly simplify the async test using the new API
6d8dda6 Accept lambdas/function<void()> as parameters to 'execute'
2d5bfd5 API change
a87272f Unify capitalization of Seasocks
2f78ab3 Accept lambdas/function<void()> as parameters to 'execute'
4997145 Tidying up
48df0d2 Fix tests
a25ed1c Slightly better async example
eb210b2 More CLion churn (c.f. https://youtrack.jetbrains.com/issue/CPP-6031)
fcd6551 Further work in progress on asynchronous handlers. Working, if ugly and inelgant interface
c09dd01 Work in progress on asynchronous handlers
2ca7237 Add override
e141a4d New CLionisms
ebe5f28 Copy the ws_test_web stuff into the build directory so it can be run directly from there
df925f2 Add all files to CMakeLists to keep CLion happy
c9ee356 Update copyright
636d1fd Enable debug info. Add a simple server executor test
34dc3fb Parameter name used in the macro.
986ff8c Merge pull request #22 from AustinSchuh/arm_alignment_error
5cf784b Fixed alignment error in HybiPacketDecoder on ARM.
d4df8ba Merge pull request #20 from offa/tests_optional
f385375 Merge pull request #19 from offa/pedantic
531f3c0 Option for tests added.
45fb99b Pedantic flag added.
e2bb596 Another attempt at fixing embedded pendantic compilation. Should address #16
b055a03 Merge pull request #17 from offa/nullptr
e32eb53 Merge pull request #18 from offa/ci_buildtypes
6c0d593 CI: Build types added to matrix.
fc36072 NULL replaced by nullptr.
55dd65f DRW config fixups
0dd6e24 Cut up large constant strings to stay clean under -pendantic. Fixes #16
e2155e7 Merge pull request #15 from offa/ci_make
87a02cb CI: Make added as extra step.
4288c74 Remove autoconf from travis
be061b9 Remove the autoconf/configure steps
c223bca Fix up TODOs; update copyright
d690c4c Remove more TODOs for CMake; c++11 and better compiler feature support
d9ae885 CMake tests and valgrind
90dea18 Misc random clion changes
2ecd0a8 Misc tidyups, no functional change
9f7dafa Add CLion files
84e430a Update DRW config
3c73fee Fix clang3.7 warning
882b6ea Fix up gcc4.7 compound initializer issues
d71d67e More warnings fixed, warnings are errors
47fa3db Patch catch.hpp
cb48383 Move to using catch instead of gmock
ee8ece3 ignore idea files for now
9ee6d50 Merge pull request #14 from offa/cmake
c6af9b6 Tests added.
f5b90a2 Apps added.
017fa41 Travis builds using cmake added and cmake set to 2.8.x, since there's no v3.x availalbe on travis yet.
4d26544 Install target added.
7a8d72b Version set.
99adbbe Merge branch 'master' into cmake
1c6fc8a Merge pull request #13 from offa/travi_apt_valgrind
b3516f9 Travis yml: Sudo explicitly disabled.
3078506 Installing valgrind using apt addon -- should enable travis ci container.
636e0f6 Merge branch 'master' into cmake
2b68564 Wall added.
f57aadc Merge pull request #12 from offa/travis_ci_addon
4737e03 Install compilers through Travis Apt-addon.
c090ad4 Embedded content linkage fixed.
3cf5a34 Linking generated sources (WIP).
161966f Static lib removed.
787d965 Embedded library.
5bba071 Map test integrated.
4fd9a1b Configure file.
70b13ec Call fix.
2a17c1c Dependencies fixed.
5ae3f0c Some Improvements.
06a5f50 CMakeFiles added.
1742e9d Look for python2 and run that in preference to python for gen_embedded.py
57c572f Merge pull request #10 from tet112001/master
1eed0fd Head method support
62e1ff1 Merge pull request #9 from Shin-nn/master
a44ec74 fixing style
cdd3f94 forgotten debug line
66f1585 Reponse can modify Cache-Control and Expires headers
8b214c4 Merge pull request #7 from Shin-nn/master
f1185a7 Fix for GCC warnings
Change-Id: I4bd1ec73efb282482c7a1e568625761e6bed0880
git-subtree-dir: third_party/seasocks
git-subtree-split: bac7d40a9bc081997ac5e9165b408e4f54410a44
diff --git a/scripts/gen_embedded.py b/scripts/gen_embedded.py
index f715b1d..901b014 100755
--- a/scripts/gen_embedded.py
+++ b/scripts/gen_embedded.py
@@ -1,35 +1,83 @@
#!/usr/bin/env python
-import os, os.path, sys
+import os, os.path, sys, argparse
-print """
+SOURCE_TEMPLATE = """
#include "internal/Embedded.h"
#include <string>
#include <unordered_map>
namespace {
+%s
-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 """
-};
+ const std::unordered_map<std::string, EmbeddedContent> embedded = {
+%s
+ };
} // namespace
const EmbeddedContent* findEmbeddedContent(const std::string& name) {
- auto found = embedded.find(name);
- if (found == embedded.end()) {
- return NULL;
- }
- return &found->second;
-}
+ const auto found = embedded.find(name);
+ if (found == embedded.end()) {
+ return nullptr;
+ }
+ return &found->second;
+}\n
"""
+MAX_SLICE = 70
+
+
+def as_byte(data):
+ if sys.version_info < (3,):
+ return ord(data)
+ else:
+ return data
+
+
+def parse_arguments():
+ parser = argparse.ArgumentParser(description="Embedded content generator")
+ parser.add_argument('--output', '-o', action='store', dest='output_file', type=str, help='Output File', required=True)
+ parser.add_argument('--file', '-f', action='store', nargs='+', dest='input_file', type=str, help='Output File', required=True)
+ return parser.parse_args()
+
+
+def create_file_byte(name, file_bytes):
+ output = []
+ output.append(' const char %s[] = {' % name)
+
+ for start in range(0, len(file_bytes), MAX_SLICE):
+ output.append('' + "".join(["'\\x%02x'," % as_byte(x) for x in file_bytes[start:start+MAX_SLICE]]) + "\n")
+ output.append('0};\n')
+ return ''.join(output)
+
+
+def create_file_info(file_list):
+ output = []
+ for name, base, length in file_list:
+ output.append(' {"/%s", { %s, %d }},\n' % (base, name, length))
+ return ''.join(output)
+
+
+def main():
+ args = parse_arguments()
+
+ files = []
+ index = 1
+ file_byte_entries = []
+
+ for file_name in args.input_file:
+ with open(file_name, 'rb') as f:
+ file_bytes = f.read()
+ name = "fileData%d" % index
+ index += 1
+ files.append((name, os.path.basename(file_name), len(file_bytes)))
+ file_byte_entries.append(create_file_byte(name, file_bytes))
+
+ with open(args.output_file, 'w') as output_file:
+ output_file.write(SOURCE_TEMPLATE % (''.join(file_byte_entries), create_file_info(files)))
+
+
+if __name__ == '__main__':
+ main()