Add seasocks to aos externals for http_status and add test server.
This is stage 1 of the http_status project!
Seasocks requires a rather elaborate method of compiling the code
and including the web pages into the compiled executable as raw data,
so some of the stuff in the gyp system may not be pretty. We will fix
these problems up in later revisions as needed.
The web directory holds the rudimentary files for the web server (404
message, javascript library that we will use in later stages of
designing th web page interface, and icons. web_test holds the files for
the test webpage that can be accessed at localhost:8080 when the server
is running. Again, this directory, along with the content of
http_status.cc, is temporary and intended only to show the functionality
of the server socket.
Change-Id: I2ad1598ae200b526620b014db970e980f3c8a563
diff --git a/aos/build/download_externals.sh b/aos/build/download_externals.sh
index 11070f9..413d0fc 100755
--- a/aos/build/download_externals.sh
+++ b/aos/build/download_externals.sh
@@ -211,4 +211,10 @@
CPPFLAGS=\"-I ${LIBUNWIND_PREFIX}/include\" \
&& make && make install"
+# get and build seasocks
+SEASOCKS_VERSION=1.1.2
+SEASOCKS_DIR=${EXTERNALS}/seasocks-${SEASOCKS_VERSION}
+[ -d ${SEASOCKS_DIR} ] || git clone --branch v${SEASOCKS_VERSION} \
+ https://github.com/mattgodbolt/seasocks.git ${SEASOCKS_DIR}
+
rm -rf ${TMPDIR}
diff --git a/aos/build/externals.gyp b/aos/build/externals.gyp
index e14850b..8764eb7 100644
--- a/aos/build/externals.gyp
+++ b/aos/build/externals.gyp
@@ -16,6 +16,7 @@
'libevent_version': '2.0.21',
'libcdd_version': '094g',
'stm32flash_commit': '8399fbe1baf2b7d097746786458021d92895d71b',
+ 'seasocks_version': '1.1.2',
'allwpilib': '<(AOS)/externals/allwpilib',
'forwpilib': '<(AOS)/externals/forwpilib',
@@ -183,5 +184,30 @@
'include_dirs': ['<(compiled_abs)/'],
},
},
+ {
+ 'target_name': 'seasocks',
+ 'type': 'static_library',
+ 'sources': [
+ '<!@(find <(externals)/seasocks-<(seasocks_version)/src/main/c -name *.cpp)',
+ ],
+ 'include_dirs': [
+ '<(AOS)/externals/seasocks',
+ '<(externals_abs)/seasocks-<(seasocks_version)/src/main/c',
+ ],
+ 'cflags': [
+ '-Wno-unused-parameter',
+ '-Wno-format-nonliteral',
+ '-Wno-error=cast-align',
+ '-Wno-switch-enum',
+ '-Wno-cast-qual',
+ '-Wno-error=strict-aliasing',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(AOS)/externals/seasocks',
+ '<(externals)/seasocks-<(seasocks_version)/src/main/c',
+ ],
+ },
+ },
],
}
diff --git a/aos/externals/seasocks/gen_embedded.py b/aos/externals/seasocks/gen_embedded.py
new file mode 100755
index 0000000..5fc0267
--- /dev/null
+++ b/aos/externals/seasocks/gen_embedded.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+# This file is a modified version of the gen_embedded script included in the
+# scripts directory of seasocks (version 1.1.2). It has been modified to
+# recursively find the web files itself, which was originally done by piping
+# in the results from a "find" shell command.
+
+# The embedded files includes only those that are required for the server to run
+# (including 404 files, a default index page, favicon, etc.)
+
+import os, os.path, sys
+
+o = open('embedded.h', 'w')
+
+web = []
+for root, dirs, files in os.walk("./web", topdown=False):
+ for name in files:
+ web.append(os.path.join(root, name))
+ for name in dirs:
+ web.append(os.path.join(root, name))
+
+o.write("""
+#include "internal/Embedded.h"
+
+#include <string>
+#include <unordered_map>
+
+namespace {
+
+std::unordered_map<std::string, EmbeddedContent> embedded = {
+""")
+
+for f in web:
+ bytes = open(f, 'rb').read()
+ o.write('{"/%s", {' % os.path.basename(f))
+ o.write('"' + "".join(['\\x%02x' % ord(x) for x in bytes]) + '"')
+ o.write(',%d }},' % len(bytes))
+
+o.write("""
+};
+
+} // namespace
+
+const EmbeddedContent* findEmbeddedContent(const std::string& name) {
+ auto found = embedded.find(name);
+ if (found == embedded.end()) {
+ return NULL;
+ }
+ return &found->second;
+}
+""")
+
+o.close()
diff --git a/aos/externals/seasocks/internal/Config.h b/aos/externals/seasocks/internal/Config.h
new file mode 100644
index 0000000..e99d356
--- /dev/null
+++ b/aos/externals/seasocks/internal/Config.h
@@ -0,0 +1,221 @@
+// Generated by Comran from version 1.1.2 with the autoconf scripts from upstream
+/* src/main/c/internal/Config.h. Generated from Config.h.in by configure. */
+/* src/main/c/internal/Config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* define if the compiler supports basic C++11 syntax */
+/* #undef HAVE_CXX11 */
+
+/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
+ don't. */
+#define HAVE_DECL_STRERROR_R 1
+
+/* Define to 1 if you have the `dup2' function. */
+#define HAVE_DUP2 1
+
+/* Define to 1 if you have the `eventfd' function. */
+#define HAVE_EVENTFD 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
+/* Define to 1 if you have the `gethostname' function. */
+#define HAVE_GETHOSTNAME 1
+
+/* Define to 1 if you have the `getopt' function. */
+#define HAVE_GETOPT 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+/* #undef HAVE_MALLOC */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if the system has the type `ptrdiff_t'. */
+#define HAVE_PTRDIFF_T 1
+
+/* Define to 1 if you have the `rmdir' function. */
+#define HAVE_RMDIR 1
+
+/* Define to 1 if you have the `socket' function. */
+#define HAVE_SOCKET 1
+
+/* Define to 1 if you have the `sqrt' function. */
+#define HAVE_SQRT 1
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#define HAVE_STRCASECMP 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the `strerror_r' function. */
+#define HAVE_STRERROR_R 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `syscall' function. */
+#define HAVE_SYSCALL 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* define if unordered_map supports emplace */
+#define HAVE_UNORDERED_MAP_EMPLACE 1
+
+/* Define to 1 if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define to 1 if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define to 1 if `fork' works. */
+#define HAVE_WORKING_FORK 1
+
+/* Define to 1 if `vfork' works. */
+#define HAVE_WORKING_VFORK 1
+
+/* Define to 1 if the system has the type `_Bool'. */
+/* #undef HAVE__BOOL */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "matt@godbolt.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "SeaSocks"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "SeaSocks 0.1"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "seasocks"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "https://github.com/mattgodbolt/seasocks"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.1"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if strerror_r returns char *. */
+#define STRERROR_R_CHAR_P 1
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT32_T */
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT64_T */
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT8_T */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to rpl_malloc if the replacement function should be used. */
+/* #undef malloc */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef pid_t */
+
+/* Define to the equivalent of the C99 'restrict' keyword, or to
+ nothing if this is not supported. Do not define if restrict is
+ supported directly. */
+#define restrict __restrict
+/* Work around a bug in Sun C++: it does not support _Restrict or
+ __restrict__, even though the corresponding Sun C compiler ends up with
+ "#define restrict _Restrict" or "#define restrict __restrict__" in the
+ previous line. Perhaps some future version of Sun C++ will work with
+ restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
+#if defined __SUNPRO_CC && !defined __RESTRICT
+# define _Restrict
+# define __restrict__
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint16_t */
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint32_t */
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint64_t */
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint8_t */
+
+/* Define as `fork' if `vfork' does not work. */
+/* #undef vfork */