├── .gitmodules ├── LICENSE ├── Makefile.in ├── README.md ├── config.h.in ├── configure ├── configure.ac ├── doc └── html │ ├── ad__http__handler_8c.html │ ├── ad__http__handler_8c.js │ ├── ad__http__handler_8c_source.html │ ├── ad__http__handler_8h.html │ ├── ad__http__handler_8h.js │ ├── ad__http__handler_8h_source.html │ ├── ad__server_8c.html │ ├── ad__server_8c.js │ ├── ad__server_8c_source.html │ ├── ad__server_8h.html │ ├── ad__server_8h.js │ ├── ad__server_8h_source.html │ ├── annotated.html │ ├── annotated.js │ ├── asyncd_8h.html │ ├── asyncd_8h_source.html │ ├── bc_s.png │ ├── bdwn.png │ ├── classes.html │ ├── closed.png │ ├── dir_9273431fadbcee3009b231da59d31b6f.html │ ├── dir_9273431fadbcee3009b231da59d31b6f.js │ ├── dir_d44c64559bbebec7f509842c48db8b23.html │ ├── dir_d44c64559bbebec7f509842c48db8b23.js │ ├── doxygen.css │ ├── doxygen.png │ ├── dynsections.js │ ├── files.html │ ├── files.js │ ├── ftv2blank.png │ ├── ftv2cl.png │ ├── ftv2doc.png │ ├── ftv2folderclosed.png │ ├── ftv2folderopen.png │ ├── ftv2lastnode.png │ ├── ftv2link.png │ ├── ftv2mlastnode.png │ ├── ftv2mnode.png │ ├── ftv2mo.png │ ├── ftv2node.png │ ├── ftv2ns.png │ ├── ftv2plastnode.png │ ├── ftv2pnode.png │ ├── ftv2splitbar.png │ ├── ftv2vertline.png │ ├── functions.html │ ├── functions_vars.html │ ├── globals.html │ ├── globals_defs.html │ ├── globals_enum.html │ ├── globals_eval.html │ ├── globals_func.html │ ├── globals_type.html │ ├── globals_vars.html │ ├── index.html │ ├── jquery.js │ ├── nav_f.png │ ├── nav_g.png │ ├── nav_h.png │ ├── navtree.css │ ├── navtree.js │ ├── navtreeindex0.js │ ├── open.png │ ├── resize.js │ ├── structad__conn__s.html │ ├── structad__conn__s.js │ ├── structad__http__s.html │ ├── structad__http__s.js │ ├── structad__server__s.html │ ├── structad__server__s.js │ ├── sync_off.png │ ├── sync_on.png │ ├── tab_a.png │ ├── tab_b.png │ ├── tab_h.png │ ├── tab_s.png │ └── tabs.css ├── examples ├── Makefile.in ├── echo_http_server.c ├── echo_tcp_server.c ├── helloworld_http_server.c ├── helloworld_ssl_server.c ├── helloworld_tcp_server.c ├── ssl.cert └── ssl.pkey ├── include └── asyncd │ ├── ad_http_handler.h │ ├── ad_server.h │ └── asyncd.h ├── install-sh ├── lib └── run2init-submodules.sh └── src ├── Makefile.in ├── ad_http_handler.c ├── ad_server.c ├── doxygen.conf └── macro.h /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/qlibc"] 2 | path = lib/qlibc 3 | url = https://github.com/wolkykim/qlibc 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | libasyncd is available for use under the following license, commonly known 2 | as BSD license: 3 | 4 | ============================================================================== 5 | libasyncd 6 | 7 | Copyright (c) 2014 Seungyoung Kim. 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, 14 | this list of conditions and the following disclaimer. 15 | 2. Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. 30 | ============================================================================== 31 | 32 | Underlying libraries that libasyncd uses are works by others, also made 33 | available by them under the BSD license above. The copyright notices are 34 | available in the corresponding libraries; Here's the list: 35 | 36 | libevent: 37 | Copyright (c) 2000-2007 Niels Provos 38 | Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 39 | 40 | qlibc: 41 | Copyright (c) 2010-2014 Seungyoung Kim. 42 | 43 | (end of LICENSE) 44 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | ## libasyncd 3 | ## 4 | ## Copyright (c) 2014 Seungyoung Kim. 5 | ## All rights reserved. 6 | ## 7 | ## Redistribution and use in source and binary forms, with or without 8 | ## modification, are permitted provided that the following conditions are met: 9 | ## 10 | ## 1. Redistributions of source code must retain the above copyright notice, 11 | ## this list of conditions and the following disclaimer. 12 | ## 2. Redistributions in binary form must reproduce the above copyright notice, 13 | ## this list of conditions and the following disclaimer in the documentation 14 | ## and/or other materials provided with the distribution. 15 | ## 16 | ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | ## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | ## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | ## POSSIBILITY OF SUCH DAMAGE. 27 | ################################################################################ 28 | 29 | RM = @RM@ 30 | 31 | all: 32 | $(MAKE) -C src all 33 | 34 | install: 35 | $(MAKE) -C src install 36 | @echo "=======================================================" 37 | @echo "Run 'make install-libs' to install dependent libraries." 38 | @echo "=======================================================" 39 | 40 | install-libs: 41 | $(MAKE) -C lib/qlibc install 42 | 43 | deinstall: uninstall 44 | uninstall: 45 | $(MAKE) -C src uninstall 46 | 47 | uninstall-libs: 48 | $(MAKE) -C lib/qlibc/ uninstall 49 | 50 | clean: 51 | $(MAKE) -C src clean 52 | 53 | distclean: clean 54 | @for DIR in src examples; do \ 55 | echo "===> $${DIR}"; \ 56 | (cd $${DIR}; ${RM} -f Makefile); \ 57 | echo "<=== $${DIR}"; \ 58 | done 59 | ${RM} -rf autom4te.cache 60 | ${RM} -f configure.lineno config.log config.status config.h 61 | ${RM} -f Makefile 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libasyncd 2 | ========= 3 | 4 | Embeddable Event-based Asynchronous Message/HTTP Server library for C/C++. 5 | 6 | ## What is libasyncd? 7 | 8 | Libasyncd is an embeddable event-driven asynchronous message server for C/C++. 9 | It supports HTTP protocol by default and you can add your own protocol handler(hook) 10 | to build your own high performance server. 11 | 12 | Asynchronous way of programming can easily go quite complicated since you need to 13 | handle every thing in non-blocking way. So the goal of Libasyncd project is 14 | to make a flexible and fast asynchronous server framework with nice abstraction that 15 | can cut down the complexity. 16 | 17 | ## Why libasyncd? 18 | 19 | libasyncd is a light-weight single-threaded asynchronous RPC server. It is efficient 20 | especially when server needs to handle a large number of concurrent connections where 21 | connection-per-thread or connection-per-process model is not appropriate to consider. 22 | 23 | * Stands as a generic event-based server library. (single-thread) 24 | * Embeddable library module - you write main(). 25 | * Pluggable protocol handlers. 26 | * Complete HTTP protocol handler. (support chunked transfer-encoding) 27 | * Support request pipelining. 28 | * Support multiple hooks. 29 | * Support SSL - Just flip the switch on. 30 | * Support IPv4, IPv6 and Unix Socket. 31 | * Simple to use - Check out examples. 32 | 33 | ## Compile & Install. 34 | ``` 35 | $ git clone https://github.com/wolkykim/libasyncd 36 | $ cd libasyncd 37 | $ ./configure 38 | # If using system wide install of qlibc, add QLIBC=system to make install command 39 | $ make install 40 | ``` 41 | 42 | ## API Reference 43 | 44 | * [libasyncd API reference](http://wolkykim.github.io/libasyncd/doc/html/globals_func.html) 45 | 46 | ## "Hello World", Asynchronous Socket Server example. 47 | ```c 48 | int my_conn_handler(short event, ad_conn_t *conn, void *userdata) { 49 | if (event & AD_EVENT_WRITE) { 50 | evbuffer_add_printf(conn->out, "Hello World."); 51 | return AD_CLOSE; 52 | } 53 | return AD_OK; 54 | } 55 | 56 | int main(int argc, char **argv) { 57 | ad_log_level(AD_LOG_DEBUG); 58 | ad_server_t *server = ad_server_new(); 59 | ad_server_set_option(server, "server.port", "2222"); 60 | ad_server_register_hook(server, my_conn_handler, NULL); 61 | return ad_server_start(server); 62 | } 63 | ``` 64 | 65 | ## "Hello World", Asynchronous HTTPS Server example. 66 | ```c 67 | int my_http_get_handler(short event, ad_conn_t *conn, void *userdata) { 68 | if (event & AD_EVENT_READ) { 69 | if (ad_http_get_status(conn) == AD_HTTP_REQ_DONE) { 70 | ad_http_response(conn, 200, "text/html", "Hello World", 11); 71 | return ad_http_is_keepalive_request(conn) ? AD_DONE : AD_CLOSE; 72 | } 73 | } 74 | return AD_OK; 75 | } 76 | 77 | int my_http_default_handler(short event, ad_conn_t *conn, void *userdata) { 78 | if (event & AD_EVENT_READ) { 79 | if (ad_http_get_status(conn) == AD_HTTP_REQ_DONE) { 80 | ad_http_response(conn, 501, "text/html", "Not implemented", 15); 81 | return AD_CLOSE; // Close connection. 82 | } 83 | } 84 | return AD_OK; 85 | } 86 | 87 | int main(int argc, char **argv) { 88 | 89 | SSL_load_error_strings(); 90 | SSL_library_init(); 91 | 92 | ad_log_level(AD_LOG_DEBUG); 93 | ad_server_t *server = ad_server_new(); 94 | ad_server_set_option(server, "server.port", "8888"); 95 | ad_server_set_ssl_ctx(server, ad_server_ssl_ctx_create_simple("ssl.cert", "ssl.pkey")); 96 | ad_server_register_hook(server, ad_http_handler, NULL); // HTTP Parser is also a hook. 97 | ad_server_register_hook_on_method(server, "GET", my_http_get_handler, NULL); 98 | ad_server_register_hook(server, my_http_default_handler, NULL); 99 | 100 | return ad_server_start(server); 101 | } 102 | ``` 103 | 104 | Please refer sample codes such as echo example in examples directory for more details. 105 | 106 | ## References 107 | 108 | * [C10K problem](http://en.wikipedia.org/wiki/C10k_problem) 109 | * [libevent library - an event notification library](http://libevent.org/) 110 | * [qLibc library - a STL like C library](http://wolkykim.github.io/qlibc/) 111 | 112 | ## Contributors 113 | 114 | The following people have helped with suggestions, ideas, code or fixing bugs: 115 | (in alphabetical order by first name) 116 | 117 | * [Seungyoung "Steve" Kim](https://github.com/wolkykim) - Author 118 | * [Carpentier Pierre-Francois](https://github.com/kakwa) 119 | * [Dmitri Toubelis](https://github.com/dtoubelis) 120 | * [Levi Durfee](https://github.com/levidurfee) 121 | * [Shaun Bruner](https://github.com/spbruner) 122 | 123 | Please send a PR for adding your name here, so we know whom to appreciate. 124 | Thanks to all the contributors. 125 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file, and it defines `DIR'. 4 | */ 5 | #undef HAVE_DIRENT_H 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #undef HAVE_INTTYPES_H 9 | 10 | /* Define to 1 if you have the `pthread' library (-lpthread). */ 11 | #undef HAVE_LIBPTHREAD 12 | 13 | /* Define to 1 if you have the header file. */ 14 | #undef HAVE_MEMORY_H 15 | 16 | /* Define to 1 if you have the header file, and it defines `DIR'. */ 17 | #undef HAVE_NDIR_H 18 | 19 | /* Define to 1 if stdbool.h conforms to C99. */ 20 | #undef HAVE_STDBOOL_H 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #undef HAVE_STDINT_H 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #undef HAVE_STDLIB_H 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #undef HAVE_STRINGS_H 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #undef HAVE_STRING_H 33 | 34 | /* Define to 1 if you have the header file, and it defines `DIR'. 35 | */ 36 | #undef HAVE_SYS_DIR_H 37 | 38 | /* Define to 1 if you have the header file, and it defines `DIR'. 39 | */ 40 | #undef HAVE_SYS_NDIR_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_SYS_STAT_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_SYS_TYPES_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_UNISTD_H 50 | 51 | /* Define to 1 if the system has the type `_Bool'. */ 52 | #undef HAVE__BOOL 53 | 54 | /* Define to the address where bug reports for this package should be sent. */ 55 | #undef PACKAGE_BUGREPORT 56 | 57 | /* Define to the full name of this package. */ 58 | #undef PACKAGE_NAME 59 | 60 | /* Define to the full name and version of this package. */ 61 | #undef PACKAGE_STRING 62 | 63 | /* Define to the one symbol short name of this package. */ 64 | #undef PACKAGE_TARNAME 65 | 66 | /* Define to the version of this package. */ 67 | #undef PACKAGE_VERSION 68 | 69 | /* Define to 1 if you have the ANSI C header files. */ 70 | #undef STDC_HEADERS 71 | 72 | /* Define to `long' if does not define. */ 73 | #undef off_t 74 | 75 | /* Define to `unsigned' if does not define. */ 76 | #undef size_t 77 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | ## libasyncd 3 | ## 4 | ## Copyright (c) 2014 Seungyoung Kim. 5 | ## All rights reserved. 6 | ## 7 | ## Redistribution and use in source and binary forms, with or without 8 | ## modification, are permitted provided that the following conditions are met: 9 | ## 10 | ## 1. Redistributions of source code must retain the above copyright notice, 11 | ## this list of conditions and the following disclaimer. 12 | ## 2. Redistributions in binary form must reproduce the above copyright notice, 13 | ## this list of conditions and the following disclaimer in the documentation 14 | ## and/or other materials provided with the distribution. 15 | ## 16 | ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | ## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | ## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | ## POSSIBILITY OF SUCH DAMAGE. 27 | ################################################################################ 28 | 29 | AC_COPYRIGHT([ 30 | ============================================================================== 31 | libasyncd 32 | 33 | Copyright (c) 2014 Seungyoung Kim. 34 | All rights reserved. 35 | 36 | Redistribution and use in source and binary forms, with or without 37 | modification, are permitted provided that the following conditions are met: 38 | 39 | 1. Redistributions of source code must retain the above copyright notice, 40 | this list of conditions and the following disclaimer. 41 | 2. Redistributions in binary form must reproduce the above copyright notice, 42 | this list of conditions and the following disclaimer in the documentation 43 | and/or other materials provided with the distribution. 44 | 45 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 46 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 47 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 48 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 49 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 50 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 51 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 52 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 53 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 55 | POSSIBILITY OF SUCH DAMAGE. 56 | ============================================================================== 57 | ]) 58 | 59 | ## Internal functions 60 | AC_DEFUN([Q_ARG_ENABLE], [ 61 | AC_ARG_ENABLE([$1],[AS_HELP_STRING([--enable-$1], [$2])],,[enableval=no]) 62 | if test "$enableval" = yes; then 63 | AC_MSG_NOTICE(['$1' feature is enabled]) 64 | CPPFLAGS="$CPPFLAGS $3" 65 | fi 66 | ]) 67 | 68 | AC_DEFUN([Q_ARG_DISABLE], [ 69 | AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1], [$2])],,[enableval=yes]) 70 | if test "$enableval" = no; then 71 | AC_MSG_NOTICE(['$1' feature is disabled]) 72 | CPPFLAGS="$CPPFLAGS $3" 73 | fi 74 | ]) 75 | 76 | ## Initialize 77 | AC_INIT([libasyncd], [1], [https://github.com/wolkykim/libasyncd]) 78 | AC_CONFIG_SRCDIR([config.h.in]) 79 | AC_CONFIG_HEADER([config.h]) 80 | AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile]) 81 | AC_SUBST(DEPLIBS, [""]) 82 | 83 | ## Set path 84 | PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" 85 | CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/local/include" 86 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" 87 | CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" 88 | LDFLAGS="$LDFLAGS -L/usr/lib -L/usr/local/lib" 89 | 90 | ## Set autoconf setting 91 | #AC_CANONICAL_TARGET 92 | AC_PREFIX_DEFAULT([/usr/local]) 93 | #AC_PRESERVE_HELP_ORDER 94 | 95 | ## Checks for programs. 96 | AC_PROG_CC 97 | if test $ac_compiler_gnu = yes; then 98 | CFLAGS="-Wall -Wstrict-prototypes -fPIC" 99 | #else 100 | # AC_MSG_FAILURE([GCC is required.]) 101 | fi 102 | AC_PROG_CC_C99 103 | if test $ac_cv_prog_cc_c99 = no; then 104 | AC_MSG_FAILURE([Compiler does not support C99 mode.]) 105 | fi 106 | 107 | AC_PROG_INSTALL 108 | AC_PROG_MKDIR_P 109 | AC_PROG_LN_S 110 | AC_PROG_MAKE_SET 111 | AC_PROG_RANLIB 112 | 113 | AC_PATH_PROG(AR, ar, [$PATH]) 114 | AC_PATH_PROG(CHMOD, chmod, [$PATH]) 115 | AC_PATH_PROG(LD, ld, [$PATH]) 116 | AC_PATH_PROG(RM, rm, [$PATH]) 117 | 118 | ## Checks for header files. 119 | AC_HEADER_STDC 120 | AC_HEADER_STDBOOL 121 | AC_HEADER_DIRENT 122 | AC_CHECK_HEADER([inttypes.h]) 123 | AC_CHECK_HEADER([openssl/ssl.h]) 124 | AC_CHECK_HEADER([event2/event.h]) 125 | 126 | ## Checks for typedefs, structures, and compiler characteristics. 127 | AC_TYPE_INT8_T 128 | AC_TYPE_INT16_T 129 | AC_TYPE_INT32_T 130 | AC_TYPE_INT64_T 131 | AC_TYPE_UINT8_T 132 | AC_TYPE_UINT16_T 133 | AC_TYPE_UINT32_T 134 | AC_TYPE_UINT64_T 135 | AC_TYPE_SIZE_T 136 | AC_TYPE_SSIZE_T 137 | AC_TYPE_OFF_T 138 | 139 | ## Checks for libraries. 140 | 141 | ## Checks for library functions. 142 | AC_CHECK_LIB([pthread], [main], [], AC_MSG_ERROR([Cannot find pthread library.])) 143 | AC_SUBST(DEPLIBS, ["$DEPLIBS -lpthread"]) 144 | 145 | AC_CHECK_LIB([event], [main], [], AC_MSG_ERROR([Cannot find libevent library.])) 146 | AC_SUBST(DEPLIBS, ["$DEPLIBS -levent"]) 147 | 148 | AC_CHECK_LIB([event_pthreads], [main], [], AC_MSG_ERROR([Cannot find libevent_pthreads library.])) 149 | AC_SUBST(DEPLIBS, ["$DEPLIBS -levent_pthreads"]) 150 | 151 | AC_CHECK_LIB([event_openssl], [main], [], AC_MSG_ERROR([Cannot find libevent_openssl library.])) 152 | AC_SUBST(DEPLIBS, ["$DEPLIBS -levent_openssl"]) 153 | 154 | AC_CHECK_LIB([ssl], [main], [], AC_MSG_ERROR([Cannot find openssl library.])) 155 | AC_SUBST(DEPLIBS, ["$DEPLIBS -lssl"]) 156 | 157 | AC_CHECK_LIB([crypto], [main], [], AC_MSG_ERROR([Cannot find crypto library.])) 158 | AC_SUBST(DEPLIBS, ["$DEPLIBS -lcrypto"]) 159 | 160 | ## 161 | ## --enable section 162 | ## 163 | 164 | Q_ARG_ENABLE([debug], [Enable debugging output. This will print out internal debugging messages to stdout.], [-DBUILD_DEBUG]) 165 | if test "$enableval" = yes; then 166 | CFLAGS="$CFLAGS -g -O2" 167 | else 168 | CFLAGS="$CFLAGS -g -O2" 169 | fi 170 | 171 | AC_MSG_NOTICE([CFLAGS $CFLAGS]) 172 | AC_MSG_NOTICE([CPPFLAGS $CPPFLAGS]) 173 | AC_MSG_NOTICE([DEPLIBS $DEPLIBS]) 174 | 175 | ## Create Makefile 176 | AC_OUTPUT 177 | -------------------------------------------------------------------------------- /doc/html/ad__http__handler_8c.js: -------------------------------------------------------------------------------- 1 | var ad__http__handler_8c = 2 | [ 3 | [ "ad_http_handler", "ad__http__handler_8c.html#a6b65a1411892e20395127d00502a2c44", null ], 4 | [ "ad_http_get_status", "ad__http__handler_8c.html#a20357ffbba80b590ad70f451b2ae299e", null ], 5 | [ "ad_http_get_inbuf", "ad__http__handler_8c.html#a9b8117eea824b918f2cc0d80251dfe3a", null ], 6 | [ "ad_http_get_outbuf", "ad__http__handler_8c.html#af5085188b8be2e7ab290fe0ec22789b4", null ], 7 | [ "ad_http_get_request_header", "ad__http__handler_8c.html#aa931a4adcd07f3bc23fe4f183dc4c8dc", null ], 8 | [ "ad_http_get_content_length", "ad__http__handler_8c.html#ac07e895997348c2885722f98c3260438", null ], 9 | [ "ad_http_get_content_length_stored", "ad__http__handler_8c.html#a468ef4268a9a7c71dfce494c446ebcb5", null ], 10 | [ "ad_http_get_content", "ad__http__handler_8c.html#a4d28e689e120cfa22217507c74683779", null ], 11 | [ "ad_http_is_keepalive_request", "ad__http__handler_8c.html#ae6a1a9707180447257fd769b249ee42d", null ], 12 | [ "ad_http_set_response_header", "ad__http__handler_8c.html#a59ed09afcce36474000c6cded0bd7b64", null ], 13 | [ "ad_http_get_response_header", "ad__http__handler_8c.html#a073c5cb0c9724167031e80907890fb88", null ], 14 | [ "ad_http_set_response_code", "ad__http__handler_8c.html#afe22e6f81773c01d316e45009996c4a3", null ], 15 | [ "ad_http_set_response_content", "ad__http__handler_8c.html#a048a0e35599f8a884494deba0dbd89b7", null ], 16 | [ "ad_http_response", "ad__http__handler_8c.html#aa54a1f3393b20b70f2769b3d039f3bd7", null ], 17 | [ "ad_http_send_header", "ad__http__handler_8c.html#a9067ac0cfb15136e63c134a5292e7716", null ], 18 | [ "ad_http_send_data", "ad__http__handler_8c.html#a5be41fc8a08dcadf94fc271aeb05b6e2", null ], 19 | [ "ad_http_send_chunk", "ad__http__handler_8c.html#a515f6b88b99a19e5c0ccdfd43b0e29ad", null ], 20 | [ "ad_http_get_reason", "ad__http__handler_8c.html#afeef7409bd771bcf2e29eb6ab70af894", null ] 21 | ]; -------------------------------------------------------------------------------- /doc/html/ad__http__handler_8h.js: -------------------------------------------------------------------------------- 1 | var ad__http__handler_8h = 2 | [ 3 | [ "ad_http_s", "structad__http__s.html", "structad__http__s" ], 4 | [ "HTTP_PROTOCOL_09", "ad__http__handler_8h.html#a037c9e7fb06bd5a319011a220c71f866", null ], 5 | [ "HTTP_PROTOCOL_10", "ad__http__handler_8h.html#a398b05c4fb1d7f2659fb67a00009ba83", null ], 6 | [ "HTTP_PROTOCOL_11", "ad__http__handler_8h.html#aba396af03e2875b5ddedee43ad3c4707", null ], 7 | [ "HTTP_NO_RESPONSE", "ad__http__handler_8h.html#ad02ab7af04409020264521a798de2a5a", null ], 8 | [ "HTTP_CODE_CONTINUE", "ad__http__handler_8h.html#ad1f324698e12fefadfc2ec5d16ce6a5b", null ], 9 | [ "HTTP_CODE_OK", "ad__http__handler_8h.html#a471de168f41ecf5e8d62a43fea28b5d7", null ], 10 | [ "HTTP_CODE_CREATED", "ad__http__handler_8h.html#a00c11c6c6bf42cf1fb483c273454cf45", null ], 11 | [ "HTTP_CODE_NO_CONTENT", "ad__http__handler_8h.html#a7e41c8a47383e2bdf4b34ce5510bc9b6", null ], 12 | [ "HTTP_CODE_PARTIAL_CONTENT", "ad__http__handler_8h.html#a57da3583490d37abb674773f712491fd", null ], 13 | [ "HTTP_CODE_MULTI_STATUS", "ad__http__handler_8h.html#a463a0b7aed650158725b205bc1bd0de8", null ], 14 | [ "HTTP_CODE_MOVED_TEMPORARILY", "ad__http__handler_8h.html#a33f32423ccbf3a2a61f56cc5aee18cd8", null ], 15 | [ "HTTP_CODE_NOT_MODIFIED", "ad__http__handler_8h.html#a225a5999b63c699c4492a8412b315452", null ], 16 | [ "HTTP_CODE_BAD_REQUEST", "ad__http__handler_8h.html#a16c7e21f17349c2515fe0134f9b7ffd4", null ], 17 | [ "HTTP_CODE_UNAUTHORIZED", "ad__http__handler_8h.html#a4667745cca24cb084488393a562647aa", null ], 18 | [ "HTTP_CODE_FORBIDDEN", "ad__http__handler_8h.html#ac68e0a1d868dad52967d757dab5220db", null ], 19 | [ "HTTP_CODE_NOT_FOUND", "ad__http__handler_8h.html#a20eb5cc8af538c827de0f7ed9811243c", null ], 20 | [ "HTTP_CODE_METHOD_NOT_ALLOWED", "ad__http__handler_8h.html#a7c8d72a7d4eda32ad9a6211958463e97", null ], 21 | [ "HTTP_CODE_REQUEST_TIME_OUT", "ad__http__handler_8h.html#a78c49465c70c576daa60e34a84a9e47c", null ], 22 | [ "HTTP_CODE_GONE", "ad__http__handler_8h.html#a0eeb0f3801fbd1ca5d0f050e12426768", null ], 23 | [ "HTTP_CODE_REQUEST_URI_TOO_LONG", "ad__http__handler_8h.html#a0023f7e49348c8c52b2fb8b547202ed3", null ], 24 | [ "HTTP_CODE_LOCKED", "ad__http__handler_8h.html#af370c9b66441321e2c3fa3fc01fbc35c", null ], 25 | [ "HTTP_CODE_INTERNAL_SERVER_ERROR", "ad__http__handler_8h.html#a6d47746cc8b934944ed4f05308b2da63", null ], 26 | [ "HTTP_CODE_NOT_IMPLEMENTED", "ad__http__handler_8h.html#a9e272d1190eb37ce4447a9021f68a0c4", null ], 27 | [ "HTTP_CODE_SERVICE_UNAVAILABLE", "ad__http__handler_8h.html#a00a05677bf92a38abf5be28b5ce0d294", null ], 28 | [ "HTTP_CRLF", "ad__http__handler_8h.html#aca074be7a96314dfc8fd39e49b563977", null ], 29 | [ "HTTP_DEF_CONTENTTYPE", "ad__http__handler_8h.html#a320e59775effe7afcab43ecc01da7b3a", null ], 30 | [ "AD_HOOK_ALL", "ad__http__handler_8h.html#a39f327ff61b9f55900a617a1b276dd5d", null ], 31 | [ "AD_HOOK_ON_CONNECT", "ad__http__handler_8h.html#a34398c7c7f8cc256833b010804dd80fc", null ], 32 | [ "AD_HOOK_AFTER_REQUESTLINE", "ad__http__handler_8h.html#a3e4b5b7d8d4a1d0c19b406ea4892c94d", null ], 33 | [ "AD_HOOK_AFTER_HEADER", "ad__http__handler_8h.html#ab51441a3e5c01b55610c999285323688", null ], 34 | [ "AD_HOOK_ON_BODY", "ad__http__handler_8h.html#a0f7140c7f5fd95bff8a271e8bfae008e", null ], 35 | [ "AD_HOOK_ON_REQUEST", "ad__http__handler_8h.html#a526d717fa61a65165d1dce7b93a1a815", null ], 36 | [ "AD_HOOK_ON_CLOSE", "ad__http__handler_8h.html#ac096c79db499c73dce8bfbceb032fbb2", null ], 37 | [ "ad_http_t", "ad__http__handler_8h.html#aab3c97042939726fecc74885bf7da46e", null ], 38 | [ "ad_http_request_status_e", "ad__http__handler_8h.html#a5492f236970d745247b5f5ba47eb9b82", [ 39 | [ "AD_HTTP_REQ_INIT", "ad__http__handler_8h.html#a5492f236970d745247b5f5ba47eb9b82a88e79c29b449f61e6f43e94410d44927", null ], 40 | [ "AD_HTTP_REQ_REQUESTLINE_DONE", "ad__http__handler_8h.html#a5492f236970d745247b5f5ba47eb9b82affd34a388ff3929b99933aaa58d298a9", null ], 41 | [ "AD_HTTP_REQ_HEADER_DONE", "ad__http__handler_8h.html#a5492f236970d745247b5f5ba47eb9b82a4f8f5da8e1d8346eba285fd27bcd9811", null ], 42 | [ "AD_HTTP_REQ_DONE", "ad__http__handler_8h.html#a5492f236970d745247b5f5ba47eb9b82a83f0b967f8a75292986a0ecc24a3d104", null ], 43 | [ "AD_HTTP_ERROR", "ad__http__handler_8h.html#a5492f236970d745247b5f5ba47eb9b82afe1bedd5b77a55a05f855420ca55e073", null ] 44 | ] ], 45 | [ "ad_http_handler", "ad__http__handler_8h.html#a6b65a1411892e20395127d00502a2c44", null ], 46 | [ "ad_http_get_status", "ad__http__handler_8h.html#a20357ffbba80b590ad70f451b2ae299e", null ], 47 | [ "ad_http_get_inbuf", "ad__http__handler_8h.html#a9b8117eea824b918f2cc0d80251dfe3a", null ], 48 | [ "ad_http_get_outbuf", "ad__http__handler_8h.html#af5085188b8be2e7ab290fe0ec22789b4", null ], 49 | [ "ad_http_get_request_header", "ad__http__handler_8h.html#aa931a4adcd07f3bc23fe4f183dc4c8dc", null ], 50 | [ "ad_http_get_content_length", "ad__http__handler_8h.html#ac07e895997348c2885722f98c3260438", null ], 51 | [ "ad_http_get_content_length_stored", "ad__http__handler_8h.html#a468ef4268a9a7c71dfce494c446ebcb5", null ], 52 | [ "ad_http_get_content", "ad__http__handler_8h.html#a4d28e689e120cfa22217507c74683779", null ], 53 | [ "ad_http_is_keepalive_request", "ad__http__handler_8h.html#ae6a1a9707180447257fd769b249ee42d", null ], 54 | [ "ad_http_set_response_header", "ad__http__handler_8h.html#a59ed09afcce36474000c6cded0bd7b64", null ], 55 | [ "ad_http_get_response_header", "ad__http__handler_8h.html#a073c5cb0c9724167031e80907890fb88", null ], 56 | [ "ad_http_set_response_code", "ad__http__handler_8h.html#afe22e6f81773c01d316e45009996c4a3", null ], 57 | [ "ad_http_set_response_content", "ad__http__handler_8h.html#a048a0e35599f8a884494deba0dbd89b7", null ], 58 | [ "ad_http_response", "ad__http__handler_8h.html#aa54a1f3393b20b70f2769b3d039f3bd7", null ], 59 | [ "ad_http_send_header", "ad__http__handler_8h.html#a9067ac0cfb15136e63c134a5292e7716", null ], 60 | [ "ad_http_send_data", "ad__http__handler_8h.html#a5be41fc8a08dcadf94fc271aeb05b6e2", null ], 61 | [ "ad_http_send_chunk", "ad__http__handler_8h.html#a515f6b88b99a19e5c0ccdfd43b0e29ad", null ], 62 | [ "ad_http_get_reason", "ad__http__handler_8h.html#afeef7409bd771bcf2e29eb6ab70af894", null ] 63 | ]; -------------------------------------------------------------------------------- /doc/html/ad__server_8c.js: -------------------------------------------------------------------------------- 1 | var ad__server_8c = 2 | [ 3 | [ "ad_log_level", "ad__server_8c.html#a1f407e2708a0c9a141d5cbeed190d73b", null ], 4 | [ "ad_server_new", "ad__server_8c.html#a677263079eb999133e9a0be48dd2cba5", null ], 5 | [ "ad_server_start", "ad__server_8c.html#a75c74385ae98f9c9457534db0557d98e", null ], 6 | [ "ad_server_stop", "ad__server_8c.html#a7c8229a12c31ee8a75a8099bae6dcf81", null ], 7 | [ "ad_server_free", "ad__server_8c.html#add3ea8aae949c0fa5a6bc9b0b0e1ec70", null ], 8 | [ "ad_server_global_free", "ad__server_8c.html#ac38aa4f50412ec4e3ed0e4f9b387e115", null ], 9 | [ "ad_server_set_option", "ad__server_8c.html#a15edb8d7e1f406085dbf8c5a5c671bda", null ], 10 | [ "ad_server_get_option", "ad__server_8c.html#ac67bad711ee893259d4c4dc3717596ab", null ], 11 | [ "ad_server_get_option_int", "ad__server_8c.html#a2b2e3ec49198b4d35e29a95dc9f06dad", null ], 12 | [ "ad_server_ssl_ctx_create_simple", "ad__server_8c.html#ac7ad549632ecf501e170aac234703541", null ], 13 | [ "ad_server_set_ssl_ctx", "ad__server_8c.html#a34aa318f8a3872aa1e756adb38acd664", null ], 14 | [ "ad_server_get_ssl_ctx", "ad__server_8c.html#addb05a5f42de5b20975a92fa69b52895", null ], 15 | [ "ad_server_get_stats", "ad__server_8c.html#a7fa3e3215415c9f7173f11ea1d276b8e", null ], 16 | [ "ad_server_register_hook", "ad__server_8c.html#aeb61485fd4f4e2f13c93871558b58025", null ], 17 | [ "ad_server_register_hook_on_method", "ad__server_8c.html#a4c319c4143b999a1c5e4b6d17415a500", null ], 18 | [ "ad_conn_set_userdata", "ad__server_8c.html#a6e2e8a73baf14dafa0842b76f31765df", null ], 19 | [ "ad_conn_get_userdata", "ad__server_8c.html#ae5630244c7bb627a0561439f3cd24aca", null ], 20 | [ "ad_conn_set_extra", "ad__server_8c.html#a5ed8e931164315ca27568958a1d70316", null ], 21 | [ "ad_conn_get_extra", "ad__server_8c.html#ad6dd41a4169cd1fcbac17462fa6b5cf8", null ], 22 | [ "ad_conn_set_method", "ad__server_8c.html#aef5876145774e9c6d38e68c06d05e34c", null ], 23 | [ "ad_conn_get_socket", "ad__server_8c.html#a5ba67b542d4ba48ad4a25280d10ef86f", null ], 24 | [ "_ad_log_level", "ad__server_8c.html#aebeaab98b3cd2af4201083b56142eab7", null ] 25 | ]; -------------------------------------------------------------------------------- /doc/html/ad__server_8h.js: -------------------------------------------------------------------------------- 1 | var ad__server_8h = 2 | [ 3 | [ "ad_server_s", "structad__server__s.html", "structad__server__s" ], 4 | [ "ad_conn_s", "structad__conn__s.html", "structad__conn__s" ], 5 | [ "AD_OK", "ad__server_8h.html#a8d1358baba080a2f6b0d350928af7a89", null ], 6 | [ "AD_TAKEOVER", "ad__server_8h.html#ab31b601df43a52ea6ca3647c62da51c4", null ], 7 | [ "AD_DONE", "ad__server_8h.html#a65ea15debc10a5e82448ff065239c4ff", null ], 8 | [ "AD_CLOSE", "ad__server_8h.html#a3b06b0e022e3225a5c252f0141cb5ae4", null ], 9 | [ "AD_SERVER_OPTIONS", "ad__server_8h.html#adc215edc66db6333bb058fb84ed332ca", null ], 10 | [ "AD_EVENT_INIT", "ad__server_8h.html#afcba550cce3f169b37f718e3a6a7a20c", null ], 11 | [ "AD_EVENT_READ", "ad__server_8h.html#a5cdb1e1bd63023d45c94447b4254b17d", null ], 12 | [ "AD_EVENT_WRITE", "ad__server_8h.html#a7ba189c66b4487ee0659d4b4e362ba4f", null ], 13 | [ "AD_EVENT_CLOSE", "ad__server_8h.html#af6be13c8801f47101a25514526b524a7", null ], 14 | [ "AD_EVENT_TIMEOUT", "ad__server_8h.html#a9dadbc14bb0003f3072d13594c81403e", null ], 15 | [ "AD_EVENT_SHUTDOWN", "ad__server_8h.html#ab3b205b8862fd4a318005466961934f1", null ], 16 | [ "AD_NUM_USERDATA", "ad__server_8h.html#a387785dd0db9ef703e97eddf21674b05", null ], 17 | [ "ad_server_t", "ad__server_8h.html#aa7eb49058c165b0fa6cf9df9f8580d73", null ], 18 | [ "ad_conn_t", "ad__server_8h.html#a13ab8ad0b151e6b08c548bb36daef631", null ], 19 | [ "ad_callback", "ad__server_8h.html#a659a16c6e03fa96212bff528033efc84", null ], 20 | [ "ad_userdata_free_cb", "ad__server_8h.html#a483770c2534078a7ca37b2e6590329b8", null ], 21 | [ "ad_log_e", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2", [ 22 | [ "AD_LOG_DISABLE", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2a4822ba6b8a48d50ffab47e875a4eea85", null ], 23 | [ "AD_LOG_ERROR", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2aadef4e51861783de662b590668c733f5", null ], 24 | [ "AD_LOG_WARN", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2ab705340dfe4deb52d8add04540e45b95", null ], 25 | [ "AD_LOG_INFO", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2a854cafd75915f95a962aca0c189aebb4", null ], 26 | [ "AD_LOG_DEBUG", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2a8812ea0ff35c50043b69112e5988e906", null ], 27 | [ "AD_LOG_DEBUG2", "ad__server_8h.html#a0fe91d344bc3f1610ea68bcec077b1c2a169716146eb4ebd68a9dfab24c9d018d", null ] 28 | ] ], 29 | [ "ad_log_level", "ad__server_8h.html#a1f407e2708a0c9a141d5cbeed190d73b", null ], 30 | [ "ad_server_new", "ad__server_8h.html#a677263079eb999133e9a0be48dd2cba5", null ], 31 | [ "ad_server_start", "ad__server_8h.html#a75c74385ae98f9c9457534db0557d98e", null ], 32 | [ "ad_server_stop", "ad__server_8h.html#a7c8229a12c31ee8a75a8099bae6dcf81", null ], 33 | [ "ad_server_free", "ad__server_8h.html#add3ea8aae949c0fa5a6bc9b0b0e1ec70", null ], 34 | [ "ad_server_global_free", "ad__server_8h.html#ac38aa4f50412ec4e3ed0e4f9b387e115", null ], 35 | [ "ad_server_set_option", "ad__server_8h.html#a15edb8d7e1f406085dbf8c5a5c671bda", null ], 36 | [ "ad_server_get_option", "ad__server_8h.html#ac67bad711ee893259d4c4dc3717596ab", null ], 37 | [ "ad_server_get_option_int", "ad__server_8h.html#a2b2e3ec49198b4d35e29a95dc9f06dad", null ], 38 | [ "ad_server_ssl_ctx_create_simple", "ad__server_8h.html#ac7ad549632ecf501e170aac234703541", null ], 39 | [ "ad_server_set_ssl_ctx", "ad__server_8h.html#a34aa318f8a3872aa1e756adb38acd664", null ], 40 | [ "ad_server_get_ssl_ctx", "ad__server_8h.html#addb05a5f42de5b20975a92fa69b52895", null ], 41 | [ "ad_server_get_stats", "ad__server_8h.html#a7fa3e3215415c9f7173f11ea1d276b8e", null ], 42 | [ "ad_server_register_hook", "ad__server_8h.html#aeb61485fd4f4e2f13c93871558b58025", null ], 43 | [ "ad_server_register_hook_on_method", "ad__server_8h.html#a4c319c4143b999a1c5e4b6d17415a500", null ], 44 | [ "ad_conn_set_userdata", "ad__server_8h.html#a6e2e8a73baf14dafa0842b76f31765df", null ], 45 | [ "ad_conn_get_userdata", "ad__server_8h.html#ae5630244c7bb627a0561439f3cd24aca", null ], 46 | [ "ad_conn_set_extra", "ad__server_8h.html#a5ed8e931164315ca27568958a1d70316", null ], 47 | [ "ad_conn_get_extra", "ad__server_8h.html#ad6dd41a4169cd1fcbac17462fa6b5cf8", null ], 48 | [ "ad_conn_set_method", "ad__server_8h.html#aef5876145774e9c6d38e68c06d05e34c", null ], 49 | [ "ad_conn_get_socket", "ad__server_8h.html#a5ba67b542d4ba48ad4a25280d10ef86f", null ] 50 | ]; -------------------------------------------------------------------------------- /doc/html/annotated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Data Structures 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 |
50 |
51 | 56 |
58 |
59 |
60 | 63 |
64 |
65 |
66 |
Data Structures
67 |
68 |
69 |
Here are the data structures with brief descriptions:
70 | 71 | 72 | 73 | 74 |
oCad_conn_sConnection structure
oCad_http_s
\Cad_server_sServer info container
75 |
76 |
77 |
78 | 79 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /doc/html/annotated.js: -------------------------------------------------------------------------------- 1 | var annotated = 2 | [ 3 | [ "ad_conn_s", "structad__conn__s.html", "structad__conn__s" ], 4 | [ "ad_http_s", "structad__http__s.html", "structad__http__s" ], 5 | [ "ad_server_s", "structad__server__s.html", "structad__server__s" ] 6 | ]; -------------------------------------------------------------------------------- /doc/html/asyncd_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: /home/wolkykim/ws/libasyncd/include/asyncd/asyncd.h File Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 |
50 |
51 | 56 |
58 |
59 |
60 | 63 |
64 |
65 |
66 |
asyncd.h File Reference
67 |
68 |
69 | 70 |

Master header file. 71 | More...

72 | 73 |

Go to the source code of this file.

74 |

Detailed Description

75 |

Master header file.

76 | 77 |

Definition in file asyncd.h.

78 |
79 |
80 | 81 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /doc/html/asyncd_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: /home/wolkykim/ws/libasyncd/include/asyncd/asyncd.h Source File 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 |
50 |
51 | 56 |
58 |
59 |
60 | 63 |
64 |
65 |
66 |
asyncd.h
67 |
68 |
69 | Go to the documentation of this file.
1 /******************************************************************************
70 |
2  * libasyncd
71 |
3  *
72 |
4  * Copyright (c) 2014 Seungyoung Kim.
73 |
5  * All rights reserved.
74 |
6  *
75 |
7  * Redistribution and use in source and binary forms, with or without
76 |
8  * modification, are permitted provided that the following conditions are met:
77 |
9  *
78 |
10  * 1. Redistributions of source code must retain the above copyright notice,
79 |
11  * this list of conditions and the following disclaimer.
80 |
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
81 |
13  * this list of conditions and the following disclaimer in the documentation
82 |
14  * and/or other materials provided with the distribution.
83 |
15  *
84 |
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
85 |
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 |
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87 |
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
88 |
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
89 |
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
90 |
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91 |
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
92 |
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
93 |
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
94 |
26  * POSSIBILITY OF SUCH DAMAGE.
95 |
27  *****************************************************************************/
96 |
28 
97 |
29 /**
98 |
30  * Master header file.
99 |
31  *
100 |
32  * @file asyncd.h
101 |
33  */
102 |
34 
103 |
35 #ifndef _ASYNCD_H
104 |
36 #define _ASYNCD_H
105 |
37 
106 |
38 #include "ad_server.h"
107 |
39 #include "ad_http_handler.h"
108 |
40 
109 |
41 #ifdef __cplusplus
110 |
42 extern "C" {
111 |
43 #endif
112 |
44 
113 |
45 #ifdef __cplusplus
114 |
46 }
115 |
47 #endif
116 |
48 
117 |
49 #endif /*_ASYNCD_H */
118 |
50 
119 |
ad_http_handler header file
120 |
ad_server header file
121 |
122 |
123 | 124 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /doc/html/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/bc_s.png -------------------------------------------------------------------------------- /doc/html/bdwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/bdwn.png -------------------------------------------------------------------------------- /doc/html/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Data Structure Index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 |
50 |
51 | 56 |
58 |
59 |
60 | 63 |
64 |
65 |
66 |
Data Structure Index
67 |
68 |
69 | 70 | 71 | 73 | 74 | 75 | 76 |
  a  
72 |
ad_http_s   ad_server_s   
ad_conn_s   
77 | 78 |
79 |
80 | 81 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /doc/html/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/closed.png -------------------------------------------------------------------------------- /doc/html/dir_9273431fadbcee3009b231da59d31b6f.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: /home/wolkykim/ws/libasyncd/include/asyncd Directory Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 |
44 |
45 | 50 |
52 |
53 |
54 | 57 |
58 |
59 |
60 |
asyncd Directory Reference
61 |
62 |
63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |

65 | Files

file  ad_http_handler.h [code]
 ad_http_handler header file
 
file  ad_server.h [code]
 ad_server header file
 
file  asyncd.h [code]
 Master header file.
 
76 |
77 |
78 | 79 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /doc/html/dir_9273431fadbcee3009b231da59d31b6f.js: -------------------------------------------------------------------------------- 1 | var dir_9273431fadbcee3009b231da59d31b6f = 2 | [ 3 | [ "ad_http_handler.h", "ad__http__handler_8h.html", "ad__http__handler_8h" ], 4 | [ "ad_server.h", "ad__server_8h.html", "ad__server_8h" ], 5 | [ "asyncd.h", "asyncd_8h.html", null ] 6 | ]; -------------------------------------------------------------------------------- /doc/html/dir_d44c64559bbebec7f509842c48db8b23.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: /home/wolkykim/ws/libasyncd/include Directory Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 |
44 |
45 | 50 |
52 |
53 |
54 | 57 |
58 |
59 |
60 |
include Directory Reference
61 |
62 |
63 | 64 | 66 | 67 | 68 |

65 | Directories

directory  asyncd
 
69 |
70 |
71 | 72 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /doc/html/dir_d44c64559bbebec7f509842c48db8b23.js: -------------------------------------------------------------------------------- 1 | var dir_d44c64559bbebec7f509842c48db8b23 = 2 | [ 3 | [ "asyncd", "dir_9273431fadbcee3009b231da59d31b6f.html", "dir_9273431fadbcee3009b231da59d31b6f" ] 4 | ]; -------------------------------------------------------------------------------- /doc/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/doxygen.png -------------------------------------------------------------------------------- /doc/html/dynsections.js: -------------------------------------------------------------------------------- 1 | function toggleVisibility(linkObj) 2 | { 3 | var base = $(linkObj).attr('id'); 4 | var summary = $('#'+base+'-summary'); 5 | var content = $('#'+base+'-content'); 6 | var trigger = $('#'+base+'-trigger'); 7 | var src=$(trigger).attr('src'); 8 | if (content.is(':visible')===true) { 9 | content.hide(); 10 | summary.show(); 11 | $(linkObj).addClass('closed').removeClass('opened'); 12 | $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); 13 | } else { 14 | content.show(); 15 | summary.hide(); 16 | $(linkObj).removeClass('closed').addClass('opened'); 17 | $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); 18 | } 19 | return false; 20 | } 21 | 22 | function updateStripes() 23 | { 24 | $('table.directory tr'). 25 | removeClass('even').filter(':visible:even').addClass('even'); 26 | } 27 | function toggleLevel(level) 28 | { 29 | $('table.directory tr').each(function(){ 30 | var l = this.id.split('_').length-1; 31 | var i = $('#img'+this.id.substring(3)); 32 | var a = $('#arr'+this.id.substring(3)); 33 | if (l 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: File List 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 |
50 |
51 | 56 |
58 |
59 |
60 | 63 |
64 |
65 |
66 |
File List
67 |
68 |
69 |
Here is a list of all files with brief descriptions:
70 |
[detail level 123]
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
o-include
|\-asyncd
| o*ad_http_handler.hAd_http_handler header file
| o*ad_server.hAd_server header file
| \*asyncd.hMaster header file
o*ad_http_handler.cHTTP protocol request/response handler
\*ad_server.cMain core logic of the server implementation
79 |
80 |
81 |
82 | 83 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /doc/html/files.js: -------------------------------------------------------------------------------- 1 | var files = 2 | [ 3 | [ "include", "dir_d44c64559bbebec7f509842c48db8b23.html", "dir_d44c64559bbebec7f509842c48db8b23" ], 4 | [ "ad_http_handler.c", "ad__http__handler_8c.html", "ad__http__handler_8c" ], 5 | [ "ad_server.c", "ad__server_8c.html", "ad__server_8c" ] 6 | ]; -------------------------------------------------------------------------------- /doc/html/ftv2blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2blank.png -------------------------------------------------------------------------------- /doc/html/ftv2cl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2cl.png -------------------------------------------------------------------------------- /doc/html/ftv2doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2doc.png -------------------------------------------------------------------------------- /doc/html/ftv2folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2folderclosed.png -------------------------------------------------------------------------------- /doc/html/ftv2folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2folderopen.png -------------------------------------------------------------------------------- /doc/html/ftv2lastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2lastnode.png -------------------------------------------------------------------------------- /doc/html/ftv2link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2link.png -------------------------------------------------------------------------------- /doc/html/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2mlastnode.png -------------------------------------------------------------------------------- /doc/html/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2mnode.png -------------------------------------------------------------------------------- /doc/html/ftv2mo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2mo.png -------------------------------------------------------------------------------- /doc/html/ftv2node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2node.png -------------------------------------------------------------------------------- /doc/html/ftv2ns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2ns.png -------------------------------------------------------------------------------- /doc/html/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2plastnode.png -------------------------------------------------------------------------------- /doc/html/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2pnode.png -------------------------------------------------------------------------------- /doc/html/ftv2splitbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2splitbar.png -------------------------------------------------------------------------------- /doc/html/ftv2vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/ftv2vertline.png -------------------------------------------------------------------------------- /doc/html/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Data Fields 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 55 | 76 |
77 |
78 | 83 |
85 |
86 |
87 | 90 |
91 |
92 |
Here is a list of all struct and union fields with links to the structures/unions they belong to:
93 | 94 |

- b -

105 | 106 | 107 |

- c -

115 | 116 | 117 |

- d -

122 | 123 | 124 |

- e -

132 | 133 | 134 |

- f -

    135 |
  • frozen_header 136 | : ad_http_s 137 |
  • 138 |
139 | 140 | 141 |

- h -

155 | 156 | 157 |

- i -

165 | 166 | 167 |

- l -

172 | 173 | 174 |

- m -

180 | 181 | 182 |

- n -

187 | 188 | 189 |

- o -

200 | 201 | 202 |

- p -

207 | 208 | 209 |

- q -

214 | 215 | 216 |

- r -

227 | 228 | 229 |

- s -

244 | 245 | 246 |

- t -

251 | 252 | 253 |

- u -

264 |
265 |
266 | 267 | 274 | 275 | 276 | -------------------------------------------------------------------------------- /doc/html/functions_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Data Fields - Variables 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 55 | 76 |
77 |
78 | 83 |
85 |
86 |
87 | 90 |
91 |
92 |   93 | 94 |

- b -

105 | 106 | 107 |

- c -

115 | 116 | 117 |

- d -

122 | 123 | 124 |

- e -

132 | 133 | 134 |

- f -

    135 |
  • frozen_header 136 | : ad_http_s 137 |
  • 138 |
139 | 140 | 141 |

- h -

155 | 156 | 157 |

- i -

165 | 166 | 167 |

- l -

172 | 173 | 174 |

- m -

180 | 181 | 182 |

- n -

187 | 188 | 189 |

- o -

200 | 201 | 202 |

- p -

207 | 208 | 209 |

- q -

214 | 215 | 216 |

- r -

227 | 228 | 229 |

- s -

244 | 245 | 246 |

- t -

251 | 252 | 253 |

- u -

264 |
265 |
266 | 267 | 274 | 275 | 276 | -------------------------------------------------------------------------------- /doc/html/globals_defs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Globals 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 60 | 66 |
67 |
68 | 73 |
75 |
76 |
77 | 80 |
81 |
82 |   83 | 84 |

- a -

143 | 144 | 145 |

- h -

225 |
226 |
227 | 228 | 235 | 236 | 237 | -------------------------------------------------------------------------------- /doc/html/globals_enum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Globals 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 60 |
61 |
62 | 67 |
69 |
70 |
71 | 74 |
75 |
76 |   84 |
85 |
86 | 87 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /doc/html/globals_eval.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Globals 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 60 |
61 |
62 | 67 |
69 |
70 |
71 | 74 |
75 |
76 |   111 |
112 |
113 | 114 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /doc/html/globals_type.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Globals 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 60 |
61 |
62 | 67 |
69 |
70 |
71 | 74 |
75 |
76 |   93 |
94 |
95 | 96 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /doc/html/globals_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Globals 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 | 60 |
61 |
62 | 67 |
69 |
70 |
71 | 74 |
75 |
76 |   81 |
82 |
83 | 84 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: Main Page 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 |
44 |
45 | 50 |
52 |
53 |
54 | 57 |
58 |
59 |
60 |
libasyncd Documentation
61 |
62 |
63 |
64 |
65 | 66 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /doc/html/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/nav_f.png -------------------------------------------------------------------------------- /doc/html/nav_g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/nav_g.png -------------------------------------------------------------------------------- /doc/html/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/nav_h.png -------------------------------------------------------------------------------- /doc/html/navtree.css: -------------------------------------------------------------------------------- 1 | #nav-tree .children_ul { 2 | margin:0; 3 | padding:4px; 4 | } 5 | 6 | #nav-tree ul { 7 | list-style:none outside none; 8 | margin:0px; 9 | padding:0px; 10 | } 11 | 12 | #nav-tree li { 13 | white-space:nowrap; 14 | margin:0px; 15 | padding:0px; 16 | } 17 | 18 | #nav-tree .plus { 19 | margin:0px; 20 | } 21 | 22 | #nav-tree .selected { 23 | background-image: url('tab_a.png'); 24 | background-repeat:repeat-x; 25 | color: #fff; 26 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 27 | } 28 | 29 | #nav-tree img { 30 | margin:0px; 31 | padding:0px; 32 | border:0px; 33 | vertical-align: middle; 34 | } 35 | 36 | #nav-tree a { 37 | text-decoration:none; 38 | padding:0px; 39 | margin:0px; 40 | outline:none; 41 | } 42 | 43 | #nav-tree .label { 44 | margin:0px; 45 | padding:0px; 46 | font: 12px 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; 47 | } 48 | 49 | #nav-tree .label a { 50 | padding:2px; 51 | } 52 | 53 | #nav-tree .selected a { 54 | text-decoration:none; 55 | color:#fff; 56 | } 57 | 58 | #nav-tree .children_ul { 59 | margin:0px; 60 | padding:0px; 61 | } 62 | 63 | #nav-tree .item { 64 | margin:0px; 65 | padding:0px; 66 | } 67 | 68 | #nav-tree { 69 | padding: 0px 0px; 70 | background-color: #FAFAFF; 71 | font-size:14px; 72 | overflow:auto; 73 | } 74 | 75 | #doc-content { 76 | overflow:auto; 77 | display:block; 78 | padding:0px; 79 | margin:0px; 80 | -webkit-overflow-scrolling : touch; /* iOS 5+ */ 81 | } 82 | 83 | #side-nav { 84 | padding:0 6px 0 0; 85 | margin: 0px; 86 | display:block; 87 | position: absolute; 88 | left: 0px; 89 | width: 250px; 90 | } 91 | 92 | .ui-resizable .ui-resizable-handle { 93 | display:block; 94 | } 95 | 96 | .ui-resizable-e { 97 | background:url("ftv2splitbar.png") repeat scroll right center transparent; 98 | cursor:e-resize; 99 | height:100%; 100 | right:0; 101 | top:0; 102 | width:6px; 103 | } 104 | 105 | .ui-resizable-handle { 106 | display:none; 107 | font-size:0.1px; 108 | position:absolute; 109 | z-index:1; 110 | } 111 | 112 | #nav-tree-contents { 113 | margin: 6px 0px 0px 0px; 114 | } 115 | 116 | #nav-tree { 117 | background-image:url('nav_h.png'); 118 | background-repeat:repeat-x; 119 | background-color: #F9FAFC; 120 | -webkit-overflow-scrolling : touch; /* iOS 5+ */ 121 | } 122 | 123 | #nav-sync { 124 | position:absolute; 125 | top:5px; 126 | right:24px; 127 | z-index:0; 128 | } 129 | 130 | #nav-sync img { 131 | opacity:0.3; 132 | } 133 | 134 | #nav-sync img:hover { 135 | opacity:0.9; 136 | } 137 | 138 | @media print 139 | { 140 | #nav-tree { display: none; } 141 | div.ui-resizable-handle { display: none; position: relative; } 142 | } 143 | 144 | -------------------------------------------------------------------------------- /doc/html/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/open.png -------------------------------------------------------------------------------- /doc/html/resize.js: -------------------------------------------------------------------------------- 1 | var cookie_namespace = 'doxygen'; 2 | var sidenav,navtree,content,header; 3 | 4 | function readCookie(cookie) 5 | { 6 | var myCookie = cookie_namespace+"_"+cookie+"="; 7 | if (document.cookie) 8 | { 9 | var index = document.cookie.indexOf(myCookie); 10 | if (index != -1) 11 | { 12 | var valStart = index + myCookie.length; 13 | var valEnd = document.cookie.indexOf(";", valStart); 14 | if (valEnd == -1) 15 | { 16 | valEnd = document.cookie.length; 17 | } 18 | var val = document.cookie.substring(valStart, valEnd); 19 | return val; 20 | } 21 | } 22 | return 0; 23 | } 24 | 25 | function writeCookie(cookie, val, expiration) 26 | { 27 | if (val==undefined) return; 28 | if (expiration == null) 29 | { 30 | var date = new Date(); 31 | date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week 32 | expiration = date.toGMTString(); 33 | } 34 | document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/"; 35 | } 36 | 37 | function resizeWidth() 38 | { 39 | var windowWidth = $(window).width() + "px"; 40 | var sidenavWidth = $(sidenav).outerWidth(); 41 | content.css({marginLeft:parseInt(sidenavWidth)+"px"}); 42 | writeCookie('width',sidenavWidth, null); 43 | } 44 | 45 | function restoreWidth(navWidth) 46 | { 47 | var windowWidth = $(window).width() + "px"; 48 | content.css({marginLeft:parseInt(navWidth)+6+"px"}); 49 | sidenav.css({width:navWidth + "px"}); 50 | } 51 | 52 | function resizeHeight() 53 | { 54 | var headerHeight = header.outerHeight(); 55 | var footerHeight = footer.outerHeight(); 56 | var windowHeight = $(window).height() - headerHeight - footerHeight; 57 | content.css({height:windowHeight + "px"}); 58 | navtree.css({height:windowHeight + "px"}); 59 | sidenav.css({height:windowHeight + "px",top: headerHeight+"px"}); 60 | } 61 | 62 | function initResizable() 63 | { 64 | header = $("#top"); 65 | sidenav = $("#side-nav"); 66 | content = $("#doc-content"); 67 | navtree = $("#nav-tree"); 68 | footer = $("#nav-path"); 69 | $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); 70 | $(window).resize(function() { resizeHeight(); }); 71 | var width = readCookie('width'); 72 | if (width) { restoreWidth(width); } else { resizeWidth(); } 73 | resizeHeight(); 74 | var url = location.href; 75 | var i=url.indexOf("#"); 76 | if (i>=0) window.location.hash=url.substr(i); 77 | var _preventDefault = function(evt) { evt.preventDefault(); }; 78 | $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); 79 | $(document).bind('touchmove',function(e){ 80 | var device = navigator.userAgent.toLowerCase(); 81 | var ios = device.match(/(iphone|ipod|ipad)/); 82 | if (ios) { 83 | try { 84 | var target = e.target; 85 | while (target) { 86 | if ($(target).css('-webkit-overflow-scrolling')=='touch') return; 87 | target = target.parentNode; 88 | } 89 | e.preventDefault(); 90 | } catch(err) { 91 | e.preventDefault(); 92 | } 93 | } 94 | }); 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /doc/html/structad__conn__s.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | libasyncd: ad_conn_s Struct Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 30 | 31 | 32 |
27 |
libasyncd 28 |
29 |
33 |
34 | 35 | 36 | 43 | 49 |
50 |
51 | 56 |
58 |
59 |
60 | 63 |
64 |
65 | 67 |
68 |
ad_conn_s Struct Reference
69 |
70 |
71 | 72 |

Connection structure. 73 | More...

74 | 75 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |

76 | Data Fields

ad_server_tserver
 
struct bufferevent * buffer
 
struct evbuffer * in
 
struct evbuffer * out
 
int status
 
void * userdata [2]
 
ad_userdata_free_cb userdata_free_cb [2]
 
char * method
 
94 |

Detailed Description

95 |

Connection structure.

96 | 97 |

Definition at line 159 of file ad_server.h.

98 |

Field Documentation

99 | 100 |
101 |
102 | 103 | 104 | 105 | 106 |
ad_server_t* ad_conn_s::server
107 |
108 |

reference pointer to server

109 | 110 |

Definition at line 160 of file ad_server.h.

111 | 112 |
113 |
114 | 115 |
116 |
117 | 118 | 119 | 120 | 121 |
struct bufferevent* ad_conn_s::buffer
122 |
123 |

reference pointer to buffer

124 | 125 |

Definition at line 161 of file ad_server.h.

126 | 127 |
128 |
129 | 130 |
131 |
132 | 133 | 134 | 135 | 136 |
struct evbuffer* ad_conn_s::in
137 |
138 |

in buffer

139 | 140 |

Definition at line 162 of file ad_server.h.

141 | 142 |
143 |
144 | 145 |
146 |
147 | 148 | 149 | 150 | 151 |
struct evbuffer* ad_conn_s::out
152 |
153 |

out buffer

154 | 155 |

Definition at line 163 of file ad_server.h.

156 | 157 |
158 |
159 | 160 |
161 |
162 | 163 | 164 | 165 | 166 |
int ad_conn_s::status
167 |
168 |

hook status such as AD_OK

169 | 170 |

Definition at line 164 of file ad_server.h.

171 | 172 |
173 |
174 | 175 |
176 |
177 | 178 | 179 | 180 | 181 |
void* ad_conn_s::userdata[2]
182 |
183 |

userdata[0] for end user, userdata[1] for extra

184 | 185 |

Definition at line 166 of file ad_server.h.

186 | 187 |
188 |
189 | 190 |
191 |
192 | 193 | 194 | 195 | 196 |
ad_userdata_free_cb ad_conn_s::userdata_free_cb[2]
197 |
198 |

callback to release user data

199 | 200 |

Definition at line 167 of file ad_server.h.

201 | 202 |
203 |
204 | 205 |
206 |
207 | 208 | 209 | 210 | 211 |
char* ad_conn_s::method
212 |
213 |

request method. set by protocol handler

214 | 215 |

Definition at line 168 of file ad_server.h.

216 | 217 |
218 |
219 |
The documentation for this struct was generated from the following file:
    220 |
  • /home/wolkykim/ws/libasyncd/include/asyncd/ad_server.h
  • 221 |
222 |
223 |
224 | 225 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /doc/html/structad__conn__s.js: -------------------------------------------------------------------------------- 1 | var structad__conn__s = 2 | [ 3 | [ "server", "structad__conn__s.html#abb9074b951a064f2790c154475c19fa8", null ], 4 | [ "buffer", "structad__conn__s.html#a2e3de19cb9eea56002d5adec7fad66cf", null ], 5 | [ "in", "structad__conn__s.html#a0c33794bef5cb9c633c09026173f64cd", null ], 6 | [ "out", "structad__conn__s.html#a30d7905f017359ece17a8c7406fc20fc", null ], 7 | [ "status", "structad__conn__s.html#a9b7fa3872345cd7caa315e401b7d8f7d", null ], 8 | [ "userdata", "structad__conn__s.html#a157c948a7cc7157aab058ecd34fea253", null ], 9 | [ "userdata_free_cb", "structad__conn__s.html#a88cab228f7ce7dd4b54c1a2a5cbd2c72", null ], 10 | [ "method", "structad__conn__s.html#a3d78c01960c23c9a5db3216a74d903b5", null ] 11 | ]; -------------------------------------------------------------------------------- /doc/html/structad__http__s.js: -------------------------------------------------------------------------------- 1 | var structad__http__s = 2 | [ 3 | [ "status", "structad__http__s.html#a08609c6955339c939e1f46f8e00e164e", null ], 4 | [ "inbuf", "structad__http__s.html#adb7444a8f1879654976dbde11b27bcee", null ], 5 | [ "method", "structad__http__s.html#aa01e34066ff0db7db68172c9089f6e69", null ], 6 | [ "uri", "structad__http__s.html#a2192371be64acdb89a64f00c5890cbf3", null ], 7 | [ "httpver", "structad__http__s.html#a13091fc281ea98166a82dbb3a3b0a8fb", null ], 8 | [ "path", "structad__http__s.html#a50f31e3ca4954f6ae7d8944e531e7609", null ], 9 | [ "query", "structad__http__s.html#a007aa07af67fc4bf6d3aa62e726a8527", null ], 10 | [ "headers", "structad__http__s.html#a1b087616782ae37954bc9c84efcddfcb", null ], 11 | [ "host", "structad__http__s.html#a77545254e60b3c635c49efa321cfb054", null ], 12 | [ "domain", "structad__http__s.html#a129ec0244515d298b2d27bf99716e0b9", null ], 13 | [ "contentlength", "structad__http__s.html#a403c92ef9659a9ba550d17ee9745fd94", null ], 14 | [ "bodyin", "structad__http__s.html#abae1ecb8ffe1c2b514f8a490ed0364c6", null ], 15 | [ "request", "structad__http__s.html#a64ea17af0a96e99853d6fc2a08bfe23b", null ], 16 | [ "outbuf", "structad__http__s.html#a91a877df088b8c66af600e14948d0b6d", null ], 17 | [ "frozen_header", "structad__http__s.html#a292d39919e0834e76e44621d052a9a95", null ], 18 | [ "code", "structad__http__s.html#ad9b68dc98b0718b42b7ad1ced7d415f5", null ], 19 | [ "reason", "structad__http__s.html#ac812fecbfc3d456fa089cae226b7c600", null ], 20 | [ "bodyout", "structad__http__s.html#a540f3f70258433ff7568283f6e478261", null ], 21 | [ "response", "structad__http__s.html#a8aa9b5bba38a8e02cbdfc96e654db1d9", null ] 22 | ]; -------------------------------------------------------------------------------- /doc/html/structad__server__s.js: -------------------------------------------------------------------------------- 1 | var structad__server__s = 2 | [ 3 | [ "errcode", "structad__server__s.html#ac0c82aed3c82235b3788796bc7a83e0b", null ], 4 | [ "thread", "structad__server__s.html#ad09ee6ca2678d9e42124ae9d4b96d9fe", null ], 5 | [ "options", "structad__server__s.html#a2c75af08b7483c596b278c4c022cf9d5", null ], 6 | [ "stats", "structad__server__s.html#ae8cecf112a838b40cd5b94b9b57597c0", null ], 7 | [ "hooks", "structad__server__s.html#a23ca15bb12d9df2e28bd54dbdebc9fc3", null ], 8 | [ "listener", "structad__server__s.html#ae184c2444743aa61f16b5228820087e6", null ], 9 | [ "evbase", "structad__server__s.html#aa156a47562ec35a753d44be40c2bd155", null ], 10 | [ "sslctx", "structad__server__s.html#ac49ac0bf5c97d5c0ea7443c15860dc07", null ], 11 | [ "notify_buffer", "structad__server__s.html#ae17a39413f5822b4456e96b9ebd30a5d", null ] 12 | ]; -------------------------------------------------------------------------------- /doc/html/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/sync_off.png -------------------------------------------------------------------------------- /doc/html/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/sync_on.png -------------------------------------------------------------------------------- /doc/html/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/tab_a.png -------------------------------------------------------------------------------- /doc/html/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/tab_b.png -------------------------------------------------------------------------------- /doc/html/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/tab_h.png -------------------------------------------------------------------------------- /doc/html/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolkykim/libasyncd/b871bc296ce62912d92ef95802cd185540220416/doc/html/tab_s.png -------------------------------------------------------------------------------- /doc/html/tabs.css: -------------------------------------------------------------------------------- 1 | .tabs, .tabs2, .tabs3 { 2 | background-image: url('tab_b.png'); 3 | width: 100%; 4 | z-index: 101; 5 | font-size: 13px; 6 | font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; 7 | } 8 | 9 | .tabs2 { 10 | font-size: 10px; 11 | } 12 | .tabs3 { 13 | font-size: 9px; 14 | } 15 | 16 | .tablist { 17 | margin: 0; 18 | padding: 0; 19 | display: table; 20 | } 21 | 22 | .tablist li { 23 | float: left; 24 | display: table-cell; 25 | background-image: url('tab_b.png'); 26 | line-height: 36px; 27 | list-style: none; 28 | } 29 | 30 | .tablist a { 31 | display: block; 32 | padding: 0 20px; 33 | font-weight: bold; 34 | background-image:url('tab_s.png'); 35 | background-repeat:no-repeat; 36 | background-position:right; 37 | color: #283A5D; 38 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 39 | text-decoration: none; 40 | outline: none; 41 | } 42 | 43 | .tabs3 .tablist a { 44 | padding: 0 10px; 45 | } 46 | 47 | .tablist a:hover { 48 | background-image: url('tab_h.png'); 49 | background-repeat:repeat-x; 50 | color: #fff; 51 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 52 | text-decoration: none; 53 | } 54 | 55 | .tablist li.current a { 56 | background-image: url('tab_a.png'); 57 | background-repeat:repeat-x; 58 | color: #fff; 59 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 60 | } 61 | -------------------------------------------------------------------------------- /examples/Makefile.in: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | ## libasyncd 3 | ## 4 | ## Copyright (c) 2014 Seungyoung Kim. 5 | ## All rights reserved. 6 | ## 7 | ## Redistribution and use in source and binary forms, with or without 8 | ## modification, are permitted provided that the following conditions are met: 9 | ## 10 | ## 1. Redistributions of source code must retain the above copyright notice, 11 | ## this list of conditions and the following disclaimer. 12 | ## 2. Redistributions in binary form must reproduce the above copyright notice, 13 | ## this list of conditions and the following disclaimer in the documentation 14 | ## and/or other materials provided with the distribution. 15 | ## 16 | ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | ## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | ## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | ## POSSIBILITY OF SUCH DAMAGE. 27 | ################################################################################ 28 | 29 | prefix = @prefix@ 30 | exec_prefix = @exec_prefix@ 31 | 32 | ## Utilities 33 | AR = @AR@ 34 | ARFLAGS = -rc 35 | CHMOD = @CHMOD@ 36 | INSTALL = @INSTALL@ 37 | INSTALL_DATA = @INSTALL_DATA@ 38 | LN_S = @LN_S@ 39 | MKDIR_P = @MKDIR_P@ 40 | RMDIR = rmdir 41 | RANLIB = @RANLIB@ 42 | RM = @RM@ 43 | 44 | ## libasyncd related. 45 | CPPFLAGS += -I../include -I../src 46 | LIBS += ../src/libasyncd.a 47 | 48 | ## qlibc related. 49 | CPPFLAGS += -I../lib/qlibc/include 50 | LIBS += ../lib/qlibc/lib/libqlibc.a 51 | 52 | ## Which compiler & options for release 53 | CC = gcc -std=gnu99 54 | CFLAGS = -Wall -Wstrict-prototypes -fPIC -g -O2 55 | CPPFLAGS += -I/usr/include -I/usr/local/include \ 56 | -D_GNU_SOURCE -DBUILD_DEBUG 57 | LIBS += @DEPLIBS@ 58 | 59 | 60 | TARGETS = helloworld_tcp_server helloworld_http_server helloworld_ssl_server \ 61 | echo_tcp_server echo_http_server 62 | 63 | ## Make Library 64 | all: $(TARGETS) 65 | 66 | helloworld_tcp_server: helloworld_tcp_server.o 67 | $(CC) $(LDFLAGS) -o $@ helloworld_tcp_server.o $(LIBS) 68 | 69 | helloworld_http_server: helloworld_http_server.o 70 | $(CC) $(LDFLAGS) -o $@ helloworld_http_server.o $(LIBS) 71 | 72 | helloworld_ssl_server: helloworld_ssl_server.o 73 | $(CC) $(LDFLAGS) -o $@ helloworld_ssl_server.o $(LIBS) 74 | 75 | echo_tcp_server: echo_tcp_server.o 76 | $(CC) $(LDFLAGS) -o $@ echo_tcp_server.o $(LIBS) 77 | 78 | echo_http_server: echo_http_server.o 79 | $(CC) $(LDFLAGS) -o $@ echo_http_server.o $(LIBS) 80 | 81 | clean: 82 | $(RM) -f *.o $(TARGETS) 83 | 84 | ## Compile 85 | .c.o: 86 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< 87 | -------------------------------------------------------------------------------- /examples/echo_http_server.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | #include 30 | #include 31 | #include 32 | #include "asyncd/asyncd.h" 33 | #include "macro.h" 34 | 35 | /** 36 | * User data for per-connection custom information for non-blocking operation. 37 | */ 38 | struct my_cdata { 39 | int counter; 40 | }; 41 | 42 | void my_userdata_free_cb(ad_conn_t *conn, void *userdata) { 43 | free(userdata); 44 | } 45 | 46 | /** 47 | * User callback example. 48 | * 49 | * This is a simple echo handler. 50 | * It response on input line up to 3 times then close connection. 51 | * 52 | * @param event event type. see ad_server.h for details. 53 | * @param conn connection object. type is vary based on 54 | * "server.protocol_handler" option. 55 | * @userdata given shared user-data. 56 | * 57 | * @return one of AD_OK | AD_DONE | AD_CLOSE | AD_TAKEOVER 58 | * 59 | * @note Please refer ad_server.h for more details. 60 | */ 61 | int my_conn_handler(short event, ad_conn_t *conn, void *userdata) { 62 | DEBUG("my_conn_callback: %x", event); 63 | 64 | /* 65 | * AD_EVENT_INIT event is like a constructor method. 66 | * It happens only once at the beginning of connection. 67 | * This is a good place to create a per-connection base 68 | * resources. You can attach it into this connection to 69 | * use at the next callback cycle. 70 | */ 71 | if (event & AD_EVENT_INIT) { 72 | DEBUG("==> AD_EVENT_READ"); 73 | // Allocate a counter container for this connection. 74 | struct my_cdata *cdata = (struct my_cdata *)calloc(1, sizeof(struct my_cdata)); 75 | 76 | // Attach to this connection. 77 | ad_conn_set_userdata(conn, cdata, my_userdata_free_cb); 78 | } 79 | 80 | /* 81 | * AD_EVENT_READ event happens whenever data comes in. 82 | */ 83 | else if (event & AD_EVENT_READ) { 84 | DEBUG("==> AD_EVENT_READ"); 85 | if (ad_http_get_status(conn) == AD_HTTP_REQ_DONE) { 86 | // Get my per-connection data. 87 | struct my_cdata *cdata = (struct my_cdata *)ad_conn_get_userdata(conn); 88 | 89 | size_t size = 0; 90 | void *data = ad_http_get_content(conn, 0, &size); 91 | ad_http_response(conn, 200, "text/plain", data, size); 92 | 93 | cdata->counter++; 94 | if (cdata->counter > 3) { 95 | return AD_CLOSE; 96 | } 97 | } 98 | 99 | return AD_OK; 100 | } 101 | 102 | /* 103 | * AD_EVENT_WRITE event happens whenever out-buffer has lesser than certain 104 | * amount of data. 105 | * 106 | * Default watermark is 0 meaning this will happens when out-buffer is empty. 107 | * For reasonable size of message, you can send it all at once but for a large 108 | * amount of data, you need to send it out through out multiple callbacks. 109 | * 110 | * To maximize the performance, you will also want to set higher watermark 111 | * so whenever the level goes below the watermark you will be called for the 112 | * refill work before the buffer gets empty. So it's just faster if you can 113 | * fill up gas while you're driving without a stop. 114 | */ 115 | else if (event & AD_EVENT_WRITE) { 116 | DEBUG("==> AD_EVENT_WRITE"); 117 | // We've sent all the data in out-buffer. 118 | } 119 | 120 | /* 121 | * AD_EVENT_CLOSE event happens right before closing connection. 122 | * This will be the last callback for this connection. 123 | * So if you have created per-connection data then release the resource. 124 | */ 125 | else if (event & AD_EVENT_CLOSE) { 126 | DEBUG("==> AD_EVENT_CLOSE=%x (TIMEOUT=%d, SHUTDOWN=%d)", 127 | event, event & AD_EVENT_TIMEOUT, event & AD_EVENT_SHUTDOWN); 128 | // You can release your user data explicitly here if you haven't 129 | // set the callback that release your user data. 130 | } 131 | 132 | // Return AD_OK will let the hook loop to continue. 133 | return AD_OK; 134 | } 135 | 136 | int main(int argc, char **argv) { 137 | // Example shared user data. 138 | char *userdata = "SHARED-USERDATA"; 139 | 140 | // Create a server. 141 | ad_log_level(AD_LOG_DEBUG); 142 | ad_server_t *server = ad_server_new(); 143 | 144 | // Set server options. 145 | ad_server_set_option(server, "server.port", "8888"); 146 | ad_server_set_option(server, "server.addr", "0.0.0.0"); 147 | ad_server_set_option(server, "server.timeout", "60"); 148 | 149 | // Register protocol handler. 150 | ad_server_register_hook(server, ad_http_handler, NULL); 151 | 152 | // Register your hooks 153 | ad_server_register_hook(server, my_conn_handler, userdata); 154 | 155 | // SSL option. 156 | //ad_server_set_option(server, "server.enable_ssl", "1"); 157 | //ad_server_set_option(server, "server.ssl_cert", "ssl.cert"); 158 | //ad_server_set_option(server, "server.ssl_pkey", "ssl.pkey"); 159 | 160 | // Start server. 161 | int retstatus = ad_server_start(server); 162 | 163 | // That is it!!! 164 | return retstatus; 165 | } 166 | -------------------------------------------------------------------------------- /examples/echo_tcp_server.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | #include 30 | #include 31 | #include 32 | #include "asyncd/asyncd.h" 33 | #include "macro.h" 34 | 35 | /** 36 | * User data for per-connection custom information for non-blocking operation. 37 | */ 38 | struct my_cdata { 39 | int counter; 40 | }; 41 | 42 | /** 43 | * This callback will be called before closing or resetting connection for 44 | * pipelining. 45 | */ 46 | void my_userdata_free_cb(ad_conn_t *conn, void *userdata) { 47 | free(userdata); 48 | } 49 | 50 | /** 51 | * User callback example. 52 | * 53 | * This is a simple echo handler. 54 | * It response on input line up to 3 times then close connection. 55 | * 56 | * @param event event type. see ad_server.h for details. 57 | * @param conn connection object. type is vary based on 58 | * "server.protocol_handler" option. 59 | * @userdata given shared user-data. 60 | * 61 | * @return one of AD_OK | AD_DONE | AD_CLOSE | AD_TAKEOVER 62 | * 63 | * @note Please refer ad_server.h for more details. 64 | */ 65 | int my_conn_handler(short event, ad_conn_t *conn, void *userdata) { 66 | DEBUG("my_conn_callback: %x", event); 67 | 68 | /* 69 | * AD_EVENT_INIT event is like a constructor method. 70 | * It happens only once at the beginning of connection. 71 | * This is a good place to create a per-connection base 72 | * resources. You can attach it into this connection to 73 | * use at the next callback cycle. 74 | */ 75 | if (event & AD_EVENT_INIT) { 76 | DEBUG("==> AD_EVENT_READ"); 77 | // Allocate a counter container for this connection. 78 | struct my_cdata *cdata = (struct my_cdata *)calloc(1, sizeof(struct my_cdata)); 79 | 80 | // Attach to this connection. 81 | ad_conn_set_userdata(conn, cdata, my_userdata_free_cb); 82 | } 83 | 84 | /* 85 | * AD_EVENT_READ event happens whenever data comes in. 86 | */ 87 | else if (event & AD_EVENT_READ) { 88 | DEBUG("==> AD_EVENT_READ"); 89 | 90 | // Get my per-connection data. 91 | struct my_cdata *cdata = (struct my_cdata *)ad_conn_get_userdata(conn); 92 | 93 | // Try to read one line. 94 | char *data = evbuffer_readln(conn->in, NULL, EVBUFFER_EOL_ANY); 95 | if (data) { 96 | if (!strcmp(data, "SHUTDOWN")) { 97 | //return AD_SHUTDOWN; 98 | } 99 | cdata->counter++; 100 | evbuffer_add_printf(conn->out, "%s, counter:%d, userdata:%s\n", data, cdata->counter, (char*)userdata); 101 | free(data); 102 | } 103 | 104 | // Close connection after 3 echos. 105 | return (cdata->counter < 3) ? AD_OK : AD_CLOSE; 106 | } 107 | 108 | /* 109 | * AD_EVENT_WRITE event happens whenever out-buffer has lesser than certain 110 | * amount of data. 111 | * 112 | * Default watermark is 0 meaning this will happens when out-buffer is empty. 113 | * For reasonable size of message, you can send it all at once but for a large 114 | * amount of data, you need to send it out through out multiple callbacks. 115 | * 116 | * To maximize the performance, you will also want to set higher watermark 117 | * so whenever the level goes below the watermark you will be called for the 118 | * refill work before the buffer gets empty. So it's just faster if you can 119 | * fill up gas while you're driving without a stop. 120 | */ 121 | else if (event & AD_EVENT_WRITE) { 122 | DEBUG("==> AD_EVENT_WRITE"); 123 | // We've sent all the data in out-buffer. 124 | } 125 | 126 | /* 127 | * AD_EVENT_CLOSE event happens right before closing connection. 128 | * This will be the last callback for this connection. 129 | * So if you have created per-connection data then release the resource. 130 | */ 131 | else if (event & AD_EVENT_CLOSE) { 132 | DEBUG("==> AD_EVENT_CLOSE=%x (TIMEOUT=%d, SHUTDOWN=%d)", 133 | event, event & AD_EVENT_TIMEOUT, event & AD_EVENT_SHUTDOWN); 134 | // You can release your user data explicitly here if you haven't 135 | // set the callback that release your user data. 136 | } 137 | 138 | // Return AD_OK will let the hook loop to continue. 139 | return AD_OK; 140 | } 141 | 142 | int main(int argc, char **argv) { 143 | ad_log_level(AD_LOG_DEBUG); 144 | 145 | // Example shared user data. 146 | char *userdata = "SHARED-USERDATA"; 147 | 148 | // 149 | // Create a server. 150 | // 151 | ad_server_t *server = ad_server_new(); 152 | 153 | // 154 | // Set server options. 155 | // 156 | // Usually you only need to override a few default options and 157 | // that's it but it's lengthy here for a demonstration purpose. 158 | // 159 | ad_server_set_option(server, "server.port", "2222"); 160 | ad_server_set_option(server, "server.addr", "0.0.0.0"); 161 | ad_server_set_option(server, "server.timeout", "5"); 162 | 163 | // Register custom hooks. When there are multiple hooks, it will be 164 | // executed in the same order as they registered. 165 | ad_server_register_hook(server, my_conn_handler, userdata); 166 | 167 | // Enable request pipelining, this change AD_DONE's behavior. 168 | ad_server_set_option(server, "server.request_pipelining", "1"); 169 | 170 | // Run server in a separate thread. If you want to run multiple 171 | // server instances or if you want to run it in background, this 172 | // is the option. 173 | ad_server_set_option(server, "server.thread", "0"); 174 | 175 | // Call ad_server_free() internally when server is shutting down. 176 | ad_server_set_option(server, "server.free_on_stop", "1"); 177 | 178 | // 179 | // Start server. 180 | // 181 | int retstatus = ad_server_start(server); 182 | 183 | // 184 | // That is it!!! 185 | // 186 | return retstatus; 187 | } 188 | -------------------------------------------------------------------------------- /examples/helloworld_http_server.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | #include "asyncd/asyncd.h" 30 | 31 | int my_http_get_handler(short event, ad_conn_t *conn, void *userdata) { 32 | if (event & AD_EVENT_READ) { 33 | if (ad_http_get_status(conn) == AD_HTTP_REQ_DONE) { 34 | ad_http_response(conn, 200, "text/html", "Hello World", 11); 35 | return ad_http_is_keepalive_request(conn) ? AD_DONE : AD_CLOSE; 36 | } 37 | } 38 | return AD_OK; 39 | } 40 | 41 | int my_http_default_handler(short event, ad_conn_t *conn, void *userdata) { 42 | if (event & AD_EVENT_READ) { 43 | if (ad_http_get_status(conn) == AD_HTTP_REQ_DONE) { 44 | ad_http_response(conn, 501, "text/html", "Not implemented", 15); 45 | return AD_CLOSE; // Close connection. 46 | } 47 | } 48 | return AD_OK; 49 | } 50 | 51 | int main(int argc, char **argv) { 52 | //SSL_load_error_strings(); 53 | //SSL_library_init(); 54 | ad_log_level(AD_LOG_DEBUG); 55 | ad_server_t *server = ad_server_new(); 56 | ad_server_set_option(server, "server.port", "8888"); 57 | //ad_server_set_ssl_ctx(server, 58 | // ad_server_ssl_ctx_create_simple("ssl.cert", "ssl.pkey")); 59 | ad_server_register_hook(server, ad_http_handler, NULL); // HTTP Parser is also a hook. 60 | ad_server_register_hook_on_method(server, "GET", my_http_get_handler, NULL); 61 | ad_server_register_hook(server, my_http_default_handler, NULL); 62 | return ad_server_start(server); 63 | } 64 | -------------------------------------------------------------------------------- /examples/helloworld_ssl_server.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | #include 30 | #include "asyncd/asyncd.h" 31 | 32 | int my_conn_handler(short event, ad_conn_t *conn, void *userdata) { 33 | if (event & AD_EVENT_WRITE) { 34 | evbuffer_add_printf(conn->out, "Hello World.\n"); 35 | return AD_CLOSE; 36 | } 37 | return AD_OK; 38 | } 39 | 40 | int main(int argc, char **argv) { 41 | SSL_load_error_strings(); 42 | SSL_library_init(); 43 | ad_log_level(AD_LOG_DEBUG); 44 | ad_server_t *server = ad_server_new(); 45 | ad_server_set_option(server, "server.port", "2222"); 46 | ad_server_set_ssl_ctx(server, 47 | ad_server_ssl_ctx_create_simple("ssl.cert", "ssl.pkey")); 48 | ad_server_register_hook(server, my_conn_handler, NULL); 49 | return ad_server_start(server); 50 | } 51 | -------------------------------------------------------------------------------- /examples/helloworld_tcp_server.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | #include 30 | #include "asyncd/asyncd.h" 31 | 32 | int my_conn_handler(short event, ad_conn_t *conn, void *userdata) { 33 | if (event & AD_EVENT_WRITE) { 34 | evbuffer_add_printf(conn->out, "Hello World."); 35 | return AD_CLOSE; 36 | } 37 | return AD_OK; 38 | } 39 | 40 | int main(int argc, char **argv) { 41 | ad_log_level(AD_LOG_DEBUG); 42 | ad_server_t *server = ad_server_new(); 43 | ad_server_set_option(server, "server.port", "2222"); 44 | ad_server_register_hook(server, my_conn_handler, NULL); 45 | return ad_server_start(server); 46 | } 47 | -------------------------------------------------------------------------------- /examples/ssl.cert: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDGjCCAgICCQDdIaZAAIFoKDANBgkqhkiG9w0BAQUFADBPMQswCQYDVQQGEwJV 3 | UzELMAkGA1UECAwCV0ExFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UECgwT 4 | RGVmYXVsdCBDb21wYW55IEx0ZDAeFw0xNDA0MDYxMDAxNTFaFw0xNTA0MDYxMDAx 5 | NTFaME8xCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJXQTEVMBMGA1UEBwwMRGVmYXVs 6 | dCBDaXR5MRwwGgYDVQQKDBNEZWZhdWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG 7 | 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtijWIuRtWEzdU/ovbOv0d/Bj3t2Drsr/Rzqw 8 | vcbcOVfgC8xOVEXvLWzFVPUKAjGLfCK330mUbzDRq6KakfA0GSvyONdoZifg9lhm 9 | npTEwr9vMdx69XJxxkjnuK1RDVleFkINqQs3zz7Hz/2ySn1wcMm2PDNIjBZCENMx 10 | XN0KrnVixMMV2bw0U643IMHCvzhqpFvBLj/ipGN/p9+0XWiHoNgGxO8LrhUqNAL7 11 | DN9dUd0HC+DVOBN/zwPqzPaM08I1mKPIpNKhQoWvUTehDon2oZqSeEcANTZk1PT9 12 | YWBi56lerMm7eSlEIy4/RYUpmyoj+LIxkXy6tab8jMegF0kNrwIDAQABMA0GCSqG 13 | SIb3DQEBBQUAA4IBAQBdk6RlriaZx7ZMQZCoIwPNWrUD00nLS3MkHk2kK0hwWSJh 14 | kK3LYtI+1l9PuZxlL6XdhcAqWU4hA+cmkFNY511e4Bb1lKgryQwjJsbfsxclKuPC 15 | uk4ypkO7lh4l9GHy41ggzs1g9UIjU2+mqMk1b/S4qKNtx6NTnPfxTyXax2Awx/5O 16 | M/wL26YSnG72wLOGKWqkVMFZ+d5lWbqkiiNuAM7YR7ZREoGIbtTMawjgNWIjDRfw 17 | X8cdrGQVb//pF8SSeXgsR6x8qMWoiO7tZNgOTgoY+Tt4RPWww+jG3GQwkHrUdPJI 18 | NJMgkn/HIr5ro64FJ7XPC01Sj9QOTujecLDe/GR4 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /examples/ssl.pkey: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAtijWIuRtWEzdU/ovbOv0d/Bj3t2Drsr/RzqwvcbcOVfgC8xO 3 | VEXvLWzFVPUKAjGLfCK330mUbzDRq6KakfA0GSvyONdoZifg9lhmnpTEwr9vMdx6 4 | 9XJxxkjnuK1RDVleFkINqQs3zz7Hz/2ySn1wcMm2PDNIjBZCENMxXN0KrnVixMMV 5 | 2bw0U643IMHCvzhqpFvBLj/ipGN/p9+0XWiHoNgGxO8LrhUqNAL7DN9dUd0HC+DV 6 | OBN/zwPqzPaM08I1mKPIpNKhQoWvUTehDon2oZqSeEcANTZk1PT9YWBi56lerMm7 7 | eSlEIy4/RYUpmyoj+LIxkXy6tab8jMegF0kNrwIDAQABAoIBAGEJoAk2ZomDaOQz 8 | gtAjYjgCdzFiD6Qtv4/SVBTEusxRY6jlTVTXbHJmXzjC0HIaspOOayUnrUsOVqN4 9 | G59itl4yavacyaCh3dVdgk04MxkLodCOA3J9ZN6cN9TJf0P9N4Hj7iL/NtvQNeE2 10 | 5KOJ7zwmOE4Zg6wcr1UHLGSr2+TS/V08U5xI4SheoCSwckJwZVb7dUzUU5yu/TgK 11 | zNq7yk858xMkYJdfq9f1eV0p6R2calPlY9PKiUHNqtC72g+1h80mQ5dn4c2sR8RZ 12 | lXOfsEGaaQ5AQUGF1D2wezhdYKX0DMFfd/Tq71a+9w+ngR2ISFXKiOSGcZEl4ubV 13 | yV6ksgECgYEA4b37lhbK9N+Z51yEynPvd0s+MZr6JZ34dKHA51zrbWWXhjIjikFS 14 | j/V89JLVixNiXSiw1oeEbwPHq/Uz10oWegd6IGX5a2FnC+BXm6eMYe0vf7W5iFIe 15 | X+KIoFTfBHHAi30Ev6ELKBKrGJMDF6QU8Audl0+wr3m8rKOLM3A6OkkCgYEAzpNh 16 | EcQkL172cvB2/n228Wq1SZb0yCnUrdFEEuLcGPo5NhgjHm9W4Dr+gcOxjEOZ0D/+ 17 | E2N9QQpsBV2x+FPSgv9X/pzbm1LR/Hwg1EOjcqvkitX1xcbiXDW7fdWm9rjd5NzZ 18 | cm0Y6oqol+y2CfNCcls5683E16xfuSyiJHdSSDcCgYA71LjLzPq58FHASns/lX7Q 19 | pXa0exj1w2rIrt6L88rKUfTZMozM5gdV9IDL6ecDV33opxJHqd9l9SCE6RZ2Z0KR 20 | 0U2DLMPwu/4t3aYasUu54L2IIcgs42b9jvMbW6NIcEXSMq6Bg9OLKXeDqeNV7r1F 21 | 6i44nnx75c4mC6qnVYV5UQKBgQCnRqaK6WZXybENX/UrnQcgNMV6QrgSwfTLj7Jt 22 | DLEntK/RQvhlM8mIp5zh3WKPb0pFXRxT/PM3UMYqDjYIHXBQzY4mykP2YblSl/1J 23 | hT/8on7dgeaT8bno60XY3sJl9UsRgVi/lOJhQkjFRVQfeJFs4rxjWuuzrYyR+TeP 24 | CeRiPwKBgEMhs09MD0hsYyIyMUQ986qHLxdfWyB0m8IMIeJ9yaoPAsbXyUGxY0hV 25 | SQlmz7wIbtjGN3AXSZKNiiUfEHZ+3na4qyJqz2/WNvzzBj6rpvDuU2f3rC+JA+Df 26 | dTmJgPsjiyDGPInke3z/+NZaL6toDHjuW4MlfiNrp2SU9im/6dgo 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /include/asyncd/ad_http_handler.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | /** 30 | * ad_http_handler header file 31 | * 32 | * @file ad_http_handler.h 33 | */ 34 | 35 | #ifndef _AD_HTTP_HANDLER_H 36 | #define _AD_HTTP_HANDLER_H 37 | 38 | #include "qlibc/qlibc.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /*----------------------------------------------------------------------------*\ 45 | | HTTP PROTOCOL SPECIFICS | 46 | \*----------------------------------------------------------------------------*/ 47 | 48 | /* HTTP PROTOCOL CODES */ 49 | #define HTTP_PROTOCOL_09 "HTTP/0.9" 50 | #define HTTP_PROTOCOL_10 "HTTP/1.0" 51 | #define HTTP_PROTOCOL_11 "HTTP/1.1" 52 | 53 | /* HTTP RESPONSE CODES */ 54 | #define HTTP_NO_RESPONSE (0) 55 | #define HTTP_CODE_CONTINUE (100) 56 | #define HTTP_CODE_OK (200) 57 | #define HTTP_CODE_CREATED (201) 58 | #define HTTP_CODE_NO_CONTENT (204) 59 | #define HTTP_CODE_PARTIAL_CONTENT (206) 60 | #define HTTP_CODE_MULTI_STATUS (207) 61 | #define HTTP_CODE_MOVED_TEMPORARILY (302) 62 | #define HTTP_CODE_NOT_MODIFIED (304) 63 | #define HTTP_CODE_BAD_REQUEST (400) 64 | #define HTTP_CODE_UNAUTHORIZED (401) 65 | #define HTTP_CODE_FORBIDDEN (403) 66 | #define HTTP_CODE_NOT_FOUND (404) 67 | #define HTTP_CODE_METHOD_NOT_ALLOWED (405) 68 | #define HTTP_CODE_REQUEST_TIME_OUT (408) 69 | #define HTTP_CODE_GONE (410) 70 | #define HTTP_CODE_REQUEST_URI_TOO_LONG (414) 71 | #define HTTP_CODE_LOCKED (423) 72 | #define HTTP_CODE_INTERNAL_SERVER_ERROR (500) 73 | #define HTTP_CODE_NOT_IMPLEMENTED (501) 74 | #define HTTP_CODE_SERVICE_UNAVAILABLE (503) 75 | 76 | /* DEFAULT BEHAVIORS */ 77 | #define HTTP_CRLF "\r\n" 78 | #define HTTP_DEF_CONTENTTYPE "application/octet-stream" 79 | 80 | /*----------------------------------------------------------------------------*\ 81 | | TYPEDEFS | 82 | \*----------------------------------------------------------------------------*/ 83 | typedef struct ad_http_s ad_http_t; 84 | 85 | /*!< Hook type */ 86 | #define AD_HOOK_ALL (0) /*!< call on each and every phases */ 87 | #define AD_HOOK_ON_CONNECT (1) /*!< call right after the establishment of connection */ 88 | #define AD_HOOK_AFTER_REQUESTLINE (1 << 2) /*!< call after parsing request line */ 89 | #define AD_HOOK_AFTER_HEADER (1 << 3) /*!< call after parsing all headers */ 90 | #define AD_HOOK_ON_BODY (1 << 4) /*!< call on every time body data received */ 91 | #define AD_HOOK_ON_REQUEST (1 << 5) /*!< call with complete request */ 92 | #define AD_HOOK_ON_CLOSE (1 << 6) /*!< call right before closing or next request */ 93 | 94 | enum ad_http_request_status_e { 95 | AD_HTTP_REQ_INIT = 0, /*!< initial state */ 96 | AD_HTTP_REQ_REQUESTLINE_DONE,/*!< received 1st line */ 97 | AD_HTTP_REQ_HEADER_DONE, /*!< received headers completely */ 98 | AD_HTTP_REQ_DONE, /*!< received body completely. no more data expected */ 99 | 100 | AD_HTTP_ERROR, /*!< unrecoverable error found. */ 101 | }; 102 | 103 | /*----------------------------------------------------------------------------*\ 104 | | PUBLIC FUNCTIONS | 105 | \*----------------------------------------------------------------------------*/ 106 | extern int ad_http_handler(short event, ad_conn_t *conn, void *userdata); 107 | 108 | extern enum ad_http_request_status_e ad_http_get_status(ad_conn_t *conn); 109 | extern struct evbuffer *ad_http_get_inbuf(ad_conn_t *conn); 110 | extern struct evbuffer *ad_http_get_outbuf(ad_conn_t *conn); 111 | 112 | extern const char *ad_http_get_request_header(ad_conn_t *conn, const char *name); 113 | extern off_t ad_http_get_content_length(ad_conn_t *conn); 114 | extern size_t ad_http_get_content_length_stored(ad_conn_t *conn); 115 | extern void *ad_http_get_content(ad_conn_t *conn, size_t maxsize, size_t *storedsize); 116 | extern int ad_http_is_keepalive_request(ad_conn_t *conn); 117 | 118 | extern int ad_http_set_response_header(ad_conn_t *conn, const char *name, const char *value); 119 | extern const char *ad_http_get_response_header(ad_conn_t *conn, const char *name); 120 | extern int ad_http_set_response_code(ad_conn_t *conn, int code, const char *reason); 121 | extern int ad_http_set_response_content(ad_conn_t *conn, const char *contenttype, off_t size); 122 | 123 | extern size_t ad_http_response(ad_conn_t *conn, int code, const char *contenttype, const void *data, off_t size); 124 | extern size_t ad_http_send_header(ad_conn_t *conn); 125 | extern size_t ad_http_send_data(ad_conn_t *conn, const void *data, size_t size); 126 | extern size_t ad_http_send_chunk(ad_conn_t *conn, const void *data, size_t size); 127 | 128 | extern const char *ad_http_get_reason(int code); 129 | 130 | /*---------------------------------------------------------------------------*\ 131 | | DATA STRUCTURES | 132 | \*---------------------------------------------------------------------------*/ 133 | struct ad_http_s { 134 | // HTTP Request 135 | struct { 136 | enum ad_http_request_status_e status; /*!< request status. */ 137 | struct evbuffer *inbuf; /*!< input data buffer. */ 138 | 139 | // request line - available on REQ_REQUESTLINE_DONE. 140 | char *method; /*!< request method ex) GET */ 141 | char *uri; /*!< url+query ex) /data%20path?query=the%20value */ 142 | char *httpver; /*!< version ex) HTTP/1.1 */ 143 | char *path; /*!< decoded path ex) /data path */ 144 | char *query; /*!< query string ex) query=the%20value */ 145 | 146 | // request header - available on REQ_HEADER_DONE. 147 | qlisttbl_t *headers; /*!< parsed request header entries */ 148 | char *host; /*!< host ex) www.domain.com or www.domain.com:8080 */ 149 | char *domain; /*!< domain name ex) www.domain.com (no port number) */ 150 | off_t contentlength; /*!< value of Content-Length header.*/ 151 | size_t bodyin; /*!< bytes moved to in-buff */ 152 | } request; 153 | 154 | // HTTP Response 155 | struct { 156 | struct evbuffer *outbuf; /*!< output data buffer. */ 157 | bool frozen_header; /*!< indicator whether we sent header out or not */ 158 | 159 | // response headers 160 | int code; /*!< response status-code */ 161 | char *reason; /*!< reason-phrase */ 162 | qlisttbl_t *headers; /*!< response header entries */ 163 | off_t contentlength; /*!< content length in response */ 164 | size_t bodyout; /*!< bytes added to out-buffer */ 165 | } response; 166 | }; 167 | 168 | #ifdef __cplusplus 169 | } 170 | #endif 171 | 172 | #endif /*_AD_HTTP_HANDLER_H */ 173 | -------------------------------------------------------------------------------- /include/asyncd/ad_server.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | /** 30 | * ad_server header file 31 | * 32 | * @file ad_server.h 33 | */ 34 | 35 | #ifndef _AD_SERVER_H 36 | #define _AD_SERVER_H 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "qlibc/qlibc.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /*---------------------------------------------------------------------------*\ 49 | | TYPEDEFS | 50 | \*---------------------------------------------------------------------------*/ 51 | typedef struct ad_server_s ad_server_t; 52 | typedef struct ad_conn_s ad_conn_t; 53 | 54 | /* 55 | * Return values of user callback. 56 | */ 57 | #define AD_OK (0) /*!< I'm done with this request. Escalate to other hooks. */ 58 | #define AD_TAKEOVER (1) /*!< I'll handle the buffer directly this time, skip next hook */ 59 | #define AD_DONE (2) /*!< We're done with this request but keep the connection open. */ 60 | #define AD_CLOSE (3) /*!< We're done with this request. Close as soon as we sent all data out. */ 61 | 62 | /* 63 | * These flags are used for ad_log_level(); 64 | */ 65 | enum ad_log_e { 66 | AD_LOG_DISABLE = 0, 67 | AD_LOG_ERROR, 68 | AD_LOG_WARN, 69 | AD_LOG_INFO, 70 | AD_LOG_DEBUG, 71 | AD_LOG_DEBUG2, 72 | }; 73 | 74 | /*---------------------------------------------------------------------------*\ 75 | | SERVER OPTIONS | 76 | \*---------------------------------------------------------------------------*/ 77 | 78 | /** 79 | * Server option names and default values. 80 | */ 81 | #define AD_SERVER_OPTIONS { \ 82 | { "server.port", "8888" }, \ 83 | \ 84 | /* Addr format IPv4="1.2.3.4", IPv6="1:2:3:4:5:6", Unix="/path" */ \ 85 | { "server.addr", "0.0.0.0" }, \ 86 | \ 87 | { "server.backlog", "128" }, \ 88 | \ 89 | /* Set read timeout seconds. 0 means no timeout. */ \ 90 | { "server.timeout", "0" }, \ 91 | \ 92 | /* SSL options */ \ 93 | { "server.enable_ssl", "0" }, \ 94 | { "server.ssl_cert", "/usr/local/etc/ad_server/ad_server.crt" }, \ 95 | { "server.ssl_pkey", "/usr/local/etc/ad_server/ad_server.key" }, \ 96 | \ 97 | /* Enable or disable request pipelining, this change AD_DONE's behavior */ \ 98 | { "server.request_pipelining", "1" }, \ 99 | \ 100 | /* Run server in a separate thread */ \ 101 | { "server.thread", "0" }, \ 102 | \ 103 | /* Collect resources after stop */ \ 104 | { "server.free_on_stop", "1" }, \ 105 | \ 106 | /* End of array marker. Do not remove */ \ 107 | { "", "_END_" } \ 108 | }; 109 | 110 | /*---------------------------------------------------------------------------*\ 111 | | USER-CALLBACK | 112 | \*---------------------------------------------------------------------------*/ 113 | 114 | /** 115 | * User callback(hook) prototype. 116 | */ 117 | typedef int (*ad_callback)(short event, ad_conn_t *conn, void *userdata); 118 | typedef void (*ad_userdata_free_cb)(ad_conn_t *conn, void *userdata); 119 | 120 | /** 121 | * Event types 122 | */ 123 | #define AD_EVENT_INIT (1) /*!< Call once upon new connection. */ 124 | #define AD_EVENT_READ (1 << 1) /*!< Call on read */ 125 | #define AD_EVENT_WRITE (1 << 2) /*!< Call on write. */ 126 | #define AD_EVENT_CLOSE (1 << 3) /*!< Call before closing. */ 127 | #define AD_EVENT_TIMEOUT (1 << 4) /*!< Timeout indicator, this flag will be set with AD_EVENT_CLOSE. */ 128 | #define AD_EVENT_SHUTDOWN (1 << 5) /*!< Shutdown indicator, this flag will be set with AD_EVENT_CLOSE. */ 129 | 130 | /** 131 | * Defaults 132 | */ 133 | #define AD_NUM_USERDATA (2) /*!< Number of userdata. Currently 0 is for userdata, 1 is for extra. */ 134 | 135 | /*---------------------------------------------------------------------------*\ 136 | | DATA STRUCTURES | 137 | \*---------------------------------------------------------------------------*/ 138 | 139 | /** 140 | * Server info container. 141 | */ 142 | struct ad_server_s { 143 | int errcode; /*!< exit status. 0 for normal exit, non zero for error. */ 144 | pthread_t *thread; /*!< thread object. not null if server runs as a thread */ 145 | 146 | qhashtbl_t *options; /*!< server options */ 147 | qhashtbl_t *stats; /*!< internal statistics */ 148 | qlist_t *hooks; /*!< list of registered hooks */ 149 | struct evconnlistener *listener; /*!< listener */ 150 | struct event_base *evbase; /*!< event base */ 151 | SSL_CTX *sslctx; /*!< SSL connection support */ 152 | 153 | struct bufferevent *notify_buffer; /*!< internal notification channel */ 154 | }; 155 | 156 | /** 157 | * Connection structure. 158 | */ 159 | struct ad_conn_s { 160 | ad_server_t *server; /*!< reference pointer to server */ 161 | struct bufferevent *buffer; /*!< reference pointer to buffer */ 162 | struct evbuffer *in; /*!< in buffer */ 163 | struct evbuffer *out; /*!< out buffer */ 164 | int status; /*!< hook status such as AD_OK */ 165 | 166 | void *userdata[2]; /*!< userdata[0] for end user, userdata[1] for extra */ 167 | ad_userdata_free_cb userdata_free_cb[2]; /*!< callback to release user data */ 168 | char *method; /*!< request method. set by protocol handler */ 169 | }; 170 | 171 | /*----------------------------------------------------------------------------*\ 172 | | PUBLIC FUNCTIONS | 173 | \*----------------------------------------------------------------------------*/ 174 | enum ad_log_e ad_log_level(enum ad_log_e log_level); 175 | 176 | extern ad_server_t *ad_server_new(void); 177 | extern int ad_server_start(ad_server_t *server); 178 | extern void ad_server_stop(ad_server_t *server); 179 | extern void ad_server_free(ad_server_t *server); 180 | extern void ad_server_global_free(void); 181 | 182 | extern void ad_server_set_option(ad_server_t *server, const char *key, const char *value); 183 | extern char *ad_server_get_option(ad_server_t *server, const char *key); 184 | extern int ad_server_get_option_int(ad_server_t *server, const char *key); 185 | extern SSL_CTX *ad_server_ssl_ctx_create_simple(const char *cert_path, const char *pkey_path); 186 | extern void ad_server_set_ssl_ctx(ad_server_t *server, SSL_CTX *sslctx); 187 | extern SSL_CTX *ad_server_get_ssl_ctx(ad_server_t *server); 188 | extern qhashtbl_t *ad_server_get_stats(ad_server_t *server, const char *key); 189 | 190 | extern void ad_server_register_hook(ad_server_t *server, ad_callback cb, void *userdata); 191 | extern void ad_server_register_hook_on_method(ad_server_t *server, const char *method, 192 | ad_callback cb, void *userdata); 193 | 194 | extern void *ad_conn_set_userdata(ad_conn_t *conn, const void *userdata, ad_userdata_free_cb free_cb); 195 | extern void *ad_conn_get_userdata(ad_conn_t *conn); 196 | extern void *ad_conn_set_extra(ad_conn_t *conn, const void *extra, ad_userdata_free_cb free_cb); 197 | extern void *ad_conn_get_extra(ad_conn_t *conn); 198 | extern void ad_conn_set_method(ad_conn_t *conn, char *method); 199 | extern int ad_conn_get_socket(ad_conn_t *conn); 200 | 201 | /*---------------------------------------------------------------------------*\ 202 | | INTERNAL USE ONLY | 203 | \*---------------------------------------------------------------------------*/ 204 | #ifndef _DOXYGEN_SKIP 205 | #endif /* _DOXYGEN_SKIP */ 206 | 207 | #ifdef __cplusplus 208 | } 209 | #endif 210 | 211 | #endif /*_AD_SERVER_H */ 212 | -------------------------------------------------------------------------------- /include/asyncd/asyncd.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | /** 30 | * Master header file. 31 | * 32 | * @file asyncd.h 33 | */ 34 | 35 | #ifndef _ASYNCD_H 36 | #define _ASYNCD_H 37 | 38 | #include "ad_server.h" 39 | #include "ad_http_handler.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /*_ASYNCD_H */ 50 | 51 | -------------------------------------------------------------------------------- /lib/run2init-submodules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ../ 3 | git submodule init 4 | git submodule update 5 | -------------------------------------------------------------------------------- /src/Makefile.in: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | ## libasyncd 3 | ## 4 | ## Copyright (c) 2014 Seungyoung Kim. 5 | ## All rights reserved. 6 | ## 7 | ## Redistribution and use in source and binary forms, with or without 8 | ## modification, are permitted provided that the following conditions are met: 9 | ## 10 | ## 1. Redistributions of source code must retain the above copyright notice, 11 | ## this list of conditions and the following disclaimer. 12 | ## 2. Redistributions in binary form must reproduce the above copyright notice, 13 | ## this list of conditions and the following disclaimer in the documentation 14 | ## and/or other materials provided with the distribution. 15 | ## 16 | ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | ## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | ## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | ## POSSIBILITY OF SUCH DAMAGE. 27 | ################################################################################ 28 | 29 | prefix = @prefix@ 30 | exec_prefix = @exec_prefix@ 31 | 32 | ## Utilities 33 | AR = @AR@ 34 | ARFLAGS = -rc 35 | CHMOD = @CHMOD@ 36 | INSTALL = @INSTALL@ 37 | INSTALL_DATA = @INSTALL_DATA@ 38 | LN_S = @LN_S@ 39 | MKDIR_P = @MKDIR_P@ 40 | RMDIR = rmdir 41 | RANLIB = @RANLIB@ 42 | RM = @RM@ 43 | 44 | ## Install directories 45 | INST_INCDIR = @includedir@ 46 | INST_LIBDIR = @libdir@ 47 | 48 | ## qlibc related. 49 | QLIBC_DIR = ../lib/qlibc 50 | QLIBC_LIB = $(QLIBC_DIR)/lib/libqlibc.a 51 | CPPFLAGS += -I$(QLIBC_DIR)/include 52 | LIBS += $(QLIBC_LIB) 53 | QLIBC = embedded 54 | 55 | ## libasyncd related. 56 | HEADERDIR = ../include/asyncd 57 | CPPFLAGS += -I$(HEADERDIR) 58 | OBJS = ad_server.o ad_http_handler.o 59 | LIBNAME = libasyncd.a 60 | SLIBNAME = libasyncd.so.1 61 | SLIBNAME_LINK = libasyncd.so 62 | 63 | ## Which compiler & options for release 64 | CC = gcc -std=gnu99 65 | CFLAGS = -Wall -Wstrict-prototypes -fPIC -g -O2 66 | CPPFLAGS += -I/usr/include -I/usr/local/include \ 67 | -D_GNU_SOURCE -DBUILD_DEBUG -D_FILE_OFFSET_BITS=64 68 | LIBS += @DEPLIBS@ 69 | 70 | ## Make Library 71 | 72 | ifeq ($(QLIBC),system) 73 | all: $(LIBNAME) 74 | else 75 | all: qlibc $(LIBNAME) 76 | endif 77 | 78 | $(LIBNAME): $(OBJS) 79 | $(AR) $(ARFLAGS) $(LIBNAME) $(OBJS) 80 | $(RANLIB) $(LIBNAME) 81 | $(CC) -shared -Wl,-soname,$(SLIBNAME) -o $(SLIBNAME) $(OBJS) 82 | $(LN_S) -f $(SLIBNAME) $(SLIBNAME_LINK) 83 | 84 | qlibc: 85 | @if [ ! -d $(QLIBC_DIR)/src ]; then \ 86 | ../lib/run2init-submodules.sh; \ 87 | fi 88 | @if [ ! -f $(QLIBC_LIB) ]; then \ 89 | (cd $(QLIBC_DIR) && ./configure && make); \ 90 | fi 91 | 92 | install: install-libasyncd 93 | 94 | install-libasyncd: all 95 | $(MKDIR_P) $(DESTDIR)/$(INST_INCDIR)/asyncd 96 | $(INSTALL_DATA) $(HEADERDIR)/asyncd.h $(DESTDIR)/$(INST_INCDIR)/asyncd/asyncd.h 97 | $(INSTALL_DATA) $(HEADERDIR)/ad_server.h $(DESTDIR)/$(INST_INCDIR)/asyncd/ad_server.h 98 | $(INSTALL_DATA) $(HEADERDIR)/ad_http_handler.h $(DESTDIR)/$(INST_INCDIR)/asyncd/ad_http_handler.h 99 | $(MKDIR_P) $(DESTDIR)/$(INST_LIBDIR) 100 | $(INSTALL_DATA) $(LIBNAME) $(DESTDIR)/$(INST_LIBDIR)/$(LIBNAME) 101 | $(INSTALL_DATA) $(SLIBNAME) $(DESTDIR)/$(INST_LIBDIR)/$(SLIBNAME) 102 | ( cd $(DESTDIR)/$(INST_LIBDIR); $(LN_S) -f $(SLIBNAME) $(SLIBNAME_LINK) ) 103 | 104 | uninstall-libasyncd: 105 | $(RM) -rf $(DESTDIR)/$(INST_INCDIR)/asyncd 106 | $(RM) -f $(DESTDIR)/$(INST_LIBDIR)/$(LIBNAME) 107 | $(RM) -f $(DESTDIR)/$(INST_LIBDIR)/$(SLIBNAME) 108 | $(RM) -f $(DESTDIR)/$(INST_LIBDIR)/$(SLIBNAME_LINK) 109 | 110 | deinstall: uninstall 111 | uninstall: uninstall-libasyncd 112 | $(RMDIR) $(DESTDIR)/$(INST_INCDIR)/asyncd 113 | 114 | clean: 115 | $(RM) -f $(OBJS) $(LIBNAME) $(SLIBNAME) $(SLIBNAME_LINK) 116 | 117 | doc: 118 | doxygen doxygen.conf 119 | 120 | cleandoc: 121 | $(RM) -rf ../doc/html 122 | 123 | ## Compile 124 | .c.o: 125 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< 126 | -------------------------------------------------------------------------------- /src/macro.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * libasyncd 3 | * 4 | * Copyright (c) 2014 Seungyoung Kim. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | *****************************************************************************/ 28 | 29 | #ifndef _MACRO_H 30 | #define _MACRO_H 31 | 32 | /* 33 | * Macro Functions 34 | */ 35 | #define BUG_EXIT() ASSERT(false) 36 | #define ASSERT(c) assert(c) 37 | #define CONST_STRLEN(s) (sizeof(s) - 1) 38 | #define IS_EMPTY_STR(s) ((*s == '\0') ? true : false) 39 | #define IS_EQUAL_STR(s1,s2) (!strcmp(s1,s2)) 40 | #define ENDING_CHAR(s) (*(s + strlen(s) - 1)) 41 | #define NEW_OBJECT(t) ((t *)calloc(1, sizeof(t))) 42 | 43 | #define DYNAMIC_VSPRINTF(s, f) do { \ 44 | size_t _strsize; \ 45 | for(_strsize = 1024; ; _strsize *= 2) { \ 46 | s = (char*)malloc(_strsize); \ 47 | if(s == NULL) { \ 48 | DEBUG("DYNAMIC_VSPRINTF(): can't allocate memory."); \ 49 | break; \ 50 | } \ 51 | va_list _arglist; \ 52 | va_start(_arglist, f); \ 53 | int _n = vsnprintf(s, _strsize, f, _arglist); \ 54 | va_end(_arglist); \ 55 | if(_n >= 0 && _n < _strsize) break; \ 56 | free(s); \ 57 | } \ 58 | } while(0) 59 | 60 | /* 61 | * Error message 62 | */ 63 | extern int _ad_log_level; 64 | #define ERROROUT (stderr) 65 | #define ERROR(fmt, args...) if (_ad_log_level > 0) { \ 66 | fprintf(ERROROUT, "[ERROR] " fmt "\n", ##args); \ 67 | } 68 | #define WARN(fmt, args...) if (_ad_log_level >= 2) { \ 69 | fprintf(ERROROUT, "[WARN] " fmt "\n", ##args); \ 70 | } 71 | #define INFO(fmt, args...) if (_ad_log_level >= 3) { \ 72 | fprintf(ERROROUT, "[INFO] " fmt "\n", ##args); \ 73 | } 74 | 75 | /* 76 | * Debug Macros 77 | */ 78 | #ifdef BUILD_DEBUG 79 | #define DEBUGOUT (stdout) 80 | #define DEBUG(fmt, args...) if (_ad_log_level >= 4) { \ 81 | fprintf(DEBUGOUT, "[DEBUG] " fmt " [%s(),%s:%d]\n", \ 82 | ##args, __func__, __FILE__, __LINE__); \ 83 | } 84 | #else 85 | #define DEBUG(fms, args...) 86 | #endif /* BUILD_DEBUG */ 87 | 88 | // debug timer 89 | #include 90 | #define TIMER_START() \ 91 | int _swno = 0; \ 92 | struct timeval _tv1, _tv2; \ 93 | gettimeofday(&_tv1, NULL) 94 | 95 | #define TIMER_STOP(prefix) { \ 96 | gettimeofday(&_tv2, NULL); \ 97 | _swno++; \ 98 | struct timeval _diff; \ 99 | _diff.tv_sec = _tv2.tv_sec - _tv1.tv_sec; \ 100 | if(_tv2.tv_usec >= _tv1.tv_usec) { \ 101 | _diff.tv_usec = _tv2.tv_usec - _tv1.tv_usec; \ 102 | } else { \ 103 | _diff.tv_sec -= 1; \ 104 | _diff.tv_usec = 1000000 - _tv1.tv_usec + _tv2.tv_usec; \ 105 | } \ 106 | printf("TIMER(%d,%s,%d): %zus %dus (%s:%d)\n", \ 107 | getpid(), prefix, _swno, _diff.tv_sec, (int)(_diff.tv_usec), \ 108 | __FILE__, __LINE__); \ 109 | gettimeofday(&_tv1, NULL); \ 110 | } 111 | 112 | /* 113 | * Q_MUTEX Macros 114 | */ 115 | #ifndef _MULTI_THREADED 116 | #define _MULTI_THREADED 117 | #endif 118 | 119 | #include 120 | #include 121 | 122 | #define Q_MUTEX_NEW(x,r) do { \ 123 | x = (qmutex_t *)calloc(1, sizeof(qmutex_t)); \ 124 | if(x == NULL) break; \ 125 | memset((void*)x, 0, sizeof(qmutex_t)); \ 126 | pthread_mutexattr_t _mutexattr; \ 127 | pthread_mutexattr_init(&_mutexattr); \ 128 | if(r == true) { \ 129 | pthread_mutexattr_settype(&_mutexattr, PTHREAD_MUTEX_RECURSIVE); \ 130 | } \ 131 | int _ret = pthread_mutex_init(&(x->mutex), &_mutexattr); \ 132 | pthread_mutexattr_destroy(&_mutexattr); \ 133 | if(_ret != 0) { \ 134 | char _errmsg[64]; \ 135 | strerror_r(_ret, _errmsg, sizeof(_errmsg)); \ 136 | DEBUG("Q_MUTEX: can't initialize mutex. [%d:%s]", _ret, _errmsg); \ 137 | free(x); \ 138 | x = NULL; \ 139 | } \ 140 | } while(0) 141 | 142 | #define Q_MUTEX_LEAVE(x) do { \ 143 | if(x == NULL) break; \ 144 | if(!pthread_equal(x->owner, pthread_self())) { \ 145 | DEBUG("Q_MUTEX: unlock - owner mismatch."); \ 146 | } \ 147 | if((x->count--) < 0) x->count = 0; \ 148 | pthread_mutex_unlock(&(x->mutex)); \ 149 | } while(0) 150 | 151 | #define MAX_MUTEX_LOCK_WAIT (5000) 152 | #define Q_MUTEX_ENTER(x) do { \ 153 | if(x == NULL) break; \ 154 | while(true) { \ 155 | int _ret, i; \ 156 | for(i = 0; (_ret = pthread_mutex_trylock(&(x->mutex))) != 0 \ 157 | && i < MAX_MUTEX_LOCK_WAIT; i++) { \ 158 | if(i == 0) { \ 159 | DEBUG("Q_MUTEX: mutex is already locked - retrying"); \ 160 | } \ 161 | usleep(1); \ 162 | } \ 163 | if(_ret == 0) break; \ 164 | char _errmsg[64]; \ 165 | strerror_r(_ret, _errmsg, sizeof(_errmsg)); \ 166 | DEBUG("Q_MUTEX: can't get lock - force to unlock. [%d:%s]", \ 167 | _ret, _errmsg); \ 168 | Q_MUTEX_LEAVE(x); \ 169 | } \ 170 | x->count++; \ 171 | x->owner = pthread_self(); \ 172 | } while(0) 173 | 174 | #define Q_MUTEX_DESTROY(x) do { \ 175 | if(x == NULL) break; \ 176 | if(x->count != 0) DEBUG("Q_MUTEX: mutex counter is not 0."); \ 177 | int _ret; \ 178 | while((_ret = pthread_mutex_destroy(&(x->mutex))) != 0) { \ 179 | char _errmsg[64]; \ 180 | strerror_r(_ret, _errmsg, sizeof(_errmsg)); \ 181 | DEBUG("Q_MUTEX: force to unlock mutex. [%d:%s]", _ret, _errmsg); \ 182 | Q_MUTEX_LEAVE(x); \ 183 | } \ 184 | free(x); \ 185 | } while(0) 186 | 187 | #endif /* _MACRO_H */ 188 | --------------------------------------------------------------------------------