├── README.md ├── apr-util ├── Makefile └── patches │ └── 001-automake-compat.patch ├── apr ├── Makefile └── patches │ ├── 001-autoconf-compat.patch │ ├── 101-fix_apr_time_now.patch │ └── 201-upgrade-and-fix-1.5.1.patch ├── cyrus-sasl └── Makefile ├── expat └── Makefile ├── git ├── Makefile └── patches │ ├── 100-convert_builtin.patch │ └── 200-disable_fasthash.patch ├── hellorust ├── Makefile └── src │ └── hellorust.rs ├── libuv ├── Makefile ├── readme.txt └── src │ ├── CMakeLists.txt │ ├── include │ ├── android-ifaddrs.h │ ├── pthread-fixes.h │ ├── stdint-msvc2008.h │ ├── tree.h │ ├── uv-aix.h │ ├── uv-bsd.h │ ├── uv-darwin.h │ ├── uv-errno.h │ ├── uv-linux.h │ ├── uv-sunos.h │ ├── uv-threadpool.h │ ├── uv-unix.h │ ├── uv-version.h │ ├── uv-win.h │ └── uv.h │ └── src │ ├── fs-poll.c │ ├── heap-inl.h │ ├── inet.c │ ├── queue.h │ ├── threadpool.c │ ├── unix │ ├── aix.c │ ├── android-ifaddrs.c │ ├── async.c │ ├── atomic-ops.h │ ├── core.c │ ├── darwin-proctitle.c │ ├── darwin.c │ ├── dl.c │ ├── freebsd.c │ ├── fs.c │ ├── fsevents.c │ ├── getaddrinfo.c │ ├── getnameinfo.c │ ├── internal.h │ ├── kqueue.c │ ├── linux-core.c │ ├── linux-inotify.c │ ├── linux-syscalls.c │ ├── linux-syscalls.h │ ├── loop-watcher.c │ ├── loop.c │ ├── netbsd.c │ ├── openbsd.c │ ├── pipe.c │ ├── poll.c │ ├── process.c │ ├── proctitle.c │ ├── pthread-fixes.c │ ├── signal.c │ ├── spinlock.h │ ├── stream.c │ ├── sunos.c │ ├── tcp.c │ ├── thread.c │ ├── threadpool.c │ ├── timer.c │ ├── tty.c │ ├── udp.c │ └── uv-dtrace.d │ ├── uv-common.c │ ├── uv-common.h │ ├── version.c │ └── win │ ├── async.c │ ├── atomicops-inl.h │ ├── core.c │ ├── dl.c │ ├── error.c │ ├── fs-event.c │ ├── fs.c │ ├── getaddrinfo.c │ ├── getnameinfo.c │ ├── handle-inl.h │ ├── handle.c │ ├── internal.h │ ├── loop-watcher.c │ ├── pipe.c │ ├── poll.c │ ├── process-stdio.c │ ├── process.c │ ├── req-inl.h │ ├── req.c │ ├── signal.c │ ├── stream-inl.h │ ├── stream.c │ ├── tcp.c │ ├── thread.c │ ├── threadpool.c │ ├── timer.c │ ├── tty.c │ ├── udp.c │ ├── util.c │ ├── winapi.c │ ├── winapi.h │ ├── winsock.c │ └── winsock.h ├── luci-app-phddns ├── Makefile ├── lang │ └── phddns.zh-cn.po └── luasrc │ ├── Makefile │ ├── controller │ └── phddns.lua │ ├── model │ └── cbi │ │ └── admin_services │ │ ├── phddns.lua │ │ ├── subversion.lua │ │ └── vlmcsd.lua │ └── view │ └── admin_services │ └── phddns_stat.htm ├── luci └── patches │ ├── 001-change-default-conf.patch │ ├── 200-patch-ralink-wifi.patch │ └── 201-pack-mtk-wifidev.patch ├── mosquitto ├── 100-disable-memory-reporting.patch ├── 101-disable-docbook.patch ├── Makefile ├── README.md ├── files │ └── mosquitto.init └── patches │ └── 102-disable-srv.patch ├── neon ├── Makefile └── patches │ └── 001-automake-compat.patch ├── phddns ├── Makefile ├── files │ └── etc │ │ ├── config │ │ └── phddns │ │ └── init.d │ │ └── phddns └── patches │ └── 001-output_status.patch ├── rust ├── Makefile ├── README.md └── patches │ └── 001-append-mipsel-linux.patch ├── sqlite3 └── Makefile ├── subversion ├── Makefile ├── files │ └── etc │ │ ├── config │ │ └── subversion │ │ └── init.d │ │ └── subversion └── patches │ ├── 001-ac_macros.patch │ └── 002_change_configure.patch ├── tengine ├── Config.in ├── Makefile ├── files │ └── nginx.init └── patches │ ├── 001-fix-cross-compiler.patch │ └── 103-sys_nerr.patch ├── vlmcsd ├── Makefile ├── README.md ├── files │ └── etc │ │ ├── config │ │ └── vlmcsd │ │ ├── init.d │ │ └── vlmcsd │ │ └── vlmcsd.ini └── src │ ├── CMakeLists.txt │ ├── config.h │ ├── crypto.c │ ├── crypto.h │ ├── crypto_internal.c │ ├── crypto_internal.h │ ├── crypto_openssl.c │ ├── crypto_openssl.h │ ├── crypto_polarssl.h │ ├── endian.c │ ├── endian.h │ ├── helpers.c │ ├── helpers.h │ ├── kms.c │ ├── kms.h │ ├── nameser.h │ ├── nameser_compat.h │ ├── network.c │ ├── network.h │ ├── ns_name.c │ ├── ns_name.h │ ├── ns_parse.c │ ├── ns_parse.h │ ├── ntservice.c │ ├── ntservice.h │ ├── output.c │ ├── output.h │ ├── resolv.h │ ├── resolv_static.h │ ├── rpc.c │ ├── rpc.h │ ├── shared_globals.c │ ├── shared_globals.h │ ├── types.h │ ├── vlmcs.c │ ├── vlmcs.h │ ├── vlmcsd.c │ ├── vlmcsd.h │ └── vlmcsdmulti.c └── wsapi └── Makefile /README.md: -------------------------------------------------------------------------------- 1 | some Openwrt Package. 2 | ==== 3 | 4 | include subversion 1.8.10 git 2.10 ... 5 | 6 | 7 | http://hui21894558.blog.163.com/blog/static/78922943201461093133655/ -------------------------------------------------------------------------------- /apr-util/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2007-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=apr-util 11 | PKG_VERSION:=1.5.4 12 | PKG_RELEASE:=1 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 15 | PKG_SOURCE_URL:=http://mirrors.ibiblio.org/apache/apr/ 16 | PKG_MD5SUM:=2202b18f269ad606d70e1864857ed93c 17 | PKG_MAINTAINER:=Thomas Heil 18 | PKG_LICENSE:=Apache License 19 | 20 | PKG_FIXUP:=autoreconf 21 | PKG_REMOVE_FILES:=aclocal.m4 build/ltmain.sh 22 | 23 | PKG_INSTALL:=1 24 | 25 | include $(INCLUDE_DIR)/package.mk 26 | include $(INCLUDE_DIR)/nls.mk 27 | 28 | define Package/libaprutil 29 | SECTION:=libs 30 | CATEGORY:=Libraries 31 | DEPENDS:=+libapr +libexpat +libsqlite3 +libuuid +libiconv 32 | TITLE:=Apache Portable Runtime Utility Library 33 | URL:=http://apr.apache.org/ 34 | endef 35 | 36 | TARGET_CFLAGS += $(FPIC) 37 | TARGET_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 38 | 39 | CONFIGURE_ARGS += \ 40 | --with-pgsql=no \ 41 | --with-apr="$(STAGING_DIR)/usr/bin/apr-1-config" \ 42 | --with-expat="$(STAGING_DIR)/usr" \ 43 | --without-sqlite2 \ 44 | --with-sqlite3="$(STAGING_DIR)/usr" \ 45 | --with-iconv="$(ICONV_PREFIX)" \ 46 | 47 | CONFIGURE_VARS += \ 48 | ac_cv_file_dbd_apr_dbd_mysql_c=no \ 49 | APR_BUILD_DIR="$(STAGING_DIR)/usr/share/build-1" \ 50 | 51 | MAKE_FLAGS += \ 52 | APRUTIL_LIBS="-lsqlite3 $(TARGET_LDFLAGS) -lexpat -liconv -lapr-1 -luuid -lm -lcrypt" \ 53 | 54 | define Build/InstallDev 55 | $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/include/apr-1/ $(1)/usr/lib $(1)/usr/lib/pkgconfig/ 56 | $(CP) $(PKG_INSTALL_DIR)/usr/bin/apu-1-config \ 57 | $(1)/usr/bin/ 58 | $(CP) $(PKG_INSTALL_DIR)/usr/include/apr-1/* \ 59 | $(1)/usr/include/apr-1/ 60 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libaprutil-1.{la,a,so*} \ 61 | $(1)/usr/lib/ 62 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/apr-util-1.pc \ 63 | $(1)/usr/lib/pkgconfig/ 64 | $(SED) 's, -e \"s -I$$$$prefix/lib g\",,g' $(1)/usr/bin/apu-1-config 65 | $(SED) 's,^libdir=\"$$$${exec_prefix}/lib,libdir=\"$(STAGING_DIR)/usr/lib,g' $(1)/usr/bin/apu-1-config 66 | $(SED) 's,^includedir=\"$$$${prefix}/include/,includedir=\"$(STAGING_DIR)/usr/include/,g' $(1)/usr/bin/apu-1-config 67 | $(SED) 's,-L$$$$libdir,,g' $(1)/usr/bin/apu-1-config 68 | $(SED) 's,-R$$$$libdir,,g' $(1)/usr/bin/apu-1-config 69 | endef 70 | 71 | define Package/libaprutil/install 72 | $(INSTALL_DIR) $(1)/usr/lib 73 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libaprutil-1.so.* $(1)/usr/lib/ 74 | endef 75 | 76 | $(eval $(call BuildPackage,libaprutil)) 77 | -------------------------------------------------------------------------------- /apr-util/patches/001-automake-compat.patch: -------------------------------------------------------------------------------- 1 | --- a/Makefile.in 2 | +++ b/Makefile.in 3 | @@ -8,6 +8,7 @@ APRUTIL_MAJOR_VERSION=@APRUTIL_MAJOR_VER 4 | APRUTIL_DOTTED_VERSION=@APRUTIL_DOTTED_VERSION@ 5 | 6 | srcdir = @srcdir@ 7 | +top_builddir = @top_builddir@ 8 | VPATH = @srcdir@ 9 | 10 | INCLUDES = @APRUTIL_PRIV_INCLUDES@ @APR_INCLUDES@ @APRUTIL_INCLUDES@ 11 | --- a/configure.in 12 | +++ b/configure.in 13 | @@ -41,6 +41,8 @@ AC_SUBST(APU_CONFIG_LOCATION) 14 | AC_CANONICAL_SYSTEM 15 | 16 | AC_PROG_INSTALL 17 | +AC_PROG_LIBTOOL 18 | +LT_INIT 19 | 20 | # Use -no-install or -no-fast-install to link the test 21 | # programs on all platforms but Darwin, where it would cause 22 | -------------------------------------------------------------------------------- /apr/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2007-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=apr 11 | PKG_VERSION:=1.5.1 12 | PKG_RELEASE:=1 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 15 | PKG_SOURCE_URL:=http://mirrors.ibiblio.org/apache/apr/ 16 | PKG_MD5SUM:=5486180ec5a23efb5cae6d4292b300ab 17 | PKG_MAINTAINER:=Thomas Heil 18 | PKG_LICENSE:=Apache License 19 | 20 | PKG_FIXUP:=autoreconf 21 | PKG_REMOVE_FILES:=aclocal.m4 build/ltmain.sh 22 | 23 | PKG_INSTALL:=1 24 | 25 | include $(INCLUDE_DIR)/package.mk 26 | 27 | define Package/libapr 28 | SECTION:=libs 29 | CATEGORY:=Libraries 30 | DEPENDS:=+libpthread +librt +libuuid 31 | TITLE:=Apache Portable Runtime Library 32 | URL:=http://apr.apache.org/ 33 | endef 34 | 35 | TARGET_CFLAGS += $(FPIC) 36 | TARGET_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 37 | 38 | CONFIGURE_ARGS += \ 39 | --with-devrandom=/dev/urandom \ 40 | --disable-dso \ 41 | --enable-ipv6 42 | 43 | # XXX: ac_cv_sizeof_struct_iovec=1 is just to trick configure 44 | CONFIGURE_VARS += \ 45 | ac_cv_sizeof_struct_iovec=1 \ 46 | ac_cv_struct_rlimit=yes \ 47 | apr_cv_process_shared_works=no \ 48 | apr_cv_mutex_robust_shared=no \ 49 | apr_cv_tcp_nodelay_with_cork=yes \ 50 | apr_cv_use_lfs64=yes \ 51 | LDFLAGS="$$$$LDFLAGS -lpthread" \ 52 | 53 | define Build/InstallDev 54 | $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/include/apr-1 $(1)/usr/lib $(1)/usr/lib/pkgconfig $(1)/usr/share/build-1 55 | $(CP) $(PKG_INSTALL_DIR)/usr/bin/apr-1-config \ 56 | $(1)/usr/bin/ 57 | $(CP) $(PKG_INSTALL_DIR)/usr/include/apr-1/* \ 58 | $(1)/usr/include/apr-1/ 59 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libapr-1.{la,a,so*} \ 60 | $(1)/usr/lib/ 61 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/apr-1.pc \ 62 | $(1)/usr/lib/pkgconfig/ 63 | $(CP) $(PKG_INSTALL_DIR)/usr/share/build-1/* \ 64 | $(1)/usr/share/build-1/ 65 | $(SED) 's,^datadir=\"/usr/share\",datadir=\"$(STAGING_DIR)/usr/share\",g' $(1)/usr/bin/apr-1-config 66 | $(SED) 's,^installbuilddir=\"/usr/share/build-1\",installbuilddir=\"$(STAGING_DIR)/usr/share/build-1\",g' $(1)/usr/bin/apr-1-config 67 | $(SED) 's,^libdir=\"$$$${exec_prefix}/lib,libdir=\"$(STAGING_DIR)/usr/lib,g' $(1)/usr/bin/apr-1-config 68 | $(SED) 's,^includedir=\"$$$${prefix}/include/,includedir=\"$(STAGING_DIR)/usr/include/,g' $(1)/usr/bin/apr-1-config 69 | $(SED) 's,-L$$$$libdir,,g' $(1)/usr/bin/apr-1-config 70 | $(SED) 's,-R$$$$libdir,,g' $(1)/usr/bin/apr-1-config 71 | $(SED) 's,/usr/share/build-1,$(STAGING_DIR)/usr/share/build-1,g' $(1)/usr/share/build-1/apr_rules.mk 72 | endef 73 | 74 | define Package/libapr/install 75 | $(INSTALL_DIR) $(1)/usr/lib 76 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libapr-1.so.* $(1)/usr/lib/ 77 | endef 78 | 79 | $(eval $(call BuildPackage,libapr)) 80 | -------------------------------------------------------------------------------- /apr/patches/001-autoconf-compat.patch: -------------------------------------------------------------------------------- 1 | --- a/Makefile.in 2 | +++ b/Makefile.in 3 | @@ -3,6 +3,7 @@ srcdir=@srcdir@ 4 | VPATH=@srcdir@ 5 | top_srcdir=@apr_srcdir@ 6 | top_blddir=@apr_builddir@ 7 | +top_builddir=@top_builddir@ 8 | 9 | # 10 | # APR (Apache Portable Runtime) library Makefile. 11 | --- a/configure.in 12 | +++ b/configure.in 13 | @@ -246,9 +246,6 @@ case $host in 14 | gcc $CFLAGS $CPPFLAGS -o $LIBTOOL.exe $LIBTOOL.c 15 | ;; 16 | *) 17 | - if test "x$LTFLAGS" = "x"; then 18 | - LTFLAGS='--silent' 19 | - fi 20 | if test "$experimental_libtool" = "yes"; then 21 | # Use a custom-made libtool replacement 22 | echo "using jlibtool" 23 | -------------------------------------------------------------------------------- /apr/patches/101-fix_apr_time_now.patch: -------------------------------------------------------------------------------- 1 | https://dev.openwrt.org/ticket/9287 2 | 3 | --- a/time/unix/time.c 4 | +++ b/time/unix/time.c 5 | @@ -75,7 +75,7 @@ APR_DECLARE(apr_time_t) apr_time_now(voi 6 | { 7 | struct timeval tv; 8 | gettimeofday(&tv, NULL); 9 | - return tv.tv_sec * APR_USEC_PER_SEC + tv.tv_usec; 10 | + return tv.tv_sec * (apr_time_t)APR_USEC_PER_SEC + (apr_time_t)tv.tv_usec; 11 | } 12 | 13 | static void explode_time(apr_time_exp_t *xt, apr_time_t t, 14 | -------------------------------------------------------------------------------- /apr/patches/201-upgrade-and-fix-1.5.1.patch: -------------------------------------------------------------------------------- 1 | Makefile.in: fix cross compiling failed 2 | 3 | The tools/gen_test_char was invoked at build time, 4 | and it didn't work for the cross compiling, so we 5 | compile it with $BUILDCC. 6 | 7 | Remove the 'tools' dir creation, it always existed. 8 | And it caused gen_test_char unexpected rebuilt at 9 | do_install time. 10 | 11 | Upstream-Status: inappropriate [oe specific] 12 | 13 | Signed-off-by: Hongxu Jia 14 | --- 15 | Makefile.in | 10 ++-------- 16 | 1 file changed, 2 insertions(+), 8 deletions(-) 17 | 18 | Index: apr-1.5.1/Makefile.in 19 | =================================================================== 20 | --- apr-1.5.1.orig/Makefile.in 21 | +++ apr-1.5.1/Makefile.in 22 | @@ -20,7 +20,7 @@ INCDIR=./include 23 | OSDIR=$(top_srcdir)/include/arch/@OSDIR@ 24 | DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@ 25 | INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR) -I$(top_srcdir)/include/arch/@DEFAULT_OSDIR@ -I$(top_srcdir)/include -I$(top_srcdir)/include/private -I$(top_blddir)/include/private 26 | - 27 | +BUILDCC=gcc 28 | # 29 | # Macros for target determination 30 | # 31 | @@ -47,7 +47,6 @@ LT_VERSION = @LT_VERSION@ 32 | 33 | CLEAN_TARGETS = apr-config.out apr.exp exports.c export_vars.c .make.dirs \ 34 | build/apr_rules.out tools/gen_test_char@EXEEXT@ \ 35 | - tools/gen_test_char.o tools/gen_test_char.lo \ 36 | include/private/apr_escape_test_char.h 37 | DISTCLEAN_TARGETS = config.cache config.log config.status \ 38 | include/apr.h include/arch/unix/apr_private.h \ 39 | @@ -130,13 +129,8 @@ check: $(TARGET_LIB) 40 | etags: 41 | etags `find . -name '*.[ch]'` 42 | 43 | -make_tools_dir: 44 | - $(APR_MKDIR) tools 45 | - 46 | -OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS) 47 | -tools/gen_test_char.lo: make_tools_dir 48 | -tools/gen_test_char@EXEEXT@: $(OBJECTS_gen_test_char) 49 | - $(LINK_PROG) $(OBJECTS_gen_test_char) $(ALL_LIBS) 50 | +tools/gen_test_char@EXEEXT@: tools/gen_test_char.c 51 | + $(BUILDCC) $(CFLAGS_FOR_BUILD) $< -o $@ 52 | 53 | include/private/apr_escape_test_char.h: tools/gen_test_char@EXEEXT@ 54 | $(APR_MKDIR) include/private 55 | -------------------------------------------------------------------------------- /cyrus-sasl/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2006-2008 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=cyrus-sasl 11 | PKG_VERSION:=2.1.26 12 | PKG_RELEASE:=2 13 | 14 | PKG_MAINTAINER:=W. Michael Petullo 15 | 16 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 17 | PKG_SOURCE_URL:=ftp://ftp.cyrusimap.org/cyrus-sasl/ 18 | PKG_MD5SUM:=a7f4e5e559a0e37b3ffc438c9456e425 19 | 20 | PKG_LICENSE:=BSD-4c BSD 21 | PKG_LICENSE_FILES:=COPYING cmulocal/COPYING saslauthd/COPYING 22 | 23 | PKG_FIXUP:=autoreconf 24 | PKG_MACRO_PATHS:=cmulocal config ../cmulocal ../config 25 | PKG_AUTOMAKE_PATHS:=. saslauthd sasldb 26 | PKG_REMOVE_FILES:=aclocal.m4 saslauthd/aclocal.m4 config/libtool.m4 27 | 28 | include $(INCLUDE_DIR)/package.mk 29 | 30 | define Package/libsasl2 31 | SECTION:=libs 32 | CATEGORY:=Libraries 33 | TITLE:=A general purpose authentication library 34 | URL:=http://asg.web.cmu.edu/sasl/ 35 | DEPENDS:=libopenssl 36 | endef 37 | 38 | TARGET_CFLAGS += $(FPIC) 39 | CONFIGURE_ARGS += \ 40 | --enable-shared \ 41 | --enable-static \ 42 | --disable-sample \ 43 | --enable-staticdlopen \ 44 | --disable-java \ 45 | --disable-alwaystrue \ 46 | --disable-checkapop \ 47 | --enable-cram \ 48 | --enable-digest \ 49 | --without-auth-sasldb \ 50 | --disable-otp \ 51 | --disable-srp \ 52 | --disable-srp-setpass \ 53 | --disable-krb4 \ 54 | --disable-gssapi \ 55 | --disable-gss_mutexes \ 56 | --enable-plain \ 57 | --enable-anon \ 58 | --disable-login \ 59 | --disable-ntlm \ 60 | --disable-sql \ 61 | --disable-ldapdb \ 62 | --without-dblib \ 63 | --without-gdbm \ 64 | --with-devrandom="/dev/urandom" \ 65 | --without-pam \ 66 | --without-saslauthd \ 67 | --without-authdaemond \ 68 | --without-pwcheck \ 69 | --with-ipctype=unix \ 70 | --with-openssl="$(STAGING_DIR)/usr" \ 71 | --without-des \ 72 | --without-opie \ 73 | --without-ldap \ 74 | --without-mysql \ 75 | --without-pgsql \ 76 | --without-sqlite \ 77 | --without-rc4 \ 78 | --without-dmalloc \ 79 | --without-sfio \ 80 | --disable-sample 81 | 82 | define Build/Compile 83 | $(MAKE) -C $(PKG_BUILD_DIR)/include \ 84 | CC="$(HOSTCC)" \ 85 | LINK="$(HOSTCC) -o makemd5 -lc" \ 86 | CFLAGS="" \ 87 | CPPFLAGS="" \ 88 | makemd5 89 | $(MAKE) -C $(PKG_BUILD_DIR) \ 90 | DESTDIR="$(PKG_INSTALL_DIR)" \ 91 | all install 92 | endef 93 | 94 | define Build/InstallDev 95 | $(INSTALL_DIR) $(1)/usr/include/ 96 | $(CP) $(PKG_INSTALL_DIR)/usr/include/sasl $(1)/usr/include/ 97 | $(INSTALL_DIR) $(1)/usr/lib/ 98 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsasl2.{a,so*} $(1)/usr/lib/ 99 | ln -sf libsasl2.a $(1)/usr/lib/libsasl.a 100 | ln -sf libsasl2.so $(1)/usr/lib/libsasl.so 101 | $(INSTALL_DIR) $(1)/usr/lib/sasl2 102 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/sasl2/lib*.{a,so*} $(1)/usr/lib/sasl2/ 103 | endef 104 | 105 | define Package/libsasl2/install 106 | $(INSTALL_DIR) $(1)/usr/lib/ 107 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsasl2.so.* $(1)/usr/lib/ 108 | $(INSTALL_DIR) $(1)/usr/lib/sasl2 109 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/sasl2/lib*.so.* $(1)/usr/lib/sasl2/ 110 | endef 111 | 112 | $(eval $(call BuildPackage,libsasl2)) 113 | -------------------------------------------------------------------------------- /expat/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2006 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=expat 11 | PKG_VERSION:=2.1.0 12 | PKG_RELEASE:=3 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_MD5SUM:=dd7dab7a5fea97d2a6a43f511449b7cd 16 | PKG_SOURCE_URL:=@SF/expat 17 | PKG_MAINTAINER:=Steven Barth 18 | 19 | PKG_LICENSE:=MIT 20 | PKG_LICENSE_FILES:=COPYING 21 | 22 | PKG_FIXUP:=autoreconf 23 | PKG_REMOVE_FILES:=conftools/libtool.m4 24 | 25 | PKG_INSTALL:=1 26 | PKG_BUILD_PARALLEL:=1 27 | 28 | include $(INCLUDE_DIR)/host-build.mk 29 | include $(INCLUDE_DIR)/package.mk 30 | 31 | define Package/libexpat 32 | SECTION:=libs 33 | CATEGORY:=Libraries 34 | TITLE:=An XML parsing library 35 | URL:=http://expat.sourceforge.net/ 36 | endef 37 | 38 | define Package/libexpat/description 39 | A fast, non-validating, stream-oriented XML parsing library. 40 | endef 41 | 42 | TARGET_CFLAGS += $(FPIC) 43 | 44 | CONFIGURE_ARGS += \ 45 | --enable-shared \ 46 | --enable-static 47 | 48 | define Host/Install 49 | $(MAKE) -C $(HOST_BUILD_DIR) install 50 | endef 51 | 52 | define Build/InstallDev 53 | $(INSTALL_DIR) $(1)/usr/include 54 | $(CP) $(PKG_INSTALL_DIR)/usr/include/expat{,_external}.h $(1)/usr/include/ 55 | 56 | $(INSTALL_DIR) $(1)/usr/lib/pkgconfig 57 | $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/expat.pc $(1)/usr/lib/pkgconfig/ 58 | 59 | $(INSTALL_DIR) $(1)/usr/lib 60 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libexpat.{a,so*} $(1)/usr/lib/ 61 | endef 62 | 63 | define Package/libexpat/install 64 | $(INSTALL_DIR) $(1)/usr/lib 65 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libexpat.so.* $(1)/usr/lib/ 66 | endef 67 | 68 | $(eval $(call HostBuild)) 69 | $(eval $(call BuildPackage,libexpat)) 70 | -------------------------------------------------------------------------------- /git/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009-2014 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=git 11 | PKG_VERSION:=2.1.2 12 | PKG_RELEASE:=2 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz 15 | PKG_SOURCE_URL:=@KERNEL/software/scm/git/ 16 | PKG_MD5SUM:=35dc1585dc522fd715f117744b1f5992 17 | 18 | PKG_INSTALL:=1 19 | PKG_BUILD_PARALLEL:=1 20 | 21 | include $(INCLUDE_DIR)/package.mk 22 | 23 | define Package/git 24 | SECTION:=net 25 | CATEGORY:=Network 26 | SUBMENU:=Version Control Systems 27 | DEPENDS:=+libopenssl +libpthread +librt 28 | TITLE:=The fast version control system 29 | URL:=http://git-scm.com 30 | MAINTAINER:=Peter Wagner 31 | endef 32 | 33 | define Package/git/description 34 | Git is a free & open source, distributed version control system 35 | designed to handle everything from small to very large projects 36 | with speed and efficiency. 37 | endef 38 | 39 | MAKE_FLAGS := \ 40 | CC="$(TARGET_CC)" \ 41 | CFLAGS="$(TARGET_CFLAGS)" \ 42 | CPPFLAGS="$(TARGET_CPPFLAGS)" \ 43 | LDFLAGS="$(TARGET_LDFLAGS)" \ 44 | NO_CURL="YesPlease" \ 45 | NO_EXPAT="YesPlease" \ 46 | NO_MKSTEMPS="YesPlease" \ 47 | NO_GETTEXT="YesPlease" \ 48 | NO_UNIX_SOCKETS="YesPlease" \ 49 | NO_IPV6="YesPlease" \ 50 | NO_ICONV="YesPlease" \ 51 | NO_NSEC="YesPlease" \ 52 | NO_PERL="YesPlease" \ 53 | NO_PYTHON="YesPlease" \ 54 | NO_TCLTK="YesPlease" 55 | 56 | define Build/Configure 57 | $(MAKE) -C $(PKG_BUILD_DIR) \ 58 | configure 59 | 60 | ( cd $(PKG_BUILD_DIR); \ 61 | ./configure --prefix=/usr \ 62 | ); 63 | endef 64 | 65 | define Package/git/install 66 | $(INSTALL_DIR) $(1) 67 | $(RM) $(PKG_INSTALL_DIR)/usr/bin/git-cvsserver 68 | $(CP) $(PKG_INSTALL_DIR)/* $(1)/ 69 | endef 70 | 71 | # [安装前执行的脚本 记得加上#!/bin/sh 没有就空着] 72 | define Package/$(PKG_NAME)/preinst 73 | #!/bin/sh 74 | 75 | touch /etc/shells 76 | echo /usr/bin/git-shell >> /etc/shells 77 | 78 | endef 79 | 80 | $(eval $(call BuildPackage,git)) 81 | -------------------------------------------------------------------------------- /git/patches/200-disable_fasthash.patch: -------------------------------------------------------------------------------- 1 | --- a/config.mak.uname 2 | +++ b/config.mak.uname 3 | @@ -17,9 +17,6 @@ endif 4 | # because maintaining the nesting to match is a pain. If 5 | # we had "elif" things would have been much nicer... 6 | 7 | -ifeq ($(uname_M),x86_64) 8 | - XDL_FAST_HASH = YesPlease 9 | -endif 10 | ifeq ($(uname_S),OSF1) 11 | # Need this for u_short definitions et al 12 | BASIC_CFLAGS += -D_OSF_SOURCE 13 | -------------------------------------------------------------------------------- /hellorust/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=hellorust 4 | PKG_VERSION:=0.0.1 5 | PKG_RELEASE:=1 6 | 7 | 8 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 9 | 10 | 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | define Package/hellorust 14 | SUBMENU:=RUST 15 | CATEGORY:=Languages 16 | TITLE:=The hellorust Programming Language 17 | URL:=http://www.rust-lang.org/ 18 | endef 19 | 20 | define Package/hellorust/description 21 | Rust is a systems programming language that runs blazingly fast, prevents almost all crashes*, and eliminates data races. 22 | endef 23 | 24 | 25 | 26 | #编译准备工作,复制源码到目标目录 27 | define Build/Prepare 28 | mkdir -p $(PKG_BUILD_DIR) 29 | $(CP) -R ./src/* $(PKG_BUILD_DIR)/ 30 | $(Build/Patch) 31 | endef 32 | 33 | define Build/Configure 34 | 35 | endef 36 | 37 | define Build/Compile 38 | ( \ 39 | cd $(PKG_BUILD_DIR) && \ 40 | export LD_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib:$(LD_LIBRARY_PATH) &&\ 41 | rustc \ 42 | -L $(STAGING_DIR_HOST)/lib/rustlib \ 43 | --target=$(REAL_GNU_TARGET_NAME) \ 44 | -C target-cpu=mips32r2 \ 45 | -C linker=$(REAL_GNU_TARGET_NAME)-gcc \ 46 | hellorust.rs \ 47 | ) 48 | endef 49 | 50 | define Build/InstallDev 51 | 52 | endef 53 | 54 | define Package/hellorust/install 55 | $(INSTALL_DIR) $(1)/usr/sbin 56 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/hellorust $(1)/usr/sbin/ 57 | endef 58 | 59 | 60 | $(eval $(call BuildPackage,hellorust)) 61 | -------------------------------------------------------------------------------- /hellorust/src/hellorust.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![feature(lang_items)] 3 | #![feature(intrinsics)] 4 | 5 | #[lang="sized"] 6 | 7 | #[link(name = "c")] 8 | extern { 9 | fn puts(s: *const u8); 10 | } 11 | 12 | #[start] 13 | fn start(_argc: int, _argv: *const *const u8) -> int { 14 | let s = "Hello Rust!\0"; // &str 15 | unsafe { 16 | let (s,_): (*const u8, uint) = transmute(s); // see core::raw::Slice 17 | puts(s); 18 | } 19 | return 0; 20 | } 21 | 22 | #[lang = "stack_exhausted"] extern fn stack_exhausted() {} 23 | #[lang = "eh_personality"] extern fn eh_personality() {} 24 | 25 | extern "rust-intrinsic" { 26 | fn transmute(x: T) -> U; 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /libuv/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2013-2199 bywayboy 3 | # 4 | 5 | include $(TOPDIR)/rules.mk 6 | 7 | PKG_NAME:=libuv 8 | PKG_VERSION:=0.11.29 9 | PKG_RELEASE:=1 10 | PKG_REV:=1 11 | 12 | 13 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 14 | 15 | PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install 16 | 17 | PKG_BUILD_DEPENDS:= +libpthread 18 | 19 | include $(INCLUDE_DIR)/package.mk 20 | include $(INCLUDE_DIR)/cmake.mk 21 | 22 | 23 | define Package/libuv 24 | SECTION:=libs 25 | CATEGORY:=Libraries 26 | TITLE:=libuv network library 27 | URL:=https://github.com/joyent/libuv 28 | DEPENDS:= +libpthread 29 | endef 30 | 31 | define Package/libuv/description 32 | A C++ non-blocking network library for multi-threaded server in Linux 33 | endef 34 | 35 | #编译准备工作,复制源码到目标目录 36 | define Build/Prepare 37 | mkdir -p $(PKG_BUILD_DIR) 38 | $(CP) -R ./src/* $(PKG_BUILD_DIR)/ 39 | endef 40 | 41 | define Build/InstallDev 42 | $(INSTALL_DIR) $(1)/usr/include 43 | $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/ 44 | 45 | $(INSTALL_DIR) $(1)/usr/lib 46 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/ 47 | endef 48 | 49 | #[安装(编译)时执行的脚本 记得加上#!/bin/sh 没有就空着] 50 | define Package/libuv/install 51 | $(INSTALL_DIR) $(1)/usr/lib 52 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libuv.so* $(1)/usr/lib/ 53 | endef 54 | 55 | 56 | # [安装前执行的脚本 记得加上#!/bin/sh 没有就空着] 57 | define Package/libuv/preinst 58 | 59 | endef 60 | 61 | 62 | #[安装后执行的脚本 记得加上#!/bin/sh 没有就空着] 63 | define Package/libuv/postinst 64 | 65 | endef 66 | 67 | #[删除前执行的脚本 记得加上#!/bin/sh 没有就空着] 68 | define Package/libuv/prerm 69 | 70 | endef 71 | 72 | #[删除后执行的脚本 记得加上#!/bin/sh 没有就空着] 73 | define Package/libuv/postrm 74 | 75 | endef 76 | 77 | 78 | $(eval $(call BuildPackage,libuv)) 79 | -------------------------------------------------------------------------------- /libuv/readme.txt: -------------------------------------------------------------------------------- 1 | Update to libuv 0.11.29 2 | ===== 3 | 4 | this is libuv for openwrt, support netlink. 5 | -------------------------------------------------------------------------------- /libuv/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | PROJECT(uv) 4 | 5 | SET(CMAKE_SYSTEM_NAME Linux) 6 | 7 | set(CMAKE_C_FLAGS "-Os -fpic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Os --std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter -D_GNU_SOURCE") 8 | 9 | SET(SOURCES 10 | src/unix/async.c 11 | src/unix/core.c 12 | src/unix/dl.c 13 | src/unix/fs.c 14 | src/unix/getaddrinfo.c 15 | src/unix/linux-core.c 16 | src/unix/linux-inotify.c 17 | src/unix/linux-syscalls.c 18 | src/unix/loop-watcher.c 19 | src/unix/loop.c 20 | src/unix/pipe.c 21 | src/unix/poll.c 22 | src/unix/process.c 23 | src/unix/proctitle.c 24 | src/unix/signal.c 25 | src/unix/stream.c 26 | src/unix/tcp.c 27 | src/unix/thread.c 28 | src/unix/threadpool.c 29 | src/unix/timer.c 30 | src/unix/tty.c 31 | src/unix/udp.c 32 | src/fs-poll.c 33 | src/inet.c 34 | src/uv-common.c 35 | src/version.c 36 | ) 37 | 38 | INCLUDE_DIRECTORIES(include src) 39 | ADD_LIBRARY(uv SHARED ${SOURCES}) 40 | 41 | FILE(GLOB HEADERS "include/*.h") 42 | 43 | INSTALL(TARGETS uv DESTINATION lib) 44 | INSTALL(FILES ${HEADERS} DESTINATION include) 45 | 46 | -------------------------------------------------------------------------------- /libuv/src/include/android-ifaddrs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995, 1999 3 | * Berkeley Software Design, Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND 12 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 13 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 14 | * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE 15 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 16 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 17 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 19 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 20 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 21 | * SUCH DAMAGE. 22 | * 23 | * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp 24 | */ 25 | 26 | #ifndef _IFADDRS_H_ 27 | #define _IFADDRS_H_ 28 | 29 | struct ifaddrs { 30 | struct ifaddrs *ifa_next; 31 | char *ifa_name; 32 | unsigned int ifa_flags; 33 | struct sockaddr *ifa_addr; 34 | struct sockaddr *ifa_netmask; 35 | struct sockaddr *ifa_dstaddr; 36 | void *ifa_data; 37 | }; 38 | 39 | /* 40 | * This may have been defined in . Note that if is 41 | * to be included it must be included before this header file. 42 | */ 43 | #ifndef ifa_broadaddr 44 | #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ 45 | #endif 46 | 47 | #include 48 | 49 | __BEGIN_DECLS 50 | extern int getifaddrs(struct ifaddrs **ifap); 51 | extern void freeifaddrs(struct ifaddrs *ifa); 52 | __END_DECLS 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /libuv/src/include/pthread-fixes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Sony Mobile Communications AB 2 | * Copyright (c) 2012, Google Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following disclaimer 13 | in the documentation and/or other materials provided with the 14 | distribution. 15 | * Neither the name of Google Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_TESTING_PTHREAD_FIXES_H 33 | #define GOOGLE_BREAKPAD_COMMON_ANDROID_TESTING_PTHREAD_FIXES_H 34 | 35 | #include 36 | 37 | 38 | /*Android doesn't provide pthread_barrier_t for now.*/ 39 | #ifndef PTHREAD_BARRIER_SERIAL_THREAD 40 | 41 | /* Anything except 0 will do here.*/ 42 | #define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 43 | 44 | typedef struct { 45 | pthread_mutex_t mutex; 46 | pthread_cond_t cond; 47 | unsigned count; 48 | } pthread_barrier_t; 49 | 50 | int pthread_barrier_init(pthread_barrier_t* barrier, 51 | const void* barrier_attr, 52 | unsigned count); 53 | 54 | int pthread_barrier_wait(pthread_barrier_t* barrier); 55 | int pthread_barrier_destroy(pthread_barrier_t *barrier); 56 | #endif /* defined(PTHREAD_BARRIER_SERIAL_THREAD) */ 57 | 58 | int pthread_yield(void); 59 | 60 | /* Workaround pthread_sigmask() returning EINVAL on versions < 4.1 by 61 | * replacing all calls to pthread_sigmask with sigprocmask. See: 62 | * https://android.googlesource.com/platform/bionic/+/9bf330b5 63 | * https://code.google.com/p/android/issues/detail?id=15337 64 | */ 65 | int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset); 66 | 67 | #ifdef pthread_sigmask 68 | #undef pthread_sigmask 69 | #endif 70 | #define pthread_sigmask(how, set, oldset) uv__pthread_sigmask(how, set, oldset) 71 | 72 | #endif /* GOOGLE_BREAKPAD_COMMON_ANDROID_TESTING_PTHREAD_FIXES_H */ 73 | -------------------------------------------------------------------------------- /libuv/src/include/uv-aix.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_AIX_H 23 | #define UV_AIX_H 24 | 25 | #define UV_PLATFORM_LOOP_FIELDS \ 26 | int fs_fd; \ 27 | 28 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 29 | uv__io_t event_watcher; \ 30 | char *dir_filename; \ 31 | 32 | #endif /* UV_AIX_H */ 33 | -------------------------------------------------------------------------------- /libuv/src/include/uv-bsd.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_BSD_H 23 | #define UV_BSD_H 24 | 25 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 26 | uv__io_t event_watcher; \ 27 | 28 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 29 | int rcount; \ 30 | int wcount; \ 31 | 32 | #define UV_HAVE_KQUEUE 1 33 | 34 | #endif /* UV_BSD_H */ 35 | -------------------------------------------------------------------------------- /libuv/src/include/uv-darwin.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_DARWIN_H 23 | #define UV_DARWIN_H 24 | 25 | #if defined(__APPLE__) && defined(__MACH__) 26 | # include 27 | # include 28 | # include 29 | # include 30 | # define UV_PLATFORM_SEM_T semaphore_t 31 | #endif 32 | 33 | #define UV_IO_PRIVATE_PLATFORM_FIELDS \ 34 | int rcount; \ 35 | int wcount; \ 36 | 37 | #define UV_PLATFORM_LOOP_FIELDS \ 38 | uv_thread_t cf_thread; \ 39 | void* _cf_reserved; \ 40 | void* cf_state; \ 41 | uv_mutex_t cf_mutex; \ 42 | uv_sem_t cf_sem; \ 43 | void* cf_signals[2]; \ 44 | 45 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 46 | uv__io_t event_watcher; \ 47 | char* realpath; \ 48 | int realpath_len; \ 49 | int cf_flags; \ 50 | uv_async_t* cf_cb; \ 51 | void* cf_events[2]; \ 52 | void* cf_member[2]; \ 53 | int cf_error; \ 54 | uv_mutex_t cf_mutex; \ 55 | 56 | #define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ 57 | void* select; \ 58 | 59 | #define UV_HAVE_KQUEUE 1 60 | 61 | #endif /* UV_DARWIN_H */ 62 | -------------------------------------------------------------------------------- /libuv/src/include/uv-linux.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_LINUX_H 23 | #define UV_LINUX_H 24 | 25 | #include 26 | 27 | 28 | #define UV_PLATFORM_LOOP_FIELDS \ 29 | uv__io_t inotify_read_watcher; \ 30 | void* inotify_watchers; \ 31 | int inotify_fd; \ 32 | 33 | #define UV_PLATFORM_FS_EVENT_FIELDS \ 34 | void* watchers[2]; \ 35 | int wd; \ 36 | 37 | #endif /* UV_LINUX_H */ 38 | -------------------------------------------------------------------------------- /libuv/src/include/uv-sunos.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_SUNOS_H 23 | #define UV_SUNOS_H 24 | 25 | #include 26 | #include 27 | 28 | /* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, 29 | * add the fs_event fields even when this version of SunOS doesn't support 30 | * file watching. 31 | */ 32 | #define UV_PLATFORM_LOOP_FIELDS \ 33 | uv__io_t fs_event_watcher; \ 34 | int fs_fd; \ 35 | 36 | #if defined(PORT_SOURCE_FILE) 37 | 38 | # define UV_PLATFORM_FS_EVENT_FIELDS \ 39 | file_obj_t fo; \ 40 | int fd; \ 41 | 42 | #endif /* defined(PORT_SOURCE_FILE) */ 43 | 44 | #endif /* UV_SUNOS_H */ 45 | -------------------------------------------------------------------------------- /libuv/src/include/uv-threadpool.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | /* 23 | * This file is private to libuv. It provides common functionality to both 24 | * Windows and Unix backends. 25 | */ 26 | 27 | #ifndef UV_THREADPOOL_H_ 28 | #define UV_THREADPOOL_H_ 29 | 30 | struct uv__work { 31 | void (*work)(struct uv__work *w); 32 | void (*done)(struct uv__work *w, int status); 33 | struct uv_loop_s* loop; 34 | void* wq[2]; 35 | }; 36 | 37 | #endif /* UV_THREADPOOL_H_ */ 38 | -------------------------------------------------------------------------------- /libuv/src/include/uv-version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_VERSION_H 23 | #define UV_VERSION_H 24 | 25 | /* 26 | * Versions with an even minor version (e.g. 0.6.1 or 1.0.4) are API and ABI 27 | * stable. When the minor version is odd, the API can change between patch 28 | * releases. Make sure you update the -soname directives in configure.ac 29 | * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but 30 | * not UV_VERSION_PATCH.) 31 | */ 32 | 33 | #define UV_VERSION_MAJOR 0 34 | #define UV_VERSION_MINOR 11 35 | #define UV_VERSION_PATCH 29 36 | #define UV_VERSION_IS_RELEASE 0 37 | 38 | #endif /* UV_VERSION_H */ 39 | -------------------------------------------------------------------------------- /libuv/src/src/queue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Ben Noordhuis 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef QUEUE_H_ 17 | #define QUEUE_H_ 18 | 19 | typedef void *QUEUE[2]; 20 | 21 | /* Private macros. */ 22 | #define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) 23 | #define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1])) 24 | #define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) 25 | #define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) 26 | 27 | /* Public macros. */ 28 | #define QUEUE_DATA(ptr, type, field) \ 29 | ((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field))) 30 | 31 | #define QUEUE_FOREACH(q, h) \ 32 | for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) 33 | 34 | #define QUEUE_EMPTY(q) \ 35 | ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) 36 | 37 | #define QUEUE_HEAD(q) \ 38 | (QUEUE_NEXT(q)) 39 | 40 | #define QUEUE_INIT(q) \ 41 | do { \ 42 | QUEUE_NEXT(q) = (q); \ 43 | QUEUE_PREV(q) = (q); \ 44 | } \ 45 | while (0) 46 | 47 | #define QUEUE_ADD(h, n) \ 48 | do { \ 49 | QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ 50 | QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ 51 | QUEUE_PREV(h) = QUEUE_PREV(n); \ 52 | QUEUE_PREV_NEXT(h) = (h); \ 53 | } \ 54 | while (0) 55 | 56 | #define QUEUE_SPLIT(h, q, n) \ 57 | do { \ 58 | QUEUE_PREV(n) = QUEUE_PREV(h); \ 59 | QUEUE_PREV_NEXT(n) = (n); \ 60 | QUEUE_NEXT(n) = (q); \ 61 | QUEUE_PREV(h) = QUEUE_PREV(q); \ 62 | QUEUE_PREV_NEXT(h) = (h); \ 63 | QUEUE_PREV(q) = (n); \ 64 | } \ 65 | while (0) 66 | 67 | #define QUEUE_INSERT_HEAD(h, q) \ 68 | do { \ 69 | QUEUE_NEXT(q) = QUEUE_NEXT(h); \ 70 | QUEUE_PREV(q) = (h); \ 71 | QUEUE_NEXT_PREV(q) = (q); \ 72 | QUEUE_NEXT(h) = (q); \ 73 | } \ 74 | while (0) 75 | 76 | #define QUEUE_INSERT_TAIL(h, q) \ 77 | do { \ 78 | QUEUE_NEXT(q) = (h); \ 79 | QUEUE_PREV(q) = QUEUE_PREV(h); \ 80 | QUEUE_PREV_NEXT(q) = (q); \ 81 | QUEUE_PREV(h) = (q); \ 82 | } \ 83 | while (0) 84 | 85 | #define QUEUE_REMOVE(q) \ 86 | do { \ 87 | QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ 88 | QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ 89 | } \ 90 | while (0) 91 | 92 | #endif /* QUEUE_H_ */ 93 | -------------------------------------------------------------------------------- /libuv/src/src/unix/atomic-ops.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Ben Noordhuis 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef UV_ATOMIC_OPS_H_ 17 | #define UV_ATOMIC_OPS_H_ 18 | 19 | #include "internal.h" /* UV_UNUSED */ 20 | 21 | UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)); 22 | UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)); 23 | UV_UNUSED(static void cpu_relax(void)); 24 | 25 | /* Prefer hand-rolled assembly over the gcc builtins because the latter also 26 | * issue full memory barriers. 27 | */ 28 | UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { 29 | #if defined(__i386__) || defined(__x86_64__) 30 | int out; 31 | __asm__ __volatile__ ("lock; cmpxchg %2, %1;" 32 | : "=a" (out), "+m" (*(volatile int*) ptr) 33 | : "r" (newval), "0" (oldval) 34 | : "memory"); 35 | return out; 36 | #else 37 | return __sync_val_compare_and_swap(ptr, oldval, newval); 38 | #endif 39 | } 40 | 41 | UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) { 42 | #if defined(__i386__) || defined(__x86_64__) 43 | long out; 44 | __asm__ __volatile__ ("lock; cmpxchg %2, %1;" 45 | : "=a" (out), "+m" (*(volatile long*) ptr) 46 | : "r" (newval), "0" (oldval) 47 | : "memory"); 48 | return out; 49 | #else 50 | return __sync_val_compare_and_swap(ptr, oldval, newval); 51 | #endif 52 | } 53 | 54 | UV_UNUSED(static void cpu_relax(void)) { 55 | #if defined(__i386__) || defined(__x86_64__) 56 | __asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */ 57 | #endif 58 | } 59 | 60 | #endif /* UV_ATOMIC_OPS_H_ */ 61 | -------------------------------------------------------------------------------- /libuv/src/src/unix/dl.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | #include "internal.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | static int uv__dlerror(uv_lib_t* lib); 31 | 32 | 33 | int uv_dlopen(const char* filename, uv_lib_t* lib) { 34 | dlerror(); /* Reset error status. */ 35 | lib->errmsg = NULL; 36 | lib->handle = dlopen(filename, RTLD_LAZY); 37 | return lib->handle ? 0 : uv__dlerror(lib); 38 | } 39 | 40 | 41 | void uv_dlclose(uv_lib_t* lib) { 42 | if (lib->errmsg) { 43 | free(lib->errmsg); 44 | lib->errmsg = NULL; 45 | } 46 | 47 | if (lib->handle) { 48 | /* Ignore errors. No good way to signal them without leaking memory. */ 49 | dlclose(lib->handle); 50 | lib->handle = NULL; 51 | } 52 | } 53 | 54 | 55 | int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { 56 | dlerror(); /* Reset error status. */ 57 | *ptr = dlsym(lib->handle, name); 58 | return uv__dlerror(lib); 59 | } 60 | 61 | 62 | const char* uv_dlerror(const uv_lib_t* lib) { 63 | return lib->errmsg ? lib->errmsg : "no error"; 64 | } 65 | 66 | 67 | static int uv__dlerror(uv_lib_t* lib) { 68 | const char* errmsg; 69 | 70 | if (lib->errmsg) 71 | free(lib->errmsg); 72 | 73 | errmsg = dlerror(); 74 | 75 | if (errmsg) { 76 | lib->errmsg = strdup(errmsg); 77 | return -1; 78 | } 79 | else { 80 | lib->errmsg = NULL; 81 | return 0; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /libuv/src/src/unix/getaddrinfo.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * Permission is hereby granted, free of charge, to any person obtaining a copy 3 | * of this software and associated documentation files (the "Software"), to 4 | * deal in the Software without restriction, including without limitation the 5 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6 | * sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | * IN THE SOFTWARE. 19 | */ 20 | 21 | #include "uv.h" 22 | #include "internal.h" 23 | 24 | #include 25 | #include /* NULL */ 26 | #include 27 | #include 28 | 29 | 30 | int uv__getaddrinfo_translate_error(int sys_err) { 31 | switch (sys_err) { 32 | case 0: return 0; 33 | #if defined(EAI_ADDRFAMILY) 34 | case EAI_ADDRFAMILY: return UV_EAI_ADDRFAMILY; 35 | #endif 36 | #if defined(EAI_AGAIN) 37 | case EAI_AGAIN: return UV_EAI_AGAIN; 38 | #endif 39 | #if defined(EAI_BADFLAGS) 40 | case EAI_BADFLAGS: return UV_EAI_BADFLAGS; 41 | #endif 42 | #if defined(EAI_BADHINTS) 43 | case EAI_BADHINTS: return UV_EAI_BADHINTS; 44 | #endif 45 | #if defined(EAI_CANCELED) 46 | case EAI_CANCELED: return UV_EAI_CANCELED; 47 | #endif 48 | #if defined(EAI_FAIL) 49 | case EAI_FAIL: return UV_EAI_FAIL; 50 | #endif 51 | #if defined(EAI_FAMILY) 52 | case EAI_FAMILY: return UV_EAI_FAMILY; 53 | #endif 54 | #if defined(EAI_MEMORY) 55 | case EAI_MEMORY: return UV_EAI_MEMORY; 56 | #endif 57 | #if defined(EAI_NODATA) 58 | case EAI_NODATA: return UV_EAI_NODATA; 59 | #endif 60 | #if defined(EAI_NONAME) 61 | # if !defined(EAI_NODATA) || EAI_NODATA != EAI_NONAME 62 | case EAI_NONAME: return UV_EAI_NONAME; 63 | # endif 64 | #endif 65 | #if defined(EAI_OVERFLOW) 66 | case EAI_OVERFLOW: return UV_EAI_OVERFLOW; 67 | #endif 68 | #if defined(EAI_PROTOCOL) 69 | case EAI_PROTOCOL: return UV_EAI_PROTOCOL; 70 | #endif 71 | #if defined(EAI_SERVICE) 72 | case EAI_SERVICE: return UV_EAI_SERVICE; 73 | #endif 74 | #if defined(EAI_SOCKTYPE) 75 | case EAI_SOCKTYPE: return UV_EAI_SOCKTYPE; 76 | #endif 77 | #if defined(EAI_SYSTEM) 78 | case EAI_SYSTEM: return -errno; 79 | #endif 80 | } 81 | assert(!"unknown EAI_* error code"); 82 | abort(); 83 | return 0; /* Pacify compiler. */ 84 | } 85 | 86 | 87 | static void uv__getaddrinfo_work(struct uv__work* w) { 88 | uv_getaddrinfo_t* req; 89 | int err; 90 | 91 | req = container_of(w, uv_getaddrinfo_t, work_req); 92 | err = getaddrinfo(req->hostname, req->service, req->hints, &req->res); 93 | req->retcode = uv__getaddrinfo_translate_error(err); 94 | } 95 | 96 | 97 | static void uv__getaddrinfo_done(struct uv__work* w, int status) { 98 | uv_getaddrinfo_t* req; 99 | struct addrinfo *res; 100 | 101 | req = container_of(w, uv_getaddrinfo_t, work_req); 102 | uv__req_unregister(req->loop, req); 103 | 104 | res = req->res; 105 | req->res = NULL; 106 | 107 | /* See initialization in uv_getaddrinfo(). */ 108 | if (req->hints) 109 | free(req->hints); 110 | else if (req->service) 111 | free(req->service); 112 | else if (req->hostname) 113 | free(req->hostname); 114 | else 115 | assert(0); 116 | 117 | req->hints = NULL; 118 | req->service = NULL; 119 | req->hostname = NULL; 120 | 121 | if (status == -ECANCELED) { 122 | assert(req->retcode == 0); 123 | req->retcode = UV_EAI_CANCELED; 124 | } 125 | 126 | req->cb(req, req->retcode, res); 127 | } 128 | 129 | 130 | int uv_getaddrinfo(uv_loop_t* loop, 131 | uv_getaddrinfo_t* req, 132 | uv_getaddrinfo_cb cb, 133 | const char* hostname, 134 | const char* service, 135 | const struct addrinfo* hints) { 136 | size_t hostname_len; 137 | size_t service_len; 138 | size_t hints_len; 139 | size_t len; 140 | char* buf; 141 | 142 | if (req == NULL || cb == NULL || (hostname == NULL && service == NULL)) 143 | return -EINVAL; 144 | 145 | hostname_len = hostname ? strlen(hostname) + 1 : 0; 146 | service_len = service ? strlen(service) + 1 : 0; 147 | hints_len = hints ? sizeof(*hints) : 0; 148 | buf = malloc(hostname_len + service_len + hints_len); 149 | 150 | if (buf == NULL) 151 | return -ENOMEM; 152 | 153 | uv__req_init(loop, req, UV_GETADDRINFO); 154 | req->loop = loop; 155 | req->cb = cb; 156 | req->res = NULL; 157 | req->hints = NULL; 158 | req->service = NULL; 159 | req->hostname = NULL; 160 | req->retcode = 0; 161 | 162 | /* order matters, see uv_getaddrinfo_done() */ 163 | len = 0; 164 | 165 | if (hints) { 166 | req->hints = memcpy(buf + len, hints, sizeof(*hints)); 167 | len += sizeof(*hints); 168 | } 169 | 170 | if (service) { 171 | req->service = memcpy(buf + len, service, service_len); 172 | len += service_len; 173 | } 174 | 175 | if (hostname) { 176 | req->hostname = memcpy(buf + len, hostname, hostname_len); 177 | len += hostname_len; 178 | } 179 | 180 | uv__work_submit(loop, 181 | &req->work_req, 182 | uv__getaddrinfo_work, 183 | uv__getaddrinfo_done); 184 | 185 | return 0; 186 | } 187 | 188 | 189 | void uv_freeaddrinfo(struct addrinfo* ai) { 190 | if (ai) 191 | freeaddrinfo(ai); 192 | } 193 | -------------------------------------------------------------------------------- /libuv/src/src/unix/getnameinfo.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "uv.h" 28 | #include "internal.h" 29 | 30 | 31 | static void uv__getnameinfo_work(struct uv__work* w) { 32 | uv_getnameinfo_t* req; 33 | int err; 34 | socklen_t salen; 35 | 36 | req = container_of(w, uv_getnameinfo_t, work_req); 37 | 38 | if (req->storage.ss_family == AF_INET) 39 | salen = sizeof(struct sockaddr_in); 40 | else if (req->storage.ss_family == AF_INET6) 41 | salen = sizeof(struct sockaddr_in6); 42 | else 43 | abort(); 44 | 45 | err = getnameinfo((struct sockaddr*) &req->storage, 46 | salen, 47 | req->host, 48 | sizeof(req->host), 49 | req->service, 50 | sizeof(req->service), 51 | req->flags); 52 | req->retcode = uv__getaddrinfo_translate_error(err); 53 | } 54 | 55 | static void uv__getnameinfo_done(struct uv__work* w, int status) { 56 | uv_getnameinfo_t* req; 57 | char* host; 58 | char* service; 59 | 60 | req = container_of(w, uv_getnameinfo_t, work_req); 61 | uv__req_unregister(req->loop, req); 62 | host = service = NULL; 63 | 64 | if (status == -ECANCELED) { 65 | assert(req->retcode == 0); 66 | req->retcode = UV_EAI_CANCELED; 67 | } else if (req->retcode == 0) { 68 | host = req->host; 69 | service = req->service; 70 | } 71 | 72 | req->getnameinfo_cb(req, req->retcode, host, service); 73 | } 74 | 75 | /* 76 | * Entry point for getnameinfo 77 | * return 0 if a callback will be made 78 | * return error code if validation fails 79 | */ 80 | int uv_getnameinfo(uv_loop_t* loop, 81 | uv_getnameinfo_t* req, 82 | uv_getnameinfo_cb getnameinfo_cb, 83 | const struct sockaddr* addr, 84 | int flags) { 85 | if (req == NULL || getnameinfo_cb == NULL || addr == NULL) 86 | return UV_EINVAL; 87 | 88 | if (addr->sa_family == AF_INET) { 89 | memcpy(&req->storage, 90 | addr, 91 | sizeof(struct sockaddr_in)); 92 | } else if (addr->sa_family == AF_INET6) { 93 | memcpy(&req->storage, 94 | addr, 95 | sizeof(struct sockaddr_in6)); 96 | } else { 97 | return UV_EINVAL; 98 | } 99 | 100 | uv__req_init(loop, (uv_req_t*)req, UV_GETNAMEINFO); 101 | 102 | req->getnameinfo_cb = getnameinfo_cb; 103 | req->flags = flags; 104 | req->type = UV_GETNAMEINFO; 105 | req->loop = loop; 106 | req->retcode = 0; 107 | 108 | uv__work_submit(loop, 109 | &req->work_req, 110 | uv__getnameinfo_work, 111 | uv__getnameinfo_done); 112 | 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /libuv/src/src/unix/linux-syscalls.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_LINUX_SYSCALL_H_ 23 | #define UV_LINUX_SYSCALL_H_ 24 | 25 | #undef _GNU_SOURCE 26 | #define _GNU_SOURCE 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #if defined(__alpha__) 35 | # define UV__O_CLOEXEC 0x200000 36 | #elif defined(__hppa__) 37 | # define UV__O_CLOEXEC 0x200000 38 | #elif defined(__sparc__) 39 | # define UV__O_CLOEXEC 0x400000 40 | #else 41 | # define UV__O_CLOEXEC 0x80000 42 | #endif 43 | 44 | #if defined(__alpha__) 45 | # define UV__O_NONBLOCK 0x4 46 | #elif defined(__hppa__) 47 | # define UV__O_NONBLOCK 0x10004 48 | #elif defined(__mips__) 49 | # define UV__O_NONBLOCK 0x80 50 | #elif defined(__sparc__) 51 | # define UV__O_NONBLOCK 0x4000 52 | #else 53 | # define UV__O_NONBLOCK 0x800 54 | #endif 55 | 56 | #define UV__EFD_CLOEXEC UV__O_CLOEXEC 57 | #define UV__EFD_NONBLOCK UV__O_NONBLOCK 58 | 59 | #define UV__IN_CLOEXEC UV__O_CLOEXEC 60 | #define UV__IN_NONBLOCK UV__O_NONBLOCK 61 | 62 | #define UV__SOCK_CLOEXEC UV__O_CLOEXEC 63 | #define UV__SOCK_NONBLOCK UV__O_NONBLOCK 64 | 65 | /* epoll flags */ 66 | #define UV__EPOLL_CLOEXEC UV__O_CLOEXEC 67 | #define UV__EPOLL_CTL_ADD 1 68 | #define UV__EPOLL_CTL_DEL 2 69 | #define UV__EPOLL_CTL_MOD 3 70 | 71 | #define UV__EPOLLIN 1 72 | #define UV__EPOLLOUT 4 73 | #define UV__EPOLLERR 8 74 | #define UV__EPOLLHUP 16 75 | #define UV__EPOLLONESHOT 0x40000000 76 | #define UV__EPOLLET 0x80000000 77 | 78 | /* inotify flags */ 79 | #define UV__IN_ACCESS 0x001 80 | #define UV__IN_MODIFY 0x002 81 | #define UV__IN_ATTRIB 0x004 82 | #define UV__IN_CLOSE_WRITE 0x008 83 | #define UV__IN_CLOSE_NOWRITE 0x010 84 | #define UV__IN_OPEN 0x020 85 | #define UV__IN_MOVED_FROM 0x040 86 | #define UV__IN_MOVED_TO 0x080 87 | #define UV__IN_CREATE 0x100 88 | #define UV__IN_DELETE 0x200 89 | #define UV__IN_DELETE_SELF 0x400 90 | #define UV__IN_MOVE_SELF 0x800 91 | 92 | #if defined(__x86_64__) 93 | struct uv__epoll_event { 94 | uint32_t events; 95 | uint64_t data; 96 | } __attribute__((packed)); 97 | #else 98 | struct uv__epoll_event { 99 | uint32_t events; 100 | uint64_t data; 101 | }; 102 | #endif 103 | 104 | struct uv__inotify_event { 105 | int32_t wd; 106 | uint32_t mask; 107 | uint32_t cookie; 108 | uint32_t len; 109 | /* char name[0]; */ 110 | }; 111 | 112 | struct uv__mmsghdr { 113 | struct msghdr msg_hdr; 114 | unsigned int msg_len; 115 | }; 116 | 117 | int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags); 118 | int uv__eventfd(unsigned int count); 119 | int uv__epoll_create(int size); 120 | int uv__epoll_create1(int flags); 121 | int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev); 122 | int uv__epoll_wait(int epfd, 123 | struct uv__epoll_event* events, 124 | int nevents, 125 | int timeout); 126 | int uv__epoll_pwait(int epfd, 127 | struct uv__epoll_event* events, 128 | int nevents, 129 | int timeout, 130 | const sigset_t* sigmask); 131 | int uv__eventfd2(unsigned int count, int flags); 132 | int uv__inotify_init(void); 133 | int uv__inotify_init1(int flags); 134 | int uv__inotify_add_watch(int fd, const char* path, uint32_t mask); 135 | int uv__inotify_rm_watch(int fd, int32_t wd); 136 | int uv__pipe2(int pipefd[2], int flags); 137 | int uv__recvmmsg(int fd, 138 | struct uv__mmsghdr* mmsg, 139 | unsigned int vlen, 140 | unsigned int flags, 141 | struct timespec* timeout); 142 | int uv__sendmmsg(int fd, 143 | struct uv__mmsghdr* mmsg, 144 | unsigned int vlen, 145 | unsigned int flags); 146 | int uv__utimesat(int dirfd, 147 | const char* path, 148 | const struct timespec times[2], 149 | int flags); 150 | ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset); 151 | ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset); 152 | int uv__dup3(int oldfd, int newfd, int flags); 153 | 154 | #endif /* UV_LINUX_SYSCALL_H_ */ 155 | -------------------------------------------------------------------------------- /libuv/src/src/unix/loop-watcher.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | #include "internal.h" 24 | 25 | #define UV_LOOP_WATCHER_DEFINE(name, type) \ 26 | int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ 27 | uv__handle_init(loop, (uv_handle_t*)handle, UV_##type); \ 28 | handle->name##_cb = NULL; \ 29 | return 0; \ 30 | } \ 31 | \ 32 | int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \ 33 | if (uv__is_active(handle)) return 0; \ 34 | if (cb == NULL) return -EINVAL; \ 35 | QUEUE_INSERT_HEAD(&handle->loop->name##_handles, &handle->queue); \ 36 | handle->name##_cb = cb; \ 37 | uv__handle_start(handle); \ 38 | return 0; \ 39 | } \ 40 | \ 41 | int uv_##name##_stop(uv_##name##_t* handle) { \ 42 | if (!uv__is_active(handle)) return 0; \ 43 | QUEUE_REMOVE(&handle->queue); \ 44 | uv__handle_stop(handle); \ 45 | return 0; \ 46 | } \ 47 | \ 48 | void uv__run_##name(uv_loop_t* loop) { \ 49 | uv_##name##_t* h; \ 50 | QUEUE* q; \ 51 | QUEUE_FOREACH(q, &loop->name##_handles) { \ 52 | h = QUEUE_DATA(q, uv_##name##_t, queue); \ 53 | h->name##_cb(h); \ 54 | } \ 55 | } \ 56 | \ 57 | void uv__##name##_close(uv_##name##_t* handle) { \ 58 | uv_##name##_stop(handle); \ 59 | } 60 | 61 | UV_LOOP_WATCHER_DEFINE(prepare, PREPARE) 62 | UV_LOOP_WATCHER_DEFINE(check, CHECK) 63 | UV_LOOP_WATCHER_DEFINE(idle, IDLE) 64 | -------------------------------------------------------------------------------- /libuv/src/src/unix/loop.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | #include "tree.h" 24 | #include "internal.h" 25 | #include "heap-inl.h" 26 | #include 27 | #include 28 | #include 29 | 30 | static int uv__loop_init(uv_loop_t* loop, int default_loop); 31 | static void uv__loop_close(uv_loop_t* loop); 32 | 33 | static uv_loop_t default_loop_struct; 34 | static uv_loop_t* default_loop_ptr; 35 | 36 | 37 | uv_loop_t* uv_default_loop(void) { 38 | if (default_loop_ptr != NULL) 39 | return default_loop_ptr; 40 | 41 | if (uv__loop_init(&default_loop_struct, /* default_loop? */ 1)) 42 | return NULL; 43 | 44 | default_loop_ptr = &default_loop_struct; 45 | return default_loop_ptr; 46 | } 47 | 48 | 49 | int uv_loop_init(uv_loop_t* loop) { 50 | return uv__loop_init(loop, /* default_loop? */ 0); 51 | } 52 | 53 | 54 | int uv_loop_close(uv_loop_t* loop) { 55 | QUEUE* q; 56 | uv_handle_t* h; 57 | if (!QUEUE_EMPTY(&(loop)->active_reqs)) 58 | return -EBUSY; 59 | QUEUE_FOREACH(q, &loop->handle_queue) { 60 | h = QUEUE_DATA(q, uv_handle_t, handle_queue); 61 | if (!(h->flags & UV__HANDLE_INTERNAL)) 62 | return -EBUSY; 63 | } 64 | uv__loop_close(loop); 65 | #ifndef NDEBUG 66 | memset(loop, -1, sizeof(*loop)); 67 | #endif 68 | if (loop == default_loop_ptr) 69 | default_loop_ptr = NULL; 70 | return 0; 71 | } 72 | 73 | 74 | uv_loop_t* uv_loop_new(void) { 75 | uv_loop_t* loop; 76 | 77 | loop = malloc(sizeof(*loop)); 78 | if (loop == NULL) 79 | return NULL; 80 | 81 | if (uv_loop_init(loop)) { 82 | free(loop); 83 | return NULL; 84 | } 85 | 86 | return loop; 87 | } 88 | 89 | 90 | void uv_loop_delete(uv_loop_t* loop) { 91 | uv_loop_t* default_loop; 92 | int err; 93 | default_loop = default_loop_ptr; 94 | err = uv_loop_close(loop); 95 | assert(err == 0); 96 | if (loop != default_loop) 97 | free(loop); 98 | } 99 | 100 | 101 | static int uv__loop_init(uv_loop_t* loop, int default_loop) { 102 | unsigned int i; 103 | int err; 104 | 105 | uv__signal_global_once_init(); 106 | 107 | memset(loop, 0, sizeof(*loop)); 108 | heap_init((struct heap*) &loop->timer_heap); 109 | QUEUE_INIT(&loop->wq); 110 | QUEUE_INIT(&loop->active_reqs); 111 | QUEUE_INIT(&loop->idle_handles); 112 | QUEUE_INIT(&loop->async_handles); 113 | QUEUE_INIT(&loop->check_handles); 114 | QUEUE_INIT(&loop->prepare_handles); 115 | QUEUE_INIT(&loop->handle_queue); 116 | 117 | loop->nfds = 0; 118 | loop->watchers = NULL; 119 | loop->nwatchers = 0; 120 | QUEUE_INIT(&loop->pending_queue); 121 | QUEUE_INIT(&loop->watcher_queue); 122 | 123 | loop->closing_handles = NULL; 124 | uv__update_time(loop); 125 | uv__async_init(&loop->async_watcher); 126 | loop->signal_pipefd[0] = -1; 127 | loop->signal_pipefd[1] = -1; 128 | loop->backend_fd = -1; 129 | loop->emfile_fd = -1; 130 | 131 | loop->timer_counter = 0; 132 | loop->stop_flag = 0; 133 | 134 | err = uv__platform_loop_init(loop, default_loop); 135 | if (err) 136 | return err; 137 | 138 | uv_signal_init(loop, &loop->child_watcher); 139 | uv__handle_unref(&loop->child_watcher); 140 | loop->child_watcher.flags |= UV__HANDLE_INTERNAL; 141 | 142 | for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) 143 | QUEUE_INIT(loop->process_handles + i); 144 | 145 | if (uv_rwlock_init(&loop->cloexec_lock)) 146 | abort(); 147 | 148 | if (uv_mutex_init(&loop->wq_mutex)) 149 | abort(); 150 | 151 | if (uv_async_init(loop, &loop->wq_async, uv__work_done)) 152 | abort(); 153 | 154 | uv__handle_unref(&loop->wq_async); 155 | loop->wq_async.flags |= UV__HANDLE_INTERNAL; 156 | 157 | return 0; 158 | } 159 | 160 | 161 | static void uv__loop_close(uv_loop_t* loop) { 162 | uv__signal_loop_cleanup(loop); 163 | uv__platform_loop_delete(loop); 164 | uv__async_stop(loop, &loop->async_watcher); 165 | 166 | if (loop->emfile_fd != -1) { 167 | uv__close(loop->emfile_fd); 168 | loop->emfile_fd = -1; 169 | } 170 | 171 | if (loop->backend_fd != -1) { 172 | uv__close(loop->backend_fd); 173 | loop->backend_fd = -1; 174 | } 175 | 176 | uv_mutex_lock(&loop->wq_mutex); 177 | assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!"); 178 | assert(!uv__has_active_reqs(loop)); 179 | uv_mutex_unlock(&loop->wq_mutex); 180 | uv_mutex_destroy(&loop->wq_mutex); 181 | 182 | /* 183 | * Note that all thread pool stuff is finished at this point and 184 | * it is safe to just destroy rw lock 185 | */ 186 | uv_rwlock_destroy(&loop->cloexec_lock); 187 | 188 | #if 0 189 | assert(QUEUE_EMPTY(&loop->pending_queue)); 190 | assert(QUEUE_EMPTY(&loop->watcher_queue)); 191 | assert(loop->nfds == 0); 192 | #endif 193 | 194 | free(loop->watchers); 195 | loop->watchers = NULL; 196 | loop->nwatchers = 0; 197 | } 198 | -------------------------------------------------------------------------------- /libuv/src/src/unix/poll.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | #include "internal.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { 31 | uv_poll_t* handle; 32 | int pevents; 33 | 34 | handle = container_of(w, uv_poll_t, io_watcher); 35 | 36 | if (events & UV__POLLERR) { 37 | uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT); 38 | uv__handle_stop(handle); 39 | handle->poll_cb(handle, -EBADF, 0); 40 | return; 41 | } 42 | 43 | pevents = 0; 44 | if (events & UV__POLLIN) 45 | pevents |= UV_READABLE; 46 | if (events & UV__POLLOUT) 47 | pevents |= UV_WRITABLE; 48 | 49 | handle->poll_cb(handle, 0, pevents); 50 | } 51 | 52 | 53 | int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { 54 | uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); 55 | uv__io_init(&handle->io_watcher, uv__poll_io, fd); 56 | handle->poll_cb = NULL; 57 | return 0; 58 | } 59 | 60 | 61 | int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, 62 | uv_os_sock_t socket) { 63 | return uv_poll_init(loop, handle, socket); 64 | } 65 | 66 | 67 | static void uv__poll_stop(uv_poll_t* handle) { 68 | uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT); 69 | uv__handle_stop(handle); 70 | } 71 | 72 | 73 | int uv_poll_stop(uv_poll_t* handle) { 74 | assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); 75 | uv__poll_stop(handle); 76 | return 0; 77 | } 78 | 79 | 80 | int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { 81 | int events; 82 | 83 | assert((pevents & ~(UV_READABLE | UV_WRITABLE)) == 0); 84 | assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); 85 | 86 | uv__poll_stop(handle); 87 | 88 | if (pevents == 0) 89 | return 0; 90 | 91 | events = 0; 92 | if (pevents & UV_READABLE) 93 | events |= UV__POLLIN; 94 | if (pevents & UV_WRITABLE) 95 | events |= UV__POLLOUT; 96 | 97 | uv__io_start(handle->loop, &handle->io_watcher, events); 98 | uv__handle_start(handle); 99 | handle->poll_cb = poll_cb; 100 | 101 | return 0; 102 | } 103 | 104 | 105 | void uv__poll_close(uv_poll_t* handle) { 106 | uv__poll_stop(handle); 107 | } 108 | -------------------------------------------------------------------------------- /libuv/src/src/unix/proctitle.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * Permission is hereby granted, free of charge, to any person obtaining a copy 3 | * of this software and associated documentation files (the "Software"), to 4 | * deal in the Software without restriction, including without limitation the 5 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6 | * sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | * IN THE SOFTWARE. 19 | */ 20 | 21 | #include "uv.h" 22 | #include "internal.h" 23 | 24 | #include 25 | #include 26 | 27 | extern void uv__set_process_title(const char* title); 28 | 29 | static void* args_mem; 30 | 31 | static struct { 32 | char* str; 33 | size_t len; 34 | } process_title; 35 | 36 | 37 | char** uv_setup_args(int argc, char** argv) { 38 | char** new_argv; 39 | size_t size; 40 | char* s; 41 | int i; 42 | 43 | if (argc <= 0) 44 | return argv; 45 | 46 | /* Calculate how much memory we need for the argv strings. */ 47 | size = 0; 48 | for (i = 0; i < argc; i++) 49 | size += strlen(argv[i]) + 1; 50 | 51 | process_title.str = argv[0]; 52 | process_title.len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[0]; 53 | assert(process_title.len + 1 == size); /* argv memory should be adjacent. */ 54 | 55 | /* Add space for the argv pointers. */ 56 | size += (argc + 1) * sizeof(char*); 57 | 58 | new_argv = malloc(size); 59 | if (new_argv == NULL) 60 | return argv; 61 | args_mem = new_argv; 62 | 63 | /* Copy over the strings and set up the pointer table. */ 64 | s = (char*) &new_argv[argc + 1]; 65 | for (i = 0; i < argc; i++) { 66 | size = strlen(argv[i]) + 1; 67 | memcpy(s, argv[i], size); 68 | new_argv[i] = s; 69 | s += size; 70 | } 71 | new_argv[i] = NULL; 72 | 73 | return new_argv; 74 | } 75 | 76 | 77 | int uv_set_process_title(const char* title) { 78 | if (process_title.len == 0) 79 | return 0; 80 | 81 | /* No need to terminate, byte after is always '\0'. */ 82 | strncpy(process_title.str, title, process_title.len); 83 | uv__set_process_title(title); 84 | 85 | return 0; 86 | } 87 | 88 | 89 | int uv_get_process_title(char* buffer, size_t size) { 90 | if (process_title.len > 0) 91 | strncpy(buffer, process_title.str, size); 92 | else if (size > 0) 93 | buffer[0] = '\0'; 94 | 95 | return 0; 96 | } 97 | 98 | 99 | UV_DESTRUCTOR(static void free_args_mem(void)) { 100 | free(args_mem); /* Keep valgrind happy. */ 101 | args_mem = NULL; 102 | } 103 | -------------------------------------------------------------------------------- /libuv/src/src/unix/pthread-fixes.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Sony Mobile Communications AB 2 | * Copyright (c) 2012, Google Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following disclaimer 13 | in the documentation and/or other materials provided with the 14 | distribution. 15 | * Neither the name of Google Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /* Android versions < 4.1 have a broken pthread_sigmask. 33 | * Note that this block of code must come before any inclusion of 34 | * pthread-fixes.h so that the real pthread_sigmask can be referenced. 35 | * */ 36 | #include 37 | #include 38 | 39 | int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) { 40 | static int workaround; 41 | 42 | if (workaround) { 43 | return sigprocmask(how, set, oset); 44 | } else if (pthread_sigmask(how, set, oset)) { 45 | if (errno == EINVAL && sigprocmask(how, set, oset) == 0) { 46 | workaround = 1; 47 | return 0; 48 | } else { 49 | return -1; 50 | } 51 | } else { 52 | return 0; 53 | } 54 | } 55 | 56 | /*Android doesn't provide pthread_barrier_t for now.*/ 57 | #ifndef PTHREAD_BARRIER_SERIAL_THREAD 58 | 59 | #include "pthread-fixes.h" 60 | 61 | int pthread_barrier_init(pthread_barrier_t* barrier, 62 | const void* barrier_attr, 63 | unsigned count) { 64 | barrier->count = count; 65 | pthread_mutex_init(&barrier->mutex, NULL); 66 | pthread_cond_init(&barrier->cond, NULL); 67 | return 0; 68 | } 69 | 70 | int pthread_barrier_wait(pthread_barrier_t* barrier) { 71 | /* Lock the mutex*/ 72 | pthread_mutex_lock(&barrier->mutex); 73 | /* Decrement the count. If this is the first thread to reach 0, wake up 74 | waiters, unlock the mutex, then return PTHREAD_BARRIER_SERIAL_THREAD.*/ 75 | if (--barrier->count == 0) { 76 | /* First thread to reach the barrier */ 77 | pthread_cond_broadcast(&barrier->cond); 78 | pthread_mutex_unlock(&barrier->mutex); 79 | return PTHREAD_BARRIER_SERIAL_THREAD; 80 | } 81 | /* Otherwise, wait for other threads until the count reaches 0, then 82 | return 0 to indicate this is not the first thread.*/ 83 | do { 84 | pthread_cond_wait(&barrier->cond, &barrier->mutex); 85 | } while (barrier->count > 0); 86 | 87 | pthread_mutex_unlock(&barrier->mutex); 88 | return 0; 89 | } 90 | 91 | int pthread_barrier_destroy(pthread_barrier_t *barrier) { 92 | barrier->count = 0; 93 | pthread_cond_destroy(&barrier->cond); 94 | pthread_mutex_destroy(&barrier->mutex); 95 | return 0; 96 | } 97 | 98 | #endif /* defined(PTHREAD_BARRIER_SERIAL_THREAD) */ 99 | 100 | int pthread_yield(void) { 101 | sched_yield(); 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /libuv/src/src/unix/spinlock.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Ben Noordhuis 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef UV_SPINLOCK_H_ 17 | #define UV_SPINLOCK_H_ 18 | 19 | #include "internal.h" /* ACCESS_ONCE, UV_UNUSED */ 20 | #include "atomic-ops.h" 21 | 22 | #define UV_SPINLOCK_INITIALIZER { 0 } 23 | 24 | typedef struct { 25 | int lock; 26 | } uv_spinlock_t; 27 | 28 | UV_UNUSED(static void uv_spinlock_init(uv_spinlock_t* spinlock)); 29 | UV_UNUSED(static void uv_spinlock_lock(uv_spinlock_t* spinlock)); 30 | UV_UNUSED(static void uv_spinlock_unlock(uv_spinlock_t* spinlock)); 31 | UV_UNUSED(static int uv_spinlock_trylock(uv_spinlock_t* spinlock)); 32 | 33 | UV_UNUSED(static void uv_spinlock_init(uv_spinlock_t* spinlock)) { 34 | ACCESS_ONCE(int, spinlock->lock) = 0; 35 | } 36 | 37 | UV_UNUSED(static void uv_spinlock_lock(uv_spinlock_t* spinlock)) { 38 | while (!uv_spinlock_trylock(spinlock)) cpu_relax(); 39 | } 40 | 41 | UV_UNUSED(static void uv_spinlock_unlock(uv_spinlock_t* spinlock)) { 42 | ACCESS_ONCE(int, spinlock->lock) = 0; 43 | } 44 | 45 | UV_UNUSED(static int uv_spinlock_trylock(uv_spinlock_t* spinlock)) { 46 | /* TODO(bnoordhuis) Maybe change to a ticket lock to guarantee fair queueing. 47 | * Not really critical until we have locks that are (frequently) contended 48 | * for by several threads. 49 | */ 50 | return 0 == cmpxchgi(&spinlock->lock, 0, 1); 51 | } 52 | 53 | #endif /* UV_SPINLOCK_H_ */ 54 | -------------------------------------------------------------------------------- /libuv/src/src/unix/timer.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * Permission is hereby granted, free of charge, to any person obtaining a copy 3 | * of this software and associated documentation files (the "Software"), to 4 | * deal in the Software without restriction, including without limitation the 5 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6 | * sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | * IN THE SOFTWARE. 19 | */ 20 | 21 | #include "uv.h" 22 | #include "internal.h" 23 | #include "heap-inl.h" 24 | 25 | #include 26 | #include 27 | 28 | 29 | static int timer_less_than(const struct heap_node* ha, 30 | const struct heap_node* hb) { 31 | const uv_timer_t* a; 32 | const uv_timer_t* b; 33 | 34 | a = container_of(ha, const uv_timer_t, heap_node); 35 | b = container_of(hb, const uv_timer_t, heap_node); 36 | 37 | if (a->timeout < b->timeout) 38 | return 1; 39 | if (b->timeout < a->timeout) 40 | return 0; 41 | 42 | /* Compare start_id when both have the same timeout. start_id is 43 | * allocated with loop->timer_counter in uv_timer_start(). 44 | */ 45 | if (a->start_id < b->start_id) 46 | return 1; 47 | if (b->start_id < a->start_id) 48 | return 0; 49 | 50 | return 0; 51 | } 52 | 53 | 54 | int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { 55 | uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER); 56 | handle->timer_cb = NULL; 57 | handle->repeat = 0; 58 | return 0; 59 | } 60 | 61 | 62 | int uv_timer_start(uv_timer_t* handle, 63 | uv_timer_cb cb, 64 | uint64_t timeout, 65 | uint64_t repeat) { 66 | uint64_t clamped_timeout; 67 | 68 | if (uv__is_active(handle)) 69 | uv_timer_stop(handle); 70 | 71 | clamped_timeout = handle->loop->time + timeout; 72 | if (clamped_timeout < timeout) 73 | clamped_timeout = (uint64_t) -1; 74 | 75 | handle->timer_cb = cb; 76 | handle->timeout = clamped_timeout; 77 | handle->repeat = repeat; 78 | /* start_id is the second index to be compared in uv__timer_cmp() */ 79 | handle->start_id = handle->loop->timer_counter++; 80 | 81 | heap_insert((struct heap*) &handle->loop->timer_heap, 82 | (struct heap_node*) &handle->heap_node, 83 | timer_less_than); 84 | uv__handle_start(handle); 85 | 86 | return 0; 87 | } 88 | 89 | 90 | int uv_timer_stop(uv_timer_t* handle) { 91 | if (!uv__is_active(handle)) 92 | return 0; 93 | 94 | heap_remove((struct heap*) &handle->loop->timer_heap, 95 | (struct heap_node*) &handle->heap_node, 96 | timer_less_than); 97 | uv__handle_stop(handle); 98 | 99 | return 0; 100 | } 101 | 102 | 103 | int uv_timer_again(uv_timer_t* handle) { 104 | if (handle->timer_cb == NULL) 105 | return -EINVAL; 106 | 107 | if (handle->repeat) { 108 | uv_timer_stop(handle); 109 | uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); 110 | } 111 | 112 | return 0; 113 | } 114 | 115 | 116 | void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { 117 | handle->repeat = repeat; 118 | } 119 | 120 | 121 | uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { 122 | return handle->repeat; 123 | } 124 | 125 | 126 | int uv__next_timeout(const uv_loop_t* loop) { 127 | const struct heap_node* heap_node; 128 | const uv_timer_t* handle; 129 | uint64_t diff; 130 | 131 | heap_node = heap_min((const struct heap*) &loop->timer_heap); 132 | if (heap_node == NULL) 133 | return -1; /* block indefinitely */ 134 | 135 | handle = container_of(heap_node, const uv_timer_t, heap_node); 136 | if (handle->timeout <= loop->time) 137 | return 0; 138 | 139 | diff = handle->timeout - loop->time; 140 | if (diff > INT_MAX) 141 | diff = INT_MAX; 142 | 143 | return diff; 144 | } 145 | 146 | 147 | void uv__run_timers(uv_loop_t* loop) { 148 | struct heap_node* heap_node; 149 | uv_timer_t* handle; 150 | 151 | for (;;) { 152 | heap_node = heap_min((struct heap*) &loop->timer_heap); 153 | if (heap_node == NULL) 154 | break; 155 | 156 | handle = container_of(heap_node, uv_timer_t, heap_node); 157 | if (handle->timeout > loop->time) 158 | break; 159 | 160 | uv_timer_stop(handle); 161 | uv_timer_again(handle); 162 | handle->timer_cb(handle); 163 | } 164 | } 165 | 166 | 167 | void uv__timer_close(uv_timer_t* handle) { 168 | uv_timer_stop(handle); 169 | } 170 | -------------------------------------------------------------------------------- /libuv/src/src/unix/uv-dtrace.d: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | provider uv { 23 | probe tick__start(void* loop, int mode); 24 | probe tick__stop(void* loop, int mode); 25 | }; 26 | -------------------------------------------------------------------------------- /libuv/src/src/version.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | 24 | #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \ 25 | (UV_VERSION_MINOR << 8) | \ 26 | (UV_VERSION_PATCH)) 27 | 28 | #define UV_STRINGIFY(v) UV_STRINGIFY_HELPER(v) 29 | #define UV_STRINGIFY_HELPER(v) #v 30 | 31 | #define UV_VERSION_STRING_BASE UV_STRINGIFY(UV_VERSION_MAJOR) "." \ 32 | UV_STRINGIFY(UV_VERSION_MINOR) "." \ 33 | UV_STRINGIFY(UV_VERSION_PATCH) 34 | 35 | #if UV_VERSION_IS_RELEASE 36 | # define UV_VERSION_STRING UV_VERSION_STRING_BASE 37 | #else 38 | # define UV_VERSION_STRING UV_VERSION_STRING_BASE "-pre" 39 | #endif 40 | 41 | 42 | unsigned int uv_version(void) { 43 | return UV_VERSION; 44 | } 45 | 46 | 47 | const char* uv_version_string(void) { 48 | return UV_VERSION_STRING; 49 | } 50 | -------------------------------------------------------------------------------- /libuv/src/src/win/async.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #include "uv.h" 25 | #include "internal.h" 26 | #include "atomicops-inl.h" 27 | #include "handle-inl.h" 28 | #include "req-inl.h" 29 | 30 | 31 | void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) { 32 | if (handle->flags & UV__HANDLE_CLOSING && 33 | !handle->async_sent) { 34 | assert(!(handle->flags & UV_HANDLE_CLOSED)); 35 | uv__handle_close(handle); 36 | } 37 | } 38 | 39 | 40 | int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { 41 | uv_req_t* req; 42 | 43 | uv__handle_init(loop, (uv_handle_t*) handle, UV_ASYNC); 44 | handle->async_sent = 0; 45 | handle->async_cb = async_cb; 46 | 47 | req = &handle->async_req; 48 | uv_req_init(loop, req); 49 | req->type = UV_WAKEUP; 50 | req->data = handle; 51 | 52 | uv__handle_start(handle); 53 | 54 | return 0; 55 | } 56 | 57 | 58 | void uv_async_close(uv_loop_t* loop, uv_async_t* handle) { 59 | if (!((uv_async_t*)handle)->async_sent) { 60 | uv_want_endgame(loop, (uv_handle_t*) handle); 61 | } 62 | 63 | uv__handle_closing(handle); 64 | } 65 | 66 | 67 | int uv_async_send(uv_async_t* handle) { 68 | uv_loop_t* loop = handle->loop; 69 | 70 | if (handle->type != UV_ASYNC) { 71 | /* Can't set errno because that's not thread-safe. */ 72 | return -1; 73 | } 74 | 75 | /* The user should make sure never to call uv_async_send to a closing */ 76 | /* or closed handle. */ 77 | assert(!(handle->flags & UV__HANDLE_CLOSING)); 78 | 79 | if (!uv__atomic_exchange_set(&handle->async_sent)) { 80 | POST_COMPLETION_FOR_REQ(loop, &handle->async_req); 81 | } 82 | 83 | return 0; 84 | } 85 | 86 | 87 | void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle, 88 | uv_req_t* req) { 89 | assert(handle->type == UV_ASYNC); 90 | assert(req->type == UV_WAKEUP); 91 | 92 | handle->async_sent = 0; 93 | 94 | if (handle->flags & UV__HANDLE_CLOSING) { 95 | uv_want_endgame(loop, (uv_handle_t*)handle); 96 | } else if (handle->async_cb != NULL) { 97 | handle->async_cb(handle); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /libuv/src/src/win/atomicops-inl.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_WIN_ATOMICOPS_INL_H_ 23 | #define UV_WIN_ATOMICOPS_INL_H_ 24 | 25 | #include "uv.h" 26 | 27 | 28 | /* Atomic set operation on char */ 29 | #ifdef _MSC_VER /* MSVC */ 30 | 31 | /* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less */ 32 | /* efficient than InterlockedExchange, but InterlockedExchange8 does not */ 33 | /* exist, and interlocked operations on larger targets might require the */ 34 | /* target to be aligned. */ 35 | #pragma intrinsic(_InterlockedOr8) 36 | 37 | static char __declspec(inline) uv__atomic_exchange_set(char volatile* target) { 38 | return _InterlockedOr8(target, 1); 39 | } 40 | 41 | #else /* GCC */ 42 | 43 | /* Mingw-32 version, hopefully this works for 64-bit gcc as well. */ 44 | static inline char uv__atomic_exchange_set(char volatile* target) { 45 | const char one = 1; 46 | char old_value; 47 | __asm__ __volatile__ ("lock xchgb %0, %1\n\t" 48 | : "=r"(old_value), "=m"(*target) 49 | : "0"(one), "m"(*target) 50 | : "memory"); 51 | return old_value; 52 | } 53 | 54 | #endif 55 | 56 | #endif /* UV_WIN_ATOMICOPS_INL_H_ */ 57 | -------------------------------------------------------------------------------- /libuv/src/src/win/dl.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include "uv.h" 23 | #include "internal.h" 24 | 25 | static int uv__dlerror(uv_lib_t* lib, int errorno); 26 | 27 | 28 | int uv_dlopen(const char* filename, uv_lib_t* lib) { 29 | WCHAR filename_w[32768]; 30 | 31 | lib->handle = NULL; 32 | lib->errmsg = NULL; 33 | 34 | if (!uv_utf8_to_utf16(filename, filename_w, ARRAY_SIZE(filename_w))) { 35 | return uv__dlerror(lib, GetLastError()); 36 | } 37 | 38 | lib->handle = LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 39 | if (lib->handle == NULL) { 40 | return uv__dlerror(lib, GetLastError()); 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | 47 | void uv_dlclose(uv_lib_t* lib) { 48 | if (lib->errmsg) { 49 | LocalFree((void*)lib->errmsg); 50 | lib->errmsg = NULL; 51 | } 52 | 53 | if (lib->handle) { 54 | /* Ignore errors. No good way to signal them without leaking memory. */ 55 | FreeLibrary(lib->handle); 56 | lib->handle = NULL; 57 | } 58 | } 59 | 60 | 61 | int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { 62 | *ptr = (void*) GetProcAddress(lib->handle, name); 63 | return uv__dlerror(lib, *ptr ? 0 : GetLastError()); 64 | } 65 | 66 | 67 | const char* uv_dlerror(const uv_lib_t* lib) { 68 | return lib->errmsg ? lib->errmsg : "no error"; 69 | } 70 | 71 | 72 | static int uv__dlerror(uv_lib_t* lib, int errorno) { 73 | if (lib->errmsg) { 74 | LocalFree((void*)lib->errmsg); 75 | lib->errmsg = NULL; 76 | } 77 | 78 | if (errorno) { 79 | FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | 80 | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, 81 | MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), 82 | (LPSTR)&lib->errmsg, 0, NULL); 83 | } 84 | 85 | return errorno ? -1 : 0; 86 | } 87 | -------------------------------------------------------------------------------- /libuv/src/src/win/fs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bywayboy/openwrt-packages/b2914ab9e4695d62f756bac5d84733b086bbe2d3/libuv/src/src/win/fs.c -------------------------------------------------------------------------------- /libuv/src/src/win/getnameinfo.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "uv.h" 27 | #include "internal.h" 28 | #include "req-inl.h" 29 | 30 | #ifndef GetNameInfo 31 | int WSAAPI GetNameInfoW( 32 | const SOCKADDR *pSockaddr, 33 | socklen_t SockaddrLength, 34 | PWCHAR pNodeBuffer, 35 | DWORD NodeBufferSize, 36 | PWCHAR pServiceBuffer, 37 | DWORD ServiceBufferSize, 38 | INT Flags 39 | ); 40 | #endif 41 | 42 | static void uv__getnameinfo_work(struct uv__work* w) { 43 | uv_getnameinfo_t* req; 44 | WCHAR host[NI_MAXHOST]; 45 | WCHAR service[NI_MAXSERV]; 46 | int ret = 0; 47 | 48 | req = container_of(w, uv_getnameinfo_t, work_req); 49 | if (GetNameInfoW((struct sockaddr*)&req->storage, 50 | sizeof(req->storage), 51 | host, 52 | ARRAY_SIZE(host), 53 | service, 54 | ARRAY_SIZE(service), 55 | req->flags)) { 56 | ret = WSAGetLastError(); 57 | } 58 | req->retcode = uv__getaddrinfo_translate_error(ret); 59 | 60 | /* convert results to UTF-8 */ 61 | WideCharToMultiByte(CP_UTF8, 62 | 0, 63 | host, 64 | -1, 65 | req->host, 66 | sizeof(req->host), 67 | NULL, 68 | NULL); 69 | 70 | WideCharToMultiByte(CP_UTF8, 71 | 0, 72 | service, 73 | -1, 74 | req->service, 75 | sizeof(req->service), 76 | NULL, 77 | NULL); 78 | } 79 | 80 | 81 | /* 82 | * Called from uv_run when complete. 83 | */ 84 | static void uv__getnameinfo_done(struct uv__work* w, int status) { 85 | uv_getnameinfo_t* req; 86 | char* host; 87 | char* service; 88 | 89 | req = container_of(w, uv_getnameinfo_t, work_req); 90 | uv__req_unregister(req->loop, req); 91 | host = service = NULL; 92 | 93 | if (status == UV_ECANCELED) { 94 | assert(req->retcode == 0); 95 | req->retcode = UV_EAI_CANCELED; 96 | } else if (req->retcode == 0) { 97 | host = req->host; 98 | service = req->service; 99 | } 100 | 101 | req->getnameinfo_cb(req, req->retcode, host, service); 102 | } 103 | 104 | 105 | /* 106 | * Entry point for getnameinfo 107 | * return 0 if a callback will be made 108 | * return error code if validation fails 109 | */ 110 | int uv_getnameinfo(uv_loop_t* loop, 111 | uv_getnameinfo_t* req, 112 | uv_getnameinfo_cb getnameinfo_cb, 113 | const struct sockaddr* addr, 114 | int flags) { 115 | if (req == NULL || getnameinfo_cb == NULL || addr == NULL) 116 | return UV_EINVAL; 117 | 118 | if (addr->sa_family == AF_INET) { 119 | memcpy(&req->storage, 120 | addr, 121 | sizeof(struct sockaddr_in)); 122 | } else if (addr->sa_family == AF_INET6) { 123 | memcpy(&req->storage, 124 | addr, 125 | sizeof(struct sockaddr_in6)); 126 | } else { 127 | return UV_EINVAL; 128 | } 129 | 130 | uv_req_init(loop, (uv_req_t*)req); 131 | uv__req_register(loop, req); 132 | 133 | req->getnameinfo_cb = getnameinfo_cb; 134 | req->flags = flags; 135 | req->type = UV_GETNAMEINFO; 136 | req->loop = loop; 137 | req->retcode = 0; 138 | 139 | uv__work_submit(loop, 140 | &req->work_req, 141 | uv__getnameinfo_work, 142 | uv__getnameinfo_done); 143 | 144 | return 0; 145 | } 146 | -------------------------------------------------------------------------------- /libuv/src/src/win/handle.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "uv.h" 27 | #include "internal.h" 28 | #include "handle-inl.h" 29 | 30 | 31 | uv_handle_type uv_guess_handle(uv_file file) { 32 | HANDLE handle; 33 | DWORD mode; 34 | 35 | if (file < 0) { 36 | return UV_UNKNOWN_HANDLE; 37 | } 38 | 39 | handle = uv__get_osfhandle(file); 40 | 41 | switch (GetFileType(handle)) { 42 | case FILE_TYPE_CHAR: 43 | if (GetConsoleMode(handle, &mode)) { 44 | return UV_TTY; 45 | } else { 46 | return UV_FILE; 47 | } 48 | 49 | case FILE_TYPE_PIPE: 50 | return UV_NAMED_PIPE; 51 | 52 | case FILE_TYPE_DISK: 53 | return UV_FILE; 54 | 55 | default: 56 | return UV_UNKNOWN_HANDLE; 57 | } 58 | } 59 | 60 | 61 | int uv_is_active(const uv_handle_t* handle) { 62 | return (handle->flags & UV__HANDLE_ACTIVE) && 63 | !(handle->flags & UV__HANDLE_CLOSING); 64 | } 65 | 66 | 67 | void uv_close(uv_handle_t* handle, uv_close_cb cb) { 68 | uv_loop_t* loop = handle->loop; 69 | 70 | if (handle->flags & UV__HANDLE_CLOSING) { 71 | assert(0); 72 | return; 73 | } 74 | 75 | handle->close_cb = cb; 76 | 77 | /* Handle-specific close actions */ 78 | switch (handle->type) { 79 | case UV_TCP: 80 | uv_tcp_close(loop, (uv_tcp_t*)handle); 81 | return; 82 | 83 | case UV_NAMED_PIPE: 84 | uv_pipe_close(loop, (uv_pipe_t*) handle); 85 | return; 86 | 87 | case UV_TTY: 88 | uv_tty_close((uv_tty_t*) handle); 89 | return; 90 | 91 | case UV_UDP: 92 | uv_udp_close(loop, (uv_udp_t*) handle); 93 | return; 94 | 95 | case UV_POLL: 96 | uv_poll_close(loop, (uv_poll_t*) handle); 97 | return; 98 | 99 | case UV_TIMER: 100 | uv_timer_stop((uv_timer_t*)handle); 101 | uv__handle_closing(handle); 102 | uv_want_endgame(loop, handle); 103 | return; 104 | 105 | case UV_PREPARE: 106 | uv_prepare_stop((uv_prepare_t*)handle); 107 | uv__handle_closing(handle); 108 | uv_want_endgame(loop, handle); 109 | return; 110 | 111 | case UV_CHECK: 112 | uv_check_stop((uv_check_t*)handle); 113 | uv__handle_closing(handle); 114 | uv_want_endgame(loop, handle); 115 | return; 116 | 117 | case UV_IDLE: 118 | uv_idle_stop((uv_idle_t*)handle); 119 | uv__handle_closing(handle); 120 | uv_want_endgame(loop, handle); 121 | return; 122 | 123 | case UV_ASYNC: 124 | uv_async_close(loop, (uv_async_t*) handle); 125 | return; 126 | 127 | case UV_SIGNAL: 128 | uv_signal_close(loop, (uv_signal_t*) handle); 129 | return; 130 | 131 | case UV_PROCESS: 132 | uv_process_close(loop, (uv_process_t*) handle); 133 | return; 134 | 135 | case UV_FS_EVENT: 136 | uv_fs_event_close(loop, (uv_fs_event_t*) handle); 137 | return; 138 | 139 | case UV_FS_POLL: 140 | uv__fs_poll_close((uv_fs_poll_t*) handle); 141 | uv__handle_closing(handle); 142 | uv_want_endgame(loop, handle); 143 | return; 144 | 145 | default: 146 | /* Not supported */ 147 | abort(); 148 | } 149 | } 150 | 151 | 152 | int uv_is_closing(const uv_handle_t* handle) { 153 | return !!(handle->flags & (UV__HANDLE_CLOSING | UV_HANDLE_CLOSED)); 154 | } 155 | -------------------------------------------------------------------------------- /libuv/src/src/win/req.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #include "uv.h" 25 | #include "internal.h" 26 | -------------------------------------------------------------------------------- /libuv/src/src/win/stream-inl.h: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #ifndef UV_WIN_STREAM_INL_H_ 23 | #define UV_WIN_STREAM_INL_H_ 24 | 25 | #include 26 | 27 | #include "uv.h" 28 | #include "internal.h" 29 | #include "handle-inl.h" 30 | #include "req-inl.h" 31 | 32 | 33 | INLINE static void uv_stream_init(uv_loop_t* loop, 34 | uv_stream_t* handle, 35 | uv_handle_type type) { 36 | uv__handle_init(loop, (uv_handle_t*) handle, type); 37 | handle->write_queue_size = 0; 38 | handle->activecnt = 0; 39 | } 40 | 41 | 42 | INLINE static void uv_connection_init(uv_stream_t* handle) { 43 | handle->flags |= UV_HANDLE_CONNECTION; 44 | handle->write_reqs_pending = 0; 45 | 46 | uv_req_init(handle->loop, (uv_req_t*) &(handle->read_req)); 47 | handle->read_req.event_handle = NULL; 48 | handle->read_req.wait_handle = INVALID_HANDLE_VALUE; 49 | handle->read_req.type = UV_READ; 50 | handle->read_req.data = handle; 51 | 52 | handle->shutdown_req = NULL; 53 | } 54 | 55 | 56 | #endif /* UV_WIN_STREAM_INL_H_ */ 57 | -------------------------------------------------------------------------------- /libuv/src/src/win/threadpool.c: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to 5 | * deal in the Software without restriction, including without limitation the 6 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | * sell copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | * IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #include "uv.h" 25 | #include "internal.h" 26 | #include "req-inl.h" 27 | 28 | 29 | static void uv_work_req_init(uv_loop_t* loop, uv_work_t* req, 30 | uv_work_cb work_cb, uv_after_work_cb after_work_cb) { 31 | uv_req_init(loop, (uv_req_t*) req); 32 | req->type = UV_WORK; 33 | req->loop = loop; 34 | req->work_cb = work_cb; 35 | req->after_work_cb = after_work_cb; 36 | memset(&req->overlapped, 0, sizeof(req->overlapped)); 37 | } 38 | 39 | 40 | static DWORD WINAPI uv_work_thread_proc(void* parameter) { 41 | uv_work_t* req = (uv_work_t*)parameter; 42 | uv_loop_t* loop = req->loop; 43 | 44 | assert(req != NULL); 45 | assert(req->type == UV_WORK); 46 | assert(req->work_cb); 47 | 48 | req->work_cb(req); 49 | 50 | POST_COMPLETION_FOR_REQ(loop, req); 51 | 52 | return 0; 53 | } 54 | 55 | 56 | int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, 57 | uv_after_work_cb after_work_cb) { 58 | if (work_cb == NULL) 59 | return UV_EINVAL; 60 | 61 | uv_work_req_init(loop, req, work_cb, after_work_cb); 62 | 63 | if (!QueueUserWorkItem(&uv_work_thread_proc, req, WT_EXECUTELONGFUNCTION)) { 64 | return uv_translate_sys_error(GetLastError()); 65 | } 66 | 67 | uv__req_register(loop, req); 68 | return 0; 69 | } 70 | 71 | 72 | int uv_cancel(uv_req_t* req) { 73 | return UV_ENOSYS; 74 | } 75 | 76 | 77 | void uv_process_work_req(uv_loop_t* loop, uv_work_t* req) { 78 | uv__req_unregister(loop, req); 79 | if(req->after_work_cb) 80 | req->after_work_cb(req, 0); 81 | } 82 | -------------------------------------------------------------------------------- /luci-app-phddns/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=luci-app-phddns 4 | PKG_RELEASE:=0.0.1 5 | 6 | PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) 7 | 8 | PO2LMO:=$(shell find $(TOPDIR)/build_dir/target-*/luci* -name po2lmo | awk '{if(match($$0,/build\/po2lmo/)) print $$0}') 9 | 10 | include $(INCLUDE_DIR)/package.mk 11 | 12 | define Package/luci-app-phddns 13 | SECTION:=luci 14 | CATEGORY:=LuCI 15 | SUBMENU:=3. Applications 16 | TITLE:=jmtoo License Key 17 | DEPENDS:=+luci +phddns +subversion 18 | endef 19 | 20 | define Package/luci-app-phddns/description 21 | License Key Save Application. 22 | Developer by bywayboy 23 | endef 24 | 25 | define Build/Prepare 26 | mkdir -p $(PKG_BUILD_DIR) 27 | $(CP) ./luasrc $(PKG_BUILD_DIR)/ 28 | endef 29 | 30 | define Build/Configure 31 | endef 32 | 33 | define Build/Compile 34 | $(MAKE) -C $(PKG_BUILD_DIR)/luasrc 35 | endef 36 | 37 | define Package/luci-app-phddns/postinst 38 | #!/bin/sh 39 | [ -n "${IPKG_INSTROOT}" ] || { 40 | rm -f /tmp/luci-indexcache 41 | exit 0 42 | } 43 | endef 44 | 45 | define Package/luci-app-phddns/install 46 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller 47 | $(CP) $(PKG_BUILD_DIR)/luasrc/controller/* $(1)/usr/lib/lua/luci/controller 48 | 49 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/admin_services 50 | $(CP) $(PKG_BUILD_DIR)/luasrc/model/cbi/admin_services/* $(1)/usr/lib/lua/luci/model/cbi/admin_services 51 | 52 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_services 53 | $(CP) $(PKG_BUILD_DIR)/luasrc/view/admin_services/* $(1)/usr/lib/lua/luci/view/admin_services 54 | 55 | $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n 56 | $(PO2LMO) ./lang/phddns.zh-cn.po $(1)/usr/lib/lua/luci/i18n/phddns.zh-cn.lmo 57 | 58 | # $(INSTALL_DIR) $(1)/www/luci-static/resources 59 | # $(CP) ./luci-static/resources/* $(1)/www/luci-static/resources 60 | endef 61 | 62 | $(eval $(call BuildPackage,luci-app-phddns)) 63 | 64 | -------------------------------------------------------------------------------- /luci-app-phddns/lang/phddns.zh-cn.po: -------------------------------------------------------------------------------- 1 | msgid "Oray DDNS" 2 | msgstr "花生壳动态域名" 3 | 4 | msgid "Oray account" 5 | msgstr "花生壳账户配置" 6 | 7 | msgid "This page allows you to set Oray DDNS." 8 | msgstr "这个页面允许您设置花生壳动态域名配置信息." 9 | 10 | msgid "Subversion" 11 | msgstr "SVN版本仓库" 12 | 13 | msgid "Subversion Server" 14 | msgstr "SVN服务器" 15 | 16 | msgid "This page allows you to set Subversion Server." 17 | msgstr "这个页面允许您设置SVN服务器配置信息." 18 | 19 | msgid "Svn Root" 20 | msgstr "仓库根路径:" 21 | 22 | msgid "Listen Address" 23 | msgstr "监听地址:" 24 | 25 | msgid "Listen Port" 26 | msgstr "监听端口:" 27 | 28 | msgid "Cache Size" 29 | msgstr "缓存尺寸:" 30 | 31 | msgid "KMS Server" 32 | msgstr "KMS 服务器" 33 | 34 | msgid "okConnecting" 35 | msgstr "正在连接..." 36 | 37 | msgid "okConnected" 38 | msgstr "连接成功" 39 | 40 | msgid "okAuthpassed" 41 | msgstr "认证通过" 42 | 43 | msgid "okDomainListed" 44 | msgstr "域名列表已获取" 45 | 46 | msgid "okDomainsRegistered" 47 | msgstr "域名已经注册" 48 | 49 | msgid "okKeepAliveRecved" 50 | msgstr "保持连接" 51 | 52 | msgid "errorConnectFailed" 53 | msgstr "错误:连接失败" 54 | 55 | msgid "errorSocketInitialFailed" 56 | msgstr "错误:socket初始化失败" 57 | 58 | msgid "errorAuthFailed" 59 | msgstr "错误:认证失败" 60 | 61 | msgid "Running status" 62 | msgstr "运行状态" 63 | 64 | msgid "Link status" 65 | msgstr "连接状态" 66 | 67 | msgid "Registered Domains" 68 | msgstr "注册域名" 69 | 70 | -------------------------------------------------------------------------------- /luci-app-phddns/luasrc/Makefile: -------------------------------------------------------------------------------- 1 | LUAC = luac 2 | LUAC_OPTIONS = -s 3 | 4 | world: compile 5 | 6 | compile: 7 | for i in $$(find -name *.lua -not -name debug.lua); do $(LUAC) $(LUAC_OPTIONS) -o $$i $$i; done 8 | 9 | -------------------------------------------------------------------------------- /luci-app-phddns/luasrc/controller/phddns.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | LuCI - Lua Configuration Interface 3 | 4 | Copyright 2014 bywayboy 5 | 6 | ]]-- 7 | 8 | module("luci.controller.phddns", package.seeall) 9 | 10 | function index() 11 | 12 | local page 13 | 14 | if nixio.fs.access("/etc/config/phddns") then 15 | page = entry({"admin", "services", "phddns"}, cbi("admin_services/phddns"), _("Oray DDNS")) 16 | page.dependent = true 17 | entry({"admin", "services", "phddns_status"}, call("action_phddns_status")) 18 | end 19 | 20 | if nixio.fs.access("/etc/config/subversion") then 21 | page = entry({"admin", "services", "subversion"},cbi("admin_services/subversion"), _("Subversion")) 22 | page.dependent = true 23 | end 24 | 25 | 26 | if nixio.fs.access("/etc/config/vlmcsd") then 27 | page = entry({"admin", "services", "vlmcsd"},cbi("admin_services/vlmcsd"), _("KMS Server")) 28 | page.dependent = true 29 | end 30 | end 31 | 32 | 33 | function action_phddns_status() 34 | local file="/tmp/phddns.stat" 35 | local _ = luci.i18n.translate 36 | local stat="Not Running" 37 | local domain = "" 38 | 39 | function string_split(s, delimiter) 40 | result = {}; 41 | for match in (s..delimiter):gmatch("(.-)"..delimiter) do 42 | table.insert(result, match); 43 | end 44 | return result; 45 | end 46 | local m 47 | luci.http.prepare_content("application/json") 48 | if nixio.fs.access(file) then 49 | local str = nixio.fs.readfile(file) 50 | m = string_split(str,"|") 51 | if #m > 0 then stat= m[1] end 52 | if #m > 1 then domain= m[2] end 53 | end 54 | local arr = { ["stat"]=_(stat), ["domain"]=domain } 55 | luci.http.write_json(arr); 56 | end -------------------------------------------------------------------------------- /luci-app-phddns/luasrc/model/cbi/admin_services/phddns.lua: -------------------------------------------------------------------------------- 1 | local sys = require "luci.sys" 2 | local datatypes = require "luci." 3 | local uci = require "luci.model.uci" 4 | local cur = uci.cursor(); 5 | local http = require "luci.http"; 6 | local _ = luci.i18n.translate 7 | 8 | m = Map("phddns", _("Oray DDNS"), 9 | _("This page allows you to set Oray DDNS.")) 10 | 11 | m.on_after_commit = function(self) 12 | luci.sys.call("/etc/init.d/phddns restart >/dev/null") 13 | end 14 | 15 | s = m:section(TypedSection, "phddns", _("Oray account")) 16 | s.anonymous = true 17 | s.addremove = false 18 | 19 | o = s:option(Flag , "enabled", _("Enable")) 20 | 21 | o = s:option(Value, "username", _("Username")) 22 | o.datatype="string" 23 | o:depends("enabled", "1") 24 | 25 | o = s:option(Value, "password", _("Password")) 26 | o.datatype="string" 27 | o:depends("enabled", "1") 28 | 29 | o = s:option(Value, "stat", "") 30 | o.template="admin_services/phddns_stat" 31 | 32 | return m 33 | -------------------------------------------------------------------------------- /luci-app-phddns/luasrc/model/cbi/admin_services/subversion.lua: -------------------------------------------------------------------------------- 1 | local sys = require "luci.sys" 2 | local datatypes = require "luci." 3 | local uci = require "luci.model.uci" 4 | local cur = uci.cursor(); 5 | local http = require "luci.http"; 6 | local _ = luci.i18n.translate 7 | 8 | m = Map("subversion", "Subversion Server", 9 | _("This page allows you to set Subversion Server.")) 10 | 11 | m.on_after_commit = function(self) 12 | luci.sys.call("/etc/init.d/subversion restart >/dev/null") 13 | end 14 | 15 | s = m:section(TypedSection, "server") 16 | s.anonymous = true 17 | s.addremove = false 18 | 19 | 20 | o = s:option( Flag , "enabled", translate("Enable")) 21 | 22 | o = s:option(Value, "root", translate("Svn Root")) 23 | o.datatype="string" 24 | o:depends("enabled", "1") 25 | 26 | o = s:option(Value, "addr", translate("Listen Address")) 27 | o.datatype="ipaddr" 28 | o:depends("enabled", "1") 29 | 30 | o = s:option(Value, "port", translate("Listen Port")) 31 | o.datatype="port" 32 | o:depends("enabled", "1") 33 | 34 | o = s:option(ListValue, "memcache", translate("Cache Size")) 35 | o.datatype = "list(integer)" 36 | o.optional = true 37 | 38 | 39 | o:value(4,'4M') 40 | o:value(6,'6M') 41 | o:value(8,'8M') 42 | o:value(10,'10M') 43 | o:value(12,'12M') 44 | o:value(14,'14M') 45 | o:value(16,'16M') 46 | 47 | o:depends("enabled", "1") 48 | 49 | 50 | return m 51 | -------------------------------------------------------------------------------- /luci-app-phddns/luasrc/model/cbi/admin_services/vlmcsd.lua: -------------------------------------------------------------------------------- 1 | local sys = require "luci.sys" 2 | local datatypes = require "luci." 3 | local uci = require "luci.model.uci" 4 | local cur = uci.cursor(); 5 | local http = require "luci.http"; 6 | local _ = luci.i18n.translate 7 | 8 | m = Map("vlmcsd", _("KMS Server"), 9 | _("This page allows you set you owner KMS Server.")) 10 | 11 | m.on_after_commit = function(self) 12 | luci.sys.call("/etc/init.d/vlmcsd restart >/dev/null") 13 | end 14 | 15 | s = m:section(TypedSection, "vlmcsd", translate("KMS Server")) 16 | s.anonymous = true 17 | s.addremove = false 18 | 19 | o = s:option(Flag , "enabled", translate("Enable")) 20 | 21 | o = s:option(Value, "port", translate("Port")) 22 | o.datatype="port" 23 | o:depends("enabled", "1") 24 | 25 | return m 26 | -------------------------------------------------------------------------------- /luci-app-phddns/luasrc/view/admin_services/phddns_stat.htm: -------------------------------------------------------------------------------- 1 |
2 | <%:Running status%> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
<%:Link status%>:
<%:Registered Domains%>:
13 |
14 | -------------------------------------------------------------------------------- /luci/patches/001-change-default-conf.patch: -------------------------------------------------------------------------------- 1 | --- a/libs/web/root/etc/config/luci 2 | +++ b/libs/web/root/etc/config/luci 3 | @@ -1,7 +1,7 @@ 4 | config core main 5 | - option lang auto 6 | - option mediaurlbase /luci-static/openwrt.org 7 | - option resourcebase /luci-static/resources 8 | + option lang 'zh-cn' 9 | + option mediaurlbase '/luci-static/bootstrap' 10 | + option resourcebase '/luci-static/resources' 11 | 12 | config extern flash_keep 13 | option uci "/etc/config/" 14 | @@ -13,7 +13,8 @@ 15 | option uploads "/lib/uci/upload/" 16 | 17 | config internal languages 18 | - 19 | + option zh_cn 'chinese' 20 | + 21 | config internal sauth 22 | option sessionpath "/tmp/luci-sessions" 23 | option sessiontime 3600 24 | @@ -21,4 +22,6 @@ 25 | config internal ccache 26 | option enable 1 27 | 28 | -config internal themes 29 | +config internal 'themes' 30 | + option Bootstrap '/luci-static/bootstrap' 31 | + option OpenWrt '/luci-static/openwrt.org' 32 | 33 | -------------------------------------------------------------------------------- /luci/patches/201-pack-mtk-wifidev.patch: -------------------------------------------------------------------------------- 1 | diff -uNr a/libs/core/luasrc/model/network.lua ./b/libs/core/luasrc/model/network.lua 2 | --- a/libs/core/luasrc/model/network.lua 3 | +++ b/libs/core/luasrc/model/network.lua 4 | @@ -1336,19 +1336,20 @@ 5 | self.sid = net 6 | 7 | local num = { } 8 | - local netid 9 | + local netid,guess_dev 10 | _uci_real:foreach("wireless", "wifi-iface", 11 | function(s) 12 | if s.device then 13 | num[s.device] = num[s.device] and num[s.device] + 1 or 1 14 | if s['.name'] == self.sid then 15 | netid = "%s.network%d" %{ s.device, num[s.device] } 16 | + if s.mode == "sta" then guess_dev = "apcli0" end 17 | return false 18 | end 19 | end 20 | end) 21 | 22 | - local dev = _uci_state:get("wireless", self.sid, "ifname") or netid 23 | + local dev = _uci_state:get("wireless", self.sid, "ifname") or guess_dev or netid 24 | 25 | self.netid = netid 26 | self.wdev = dev 27 | diff -uNr a/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm ./b/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm 28 | --- a/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm 29 | +++ b/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm 30 | @@ -174,6 +174,12 @@ 31 | XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "wireless_status", table.concat(netlist, ","))%>', null, 32 | function(x, st) 33 | { 34 | + if(!st){ 35 | + try{ 36 | + st=eval('('+x.responseText+')'); 37 | + }catch(e){ 38 | + } 39 | + } 40 | if (st) 41 | { 42 | var assoctable = document.getElementById('iw-assoclist'); 43 | @@ -395,7 +401,7 @@ 44 | 45 | 46 | 47 | - '" title="<%:Delete this network%>" value="<%:Remove%>" /> 48 | + '" title="<%:Delete this network%>" value="<%:Remove%>" /> 49 | 50 | 51 | <% end %> -------------------------------------------------------------------------------- /mosquitto/100-disable-memory-reporting.patch: -------------------------------------------------------------------------------- 1 | diff -r 490c907277dc config.h 2 | --- a/config.h Sat Jan 15 22:23:50 2011 +0000 3 | +++ b/config.h Wed Jan 26 13:37:36 2011 +0000 4 | @@ -15,7 +15,7 @@ 5 | /* Compile with memory tracking support? If disabled, mosquitto won't track 6 | * heap memory usage nor export '$SYS/broker/heap/current size', but will use 7 | * slightly less memory and CPU time. */ 8 | -#define WITH_MEMORY_TRACKING 9 | +//#define WITH_MEMORY_TRACKING 10 | 11 | /* Compile with the ability to upgrade from old style sqlite persistent 12 | * databases to the new mosquitto format. This means a dependency on sqlite. It 13 | -------------------------------------------------------------------------------- /mosquitto/101-disable-docbook.patch: -------------------------------------------------------------------------------- 1 | diff -r bebd02e8bed4 -r 77b64fb10075 Makefile 2 | --- a/Makefile Thu Jul 07 13:34:54 2011 +0100 3 | +++ b/Makefile Thu Jul 07 16:50:05 2011 +0000 4 | @@ -1,6 +1,6 @@ 5 | include config.mk 6 | 7 | -DIRS=lib client src man 8 | +DIRS=lib client src 9 | DISTDIRS=man 10 | 11 | .PHONY : all mosquitto clean reallyclean install uninstall dist sign copy 12 | -------------------------------------------------------------------------------- /mosquitto/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011,2012 OpenWrt.org 3 | # Copyright (C) 2010 Jo-Philipp Wich 4 | # 5 | # This is free software, licensed under the GNU General Public License v2. 6 | # See /LICENSE for more information. 7 | # 8 | 9 | include $(TOPDIR)/rules.mk 10 | 11 | PKG_NAME:=mosquitto 12 | PKG_VERSION:=1.3.1 13 | PKG_RELEASE:=1 14 | 15 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 16 | PKG_SOURCE_URL:=http://mosquitto.org/files/source/ 17 | #PKG_MD5SUM:=7ae0ac38f1f379578ab5530e5dc7269e 18 | 19 | 20 | include $(INCLUDE_DIR)/package.mk 21 | 22 | define Package/mosquitto/default 23 | SECTION:=net 24 | CATEGORY:=Network 25 | TITLE:=mosquitto - an MQTT message broker 26 | URL:=http://www.mosquitto.org/ 27 | DEPENDS:= +libopenssl +libssl +libcrypto +librt 28 | endef 29 | 30 | define Package/mosquitto 31 | $(Package/mosquitto/default) 32 | endef 33 | 34 | define Package/mosquitto/description 35 | mosquitto is a message broker that supports v3.1 of the MQ Telemetry 36 | Transport protocol. MQTT provides a lightweight method for 37 | messaging using a publish/subscribe model. 38 | endef 39 | 40 | define Package/mosquitto-client 41 | $(Package/mosquitto/default) 42 | TITLE:= mosquitto - client tools 43 | DEPENDS:= +libmosquitto +libopenssl +libssl +libcrypto +librt 44 | endef 45 | 46 | define Package/mosquitto-client/description 47 | Command line client tools for publishing messages to MQTT servers 48 | and subscribing to topics. 49 | endef 50 | 51 | define Package/libmosquitto 52 | $(Package/mosquitto/default) 53 | SECTION:=libs 54 | CATEGORY:=Libraries 55 | TITLE:= mosquitto - client library 56 | endef 57 | 58 | define Package/libmosquitto/description 59 | Library required for mosquitto's command line client tools, also for 60 | use by any third party software that wants to communicate with a 61 | mosquitto server. 62 | 63 | Should be useable for communicating with any MQTT v3.1 compatible 64 | server, such as IBM's RSMB, in addition to Mosquitto 65 | endef 66 | 67 | define Build/Compile 68 | # $(MAKE) -C $(PKG_BUILD_DIR) \ 69 | # CC="$(TARGET_CC)" \ 70 | # CXX="$(TARGET_CXX)" \ 71 | # CFLAGS="$(TARGET_CFLAGS) -Wall" \ 72 | # LDFLAGS="$(TARGET_LDFLAGS)" 73 | $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS) 74 | endef 75 | 76 | define Package/mosquitto/conffiles 77 | /etc/mosquitto/mosquitto.conf 78 | endef 79 | 80 | define Package/mosquitto/install 81 | $(INSTALL_DIR) $(1)/usr/sbin 82 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mosquitto $(1)/usr/sbin/mosquitto 83 | $(INSTALL_DIR) $(1)/etc/mosquitto 84 | $(INSTALL_CONF) $(PKG_BUILD_DIR)/mosquitto.conf $(1)/etc/mosquitto/mosquitto.conf 85 | $(INSTALL_DIR) $(1)/etc/init.d 86 | $(INSTALL_BIN) ./files/mosquitto.init $(1)/etc/init.d/mosquitto 87 | endef 88 | 89 | define Package/mosquitto-client/install 90 | $(INSTALL_DIR) $(1)/usr/bin 91 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/client/mosquitto_pub $(1)/usr/bin/mosquitto_pub 92 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/client/mosquitto_sub $(1)/usr/bin/mosquitto_sub 93 | endef 94 | 95 | # This installs files into ./staging_dir/. so that you can cross compile from the host 96 | define Build/InstallDev 97 | $(INSTALL_DIR) $(1)/usr/include 98 | $(CP) $(PKG_BUILD_DIR)/lib/mosquitto.h $(1)/usr/include 99 | $(INSTALL_DIR) $(1)/usr/lib 100 | # This should just get symlinked, but I can't work out the magic syntax :( 101 | $(CP) $(PKG_BUILD_DIR)/lib/libmosquitto.so.* $(1)/usr/lib/libmosquitto.so 102 | endef 103 | 104 | # This installs files on the target. Compare with Build/InstallDev 105 | define Package/libmosquitto/install 106 | $(INSTALL_DIR) $(1)/usr/lib 107 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/libmosquitto.so.* $(1)/usr/lib/ 108 | endef 109 | $(eval $(call BuildPackage,mosquitto)) 110 | $(eval $(call BuildPackage,libmosquitto)) 111 | $(eval $(call BuildPackage,mosquitto-client)) 112 | -------------------------------------------------------------------------------- /mosquitto/README.md: -------------------------------------------------------------------------------- 1 | mosquitto 介绍 2 | ====== 3 | 4 | mosquitto 一款实现了消息推送协议 MQTT v3.1 的开源消息代理软件,提供轻量级的, 5 | 支持可发布/可订阅的的消息推送模式,使设备对设备之间的短消息通信变得简单, 6 | 比如现在应用广泛的低功耗传感器,手机、嵌入式计算机、微型控制器等移动设备。 7 | 一个典型的应用案例就是 Andy Stanford-ClarkMosquitto(MQTT协议创始人之一) 8 | 在家中实现的远程监控和自动化。并在 OggCamp 的演讲上,对MQTT协议进行详细阐述。 9 | 10 | 更新到最新版本 1.3.1 兼容OpenWRT. 11 | -------------------------------------------------------------------------------- /mosquitto/files/mosquitto.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Basic init script for mosquitto 3 | # April 2012, OpenWrt.org 4 | # Provides support for the luci-app-mosquitto package, if installed 5 | 6 | START=80 7 | APP=`which mosquitto` 8 | USE_UCI_CONFIG=$(uci -q get mosquitto.owrt.use_uci) 9 | if [ $? -eq 1 ]; then 10 | USE_UCI_CONFIG=0 11 | fi 12 | 13 | SERVICE_DAEMONIZE=1 14 | SERVICE_WRITE_PID=1 15 | 16 | start() { 17 | user_exists mosquitto 200 || user_add mosquitto 200 18 | if [ "$USE_UCI_CONFIG" -eq 1 ]; then 19 | CONF=/tmp/mosquitto.converted.$$.conf 20 | mosquitto.uci.convert -f $CONF 21 | else 22 | CONF=/etc/mosquitto/mosquitto.conf 23 | fi 24 | service_start $APP -c $CONF 25 | } 26 | 27 | stop() { 28 | service_stop $APP 29 | } 30 | -------------------------------------------------------------------------------- /mosquitto/patches/102-disable-srv.patch: -------------------------------------------------------------------------------- 1 | diff -r bebd02e8bed4 -r 77b64fb10075 Makefile 2 | --- a/config.mk Thu Jul 07 13:34:54 2011 +0100 3 | +++ b/config.mk Thu Jul 07 16:50:05 2011 +0000 4 | @@ -54,2 +54,2 @@ 5 | # size', but will use slightly less memory and CPU time. 6 | -WITH_MEMORY_TRACKING:=yes 7 | +WITH_MEMORY_TRACKING:=no 8 | 9 | --- a/config.mk Thu Jul 07 13:34:54 2011 +0100 10 | +++ b/config.mk Thu Jul 07 16:50:05 2011 +0000 11 | @@ -70,2 +70,2 @@ 12 | # Build with SRV lookup support. 13 | -WITH_SRV:=yes 14 | +WITH_SRV:=no 15 | 16 | -------------------------------------------------------------------------------- /neon/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2007-2011 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=neon 11 | PKG_VERSION:=0.30.0 12 | PKG_RELEASE:=2 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_SOURCE_URL:=http://www.webdav.org/neon 16 | PKG_MD5SUM:=fb60b3a124eeec441937a812c456fd94 17 | 18 | PKG_FIXUP:=autoreconf 19 | PKG_INSTALL:=1 20 | 21 | include $(INCLUDE_DIR)/package.mk 22 | 23 | define Package/libneon 24 | SECTION:=libs 25 | CATEGORY:=Libraries 26 | TITLE:=HTTP and WebDAV client library 27 | URL:=http://www.webdav.org/neon/ 28 | DEPENDS:=+libopenssl +libexpat 29 | endef 30 | 31 | TARGET_CFLAGS += $(FPIC) 32 | TARGET_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 33 | 34 | CONFIGURE_ARGS += \ 35 | --enable-shared \ 36 | --enable-static \ 37 | --with-expat \ 38 | --with-ssl="openssl" \ 39 | --without-egd \ 40 | --without-libproxy \ 41 | 42 | CONFIGURE_VARS += \ 43 | LDFLAGS="$$$$LDFLAGS -lcrypto -lssl" 44 | 45 | define Build/InstallDev 46 | $(INSTALL_DIR) $(1)/usr/bin 47 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/neon-config $(1)/usr/bin/ 48 | $(INSTALL_DIR) $(1)/usr/include 49 | $(CP) $(PKG_INSTALL_DIR)/usr/include/neon $(1)/usr/include/ 50 | $(INSTALL_DIR) $(1)/usr/lib 51 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libneon.{a,so*} $(1)/usr/lib/ 52 | $(INSTALL_DIR) $(1)/usr/lib/pkgconfig 53 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/neon.pc $(1)/usr/lib/pkgconfig/ 54 | $(SED) 's,-I$$$${includedir}/,-I$(STAGING_DIR)/usr/include/,g' $(1)/usr/bin/neon-config 55 | $(SED) 's,-L$$$${libdir},,g' $(1)/usr/bin/neon-config 56 | endef 57 | 58 | define Package/libneon/install 59 | $(INSTALL_DIR) $(1)/usr/lib 60 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libneon.so.* $(1)/usr/lib/ 61 | endef 62 | 63 | $(eval $(call BuildPackage,libneon)) 64 | -------------------------------------------------------------------------------- /neon/patches/001-automake-compat.patch: -------------------------------------------------------------------------------- 1 | --- /dev/null 2 | +++ b/Makefile.am 3 | @@ -0,0 +1,2 @@ 4 | +SUBDIRS = . 5 | +ACLOCAL_AMFLAGS = -I macros 6 | -------------------------------------------------------------------------------- /phddns/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=phddns 4 | PKG_VERSION:=2.0.6 5 | PKG_RELEASE:=32828 6 | 7 | 8 | PKG_SOURCE:=$(PKG_NAME)-sdk-$(PKG_VERSION).$(PKG_RELEASE).tar.gz 9 | PKG_SOURCE_URL:=http://download.oray.com/peanuthull/ 10 | #http://download.oray.com/peanuthull/phddns-sdk-2.0.6.32828.tar.gz 11 | 12 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION).$(PKG_RELEASE) 13 | PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install 14 | 15 | include $(INCLUDE_DIR)/package.mk 16 | 17 | 18 | define Package/phddns 19 | SECTION:=net 20 | CATEGORY:=Network 21 | TITLE:=Oray PHDDNS client for OpenWRT 22 | URL:=http://www.oray.com/ 23 | endef 24 | 25 | define Package/phddns/Description 26 | Oray PHDDNS Client. Author:bywayboy@qq.com 27 | endef 28 | 29 | 30 | #[安装(编译)时执行的脚本 记得加上#!/bin/sh 没有就空着] 31 | define Package/$(PKG_NAME)/install 32 | $(INSTALL_DIR) $(1)/usr/sbin 33 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/phddns $(1)/usr/sbin/phddns 34 | 35 | $(INSTALL_DIR) $(1)/etc/init.d 36 | $(INSTALL_DIR) $(1)/etc/rc.d 37 | $(INSTALL_BIN) ./files/etc/init.d/phddns $(1)/etc/init.d/phddns 38 | ln -s ../init.d/phddns $(1)/etc/rc.d/S92phddns 39 | 40 | $(INSTALL_DIR) $(1)/etc/config 41 | $(INSTALL_BIN) ./files/etc/config/phddns $(1)/etc/config/phddns 42 | 43 | endef 44 | 45 | 46 | #[删除后执行的脚本 记得加上#!/bin/sh 没有就空着] 47 | define Package/$(PKG_NAME)/postrm 48 | #!/bin/sh 49 | rm -rf /usr/sbin/phddns /etc/init.d/phddns /etc/rc.d/S92phddns 50 | 51 | 52 | endef 53 | 54 | $(eval $(call BuildPackage,phddns)) 55 | -------------------------------------------------------------------------------- /phddns/files/etc/config/phddns: -------------------------------------------------------------------------------- 1 | config phddns 2 | option enabled '1' 3 | option username 'gqlhome' 4 | option password 'z2x5y8' 5 | 6 | -------------------------------------------------------------------------------- /phddns/files/etc/init.d/phddns: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=92 4 | BIN_FILE=/usr/sbin/phddns 5 | PID_FILE=/var/run/phddns.pid 6 | CFG_FILE=/var/phddns.cfg 7 | 8 | . /lib/functions.sh 9 | 10 | local username 11 | local password 12 | local enabled 13 | local ifname=`cat /var/state/network | awk ' BEGIN{FS="="} $1=="network.lan.ifname" {print $2}'` 14 | 15 | config_load "phddns" 16 | 17 | parse_account() 18 | { 19 | config_get username "$section" "username" 20 | config_get password "$section" "password" 21 | config_get enabled "$section" "enabled" 22 | } 23 | 24 | config_foreach parse_account 'phddns' 25 | 26 | start() 27 | { 28 | if [ "1" = "$enabled" ] || [ "on" = "$enabled" ] || [ "true" = "$enabled" ]; then 29 | cat > $CFG_FILE </dev/null 46 | else 47 | echo "svnserv is disabled!" 48 | fi 49 | } 50 | 51 | stop() 52 | { 53 | if [ -f "$PID_FILE" ]; then 54 | local pid=`cat $PID_FILE` 55 | kill $pid 56 | rm -f "$PID_FILE" 57 | fi 58 | } 59 | 60 | boot () 61 | { 62 | start "$@" 63 | } 64 | 65 | shutdown() 66 | { 67 | stop 68 | } 69 | 70 | -------------------------------------------------------------------------------- /subversion/patches/002_change_configure.patch: -------------------------------------------------------------------------------- 1 | --- a/configure 2 | +++ b/configure 3 | @@ -3097,10 +3097,8 @@ 4 | $as_echo "$as_me: failed program was:" >&5 5 | sed 's/^/| /' conftest.$ac_ext >&5 6 | 7 | -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 8 | -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} 9 | -as_fn_error 77 "C compiler cannot create executables 10 | -See \`config.log' for more details" "$LINENO" 5; } 11 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 12 | +$as_echo "yes" >&6; } 13 | else 14 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 15 | $as_echo "yes" >&6; } 16 | -------------------------------------------------------------------------------- /tengine/Config.in: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010-2012 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | menu "Configuration" 9 | depends on PACKAGE_tengine 10 | 11 | config TENGINE_STUB_STATUS 12 | bool 13 | prompt "Enable stub status module" 14 | default n 15 | help 16 | Enable the stub status module which gives some status from the server. 17 | 18 | config TENGINE_FLV 19 | bool 20 | prompt "Enable FLV module" 21 | default n 22 | help 23 | Provides the ability to seek within FLV (Flash) files using time-based offsets. 24 | 25 | config TENGINE_SSL 26 | bool 27 | prompt "Enable SSL module" 28 | default n 29 | help 30 | Enable HTTPS/SSL support. 31 | 32 | config TENGINE_DAV 33 | bool 34 | prompt "Enable WebDAV module" 35 | default n 36 | help 37 | Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE. 38 | 39 | config TENGINE_SUB_MODULE 40 | bool 41 | prompt "Enable sub filter" 42 | default n 43 | help 44 | Enable the HTTP response content replace module( sub filter module). 45 | 46 | config TENGINE_HTTP_PROXY 47 | bool 48 | prompt "Enable proxy module" 49 | default n 50 | help 51 | Enable the Tengine proxy module.( proxy module). 52 | 53 | endmenu 54 | -------------------------------------------------------------------------------- /tengine/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include $(TOPDIR)/rules.mk 3 | 4 | PKG_NAME:=tengine 5 | PKG_VERSION:=1.5.2 6 | PKG_RELEASE:=1 7 | 8 | PKG_SOURCE:=tengine-$(PKG_VERSION).tar.gz 9 | PKG_SOURCE_URL:=http://tengine.taobao.org/download/ 10 | PKG_MD5SUM:=800d7c8e9d197d77495219a542464776 11 | 12 | PKG_BUILD_PARALLEL:=1 13 | PKG_INSTALL:=1 14 | 15 | include $(INCLUDE_DIR)/package.mk 16 | 17 | define Package/$(PKG_NAME) 18 | SECTION:=net 19 | CATEGORY:=Network 20 | SUBMENU:=Web Servers/Proxies 21 | TITLE:=Tengine web server 22 | URL:=http://tengine.taobao.org/ 23 | DEPENDS:=+libpcre +zlib +libpthread 24 | MENU:=1 25 | endef 26 | 27 | define Package/$(PKG_NAME)/description 28 | tengine is an HTTP and reverse proxy server, as well as a mail proxy server, 29 | written by Igor Sysoev. 30 | endef 31 | 32 | define Package/$(PKG_NAME)/config 33 | source "$(SOURCE)/Config.in" 34 | endef 35 | 36 | PKG_CONFIG_DEPENDS := \ 37 | CONFIG_TENGINE_STUB_STATUS \ 38 | CONFIG_TENGINE_FLV 39 | 40 | define Package/nginx/conffiles 41 | /etc/nginx/ 42 | endef 43 | 44 | 45 | ADDITIONAL_MODULES:= 46 | 47 | ifeq ($(CONFIG_IPV6),y) 48 | ADDITIONAL_MODULES += --with-ipv6 49 | endif 50 | ifeq ($(CONFIG_TENGINE_STUB_STATUS),y) 51 | ADDITIONAL_MODULES += --with-http_stub_status_module 52 | endif 53 | ifeq ($(CONFIG_TENGINE_FLV),y) 54 | ADDITIONAL_MODULES += --with-http_flv_module=shared 55 | endif 56 | ifeq ($(CONFIG_TENGINE_SSL),y) 57 | ADDITIONAL_MODULES += --with-http_ssl_module 58 | else 59 | ADDITIONAL_MODULES += --without-http-cache --without-http_ssl_module 60 | endif 61 | ifeq ($(CONFIG_TENGINE_DAV),y) 62 | ADDITIONAL_MODULES += --with-http_dav_module=shared 63 | endif 64 | 65 | ifeq ($(CONFIG_TENGINE_SUB_MODULE),y) 66 | ADDITIONAL_MODULES += --with-http_sub_module 67 | endif 68 | 69 | ifneq ($(CONFIG_TENGINE_HTTP_PROXY),y) 70 | ADDITIONAL_MODULES += --without-http_proxy_module 71 | endif 72 | 73 | define Build/Configure 74 | # TODO: fix --crossbuild 75 | $(TARGET_CC) --help 76 | 77 | (cd $(PKG_BUILD_DIR) ;\ 78 | ./configure \ 79 | --crossbuild=Linux::$(ARCH) \ 80 | --prefix=/usr \ 81 | --conf-path=/etc/nginx/nginx.conf \ 82 | --error-log-path=/var/log/nginx/error.log \ 83 | --pid-path=/var/run/nginx.pid \ 84 | --lock-path=/var/lock/nginx.lock \ 85 | --http-log-path=/var/log/nginx/access.log \ 86 | --http-client-body-temp-path=/var/lib/nginx/body \ 87 | --http-proxy-temp-path=/var/lib/nginx/proxy \ 88 | --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ 89 | --with-cc="$(TARGET_CC)" \ 90 | --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ 91 | --with-ld-opt="$(TARGET_LDFLAGS)" \ 92 | --without-http_ssi_module \ 93 | --without-http_geo_module \ 94 | --without-http_upstream_check_module\ 95 | --without-http_upstream_least_conn_module \ 96 | --without-http_upstream_session_sticky_module \ 97 | --without-http_upstream_keepalive_module \ 98 | --without-http_upstream_ip_hash_module \ 99 | --without-http_upstream_consistent_hash_module \ 100 | --without-http_stub_status_module \ 101 | --without-syslog \ 102 | --without-dso \ 103 | --without-select_module \ 104 | --with-poll_module \ 105 | --without-http_empty_gif_module \ 106 | --without-http_memcached_module \ 107 | $(ADDITIONAL_MODULES) ) 108 | endef 109 | 110 | define Package/$(PKG_NAME)/install 111 | $(INSTALL_DIR) $(1)/usr/sbin 112 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/ 113 | 114 | $(INSTALL_DIR) $(1)/etc/nginx 115 | $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/nginx/* $(1)/etc/nginx/ 116 | 117 | $(INSTALL_DIR) $(1)/etc/init.d 118 | $(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx 119 | 120 | $(INSTALL_DIR) $(1)/etc/rc.d 121 | ln -s ../init.d/nginx $(1)/etc/rc.d/S50nginx 122 | endef 123 | 124 | $(eval $(call BuildPackage,$(PKG_NAME))) 125 | -------------------------------------------------------------------------------- /tengine/files/nginx.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2009-2012 OpenWrt.org 3 | 4 | START=50 5 | NGINX_BIN=/usr/sbin/nginx 6 | 7 | start() { 8 | mkdir -p /var/log/nginx 9 | mkdir -p /var/lib/nginx 10 | $NGINX_BIN 11 | } 12 | 13 | stop() { 14 | $NGINX_BIN -s stop 15 | } 16 | 17 | reload() { 18 | $NGINX_BIN -s reload 19 | } 20 | 21 | shutdown() { 22 | $NGINX_BIN -s quit 23 | } 24 | 25 | -------------------------------------------------------------------------------- /tengine/patches/001-fix-cross-compiler.patch: -------------------------------------------------------------------------------- 1 | diff -uNr a/auto/cc/name b/auto/cc/name 2 | --- a/auto/cc/name 2013-11-22 15:47:33.000000000 +0800 3 | +++ b/auto/cc/name 2014-11-11 16:59:06.469301606 +0800 4 | @@ -18,7 +18,7 @@ 5 | echo 6 | echo $0: error: C compiler $CC is not found 7 | echo 8 | - exit 1 9 | +# exit 1 10 | fi 11 | 12 | fi 13 | diff -uNr a/auto/types/sizeof b/auto/types/sizeof 14 | --- a/auto/types/sizeof 2013-11-22 15:47:33.000000000 +0800 15 | +++ b/auto/types/sizeof 2014-11-11 16:56:31.853302647 +0800 16 | @@ -25,8 +25,13 @@ 17 | $NGX_INCLUDE_INTTYPES_H 18 | $NGX_INCLUDE_AUTO_CONFIG_H 19 | 20 | +char object_code_block[] = { 21 | + '\n', 'e', '4', 'V', 'A', 22 | + '0', 'x', ('0' + sizeof($ngx_type)), 23 | + 'Y', '3', 'p', 'M', '\n' 24 | +}; 25 | + 26 | int main() { 27 | - printf("%d", (int) sizeof($ngx_type)); 28 | return 0; 29 | } 30 | 31 | @@ -40,7 +45,7 @@ 32 | 33 | 34 | if [ -x $NGX_AUTOTEST ]; then 35 | - ngx_size=`$NGX_AUTOTEST` 36 | + ngx_size=`sed -ne 's/^e4VA0x\(.\)Y3pM$/\1/p' < $NGX_AUTOTEST` 37 | echo " $ngx_size bytes" 38 | fi 39 | 40 | diff -uNr a/auto/unix b/auto/unix 41 | --- a/auto/unix 2013-11-22 15:47:33.000000000 +0800 42 | +++ b/auto/unix 2014-11-11 17:20:43.021292864 +0800 43 | @@ -715,7 +715,7 @@ 44 | 45 | ngx_feature="System V shared memory" 46 | ngx_feature_name="NGX_HAVE_SYSVSHM" 47 | -ngx_feature_run=yes 48 | +ngx_feature_run=no 49 | ngx_feature_incs="#include 50 | #include " 51 | ngx_feature_path= 52 | -------------------------------------------------------------------------------- /tengine/patches/103-sys_nerr.patch: -------------------------------------------------------------------------------- 1 | --- a/src/os/unix/ngx_errno.c 2 | +++ b/src/os/unix/ngx_errno.c 3 | @@ -8,6 +8,9 @@ 4 | #include 5 | #include 6 | 7 | +#ifndef NGX_SYS_NERR 8 | +#define NGX_SYS_NERR 128 9 | +#endif 10 | 11 | /* 12 | * The strerror() messages are copied because: 13 | -------------------------------------------------------------------------------- /vlmcsd/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=vlmcsd 4 | PKG_VERSION:=svn796 5 | PKG_REV:=1 6 | 7 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 8 | PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install 9 | 10 | PKG_BUILD_DEPENDS:= +libpthread 11 | 12 | include $(INCLUDE_DIR)/package.mk 13 | include $(INCLUDE_DIR)/cmake.mk 14 | 15 | define Package/vlmcsd 16 | SECTION:=net 17 | CATEGORY:=Network 18 | SUBMENU:=Other Servers 19 | TITLE:=KMS server on OpenWRT 20 | URL:=https://github.com/bywayboy/openwrt-packages 21 | DEPENDS:= +libpthread 22 | endef 23 | 24 | define Package/vlmcsd/description 25 | A KMS server for openwrt svn498 26 | endef 27 | 28 | #编译准备工作,复制源码到目标目录 29 | define Build/Prepare 30 | mkdir -p $(PKG_BUILD_DIR) 31 | $(CP) -R ./src/* $(PKG_BUILD_DIR)/ 32 | endef 33 | 34 | #[安装(编译)时执行的脚本 记得加上#!/bin/sh 没有就空着] 35 | define Package/vlmcsd/install 36 | $(INSTALL_DIR) $(1)/usr/sbin 37 | $(CP) $(PKG_INSTALL_DIR)/usr/sbin/vlmcsd $(1)/usr/sbin/ 38 | $(INSTALL_DIR) $(1)/etc 39 | $(INSTALL_DIR) $(1)/etc/config 40 | $(CP) ./files/etc/vlmcsd.ini $(1)/etc/vlmcsd.ini 41 | $(CP) ./files/etc/config/vlmcsd $(1)/etc/config/vlmcsd 42 | 43 | $(INSTALL_DIR) $(1)/etc/init.d 44 | $(INSTALL_BIN) ./files/etc/init.d/vlmcsd $(1)/etc/init.d/vlmcsd 45 | 46 | $(INSTALL_DIR) $(1)/etc/rc.d 47 | ln -s ../init.d/vlmcsd $(1)/etc/rc.d/S93vlmcsd 48 | endef 49 | 50 | $(eval $(call BuildPackage,vlmcsd)) 51 | -------------------------------------------------------------------------------- /vlmcsd/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bywayboy/openwrt-packages/b2914ab9e4695d62f756bac5d84733b086bbe2d3/vlmcsd/README.md -------------------------------------------------------------------------------- /vlmcsd/files/etc/config/vlmcsd: -------------------------------------------------------------------------------- 1 | config vlmcsd 2 | option port '1688' 3 | option enabled '1' 4 | option useepifile '0' -------------------------------------------------------------------------------- /vlmcsd/files/etc/init.d/vlmcsd: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2014-2999 extgui.com 3 | # Author bywayboy 4 | # Last Update: 2014-09-23 5 | 6 | . /lib/functions.sh 7 | 8 | START=93 9 | 10 | EXECUTEBIN="/usr/sbin/vlmcsd" 11 | PIDFILE="/var/run/vlmcsd.pid" 12 | INIFILE="/etc/vlmcsd.ini" 13 | CONFIGFILE="" 14 | LISTENPORT=1688 15 | ENABLED='1' 16 | USEEPIDFILE='0' 17 | 18 | config_load "vlmcsd" 19 | 20 | parse_vlmcsd() 21 | { 22 | config_get LISTENPORT "$section" "port" 23 | config_get ENABLED "$section" "enabled" 24 | config_get USEEPIDFILE "$section" "useepifile" 25 | } 26 | config_foreach parse_vlmcsd 'vlmcsd' 27 | 28 | start () 29 | { 30 | if [ "1" = "$ENABLED" ] || [ "on" = "$ENABLED" ] || [ "true" = "$ENABLED" ]; then 31 | if [ ! -f $PIDFILE ]; then 32 | if [ "1" = "$USEEPIDFILE" ] || [ "on" = "$USEEPIDFILE" ] || [ "true" = "$USEEPIDFILE" ]; then 33 | $EXECUTEBIN -d -i $INIFILE -p $PIDFILE -P $LISTENPORT -l syslog 34 | else 35 | $EXECUTEBIN -d -p $PIDFILE -P $LISTENPORT -l syslog 36 | fi 37 | else 38 | PID=`cat $PIDFILE` 39 | kill -s 0 $PID 40 | RESULT=$? 41 | if [ -f $PIDFILE ] && [ $RESULT -eq 0 ]; then 42 | echo "KMS Server is already running" 43 | exit 2 44 | else 45 | echo "Please check pid file or use forcestart to overwrite pid" 46 | fi 47 | fi 48 | else 49 | echo "vlmcsd is disabled!" 50 | fi 51 | } 52 | 53 | stop () 54 | { 55 | if [ -f $PIDFILE ]; then 56 | PID=`cat $PIDFILE` 57 | kill $PID 58 | echo "KMS Has been stopped" 59 | else 60 | echo "KMS is not running" 61 | fi 62 | } 63 | 64 | restart () 65 | { 66 | stop 67 | sleep 1s; 68 | start 69 | 70 | } 71 | -------------------------------------------------------------------------------- /vlmcsd/files/etc/vlmcsd.ini: -------------------------------------------------------------------------------- 1 | 55c92734-d682-4d71-983e-d6ec3f16059f = 55041-00168-314-567419-03-1033-3790.0000-0142013 2 | 59a52881-a989-479d-af46-f275c6370663 = 55041-00096-216-598637-03-17418-6002.0000-3312013 3 | 0ff1ce15-a989-479d-af46-f275c6370663 = 55041-00206-234-742099-03-9217-6002.0000-2942013 4 | -------------------------------------------------------------------------------- /vlmcsd/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | PROJECT(vlmcsd) 4 | 5 | SET(CMAKE_SYSTEM_NAME Linux) 6 | #SET(CMAKE_C_COMPILER "mipsel-openwrt-linux-gcc") 7 | #SET(CMAKE_CXX_COMPILER "mipsel-openwrt-linux-g++") 8 | 9 | SET(CMAKE_C_FLAGS "-Os -std=gnu99 -pthread -fpic ") 10 | SET(CMAKE_CXX_FLAGS "-Os -std=gnu++0x -pthread -fpic") 11 | 12 | ADD_DEFINITIONS("-DBUILD_TIME") 13 | SET(SOURCES 14 | vlmcsd.c 15 | kms.c 16 | crypto.c 17 | rpc.c 18 | network.c 19 | output.c 20 | crypto_internal.c 21 | shared_globals.c 22 | helpers.c 23 | dns_srv.c 24 | ns_name.c 25 | ns_parser.c 26 | ) 27 | 28 | ADD_EXECUTABLE(vlmcsd ${SOURCES}) 29 | TARGET_LINK_LIBRARIES(vlmcsd pthread dl) 30 | 31 | 32 | 33 | INSTALL(TARGETS vlmcsd 34 | RUNTIME DESTINATION /usr/sbin 35 | ) 36 | -------------------------------------------------------------------------------- /vlmcsd/src/crypto.h: -------------------------------------------------------------------------------- 1 | #ifndef __crypto_h 2 | #define __crypto_h 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include "types.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "endian.h" 15 | #include 16 | 17 | //#define AES_ROUNDS (10) 18 | #define AES_KEY_BYTES (16) // 128 Bits 19 | #define AES_BLOCK_BYTES (16) 20 | #define AES_BLOCK_WORDS (AES_BLOCK_BYTES / sizeof(DWORD)) 21 | #define AES_KEY_DWORDS (AES_KEY_BYTES / sizeof(DWORD)) 22 | //#define V4_ROUNDS (11) 23 | #define V4_KEY_BYTES (20) // 160 Bits 24 | 25 | #define ROR32(v, n) ( (v) << (32 - n) | (v) >> n ) 26 | 27 | void XorBlock(const BYTE *const in, const BYTE *out); 28 | 29 | void AesCmacV4(BYTE *data, size_t len, BYTE *hash); 30 | 31 | extern const BYTE AesKeyV5[]; 32 | extern const BYTE AesKeyV6[]; 33 | 34 | typedef struct { 35 | DWORD Key[48]; // Supports a maximum of 160 key bits! 36 | uint_fast8_t rounds; 37 | } AesCtx; 38 | 39 | void AesInitKey(AesCtx *Ctx, const BYTE *Key, int_fast8_t IsV6, int AesKeyBytes); 40 | void AesEncryptBlock(const AesCtx *const Ctx, BYTE *block); 41 | void AesDecryptBlock(const AesCtx *const Ctx, BYTE *block); 42 | void AesEncryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t *len); 43 | void AesDecryptCbc(const AesCtx *const Ctx, BYTE *iv, BYTE *data, size_t len); 44 | void MixColumnsR(BYTE *restrict state); 45 | 46 | #if defined(_CRYPTO_OPENSSL) 47 | #include "crypto_openssl.h" 48 | 49 | #elif defined(_CRYPTO_POLARSSL) 50 | #include "crypto_polarssl.h" 51 | 52 | #elif defined(_CRYPTO_WINDOWS) 53 | #include "crypto_windows.h" 54 | 55 | #else 56 | #include "crypto_internal.h" 57 | 58 | #endif 59 | #endif // __crypto_h 60 | -------------------------------------------------------------------------------- /vlmcsd/src/crypto_internal.c: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG 2 | #define CONFIG "config.h" 3 | #endif // CONFIG 4 | #include CONFIG 5 | 6 | #if !defined(_CRYPTO_OPENSSL) && !defined(_CRYPTO_POLARSSL) && !defined(_CRYPTO_WINDOWS) 7 | #include "crypto_internal.h" 8 | #include "endian.h" 9 | 10 | #define F0(x, y, z) ( ((x) & (y)) | (~(x) & (z)) ) 11 | #define F1(x, y, z) ( ((x) & (y)) | ((x) & (z)) | ((y) & (z)) ) 12 | 13 | #define SI1(x) ( ROR32(x, 2 ) ^ ROR32(x, 13) ^ ROR32(x, 22) ) 14 | #define SI2(x) ( ROR32(x, 6 ) ^ ROR32(x, 11) ^ ROR32(x, 25) ) 15 | #define SI3(x) ( ROR32(x, 7 ) ^ ROR32(x, 18) ^ ((x) >> 3 ) ) 16 | #define SI4(x) ( ROR32(x, 17) ^ ROR32(x, 19) ^ ((x) >> 10) ) 17 | 18 | static const DWORD k[] = { 19 | 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 20 | 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 21 | 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 22 | 0x0FC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 23 | 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 24 | 0x06CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 25 | 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 26 | 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 27 | 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 28 | 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 29 | 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 30 | }; 31 | 32 | 33 | static void Sha256Init(Sha256Ctx *Ctx) 34 | { 35 | Ctx->State[0] = 0x6A09E667; 36 | Ctx->State[1] = 0xBB67AE85; 37 | Ctx->State[2] = 0x3C6EF372; 38 | Ctx->State[3] = 0xA54FF53A; 39 | Ctx->State[4] = 0x510E527F; 40 | Ctx->State[5] = 0x9B05688C; 41 | Ctx->State[6] = 0x1F83D9AB; 42 | Ctx->State[7] = 0x5BE0CD19; 43 | Ctx->Len = 0; 44 | } 45 | 46 | 47 | static void Sha256ProcessBlock(Sha256Ctx *Ctx, BYTE *block) 48 | { 49 | unsigned int i; 50 | DWORD w[64], temp1, temp2; 51 | DWORD a = Ctx->State[0]; 52 | DWORD b = Ctx->State[1]; 53 | DWORD c = Ctx->State[2]; 54 | DWORD d = Ctx->State[3]; 55 | DWORD e = Ctx->State[4]; 56 | DWORD f = Ctx->State[5]; 57 | DWORD g = Ctx->State[6]; 58 | DWORD h = Ctx->State[7]; 59 | 60 | for (i = 0; i < 16; i++) 61 | //w[ i ] = GET_UAA32BE(block, i); 62 | w[i] = BE32(((DWORD*)block)[i]); 63 | 64 | for (i = 16; i < 64; i++) 65 | w[ i ] = SI4(w[ i - 2 ]) + w[ i - 7 ] + SI3(w[ i - 15 ]) + w[ i - 16 ]; 66 | 67 | for (i = 0; i < 64; i++) 68 | { 69 | temp1 = h + SI2(e) + F0(e, f, g) + k[ i ] + w[ i ]; 70 | temp2 = SI1(a) + F1(a, b, c); 71 | 72 | h = g; 73 | g = f; 74 | f = e; 75 | e = d + temp1; 76 | d = c; 77 | c = b; 78 | b = a; 79 | a = temp1 + temp2; 80 | } 81 | 82 | Ctx->State[0] += a; 83 | Ctx->State[1] += b; 84 | Ctx->State[2] += c; 85 | Ctx->State[3] += d; 86 | Ctx->State[4] += e; 87 | Ctx->State[5] += f; 88 | Ctx->State[6] += g; 89 | Ctx->State[7] += h; 90 | } 91 | 92 | 93 | static void Sha256Update(Sha256Ctx *Ctx, BYTE *data, size_t len) 94 | { 95 | unsigned int b_len = Ctx->Len & 63, 96 | r_len = (b_len ^ 63) + 1; 97 | 98 | Ctx->Len += len; 99 | 100 | if ( len < r_len ) 101 | { 102 | memcpy(Ctx->Buffer + b_len, data, len); 103 | return; 104 | } 105 | 106 | if ( r_len < 64 ) 107 | { 108 | memcpy(Ctx->Buffer + b_len, data, r_len); 109 | len -= r_len; 110 | data += r_len; 111 | Sha256ProcessBlock(Ctx, Ctx->Buffer); 112 | } 113 | 114 | for (; len >= 64; len -= 64, data += 64) 115 | Sha256ProcessBlock(Ctx, data); 116 | 117 | if ( len ) memcpy(Ctx->Buffer, data, len); 118 | } 119 | 120 | 121 | static void Sha256Finish(Sha256Ctx *Ctx, BYTE *hash) 122 | { 123 | unsigned int i, b_len = Ctx->Len & 63; 124 | 125 | Ctx->Buffer[ b_len ] = 0x80; 126 | if ( b_len ^ 63 ) memset(Ctx->Buffer + b_len + 1, 0, b_len ^ 63); 127 | 128 | if ( b_len >= 56 ) 129 | { 130 | Sha256ProcessBlock(Ctx, Ctx->Buffer); 131 | memset(Ctx->Buffer, 0, 56); 132 | } 133 | 134 | //PUT_UAA64BE(Ctx->Buffer, (unsigned long long)(Ctx->Len * 8), 7); 135 | ((uint64_t*)Ctx->Buffer)[7] = BE64((uint64_t)Ctx->Len << 3); 136 | Sha256ProcessBlock(Ctx, Ctx->Buffer); 137 | 138 | for (i = 0; i < 8; i++) 139 | //PUT_UAA32BE(hash, Ctx->State[i], i); 140 | ((DWORD*)hash)[i] = BE32(Ctx->State[i]); 141 | 142 | } 143 | 144 | 145 | void Sha256(BYTE *data, size_t len, BYTE *hash) 146 | { 147 | Sha256Ctx Ctx; 148 | 149 | Sha256Init(&Ctx); 150 | Sha256Update(&Ctx, data, len); 151 | Sha256Finish(&Ctx, hash); 152 | } 153 | 154 | 155 | static void _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen) 156 | { 157 | BYTE IPad[64]; 158 | unsigned int i; 159 | 160 | memset(IPad, 0x36, sizeof(IPad)); 161 | memset(Ctx->OPad, 0x5C, sizeof(Ctx->OPad)); 162 | 163 | if ( klen > 64 ) 164 | { 165 | BYTE *temp = (BYTE*)alloca(32); 166 | Sha256(key, klen, temp); 167 | klen = 32; 168 | key = temp; 169 | } 170 | 171 | for (i = 0; i < klen; i++) 172 | { 173 | IPad[ i ] ^= key[ i ]; 174 | Ctx->OPad[ i ] ^= key[ i ]; 175 | } 176 | 177 | Sha256Init(&Ctx->ShaCtx); 178 | Sha256Update(&Ctx->ShaCtx, IPad, sizeof(IPad)); 179 | } 180 | 181 | 182 | static void _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len) 183 | { 184 | Sha256Update(&Ctx->ShaCtx, data, len); 185 | } 186 | 187 | 188 | static void _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac) 189 | { 190 | BYTE temp[32]; 191 | 192 | Sha256Finish(&Ctx->ShaCtx, temp); 193 | Sha256Init(&Ctx->ShaCtx); 194 | Sha256Update(&Ctx->ShaCtx, Ctx->OPad, sizeof(Ctx->OPad)); 195 | Sha256Update(&Ctx->ShaCtx, temp, sizeof(temp)); 196 | Sha256Finish(&Ctx->ShaCtx, hmac); 197 | } 198 | 199 | 200 | 201 | int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac) 202 | { 203 | Sha256HmacCtx Ctx; 204 | _Sha256HmacInit(&Ctx, key, 16); 205 | _Sha256HmacUpdate(&Ctx, data, len); 206 | _Sha256HmacFinish(&Ctx, hmac); 207 | return TRUE; 208 | } 209 | 210 | 211 | #endif // No external Crypto 212 | 213 | -------------------------------------------------------------------------------- /vlmcsd/src/crypto_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef __crypto_internal_h 2 | #define __crypto_internal_h 3 | 4 | #if !defined(_CRYPTO_OPENSSL) && !defined(_CRYPTO_POLARSSL) && !defined(_CRYPTO_WINDOWS) 5 | 6 | #ifndef CONFIG 7 | #define CONFIG "config.h" 8 | #endif // CONFIG 9 | #include CONFIG 10 | 11 | #include "crypto.h" 12 | 13 | typedef struct { 14 | DWORD State[8]; 15 | BYTE Buffer[64]; 16 | unsigned int Len; 17 | } Sha256Ctx; 18 | 19 | typedef struct { 20 | Sha256Ctx ShaCtx; 21 | BYTE OPad[64]; 22 | } Sha256HmacCtx; 23 | 24 | void Sha256(BYTE *data, size_t len, BYTE *hash); 25 | int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac); 26 | 27 | //void _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen); 28 | //void _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len); 29 | //void _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac); 30 | 31 | //#define Sha256HmacInit(c, k, l) ( _Sha256HmacInit(c, k, l), !0 ) 32 | //#define Sha256HmacUpdate(c, d, l) ( _Sha256HmacUpdate(c, d, l), !0 ) 33 | //#define Sha256HmacFinish(c, h) ( _Sha256HmacFinish(c, h), !0 ) 34 | 35 | 36 | #endif // !defined(_CRYPTO_OPENSSL) && !defined(_CRYPTO_POLARSSL) && !defined(_CRYPTO_WINDOWS) 37 | 38 | #endif // __crypto_internal_h 39 | -------------------------------------------------------------------------------- /vlmcsd/src/crypto_openssl.h: -------------------------------------------------------------------------------- 1 | #ifndef __crypto_openssl_h 2 | #define __crypto_openssl_h 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "crypto.h" 14 | 15 | #define Sha256(d, l, h) SHA256(d, l, h) 16 | int_fast8_t Sha256Hmac(BYTE* key, BYTE* restrict data, DWORD len, BYTE* restrict hmac); 17 | 18 | #ifndef _OPENSSL_NO_HMAC 19 | #define Sha256HmacCtx HMAC_CTX 20 | #else 21 | typedef struct { 22 | SHA256_CTX ShaCtx; 23 | BYTE OPad[64]; 24 | } Sha256HmacCtx; 25 | #endif 26 | 27 | #ifndef _OPENSSL_NO_HMAC 28 | 29 | #define Sha256HmacInit(c, k, l) Sha256HmacInit_OpenSSL(c, k, l) 30 | #define Sha256HmacFinish(c, h) Sha256HmacFinish_OpenSSL(c, h, NULL) 31 | 32 | #if OPENSSL_VERSION_NUMBER >= 0x10000000L 33 | #define Sha256HmacUpdate(c, d, l) HMAC_Update(c, d, l) 34 | #else // OPENSSL_VERSION_NUMBER < 0x10000000L 35 | #define Sha256HmacUpdate(c, d, l) (HMAC_Update(c, d, l), !0) 36 | #endif // OPENSSL_VERSION_NUMBER >= 0x10000000L 37 | 38 | int Sha256HmacInit_OpenSSL(HMAC_CTX *c, const void *k, int l); 39 | int Sha256HmacFinish_OpenSSL(HMAC_CTX *c, unsigned char *h, unsigned int *l); 40 | 41 | #else // _OPENSSL_NO_HMAC 42 | 43 | int _Sha256HmacInit(Sha256HmacCtx *Ctx, BYTE *key, size_t klen); 44 | int _Sha256HmacUpdate(Sha256HmacCtx *Ctx, BYTE *data, size_t len); 45 | int _Sha256HmacFinish(Sha256HmacCtx *Ctx, BYTE *hmac, void* dummy); 46 | #define Sha256HmacInit(c, k, l) _Sha256HmacInit(c, k, l) 47 | #define Sha256HmacFinish(c, h) _Sha256HmacFinish(c, h, NULL) 48 | #define Sha256HmacUpdate(c, d, l) _Sha256HmacUpdate(c, d, l) 49 | 50 | #endif // _OPENSSL_NO_HMAC 51 | 52 | extern const BYTE AesKeyV4[]; 53 | #endif // __crypto_openssl_h 54 | -------------------------------------------------------------------------------- /vlmcsd/src/crypto_polarssl.h: -------------------------------------------------------------------------------- 1 | #ifndef __crypto_polarssl_h 2 | #define __crypto_polarssl_h 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include 10 | #include "crypto.h" 11 | 12 | #if POLARSSL_VERSION_NUMBER >= 0x01030000 13 | 14 | #include 15 | 16 | #define Sha256(d, l, h) sha256(d, l, h, 0) 17 | 18 | #define Sha256HmacCtx sha256_context 19 | #define Sha256HmacInit(c, k, l) ( sha256_hmac_starts(c, k, l, 0), !0 ) 20 | #define Sha256HmacUpdate(c, d, l) ( sha256_hmac_update(c, d, l), !0 ) 21 | #define Sha256HmacFinish(c, h) ( sha256_hmac_finish(c, h), !0 ) 22 | #define Sha256Hmac(k, d, l, h) ( sha256_hmac(k, 16, d, l, h, FALSE), !0 ) 23 | 24 | #else // POLARSSL_VERSION_NUMBER 25 | 26 | #include 27 | 28 | #define Sha256(d, l, h) sha2(d, l, h, 0) 29 | 30 | #define Sha256HmacCtx sha2_context 31 | #define Sha256HmacInit(c, k, l) ( sha2_hmac_starts(c, k, l, 0), !0 ) 32 | #define Sha256HmacUpdate(c, d, l) ( sha2_hmac_update(c, d, l), !0 ) 33 | #define Sha256HmacFinish(c, h) ( sha2_hmac_finish(c, h), !0 ) 34 | #define Sha256Hmac(k, d, l, h) ( sha2_hmac(k, 16, d, l, h, FALSE), !0 ) 35 | 36 | #endif // POLARSSL_VERSION_NUMBER 37 | #endif // __crypto_polarssl_h 38 | 39 | 40 | -------------------------------------------------------------------------------- /vlmcsd/src/endian.c: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG 2 | #define CONFIG "config.h" 3 | #endif // CONFIG 4 | #include CONFIG 5 | 6 | #include "endian.h" 7 | 8 | #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \ 9 | && defined(BS16) && defined(BS32) && defined(BS64) 10 | 11 | #else // ! defined(__BYTE_ORDER) 12 | 13 | void PUT_UAA64BE(void *p, unsigned long long v, unsigned int i) 14 | { 15 | unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i]; 16 | _p[ 0 ] = v >> 56; 17 | _p[ 1 ] = v >> 48; 18 | _p[ 2 ] = v >> 40; 19 | _p[ 3 ] = v >> 32; 20 | _p[ 4 ] = v >> 24; 21 | _p[ 5 ] = v >> 16; 22 | _p[ 6 ] = v >> 8; 23 | _p[ 7 ] = v; 24 | } 25 | 26 | void PUT_UAA32BE(void *p, unsigned int v, unsigned int i) 27 | { 28 | unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i]; 29 | _p[ 0 ] = v >> 24; 30 | _p[ 1 ] = v >> 16; 31 | _p[ 2 ] = v >> 8; 32 | _p[ 3 ] = v; 33 | } 34 | 35 | void PUT_UAA16BE(void *p, unsigned short v, unsigned int i) 36 | { 37 | unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i]; 38 | _p[ 0 ] = v >> 8; 39 | _p[ 1 ] = v; 40 | } 41 | 42 | 43 | void PUT_UAA64LE(void *p, unsigned long long v, unsigned int i) 44 | { 45 | unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i]; 46 | _p[ 0 ] = v; 47 | _p[ 1 ] = v >> 8; 48 | _p[ 2 ] = v >> 16; 49 | _p[ 3 ] = v >> 24; 50 | _p[ 4 ] = v >> 32; 51 | _p[ 5 ] = v >> 40; 52 | _p[ 6 ] = v >> 48; 53 | _p[ 7 ] = v >> 56; 54 | } 55 | 56 | void PUT_UAA32LE(void *p, unsigned int v, unsigned int i) 57 | { 58 | unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i]; 59 | _p[ 0 ] = v; 60 | _p[ 1 ] = v >> 8; 61 | _p[ 2 ] = v >> 16; 62 | _p[ 3 ] = v >> 24; 63 | } 64 | 65 | void PUT_UAA16LE(void *p, unsigned short v, unsigned int i) 66 | { 67 | unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i]; 68 | _p[ 0 ] = v; 69 | _p[ 1 ] = v >> 8; 70 | } 71 | 72 | 73 | unsigned long long GET_UAA64BE(void *p, unsigned int i) 74 | { 75 | unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i]; 76 | return 77 | (unsigned long long)_p[ 0 ] << 56 | 78 | (unsigned long long)_p[ 1 ] << 48 | 79 | (unsigned long long)_p[ 2 ] << 40 | 80 | (unsigned long long)_p[ 3 ] << 32 | 81 | (unsigned long long)_p[ 4 ] << 24 | 82 | (unsigned long long)_p[ 5 ] << 16 | 83 | (unsigned long long)_p[ 6 ] << 8 | 84 | (unsigned long long)_p[ 7 ]; 85 | 86 | } 87 | 88 | unsigned int GET_UAA32BE(void *p, unsigned int i) 89 | { 90 | unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i]; 91 | return 92 | (unsigned int)_p[ 0 ] << 24 | 93 | (unsigned int)_p[ 1 ] << 16 | 94 | (unsigned int)_p[ 2 ] << 8 | 95 | (unsigned int)_p[ 3 ]; 96 | } 97 | 98 | unsigned short GET_UAA16BE(void *p, unsigned int i) 99 | { 100 | unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i]; 101 | return 102 | (unsigned short)_p[ 0 ] << 8 | 103 | (unsigned short)_p[ 1 ]; 104 | } 105 | 106 | 107 | unsigned long long GET_UAA64LE(void *p, unsigned int i) 108 | { 109 | unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i]; 110 | return 111 | (unsigned long long)_p[ 0 ] | 112 | (unsigned long long)_p[ 1 ] << 8 | 113 | (unsigned long long)_p[ 2 ] << 16 | 114 | (unsigned long long)_p[ 3 ] << 24 | 115 | (unsigned long long)_p[ 4 ] << 32 | 116 | (unsigned long long)_p[ 5 ] << 40 | 117 | (unsigned long long)_p[ 6 ] << 48 | 118 | (unsigned long long)_p[ 7 ] << 56; 119 | 120 | } 121 | 122 | unsigned int GET_UAA32LE(void *p, unsigned int i) 123 | { 124 | unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i]; 125 | return 126 | (unsigned int)_p[ 0 ] | 127 | (unsigned int)_p[ 1 ] << 8 | 128 | (unsigned int)_p[ 2 ] << 16 | 129 | (unsigned int)_p[ 3 ] << 24; 130 | } 131 | 132 | unsigned short GET_UAA16LE(void *p, unsigned int i) 133 | { 134 | unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i]; 135 | return 136 | (unsigned short)_p[ 0 ] | 137 | (unsigned short)_p[ 1 ] << 8; 138 | } 139 | 140 | 141 | unsigned short BE16(unsigned short x) 142 | { 143 | return GET_UAA16BE(&x, 0); 144 | } 145 | 146 | unsigned short LE16(unsigned short x) 147 | { 148 | return GET_UAA16LE(&x, 0); 149 | } 150 | 151 | unsigned int BE32(unsigned int x) 152 | { 153 | return GET_UAA32BE(&x, 0); 154 | } 155 | 156 | unsigned int LE32(unsigned int x) 157 | { 158 | return GET_UAA32LE(&x, 0); 159 | } 160 | 161 | unsigned long long BE64(unsigned long long x) 162 | { 163 | return GET_UAA64BE(&x, 0); 164 | } 165 | 166 | inline unsigned long long LE64(unsigned long long x) 167 | { 168 | return GET_UAA64LE(&x, 0); 169 | } 170 | 171 | #endif // defined(__BYTE_ORDER) 172 | -------------------------------------------------------------------------------- /vlmcsd/src/helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef HELPERS_H 2 | #define HELPERS_H 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include 10 | #include "types.h" 11 | 12 | #define GUID_LE 0 13 | #define GUID_BE 1 14 | #define GUID_SWAP 2 15 | 16 | BOOL stringToInt(const char *const szValue, const int min, const int max, int *const value); 17 | int getOptionArgumentInt(const char o, const int min, const int max); 18 | void optReset(void); 19 | char* win_strerror(const int message); 20 | int ucs2_to_utf8_char (const WCHAR ucs2_le, char *utf8); 21 | size_t utf8_to_ucs2(WCHAR* const ucs2_le, const char* const utf8, const size_t maxucs2, const size_t maxutf8); 22 | WCHAR utf8_to_ucs2_char (const unsigned char * input, const unsigned char ** end_ptr); 23 | BOOL ucs2_to_utf8(const WCHAR* const ucs2_le, char* utf8, size_t maxucs2, size_t maxutf8); 24 | int_fast8_t string2Uuid(const char *const restrict input, GUID *const restrict guid); 25 | void randomNumberInit(); 26 | void LEGUID(GUID *const restrict result, const GUID* const restrict guid); 27 | void parseAddress(char *const addr, char** szHost, char** szPort); 28 | __noreturn void OutOfMemory(void); 29 | void* vlmcsd_malloc(size_t len); 30 | void hex2bin(BYTE *const bin, const char *hex, const size_t maxbin); 31 | __pure BOOL getArgumentBool(int_fast8_t *result, const char *const argument); 32 | 33 | 34 | #endif // HELPERS_H 35 | -------------------------------------------------------------------------------- /vlmcsd/src/network.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_NETWORK_H 2 | #define INCLUDED_NETWORK_H 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #ifndef _GNU_SOURCE 10 | #define _GNU_SOURCE 11 | #endif 12 | 13 | #include "types.h" 14 | 15 | 16 | 17 | int_fast8_t sendrecv(SOCKET sock, BYTE *data, int len, int_fast8_t do_send); 18 | 19 | #define _recv(s, d, l) sendrecv(s, (BYTE *)d, l, 0) 20 | #define _send(s, d, l) sendrecv(s, (BYTE *)d, l, !0) 21 | 22 | #ifndef NO_SOCKETS 23 | 24 | void closeAllListeningSockets(); 25 | BOOL addListeningSocket(const char *const addr); 26 | __pure int_fast8_t checkProtocolStack(const int addressfamily); 27 | 28 | #endif // NO_SOCKETS 29 | 30 | int runServer(); 31 | SOCKET connectToAddress(const char *const addr, const int AddressFamily, int_fast8_t showHostName); 32 | int_fast8_t isDisconnected(const SOCKET s); 33 | 34 | #endif // INCLUDED_NETWORK_H 35 | -------------------------------------------------------------------------------- /vlmcsd/src/ns_name.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NS_NAME_H_ 3 | #define NS_NAME_H_ 4 | 5 | int 6 | ns_name_uncompress_vlmcsd(const uint8_t *msg, const uint8_t *eom, const uint8_t *src, 7 | char *dst, size_t dstsiz); 8 | 9 | #endif /* NS_NAME_H_ */ 10 | -------------------------------------------------------------------------------- /vlmcsd/src/ns_parse.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NS_PARSE_H_ 3 | #define NS_PARSE_H_ 4 | 5 | #ifndef NS_INT16SZ 6 | #define NS_INT16SZ (sizeof(uint16_t)) 7 | #endif // NS_INT16SZ 8 | 9 | #ifndef NS_INT32SZ 10 | #define NS_INT32SZ (sizeof(uint32_t)) 11 | #endif // NS_INT32SZ 12 | 13 | #ifndef NS_MAXDNAME 14 | #define NS_MAXDNAME 1025 15 | #endif 16 | 17 | #define ns_msg_id_vlmcsd(handle) ((handle)._id + 0) 18 | #define ns_msg_base_vlmcsd(handle) ((handle)._msg + 0) 19 | #define ns_msg_end_vlmcsd(handle) ((handle)._eom + 0) 20 | #define ns_msg_size_vlmcsd(handle) ((handle)._eom - (handle)._msg) 21 | #define ns_msg_count_vlmcsd(handle, section) ((handle)._counts[section] + 0) 22 | 23 | #define ns_rr_name_vlmcsd(rr) (((rr).name[0] != '\0') ? (rr).name : ".") 24 | #define ns_rr_type_vlmcsd(rr) ((ns_type)((rr).type + 0)) 25 | #define ns_rr_class_vlmcsd(rr) ((ns_class)((rr).rr_class + 0)) 26 | #define ns_rr_ttl_vlmcsd(rr) ((rr).ttl + 0) 27 | #define ns_rr_rdlen_vlmcsd(rr) ((rr).rdlength + 0) 28 | #define ns_rr_rdata_vlmcsd(rr) ((rr).rdata + 0) 29 | 30 | #define ns_msg_id_vlmcsd(handle) ((handle)._id + 0) 31 | #define ns_msg_base_vlmcsd(handle) ((handle)._msg + 0) 32 | #define ns_msg_end_vlmcsd(handle) ((handle)._eom + 0) 33 | #define ns_msg_size_vlmcsd(handle) ((handle)._eom - (handle)._msg) 34 | #define ns_msg_count_vlmcsd(handle, section) ((handle)._counts[section] + 0) 35 | 36 | 37 | typedef enum __ns_sect_vlmcsd { 38 | ns_s_qd_vlmcsd = 0, /*%< Query: Question. */ 39 | ns_s_zn_vlmcsd = 0, /*%< Update: Zone. */ 40 | ns_s_an_vlmcsd = 1, /*%< Query: Answer. */ 41 | ns_s_pr_vlmcsd = 1, /*%< Update: Prerequisites. */ 42 | ns_s_ns_vlmcsd = 2, /*%< Query: Name servers. */ 43 | ns_s_ud_vlmcsd = 2, /*%< Update: Update. */ 44 | ns_s_ar_vlmcsd = 3, /*%< Query|Update: Additional records. */ 45 | ns_s_max_vlmcsd = 4 46 | } ns_sect_vlmcsd; 47 | 48 | typedef struct __ns_msg_vlmcsd { 49 | const uint8_t *_msg, *_eom; 50 | uint16_t _id, _flags, _counts[ns_s_max_vlmcsd]; 51 | const uint8_t *_sections[ns_s_max_vlmcsd]; 52 | ns_sect_vlmcsd _sect; 53 | int _rrnum; 54 | const uint8_t *_msg_ptr; 55 | } ns_msg_vlmcsd; 56 | 57 | 58 | typedef struct __ns_rr_vlmcsd { 59 | char name[NS_MAXDNAME]; 60 | uint16_t type; 61 | uint16_t rr_class; 62 | uint32_t ttl; 63 | uint16_t rdlength; 64 | const uint8_t * rdata; 65 | } ns_rr_vlmcsd; 66 | 67 | int ns_initparse_vlmcsd(const uint8_t *msg, int msglen, ns_msg_vlmcsd *handle); 68 | 69 | int ns_parserr_vlmcsd(ns_msg_vlmcsd *handle, ns_sect_vlmcsd section, int rrnum, ns_rr_vlmcsd *rr); 70 | 71 | 72 | 73 | #endif /* NS_PARSE_H_ */ 74 | -------------------------------------------------------------------------------- /vlmcsd/src/ntservice.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_NTSERVICE_H 2 | #define INCLUDED_NTSERVICE_H 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include "types.h" 10 | #ifdef _NTSERVICE 11 | 12 | //#include 13 | 14 | #define NT_SERVICE_NAME "vlmcsd" 15 | #define NT_SERVICE_DISPLAY_NAME "Key Management Server" 16 | 17 | extern SERVICE_TABLE_ENTRY NTServiceDispatchTable[]; 18 | 19 | VOID ReportServiceStatus(const DWORD, const DWORD, const DWORD); 20 | int NtServiceInstallation(const int_fast8_t installService, const char *restrict ServiceUser, const char *const ServicePassword); 21 | 22 | #else // !_NTSERVICE 23 | 24 | #define ReportServiceStatus(x,y,z) 25 | 26 | #endif // _NTSERVICE 27 | 28 | #endif // INCLUDED_NTSERVICE_H 29 | -------------------------------------------------------------------------------- /vlmcsd/src/output.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_OUTPUT_H 2 | #define INCLUDED_OUTPUT_H 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include "kms.h" 10 | 11 | typedef int (*PRINTFUNC)(const char *const fmt, ...); 12 | 13 | void printerrorf(const char *const fmt, ...); 14 | int errorout(const char* fmt, ...); 15 | void logRequestVerbose(const REQUEST *const Request, const PRINTFUNC p); 16 | void logResponseVerbose(const char *const ePID, const BYTE *const hwid, const RESPONSE *const response, const PRINTFUNC p); 17 | 18 | #ifndef NO_LOG 19 | int logger(const char *const fmt, ...); 20 | #endif //NO_LOG 21 | 22 | void uuid2StringLE(const GUID *const guid, char *const string); 23 | 24 | //void copy_arguments(int argc, char **argv, char ***new_argv); 25 | //void destroy_arguments(int argc, char **argv); 26 | 27 | #endif // INCLUDED_OUTPUT_H 28 | -------------------------------------------------------------------------------- /vlmcsd/src/resolv_static.h: -------------------------------------------------------------------------------- 1 | #ifndef _RESOLV_STATIC_H 2 | #define _RESOLV_STATIC_H 3 | 4 | #include 5 | 6 | /* this structure contains all the variables that were declared 7 | * 'static' in the original NetBSD resolver code. 8 | * 9 | * this caused vast amounts of crashes and memory corruptions 10 | * when the resolver was being used by multiple threads. 11 | * 12 | * (note: the OpenBSD/FreeBSD resolver has similar 'issues') 13 | */ 14 | 15 | #define MAXALIASES 35 16 | #define MAXADDRS 35 17 | 18 | typedef struct res_static { 19 | char* h_addr_ptrs[MAXADDRS + 1]; 20 | char* host_aliases[MAXALIASES]; 21 | char hostbuf[8*1024]; 22 | u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */ 23 | FILE* hostf; 24 | int stayopen; 25 | const char* servent_ptr; 26 | struct servent servent; 27 | struct hostent host; 28 | } *res_static; 29 | 30 | extern res_static __res_get_static(void); 31 | 32 | #endif /* _RESOLV_STATIC_H */ 33 | -------------------------------------------------------------------------------- /vlmcsd/src/rpc.h: -------------------------------------------------------------------------------- 1 | #ifndef __rpc_h 2 | #define __rpc_h 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include "types.h" 10 | 11 | typedef struct { 12 | BYTE VersionMajor; 13 | BYTE VersionMinor; 14 | BYTE PacketType; 15 | BYTE PacketFlags; 16 | DWORD DataRepresentation; 17 | WORD FragLength; 18 | WORD AuthLength; 19 | DWORD CallId; 20 | } /*__packed*/ RPC_HEADER; 21 | 22 | 23 | typedef struct { 24 | WORD MaxXmitFrag; 25 | WORD MaxRecvFrag; 26 | DWORD AssocGroup; 27 | DWORD NumCtxItems; 28 | struct { 29 | WORD ContextId; 30 | WORD NumTransItems; 31 | GUID InterfaceUUID; 32 | WORD InterfaceVerMajor; 33 | WORD InterfaceVerMinor; 34 | GUID TransferSyntax; 35 | DWORD SyntaxVersion; 36 | } CtxItems[1]; 37 | } /*__packed*/ RPC_BIND_REQUEST; 38 | 39 | typedef struct { 40 | WORD MaxXmitFrag; 41 | WORD MaxRecvFrag; 42 | DWORD AssocGroup; 43 | WORD SecondaryAddressLength; 44 | BYTE SecondaryAddress[6]; 45 | DWORD NumResults; 46 | struct { 47 | WORD AckResult; 48 | WORD AckReason; 49 | GUID TransferSyntax; 50 | DWORD SyntaxVersion; 51 | } Results[0]; 52 | } /*__packed*/ RPC_BIND_RESPONSE; 53 | 54 | 55 | typedef struct { 56 | DWORD AllocHint; 57 | WORD ContextId; 58 | WORD Opnum; 59 | struct { 60 | DWORD DataLength; 61 | DWORD DataSizeIs; 62 | } Ndr; 63 | BYTE Data[0]; 64 | } /*__packed*/ RPC_REQUEST; 65 | 66 | typedef struct { 67 | DWORD AllocHint; 68 | WORD ContextId; 69 | BYTE CancelCount; 70 | BYTE Pad1; 71 | struct { 72 | DWORD DataLength; 73 | DWORD DataSizeIs1; 74 | DWORD DataSizeIs2; 75 | } Ndr; 76 | BYTE Data[0]; 77 | } /*__packed*/ RPC_RESPONSE; 78 | 79 | typedef struct { 80 | DWORD AllocHint; 81 | WORD ContextId; 82 | WORD Opnum; 83 | union { 84 | struct { 85 | DWORD DataLength; 86 | DWORD DataSizeIs; 87 | BYTE Data[0]; 88 | } Ndr; 89 | struct { 90 | uint64_t DataLength; 91 | uint64_t DataSizeIs; 92 | BYTE Data[0]; 93 | } Ndr64; 94 | }; 95 | } /*__packed*/ RPC_REQUEST64; 96 | 97 | typedef struct { 98 | DWORD AllocHint; 99 | WORD ContextId; 100 | BYTE CancelCount; 101 | BYTE Pad1; 102 | union { 103 | struct { 104 | DWORD DataLength; 105 | DWORD DataSizeMax; 106 | union 107 | { 108 | DWORD DataSizeIs; 109 | DWORD status; 110 | }; 111 | BYTE Data[0]; 112 | } Ndr; 113 | struct { 114 | uint64_t DataLength; 115 | uint64_t DataSizeMax; 116 | union 117 | { 118 | uint64_t DataSizeIs; 119 | DWORD status; 120 | }; 121 | BYTE Data[0]; 122 | } Ndr64; 123 | }; 124 | } /*__packed*/ RPC_RESPONSE64; 125 | 126 | 127 | typedef SOCKET RpcCtx; 128 | typedef int RpcStatus; 129 | 130 | #define INVALID_NDR_CTX ((WORD)~0) 131 | 132 | #define RPC_BIND_ACCEPT (0) 133 | #define RPC_BIND_NACK (LE16(2)) 134 | #define RPC_BIND_ACK (LE16(3)) 135 | 136 | #define RPC_SYNTAX_UNSUPPORTED (LE16(2)) 137 | #define RPC_ABSTRACTSYNTAX_UNSUPPORTED (LE16(1)) 138 | 139 | #define RPC_BTFN_SEC_CONTEXT_MULTIPLEX (LE16(1)) 140 | #define RPC_BTFN_KEEP_ORPHAN (LE16(2)) 141 | 142 | #define INVALID_RPCCTX INVALID_SOCKET 143 | #define closeRpc socketclose 144 | 145 | #define RPC_PT_REQUEST 0 146 | #define RPC_PT_RESPONSE 2 147 | #define RPC_PT_BIND_REQ 11 148 | #define RPC_PT_BIND_ACK 12 149 | #define RPC_PT_ALTERCONTEXT_REQ 14 150 | #define RPC_PT_ALTERCONTEXT_ACK 15 151 | 152 | #define RPC_PF_FIRST 1 153 | #define RPC_PF_LAST 2 154 | #define RPC_PF_CANCEL_PENDING 4 155 | #define RPC_PF_RESERVED 8 156 | #define RPC_PF_MULTIPLEX 16 157 | #define RPC_PF_NOT_EXEC 32 158 | #define RPC_PF_MAYBE 64 159 | #define RPC_PF_OBJECT 128 160 | 161 | typedef union _RPC_FLAGS 162 | { 163 | DWORD mask; 164 | struct { 165 | uint32_t FlagsBTFN : 16; 166 | BOOL HasNDR32 : 1; 167 | BOOL HasNDR64 : 1; 168 | BOOL HasBTFN : 1; 169 | }; 170 | } RPC_FLAGS, *PRPC_FLAGS; 171 | 172 | extern RPC_FLAGS RpcFlags; 173 | 174 | void rpcServer(const RpcCtx socket, const DWORD RpcAssocGroup, const char* const ipstr); 175 | RpcStatus rpcBindClient(const RpcCtx sock, const int_fast8_t verbose); 176 | RpcStatus rpcSendRequest(const RpcCtx socket, const BYTE *const KmsRequest, const size_t requestSize, BYTE **KmsResponse, size_t *const responseSize); 177 | 178 | #endif // __rpc_h 179 | -------------------------------------------------------------------------------- /vlmcsd/src/shared_globals.c: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG 2 | #define CONFIG "config.h" 3 | #endif // CONFIG 4 | #include CONFIG 5 | 6 | #include "shared_globals.h" 7 | 8 | int global_argc, multi_argc = 0; 9 | CARGV global_argv, multi_argv = NULL; 10 | const char *const Version = VERSION; 11 | DWORD VLActivationInterval = 60 * 2; // 2 hours 12 | DWORD VLRenewalInterval = 60 * 24 * 7; // 7 days 13 | int_fast8_t DisconnectImmediately = FALSE; 14 | const char *const cIPv4 = "IPv4"; 15 | const char *const cIPv6 = "IPv6"; 16 | 17 | #ifndef USE_MSRPC 18 | int_fast8_t UseMultiplexedRpc = TRUE; 19 | int_fast8_t UseRpcNDR64 = TRUE; 20 | int_fast8_t UseRpcBTFN = TRUE; 21 | #endif // USE_MSRPC 22 | 23 | #ifndef NO_SOCKETS 24 | const char *defaultport = "1688"; 25 | #endif // NO_SOCKETS 26 | 27 | KmsResponseParam_t KmsResponseParameters[MAX_KMSAPPS]; 28 | 29 | #if !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32) 30 | int_fast8_t IsRestarted = FALSE; 31 | #endif // !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32) 32 | 33 | #if !defined(NO_TIMEOUT) && !__minix__ 34 | DWORD ServerTimeout = 30; 35 | #endif // !defined(NO_TIMEOUT) && !__minix__ 36 | 37 | #if !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__ 38 | #ifdef USE_MSRPC 39 | int32_t MaxTasks = RPC_C_LISTEN_MAX_CALLS_DEFAULT; 40 | #else // !USE_MSRPC 41 | int32_t MaxTasks = SEM_VALUE_MAX; 42 | #endif // !USE_MSRPC 43 | #endif // !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__ 44 | 45 | #ifndef NO_LOG 46 | char *fn_log = NULL; 47 | int_fast8_t logstdout = 0; 48 | #ifndef NO_VERBOSE_LOG 49 | int_fast8_t logverbose = 0; 50 | #endif // NO_VERBOSE_LOG 51 | #endif // NO_LOG 52 | 53 | #ifndef NO_SOCKETS 54 | int_fast8_t nodaemon = 0; 55 | int_fast8_t InetdMode = 0; 56 | #else 57 | int_fast8_t nodaemon = 1; 58 | int_fast8_t InetdMode = 1; 59 | #endif 60 | 61 | #ifndef NO_RANDOM_EPID 62 | int_fast8_t RandomizationLevel = 1; 63 | uint16_t Lcid = 0; 64 | #endif 65 | 66 | #ifndef NO_SOCKETS 67 | SOCKET *SocketList; 68 | int numsockets = 0; 69 | 70 | #if !defined(NO_LIMIT) && !__minix__ 71 | #ifndef _WIN32 // Posix 72 | sem_t *Semaphore; 73 | #else // _WIN32 74 | HANDLE Semaphore; 75 | #endif // _WIN32 76 | 77 | #endif // !defined(NO_LIMIT) && !__minix__ 78 | #endif // NO_SOCKETS 79 | 80 | #ifdef _NTSERVICE 81 | int_fast8_t IsNTService = TRUE; 82 | int_fast8_t ServiceShutdown = FALSE; 83 | #endif // _NTSERVICE 84 | 85 | #ifndef NO_LOG 86 | #ifdef USE_THREADS 87 | #if !defined(_WIN32) && !defined(__CYGWIN__) 88 | pthread_mutex_t logmutex = PTHREAD_MUTEX_INITIALIZER; 89 | #else 90 | CRITICAL_SECTION logmutex; 91 | #endif // !defined(_WIN32) && !defined(__CYGWIN__) 92 | #endif // USE_THREADS 93 | #endif // NO_LOG 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /vlmcsd/src/shared_globals.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_SHARED_GLOBALS_H 2 | #define INCLUDED_SHARED_GLOBALS_H 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #include 10 | 11 | #ifndef _WIN32 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #if (!defined(NO_LIMIT) || defined(USE_THREADS)) && !__minix__ 20 | #include 21 | #endif // (!defined(NO_LIMIT) || defined(USE_THREADS)) && !__minix__ 22 | #include 23 | #include 24 | #if !defined(NO_LIMIT) && !__minix__ 25 | #include 26 | #endif // !defined(NO_LIMIT) && !__minix__ 27 | #else 28 | #ifndef USE_MSRPC 29 | #include 30 | #include 31 | #endif // USE_MSRPC 32 | #include 33 | #endif 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include "types.h" 47 | 48 | #define MAX_KMSAPPS 3 49 | typedef struct 50 | { 51 | const char* Epid; 52 | const BYTE* HwId; 53 | #ifndef NO_LOG 54 | const char* EpidSource; 55 | #endif // NO_LOG 56 | } KmsResponseParam_t, *PKmsResponseParam_t; 57 | 58 | #if !defined(NO_LIMIT) && !__minix__ 59 | #ifndef SEM_VALUE_MAX // Android does not define this 60 | #ifdef __ANDROID__ 61 | #define SEM_VALUE_MAX 0x3fffffff 62 | #elif !defined(_WIN32) 63 | #define SEM_VALUE_MAX 0x7fffffff 64 | #else 65 | #define SEM_VALUE_MAX 0x7fff // Be cautious if unknown 66 | #endif // __ANDROID__ 67 | #endif // !defined(SEM_VALUE_MAX) 68 | #endif // !defined(NO_LIMIT) && !__minix__ 69 | 70 | extern const char *const Version; 71 | 72 | //Fix for stupid eclipse parser 73 | #ifndef UINT_MAX 74 | #define UINT_MAX 4294967295 75 | #endif 76 | 77 | 78 | extern int global_argc, multi_argc; 79 | extern CARGV global_argv, multi_argv; 80 | extern int_fast8_t nodaemon; 81 | extern DWORD VLActivationInterval; 82 | extern DWORD VLRenewalInterval; 83 | extern int_fast8_t DisconnectImmediately; 84 | extern KmsResponseParam_t KmsResponseParameters[MAX_KMSAPPS]; 85 | extern const char *const cIPv4; 86 | extern const char *const cIPv6; 87 | extern int_fast8_t InetdMode; 88 | 89 | #ifndef USE_MSRPC 90 | extern int_fast8_t UseMultiplexedRpc; 91 | extern int_fast8_t UseRpcNDR64; 92 | extern int_fast8_t UseRpcBTFN; 93 | #endif // USE_MSRPC 94 | 95 | #ifndef NO_SOCKETS 96 | extern const char *defaultport; 97 | #endif // NO_SOCKETS 98 | 99 | #if !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32) 100 | extern int_fast8_t IsRestarted; 101 | #endif // !defined(NO_SOCKETS) && !defined(NO_SIGHUP) && !defined(_WIN32) 102 | 103 | #if !defined(NO_TIMEOUT) && !__minix__ 104 | extern DWORD ServerTimeout; 105 | #endif // !defined(NO_TIMEOUT) && !__minix__ 106 | 107 | #if !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__ 108 | extern int32_t MaxTasks; 109 | #endif // !defined(NO_LIMIT) && !defined (NO_SOCKETS) && !__minix__ 110 | 111 | #ifndef NO_LOG 112 | extern char *fn_log; 113 | extern int_fast8_t logstdout; 114 | #ifndef NO_VERBOSE_LOG 115 | extern int_fast8_t logverbose; 116 | #endif 117 | #endif 118 | 119 | #ifndef NO_RANDOM_EPID 120 | extern int_fast8_t RandomizationLevel; 121 | extern uint16_t Lcid; 122 | #endif 123 | 124 | #if !defined(NO_SOCKETS) && !defined(USE_MSRPC) 125 | extern SOCKET *SocketList; 126 | extern int numsockets; 127 | 128 | #if !defined(NO_LIMIT) && !__minix__ 129 | 130 | #ifndef _WIN32 131 | extern sem_t *Semaphore; 132 | #else // _WIN32 133 | extern HANDLE Semaphore; 134 | #endif // _WIN32 135 | 136 | #endif // !defined(NO_LIMIT) && !__minix__ 137 | 138 | #endif // !defined(NO_SOCKETS) && !defined(USE_MSRPC) 139 | 140 | #ifdef _NTSERVICE 141 | extern int_fast8_t IsNTService; 142 | extern int_fast8_t ServiceShutdown; 143 | #endif 144 | 145 | #ifndef NO_LOG 146 | #ifdef USE_THREADS 147 | #if !defined(_WIN32) && !defined(__CYGWIN__) 148 | extern pthread_mutex_t logmutex; 149 | #else 150 | extern CRITICAL_SECTION logmutex; 151 | #endif // _WIN32 152 | #endif // USE_THREADS 153 | #endif // NO_LOG 154 | 155 | 156 | #endif // INCLUDED_SHARED_GLOBALS_H 157 | -------------------------------------------------------------------------------- /vlmcsd/src/vlmcs.h: -------------------------------------------------------------------------------- 1 | #ifndef VLMCS_H_ 2 | #define VLMCS_H_ 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #if defined(USE_MSRPC) && defined(_WIN32) 10 | #include 11 | #endif // defined(USE_MSRPC) && defined(_WIN32) 12 | #include "types.h" 13 | 14 | #if MULTI_CALL_BINARY < 1 15 | #define client_main main 16 | #else 17 | int client_main(int argc, CARGV argv); 18 | #endif 19 | 20 | #endif /* VLMCS_H_ */ 21 | 22 | -------------------------------------------------------------------------------- /vlmcsd/src/vlmcsd.h: -------------------------------------------------------------------------------- 1 | #ifndef __main_h 2 | #define __main_h 3 | 4 | #ifndef CONFIG 5 | #define CONFIG "config.h" 6 | #endif // CONFIG 7 | #include CONFIG 8 | 9 | #define __T(x) #x 10 | #define _T(x) __T(x) 11 | 12 | extern char *fn_log; 13 | 14 | #include "types.h" 15 | 16 | //int main(int argc, CARGV); 17 | extern void cleanup(); 18 | 19 | #ifdef _NTSERVICE 20 | int newmain(); 21 | #endif 22 | 23 | #if MULTI_CALL_BINARY < 1 24 | #define server_main main 25 | #else 26 | int server_main(int argc, CARGV argv); 27 | #endif 28 | 29 | #ifndef SA_NOCLDWAIT // required for Cygwin 30 | #define SA_NOCLDWAIT 0 31 | #endif 32 | 33 | #ifndef NO_INI_FILE 34 | #define INI_PARAM_RANDOMIZATION_LEVEL 1 35 | #define INI_PARAM_LCID 2 36 | #define INI_PARAM_LISTEN 3 37 | #define INI_PARAM_MAX_WORKERS 4 38 | #define INI_PARAM_CONNECTION_TIMEOUT 5 39 | #define INI_PARAM_PID_FILE 6 40 | #define INI_PARAM_LOG_FILE 7 41 | #define INI_PARAM_LOG_VERBOSE 8 42 | #define INI_PARAM_ACTIVATION_INTERVAL 9 43 | #define INI_PARAM_RENEWAL_INTERVAL 10 44 | #define INI_PARAM_DISCONNECT_IMMEDIATELY 11 45 | #define INI_PARAM_UID 12 46 | #define INI_PARAM_GID 13 47 | #define INI_PARAM_PORT 14 48 | #define INI_PARAM_RPC_NDR64 15 49 | #define INI_PARAM_RPC_BTFN 16 50 | 51 | #define INI_FILE_PASS_1 1 52 | #define INI_FILE_PASS_2 2 53 | 54 | typedef struct 55 | { 56 | const char* const Name; 57 | uint_fast8_t Id; 58 | } IniFileParameter_t, *PIniFileParameter_t; 59 | #endif // NO_INI_FILE 60 | 61 | #endif // __main_h 62 | -------------------------------------------------------------------------------- /vlmcsd/src/vlmcsdmulti.c: -------------------------------------------------------------------------------- 1 | /* Multi-Call Binary for vlmcs and vlmcsd */ 2 | 3 | #ifndef CONFIG 4 | #define CONFIG "config.h" 5 | #endif // CONFIG 6 | #include CONFIG 7 | 8 | #if MULTI_CALL_BINARY < 1 9 | #error "Please define MULTI_CALL_BINARY=1 when compiling this file." 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include "vlmcs.h" 16 | #include "vlmcsd.h" 17 | #include "types.h" 18 | #include "shared_globals.h" 19 | #include "output.h" 20 | 21 | #if (defined(_WIN32) || defined(__CYGWIN__)) 22 | #define compare strcasecmp // Best for case-preserving (but otherwise case-insensitive) filesystems 23 | #else // native Unix 24 | #define compare strcmp // for case-sensitive filesystems 25 | #endif // native Unix 26 | 27 | int main(int argc, CARGV argv) 28 | { 29 | multi_argv = argv; 30 | multi_argc = argc; 31 | 32 | if (!compare(basename((char*)*argv), "vlmcsd")) 33 | return server_main(argc, argv); 34 | 35 | if (!compare(basename((char*)*argv), "vlmcs")) 36 | return client_main(argc, argv); 37 | 38 | #ifdef _WIN32 39 | if (!compare(basename((char*)*argv), "vlmcsd.exe")) 40 | return server_main(argc, argv); 41 | 42 | if (!compare(basename((char*)*argv), "vlmcs.exe")) 43 | return client_main(argc, argv); 44 | #endif // _WIN32 45 | 46 | if (argc > 1) 47 | { 48 | if (!strcmp((char*)argv[1],"vlmcsd")) 49 | return server_main(argc - 1, argv + 1); 50 | 51 | if (!strcmp((char*)argv[1],"vlmcs")) 52 | return client_main(argc - 1, argv + 1); 53 | } 54 | 55 | errorout( 56 | "vlmcsdmulti %s\n\n" 57 | "Usage:\n" 58 | "\t%s vlmcsd []\n" 59 | "\t%s vlmcs []\n\n", 60 | Version, *argv, *argv 61 | ); 62 | 63 | return !0; 64 | } 65 | -------------------------------------------------------------------------------- /wsapi/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | 4 | PKG_NAME:=wsapi 5 | PKG_VERSION:=1.5.0 6 | PKG_RELEASE:=1 7 | 8 | PKG_SOURCE_PROTO:=git 9 | PKG_SOURCE_VERSION:=ee910fb6428631cea430216138d0e34ef93022ad 10 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 11 | 12 | PKG_SOURCE_URL:=https://github.com/keplerproject/$(PKG_NAME).git 13 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz 14 | 15 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 16 | PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install 17 | PKG_BUILD_PARALLEL:=1 18 | 19 | include $(INCLUDE_DIR)/package.mk 20 | 21 | 22 | define Package/wsapi 23 | SUBMENU:=Lua 24 | SECTION:=lang 25 | CATEGORY:=Languages 26 | TITLE:=Lua WSAPI Module 27 | URL:=http://nginx.org/ 28 | DEPENDS:= +lua 29 | endef 30 | 31 | define Package/wsapi/description 32 | wsapi ... 33 | endef 34 | 35 | define Build/Configure 36 | 37 | mkdir -p $(PKG_INSTALL_DIR)/usr/sbin 38 | mkdir -p $(PKG_INSTALL_DIR)/usr/lib 39 | (\ 40 | cd $(PKG_BUILD_DIR) && \ 41 | echo "CFLAGS=$(TARGET_CFLAGS) -fPIC" > config && \ 42 | echo "CC=$(TARGET_CC)" >> config && \ 43 | echo "LIB_OPTION= -shared" >> config && \ 44 | echo "LUA_DIR= $(PKG_INSTALL_DIR)" >> config &&\ 45 | echo "BIN_DIR= $(PKG_INSTALL_DIR)/usr/sbin" >> config && \ 46 | echo "LUA_LIBDIR= $(PKG_INSTALL_DIR)/usr/lib" >> config \ 47 | ) 48 | endef 49 | define Build/Compile 50 | ( \ 51 | cd $(PKG_BUILD_DIR) && \ 52 | make && \ 53 | make install-fcgi && \ 54 | make install \ 55 | ) 56 | endef 57 | 58 | define Package/$(PKG_NAME)/install 59 | $(INSTALL_DIR) $(1)/usr/sbin 60 | $(CP) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin/ 61 | endef 62 | 63 | 64 | $(eval $(call BuildPackage,$(PKG_NAME))) 65 | --------------------------------------------------------------------------------