Ver Fonte

初始化

zzj há 6 anos atrás
pai
commit
77366d3fd3
49 ficheiros alterados com 12904 adições e 0 exclusões
  1. 1 0
      COPYING
  2. 1 0
      INSTALL
  3. 32 0
      Makefile.am
  4. 961 0
      Makefile.in
  5. 944 0
      aclocal.m4
  6. 172 0
      ant.cpp
  7. 148 0
      ant.h
  8. 115 0
      async.cpp
  9. 88 0
      base64.cpp
  10. 9 0
      base64.h
  11. 126 0
      c2.cpp
  12. 194 0
      card.cpp
  13. 19 0
      card.h
  14. 64 0
      card_timer.xx
  15. 64 0
      client.cpp
  16. 92 0
      clock.h
  17. 6454 0
      configure
  18. 44 0
      configure.ac
  19. 1 0
      depcomp
  20. 1 0
      install-sh
  21. 350 0
      io_buf.h
  22. 1 0
      libzlog.so
  23. 224 0
      line.h
  24. 1 0
      log.h
  25. 27 0
      log.ini
  26. 1 0
      logger
  27. 14 0
      main.cpp
  28. 89 0
      message.cpp
  29. 49 0
      message.h
  30. 151 0
      message_file.cpp
  31. 25 0
      message_file.h
  32. 1 0
      missing
  33. 90 0
      net-service.cpp
  34. 21 0
      net-service.h
  35. 20 0
      point.cpp
  36. 124 0
      point.h
  37. 25 0
      tdoa_sync.cpp
  38. 19 0
      tdoa_sync.h
  39. 353 0
      test.cpp
  40. 179 0
      web-client.cpp
  41. 14 0
      web-client.h
  42. 82 0
      webc.i
  43. 127 0
      worker.cpp
  44. 48 0
      worker.h
  45. 344 0
      zio.h
  46. 86 0
      zloop.h
  47. 492 0
      znet.cpp
  48. 84 0
      znet.h
  49. 333 0
      zstream.h

+ 1 - 0
COPYING

@@ -0,0 +1 @@
+/usr/share/automake-1.12/COPYING

+ 1 - 0
INSTALL

@@ -0,0 +1 @@
+/usr/share/automake-1.12/INSTALL

+ 32 - 0
Makefile.am

@@ -0,0 +1,32 @@
+
+AM_SOURCES= ant.cpp ant.h base64.cpp base64.h card.cpp card.h clock.h \
+io_buf.h line.h log.h message.cpp message.h point.cpp \
+point.h tdoa_sync.cpp tdoa_sync.h web-client.cpp web-client.h worker.cpp worker.h zio.h \
+zloop.h znet.cpp znet.h zstream.h net-service.h net-service.cpp
+
+AM_CPPFLAGS=-Wall -pthread -m64 -std=c++11 -fPIC
+AM_LDFLAGS= -Wall -pthread -m64 -std=c++11 -fPIC
+
+bin_PROGRAMS=yals client async test
+
+yals_SOURCES=${AM_SOURCES} main.cpp 
+yals_CPPFLAGS=${AM_CPPFLAGS}
+yals_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog -lrt
+
+async_SOURCES=async.cpp
+async_CPPFLAGS=${AM_CPPFLAGS}
+async_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog -lrt
+
+client_SOURCES=client.cpp message_file.cpp
+client_CPPFLAGS=${AM_CPPFLAGS}
+client_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog
+
+test_SOURCES=test.cpp base64.cpp
+test_CPPFLAGS=${AM_CPPFLAGS}
+test_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog -lrt
+
+DEFS= 
+EXTRA_DIST=message_file.h 
+
+
+

+ 961 - 0
Makefile.in

@@ -0,0 +1,961 @@
+# Makefile.in generated by automake 1.12.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+bin_PROGRAMS = yals$(EXEEXT) client$(EXEEXT) async$(EXEEXT) \
+	test$(EXEEXT)
+subdir = .
+DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in $(top_srcdir)/configure COPYING INSTALL \
+	depcomp install-sh missing
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_async_OBJECTS = async-async.$(OBJEXT)
+async_OBJECTS = $(am_async_OBJECTS)
+async_LDADD = $(LDADD)
+async_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(async_LDFLAGS) \
+	$(LDFLAGS) -o $@
+am_client_OBJECTS = client-client.$(OBJEXT) \
+	client-message_file.$(OBJEXT)
+client_OBJECTS = $(am_client_OBJECTS)
+client_LDADD = $(LDADD)
+client_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(client_LDFLAGS) \
+	$(LDFLAGS) -o $@
+am_test_OBJECTS = test-test.$(OBJEXT) test-base64.$(OBJEXT)
+test_OBJECTS = $(am_test_OBJECTS)
+test_LDADD = $(LDADD)
+test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(test_LDFLAGS) \
+	$(LDFLAGS) -o $@
+am__objects_1 = yals-ant.$(OBJEXT) yals-base64.$(OBJEXT) \
+	yals-card.$(OBJEXT) yals-message.$(OBJEXT) \
+	yals-point.$(OBJEXT) yals-tdoa_sync.$(OBJEXT) \
+	yals-web-client.$(OBJEXT) yals-worker.$(OBJEXT) \
+	yals-znet.$(OBJEXT) yals-net-service.$(OBJEXT)
+am_yals_OBJECTS = $(am__objects_1) yals-main.$(OBJEXT)
+yals_OBJECTS = $(am_yals_OBJECTS)
+yals_LDADD = $(LDADD)
+yals_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(yals_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+	-o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
+	$(yals_SOURCES)
+DIST_SOURCES = $(async_SOURCES) $(client_SOURCES) $(test_SOURCES) \
+	$(yals_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+AM_RECURSIVE_TARGETS = cscope
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  if test -d "$(distdir)"; then \
+    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+      && rm -rf "$(distdir)" \
+      || { sleep 5 && rm -rf "$(distdir)"; }; \
+  else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = 
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build_alias = @build_alias@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_SOURCES = ant.cpp ant.h base64.cpp base64.h card.cpp card.h clock.h \
+io_buf.h line.h log.h message.cpp message.h point.cpp \
+point.h tdoa_sync.cpp tdoa_sync.h web-client.cpp web-client.h worker.cpp worker.h zio.h \
+zloop.h znet.cpp znet.h zstream.h net-service.h net-service.cpp
+
+AM_CPPFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC
+AM_LDFLAGS = -Wall -pthread -m64 -std=c++11 -fPIC
+yals_SOURCES = ${AM_SOURCES} main.cpp 
+yals_CPPFLAGS = ${AM_CPPFLAGS}
+yals_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog -lrt
+async_SOURCES = async.cpp
+async_CPPFLAGS = ${AM_CPPFLAGS}
+async_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog -lrt
+client_SOURCES = client.cpp message_file.cpp
+client_CPPFLAGS = ${AM_CPPFLAGS}
+client_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog
+test_SOURCES = test.cpp base64.cpp
+test_CPPFLAGS = ${AM_CPPFLAGS}
+test_LDFLAGS = ${AM_LDFLAGS}  -L. -lzlog -lrt
+EXTRA_DIST = message_file.h 
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj
+am--refresh: Makefile
+	@:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	$(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+	fi; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	      echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	      $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+async$(EXEEXT): $(async_OBJECTS) $(async_DEPENDENCIES) $(EXTRA_async_DEPENDENCIES) 
+	@rm -f async$(EXEEXT)
+	$(async_LINK) $(async_OBJECTS) $(async_LDADD) $(LIBS)
+client$(EXEEXT): $(client_OBJECTS) $(client_DEPENDENCIES) $(EXTRA_client_DEPENDENCIES) 
+	@rm -f client$(EXEEXT)
+	$(client_LINK) $(client_OBJECTS) $(client_LDADD) $(LIBS)
+test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) $(EXTRA_test_DEPENDENCIES) 
+	@rm -f test$(EXEEXT)
+	$(test_LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS)
+yals$(EXEEXT): $(yals_OBJECTS) $(yals_DEPENDENCIES) $(EXTRA_yals_DEPENDENCIES) 
+	@rm -f yals$(EXEEXT)
+	$(yals_LINK) $(yals_OBJECTS) $(yals_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/async-async.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client-client.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client-message_file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-base64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-ant.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-base64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-card.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-message.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-net-service.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-point.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-tdoa_sync.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-web-client.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-worker.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yals-znet.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+async-async.o: async.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(async_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT async-async.o -MD -MP -MF $(DEPDIR)/async-async.Tpo -c -o async-async.o `test -f 'async.cpp' || echo '$(srcdir)/'`async.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/async-async.Tpo $(DEPDIR)/async-async.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='async.cpp' object='async-async.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(async_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o async-async.o `test -f 'async.cpp' || echo '$(srcdir)/'`async.cpp
+
+async-async.obj: async.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(async_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT async-async.obj -MD -MP -MF $(DEPDIR)/async-async.Tpo -c -o async-async.obj `if test -f 'async.cpp'; then $(CYGPATH_W) 'async.cpp'; else $(CYGPATH_W) '$(srcdir)/async.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/async-async.Tpo $(DEPDIR)/async-async.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='async.cpp' object='async-async.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(async_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o async-async.obj `if test -f 'async.cpp'; then $(CYGPATH_W) 'async.cpp'; else $(CYGPATH_W) '$(srcdir)/async.cpp'; fi`
+
+client-client.o: client.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT client-client.o -MD -MP -MF $(DEPDIR)/client-client.Tpo -c -o client-client.o `test -f 'client.cpp' || echo '$(srcdir)/'`client.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/client-client.Tpo $(DEPDIR)/client-client.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='client.cpp' object='client-client.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o client-client.o `test -f 'client.cpp' || echo '$(srcdir)/'`client.cpp
+
+client-client.obj: client.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT client-client.obj -MD -MP -MF $(DEPDIR)/client-client.Tpo -c -o client-client.obj `if test -f 'client.cpp'; then $(CYGPATH_W) 'client.cpp'; else $(CYGPATH_W) '$(srcdir)/client.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/client-client.Tpo $(DEPDIR)/client-client.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='client.cpp' object='client-client.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o client-client.obj `if test -f 'client.cpp'; then $(CYGPATH_W) 'client.cpp'; else $(CYGPATH_W) '$(srcdir)/client.cpp'; fi`
+
+client-message_file.o: message_file.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT client-message_file.o -MD -MP -MF $(DEPDIR)/client-message_file.Tpo -c -o client-message_file.o `test -f 'message_file.cpp' || echo '$(srcdir)/'`message_file.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/client-message_file.Tpo $(DEPDIR)/client-message_file.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='message_file.cpp' object='client-message_file.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o client-message_file.o `test -f 'message_file.cpp' || echo '$(srcdir)/'`message_file.cpp
+
+client-message_file.obj: message_file.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT client-message_file.obj -MD -MP -MF $(DEPDIR)/client-message_file.Tpo -c -o client-message_file.obj `if test -f 'message_file.cpp'; then $(CYGPATH_W) 'message_file.cpp'; else $(CYGPATH_W) '$(srcdir)/message_file.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/client-message_file.Tpo $(DEPDIR)/client-message_file.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='message_file.cpp' object='client-message_file.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o client-message_file.obj `if test -f 'message_file.cpp'; then $(CYGPATH_W) 'message_file.cpp'; else $(CYGPATH_W) '$(srcdir)/message_file.cpp'; fi`
+
+test-test.o: test.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT test-test.o -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.o `test -f 'test.cpp' || echo '$(srcdir)/'`test.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='test.cpp' object='test-test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-test.o `test -f 'test.cpp' || echo '$(srcdir)/'`test.cpp
+
+test-test.obj: test.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT test-test.obj -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.obj `if test -f 'test.cpp'; then $(CYGPATH_W) 'test.cpp'; else $(CYGPATH_W) '$(srcdir)/test.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='test.cpp' object='test-test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-test.obj `if test -f 'test.cpp'; then $(CYGPATH_W) 'test.cpp'; else $(CYGPATH_W) '$(srcdir)/test.cpp'; fi`
+
+test-base64.o: base64.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT test-base64.o -MD -MP -MF $(DEPDIR)/test-base64.Tpo -c -o test-base64.o `test -f 'base64.cpp' || echo '$(srcdir)/'`base64.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/test-base64.Tpo $(DEPDIR)/test-base64.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='base64.cpp' object='test-base64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-base64.o `test -f 'base64.cpp' || echo '$(srcdir)/'`base64.cpp
+
+test-base64.obj: base64.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT test-base64.obj -MD -MP -MF $(DEPDIR)/test-base64.Tpo -c -o test-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/test-base64.Tpo $(DEPDIR)/test-base64.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='base64.cpp' object='test-base64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
+
+yals-ant.o: ant.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-ant.o -MD -MP -MF $(DEPDIR)/yals-ant.Tpo -c -o yals-ant.o `test -f 'ant.cpp' || echo '$(srcdir)/'`ant.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-ant.Tpo $(DEPDIR)/yals-ant.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='ant.cpp' object='yals-ant.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-ant.o `test -f 'ant.cpp' || echo '$(srcdir)/'`ant.cpp
+
+yals-ant.obj: ant.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-ant.obj -MD -MP -MF $(DEPDIR)/yals-ant.Tpo -c -o yals-ant.obj `if test -f 'ant.cpp'; then $(CYGPATH_W) 'ant.cpp'; else $(CYGPATH_W) '$(srcdir)/ant.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-ant.Tpo $(DEPDIR)/yals-ant.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='ant.cpp' object='yals-ant.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-ant.obj `if test -f 'ant.cpp'; then $(CYGPATH_W) 'ant.cpp'; else $(CYGPATH_W) '$(srcdir)/ant.cpp'; fi`
+
+yals-base64.o: base64.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-base64.o -MD -MP -MF $(DEPDIR)/yals-base64.Tpo -c -o yals-base64.o `test -f 'base64.cpp' || echo '$(srcdir)/'`base64.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-base64.Tpo $(DEPDIR)/yals-base64.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='base64.cpp' object='yals-base64.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-base64.o `test -f 'base64.cpp' || echo '$(srcdir)/'`base64.cpp
+
+yals-base64.obj: base64.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-base64.obj -MD -MP -MF $(DEPDIR)/yals-base64.Tpo -c -o yals-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-base64.Tpo $(DEPDIR)/yals-base64.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='base64.cpp' object='yals-base64.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-base64.obj `if test -f 'base64.cpp'; then $(CYGPATH_W) 'base64.cpp'; else $(CYGPATH_W) '$(srcdir)/base64.cpp'; fi`
+
+yals-card.o: card.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-card.o -MD -MP -MF $(DEPDIR)/yals-card.Tpo -c -o yals-card.o `test -f 'card.cpp' || echo '$(srcdir)/'`card.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-card.Tpo $(DEPDIR)/yals-card.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='card.cpp' object='yals-card.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-card.o `test -f 'card.cpp' || echo '$(srcdir)/'`card.cpp
+
+yals-card.obj: card.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-card.obj -MD -MP -MF $(DEPDIR)/yals-card.Tpo -c -o yals-card.obj `if test -f 'card.cpp'; then $(CYGPATH_W) 'card.cpp'; else $(CYGPATH_W) '$(srcdir)/card.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-card.Tpo $(DEPDIR)/yals-card.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='card.cpp' object='yals-card.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-card.obj `if test -f 'card.cpp'; then $(CYGPATH_W) 'card.cpp'; else $(CYGPATH_W) '$(srcdir)/card.cpp'; fi`
+
+yals-message.o: message.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-message.o -MD -MP -MF $(DEPDIR)/yals-message.Tpo -c -o yals-message.o `test -f 'message.cpp' || echo '$(srcdir)/'`message.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-message.Tpo $(DEPDIR)/yals-message.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='message.cpp' object='yals-message.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-message.o `test -f 'message.cpp' || echo '$(srcdir)/'`message.cpp
+
+yals-message.obj: message.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-message.obj -MD -MP -MF $(DEPDIR)/yals-message.Tpo -c -o yals-message.obj `if test -f 'message.cpp'; then $(CYGPATH_W) 'message.cpp'; else $(CYGPATH_W) '$(srcdir)/message.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-message.Tpo $(DEPDIR)/yals-message.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='message.cpp' object='yals-message.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-message.obj `if test -f 'message.cpp'; then $(CYGPATH_W) 'message.cpp'; else $(CYGPATH_W) '$(srcdir)/message.cpp'; fi`
+
+yals-point.o: point.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-point.o -MD -MP -MF $(DEPDIR)/yals-point.Tpo -c -o yals-point.o `test -f 'point.cpp' || echo '$(srcdir)/'`point.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-point.Tpo $(DEPDIR)/yals-point.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='point.cpp' object='yals-point.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-point.o `test -f 'point.cpp' || echo '$(srcdir)/'`point.cpp
+
+yals-point.obj: point.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-point.obj -MD -MP -MF $(DEPDIR)/yals-point.Tpo -c -o yals-point.obj `if test -f 'point.cpp'; then $(CYGPATH_W) 'point.cpp'; else $(CYGPATH_W) '$(srcdir)/point.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-point.Tpo $(DEPDIR)/yals-point.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='point.cpp' object='yals-point.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-point.obj `if test -f 'point.cpp'; then $(CYGPATH_W) 'point.cpp'; else $(CYGPATH_W) '$(srcdir)/point.cpp'; fi`
+
+yals-tdoa_sync.o: tdoa_sync.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-tdoa_sync.o -MD -MP -MF $(DEPDIR)/yals-tdoa_sync.Tpo -c -o yals-tdoa_sync.o `test -f 'tdoa_sync.cpp' || echo '$(srcdir)/'`tdoa_sync.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-tdoa_sync.Tpo $(DEPDIR)/yals-tdoa_sync.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='tdoa_sync.cpp' object='yals-tdoa_sync.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-tdoa_sync.o `test -f 'tdoa_sync.cpp' || echo '$(srcdir)/'`tdoa_sync.cpp
+
+yals-tdoa_sync.obj: tdoa_sync.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-tdoa_sync.obj -MD -MP -MF $(DEPDIR)/yals-tdoa_sync.Tpo -c -o yals-tdoa_sync.obj `if test -f 'tdoa_sync.cpp'; then $(CYGPATH_W) 'tdoa_sync.cpp'; else $(CYGPATH_W) '$(srcdir)/tdoa_sync.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-tdoa_sync.Tpo $(DEPDIR)/yals-tdoa_sync.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='tdoa_sync.cpp' object='yals-tdoa_sync.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-tdoa_sync.obj `if test -f 'tdoa_sync.cpp'; then $(CYGPATH_W) 'tdoa_sync.cpp'; else $(CYGPATH_W) '$(srcdir)/tdoa_sync.cpp'; fi`
+
+yals-web-client.o: web-client.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-web-client.o -MD -MP -MF $(DEPDIR)/yals-web-client.Tpo -c -o yals-web-client.o `test -f 'web-client.cpp' || echo '$(srcdir)/'`web-client.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-web-client.Tpo $(DEPDIR)/yals-web-client.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='web-client.cpp' object='yals-web-client.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-web-client.o `test -f 'web-client.cpp' || echo '$(srcdir)/'`web-client.cpp
+
+yals-web-client.obj: web-client.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-web-client.obj -MD -MP -MF $(DEPDIR)/yals-web-client.Tpo -c -o yals-web-client.obj `if test -f 'web-client.cpp'; then $(CYGPATH_W) 'web-client.cpp'; else $(CYGPATH_W) '$(srcdir)/web-client.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-web-client.Tpo $(DEPDIR)/yals-web-client.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='web-client.cpp' object='yals-web-client.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-web-client.obj `if test -f 'web-client.cpp'; then $(CYGPATH_W) 'web-client.cpp'; else $(CYGPATH_W) '$(srcdir)/web-client.cpp'; fi`
+
+yals-worker.o: worker.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-worker.o -MD -MP -MF $(DEPDIR)/yals-worker.Tpo -c -o yals-worker.o `test -f 'worker.cpp' || echo '$(srcdir)/'`worker.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-worker.Tpo $(DEPDIR)/yals-worker.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='worker.cpp' object='yals-worker.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-worker.o `test -f 'worker.cpp' || echo '$(srcdir)/'`worker.cpp
+
+yals-worker.obj: worker.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-worker.obj -MD -MP -MF $(DEPDIR)/yals-worker.Tpo -c -o yals-worker.obj `if test -f 'worker.cpp'; then $(CYGPATH_W) 'worker.cpp'; else $(CYGPATH_W) '$(srcdir)/worker.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-worker.Tpo $(DEPDIR)/yals-worker.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='worker.cpp' object='yals-worker.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-worker.obj `if test -f 'worker.cpp'; then $(CYGPATH_W) 'worker.cpp'; else $(CYGPATH_W) '$(srcdir)/worker.cpp'; fi`
+
+yals-znet.o: znet.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-znet.o -MD -MP -MF $(DEPDIR)/yals-znet.Tpo -c -o yals-znet.o `test -f 'znet.cpp' || echo '$(srcdir)/'`znet.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-znet.Tpo $(DEPDIR)/yals-znet.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='znet.cpp' object='yals-znet.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-znet.o `test -f 'znet.cpp' || echo '$(srcdir)/'`znet.cpp
+
+yals-znet.obj: znet.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-znet.obj -MD -MP -MF $(DEPDIR)/yals-znet.Tpo -c -o yals-znet.obj `if test -f 'znet.cpp'; then $(CYGPATH_W) 'znet.cpp'; else $(CYGPATH_W) '$(srcdir)/znet.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-znet.Tpo $(DEPDIR)/yals-znet.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='znet.cpp' object='yals-znet.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-znet.obj `if test -f 'znet.cpp'; then $(CYGPATH_W) 'znet.cpp'; else $(CYGPATH_W) '$(srcdir)/znet.cpp'; fi`
+
+yals-net-service.o: net-service.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-net-service.o -MD -MP -MF $(DEPDIR)/yals-net-service.Tpo -c -o yals-net-service.o `test -f 'net-service.cpp' || echo '$(srcdir)/'`net-service.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-net-service.Tpo $(DEPDIR)/yals-net-service.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='net-service.cpp' object='yals-net-service.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-net-service.o `test -f 'net-service.cpp' || echo '$(srcdir)/'`net-service.cpp
+
+yals-net-service.obj: net-service.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-net-service.obj -MD -MP -MF $(DEPDIR)/yals-net-service.Tpo -c -o yals-net-service.obj `if test -f 'net-service.cpp'; then $(CYGPATH_W) 'net-service.cpp'; else $(CYGPATH_W) '$(srcdir)/net-service.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-net-service.Tpo $(DEPDIR)/yals-net-service.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='net-service.cpp' object='yals-net-service.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-net-service.obj `if test -f 'net-service.cpp'; then $(CYGPATH_W) 'net-service.cpp'; else $(CYGPATH_W) '$(srcdir)/net-service.cpp'; fi`
+
+yals-main.o: main.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-main.o -MD -MP -MF $(DEPDIR)/yals-main.Tpo -c -o yals-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-main.Tpo $(DEPDIR)/yals-main.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='main.cpp' object='yals-main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp
+
+yals-main.obj: main.cpp
+@am__fastdepCXX_TRUE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yals-main.obj -MD -MP -MF $(DEPDIR)/yals-main.Tpo -c -o yals-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi`
+@am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/yals-main.Tpo $(DEPDIR)/yals-main.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='main.cpp' object='yals-main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yals_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yals-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi`
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+cscope: cscope.files
+	test ! -s cscope.files \
+	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+
+clean-cscope:
+	-rm -f cscope.files
+
+cscope.files: clean-cscope  cscopelist
+
+cscopelist:  $(HEADERS) $(SOURCES) $(LISP)
+	list='$(SOURCES) $(HEADERS) $(LISP)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	test -d "$(distdir)" || mkdir "$(distdir)"
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	-test -n "$(am__skip_mode_fix)" \
+	|| find "$(distdir)" -type d ! -perm -755 \
+		-exec chmod u+rwx,go+rx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__post_remove_distdir)
+
+dist-bzip2: distdir
+	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+	$(am__post_remove_distdir)
+
+dist-lzip: distdir
+	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+	$(am__post_remove_distdir)
+
+dist-xz: distdir
+	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+	$(am__post_remove_distdir)
+
+dist-tarZ: distdir
+	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+	$(am__post_remove_distdir)
+
+dist-shar: distdir
+	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	$(am__post_remove_distdir)
+
+dist-zip: distdir
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(am__post_remove_distdir)
+
+dist dist-all:
+	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+	$(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+	case '$(DIST_ARCHIVES)' in \
+	*.tar.gz*) \
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+	*.tar.bz2*) \
+	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lz*) \
+	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+	*.tar.xz*) \
+	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+	*.tar.Z*) \
+	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+	*.shar.gz*) \
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+	*.zip*) \
+	  unzip $(distdir).zip ;;\
+	esac
+	chmod -R a-w $(distdir)
+	chmod u+w $(distdir)
+	mkdir $(distdir)/_build $(distdir)/_inst
+	chmod a-w $(distdir)
+	test -d $(distdir)/_build || exit 0; \
+	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && am__cwd=`pwd` \
+	  && $(am__cd) $(distdir)/_build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist \
+	  && rm -rf $(DIST_ARCHIVES) \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+	  && cd "$$am__cwd" \
+	  || exit 1
+	$(am__post_remove_distdir)
+	@(echo "$(distdir) archives ready for distribution: "; \
+	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+	@test -n '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: trying to run $@ with an empty' \
+	       '$$(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	$(am__cd) '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	@if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-am
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf $(top_srcdir)/autom4te.cache
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
+	clean-binPROGRAMS clean-cscope clean-generic cscope cscopelist \
+	ctags dist dist-all dist-bzip2 dist-gzip dist-lzip dist-shar \
+	dist-tarZ dist-xz dist-zip distcheck distclean \
+	distclean-compile distclean-generic distclean-tags \
+	distcleancheck distdir distuninstallcheck dvi dvi-am html \
+	html-am info info-am install install-am install-binPROGRAMS \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-binPROGRAMS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

+ 944 - 0
aclocal.m4

@@ -0,0 +1,944 @@
+# generated automatically by aclocal 1.12.3 -*- Autoconf -*-
+
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
+
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.12'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.12.3], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.12.3])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named 'Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running 'make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+[$0: two- and three-arguments forms are deprecated.  For more info, see:
+http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+			     [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+		  [_AM_DEPENDENCIES([CC])],
+		  [m4_define([AC_PROG_CC],
+			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+		  [_AM_DEPENDENCIES([CXX])],
+		  [m4_define([AC_PROG_CXX],
+			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+		  [_AM_DEPENDENCIES([OBJC])],
+		  [m4_define([AC_PROG_OBJC],
+			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+dnl Support for Objective C++ was only introduced in Autoconf 2.65,
+dnl but we still cater to Autoconf 2.62.
+m4_ifdef([AC_PROG_OBJCXX],
+[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+		  [_AM_DEPENDENCIES([OBJCXX])],
+		  [m4_define([AC_PROG_OBJCXX],
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST([install_sh])])
+
+# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN(['missing' script is too old or missing])
+fi
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
+m4_if([$1], [v7],
+     [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of '-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+

+ 172 - 0
ant.cpp

@@ -0,0 +1,172 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "ant.h"
+
+int ant::index()const
+{
+	return m_algo+(m_num_dims<<1);
+}
+
+ant_list*ant_list::instance()
+{
+	static ant_list _impl;
+	_impl.load_from_db();
+	return &_impl;
+}
+
+const algo_config&ant::config()const
+{
+	return g_config[m_algo+(m_num_dims<<1)];
+}
+
+
+loc_message::loc_message()
+	:m_ant(nullptr)
+	 ,m_num_ticks(0)
+{
+}
+int loc_message::tool_index()const
+{
+	return m_ant->index();
+}
+
+
+std::vector<point> loc_tool_tdoa_3_base::calc_location(const std::vector<loc_message>&locm)
+{
+	return std::vector<point>();
+}
+int loc_tool_tdoa_3_base::index() 
+{
+	return 5;
+}
+
+std::vector<point> loc_tool_tdoa_2_base::calc_location(const std::vector<loc_message>&locm)
+{
+	return std::vector<point>();
+}
+int loc_tool_tdoa_2_base::index() 
+{
+	return 3;
+}
+
+std::vector<point> loc_tool_tdoa_1_base::calc_location(const std::vector<loc_message>&locm)
+{
+	return std::vector<point>();
+}
+int loc_tool_tdoa_1_base::index() 
+{
+	return 1;
+}
+
+std::vector<point> loc_tool_tof_3_base::calc_location(const std::vector<loc_message>&locm)
+{
+	return std::vector<point>();
+}
+int loc_tool_tof_3_base::index() 
+{
+	return 4;
+}
+
+std::vector<point> loc_tool_tof_2_base::calc_location(const std::vector<loc_message>&locm)
+{
+	return std::vector<point>();
+}
+int loc_tool_tof_2_base::index() 
+{
+	return 2;
+}
+
+
+std::vector<point> loc_tool_tof_1_base::calc_location(const std::vector<loc_message>&locm)
+{
+	return std::vector<point>();
+}
+int loc_tool_tof_1_base::index() 
+{
+	return 0;
+}
+
+loc_tool_main::loc_tool_main()
+{
+	set_tool(new loc_tool_tof_1_base());
+	set_tool(new loc_tool_tof_2_base());
+	set_tool(new loc_tool_tof_3_base());
+	set_tool(new loc_tool_tdoa_1_base());
+	set_tool(new loc_tool_tdoa_2_base());
+	set_tool(new loc_tool_tdoa_3_base());
+}
+
+loc_tool_main::~loc_tool_main()
+{
+	for(auto&tool:g_tool)
+		delete tool;
+}
+
+void loc_tool_main::set_tool(loc_tool*tool)
+{
+	int index=tool->index();
+	if(g_tool[index])
+	{
+		delete g_tool[index];
+		g_tool[index]=0;
+	}
+	g_tool[index]=tool;
+}
+
+std::vector<point> loc_tool_main::calc_location(const std::vector<loc_message>&locm)
+{
+	if(locm.empty()) return {};
+	int tool_index=locm[0].tool_index(),i=1,len=locm.size();
+	for(;i<len;i++)
+	{
+		if(tool_index!=locm[i].tool_index())
+			break;
+	}
+
+	if(i==len)
+	{
+		return std::move(g_tool[tool_index]->calc_location(locm));
+	}
+
+	//包含至少两种定位方式的基站,目前只考虑两种
+	std::vector<loc_message> locm1,locm2;
+	locm1.assign(locm.begin(),locm.begin()+i);
+
+	for(;i<len;i++)
+	{
+		if(tool_index!=locm[i].tool_index())
+			locm2.push_back(locm[i]);
+		else
+			locm1.push_back(locm[i]);
+	}
+
+	std::vector<point> rc;
+	if(locm1[0].m_ant->config().best_msg_cnt<=(int)locm1.size())
+	{
+		rc=std::move(g_tool[tool_index]->calc_location(locm1));
+	}
+
+	if(locm1[1].m_ant->config().best_msg_cnt<=(int)locm2.size())
+	{
+		int index=locm2[0].tool_index();
+		auto v=std::move(g_tool[index]->calc_location(locm2));
+		rc.insert(rc.begin(),v.begin(),v.end());
+	}
+
+	return std::move(rc);
+}
+
+loc_tool* loc_tool_main::g_tool[6]={0,0,0,0,0,0};
+
+algo_config ant::g_config[]=
+{
+	{ "tof-1",  1, 2, 100, 1000 },
+	{ "tdoa-1", 2, 2, 100, 1000 },
+	{ "tof-2",  2, 3, 100, 1000 },
+	{ "tdoa-2", 3, 3, 100, 1000 },
+	{ "tof-3",  3, 4, 100, 1000 },
+	{ "tdoa-3", 4, 4, 100, 1000 }
+};
+

+ 148 - 0
ant.h

@@ -0,0 +1,148 @@
+#ifndef _ANT_LIST_HPP_
+#define _ANT_LIST_HPP_
+
+#include <math.h>
+#include <array>
+#include <deque>
+#include <tuple>
+#include <memory>
+#include <algorithm>
+#include "line.h"
+#include "point.h"
+
+struct path
+{
+	line_v	m_line; 
+	double  m_slope=0;
+};
+
+struct algo_config
+{
+	const char*desc;
+	int min_msg_cnt;
+	int best_msg_cnt;
+	int min_wait_time;
+	int max_wait_time;
+};
+
+struct ant
+{
+	static algo_config g_config[];
+	int      m_site_id;
+	int      m_algo;			//TOF:0,TDOA:1
+	int      m_num_dims;	    //1维:0,2维:1,3维:2
+	point    m_position;
+	std::vector<path> m_path;
+
+	int index()const;
+	const algo_config&config()const;
+};
+
+struct ant_list
+{
+	std::vector<ant*> m_ant_list;
+	ant*get(uint32_t site_id,uint32_t ant_id)
+	{
+		return 0;
+	}
+
+	void load_from_db()
+	{
+	
+	}
+
+	static ant_list*instance();
+};
+
+struct site
+{
+	std::vector<ant*> m_ant_list;
+};
+
+struct site_list
+{
+	std::vector<site*> m_site_list;
+
+	site*get(uint32_t site_id)
+	{
+		return 0;
+	}
+
+	void load_from_db()
+	{
+	
+	}
+	static site_list*instance();
+};
+
+
+struct loc_message
+{
+	ant*     m_ant;
+	uint64_t m_num_ticks; //tof时间片或tdoa相对root时间
+
+	loc_message();
+	loc_message(ant*a,uint64_t num_ticks)
+		:m_ant(a)
+		 ,m_num_ticks(num_ticks)
+	{}
+	int tool_index()const;
+};
+
+struct loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm)=0;
+	virtual int index()
+	{
+		return -1;
+	}
+	virtual ~loc_tool(){}
+};
+
+struct loc_tool_tdoa_3_base:loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
+	virtual int index();
+};
+
+struct loc_tool_tdoa_2_base:loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
+	virtual int index();
+};
+
+struct loc_tool_tdoa_1_base:loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
+	virtual int index();
+};
+
+struct loc_tool_tof_3_base:loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
+	virtual int index();
+};
+
+struct loc_tool_tof_2_base:loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
+	virtual int index();
+};
+
+struct loc_tool_tof_1_base:loc_tool
+{
+	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
+	virtual int index();
+};
+
+struct loc_tool_main:loc_tool
+{
+	static loc_tool* g_tool[6];
+	loc_tool_main();
+	~loc_tool_main();
+	static void set_tool(loc_tool*tool);
+	std::vector<point> calc_location(const std::vector<loc_message>&locm);
+};
+
+#endif
+

+ 115 - 0
async.cpp

@@ -0,0 +1,115 @@
+
+#include <log.h>
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <vector>
+#include <list>
+#include <thread>
+#include <atomic>
+#include <algorithm>
+
+#define EV_MULTIPLICITY 1
+#define EV_SIGNAL_ENABLE 1
+#define EV_ASYNC_ENABLE 1
+#include <ev++.h>
+
+#include <clock.h>
+#include <zio.h>
+#include <znet.h>
+
+struct io_thread:ev::dynamic_loop
+{
+	std::atomic<bool> m_stop_flag{false};
+	std::thread*m_thread;
+	ev::async   m_async;
+	uint64_t    m_count;
+	io_thread ()
+	{
+		m_count=0;
+		m_async.set(*this);
+		m_async.set<io_thread,&io_thread::on_async>(this);
+		m_async.start();
+
+		m_thread=new std::thread(std::bind(&io_thread::run,this));
+	}
+
+	void on_async()
+	{
+		if(m_stop_flag.load())
+			ev::dynamic_loop::break_loop(ev::ALL);
+			
+		++m_count;
+	}
+
+	void run()
+	{
+		dynamic_loop::run(0);
+		log_info("thread exit.");
+	}
+
+	void destroy()
+	{
+		m_thread->join();
+		delete this;
+	}
+
+	void notify(int i)
+	{
+		if(i==0)
+		{
+			m_stop_flag.store(true);
+		}
+		m_async.send();
+	}
+private:
+	~io_thread()
+	{
+		delete m_thread;
+	}
+};
+
+int main()
+{
+//	log_init("log.ini");
+
+	std::vector<io_thread*>   ivec;
+
+	const int NUM_THREAD=4;
+
+	for(int i=0;i<NUM_THREAD;i++)
+	{
+		ivec.push_back(new io_thread());
+	}
+
+	zclock c;
+	uint64_t atps=0;
+	uint64_t tps=0;
+
+	for(uint64_t i=1;i<1e8;i++)
+	{
+		for(auto&t:ivec)
+		{
+			tps++;
+			atps++;
+			t->notify(i);
+		}
+
+		if((i-1)%1000==0 && c.count_ms()>1000)
+		{
+			std_info("tps=%ld,all=%ld",tps,atps);
+			tps=0;
+			c.reset();
+		}
+	}
+
+	std::for_each(ivec.begin(),ivec.end(),[](io_thread*i){
+		i->notify(0);
+		i->destroy();
+		std_info("thread_counter=%d",i->m_count);
+	});
+	
+	return 0;
+}
+

+ 88 - 0
base64.cpp

@@ -0,0 +1,88 @@
+namespace base64
+{
+	unsigned char BASE64DECODE[256] =
+	{
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3e,0xff,0xff,0xff,0x3f,
+		0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0xff,0xff,0xff,0x40,0xff,0xff,
+		0xff,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
+		0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xff,0xff,0xff,0xff,0xff,
+		0xff,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
+		0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+		0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+	};
+
+	void encode(const unsigned char* in,int inlen,unsigned char* out)
+	{
+		const char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+		for (; inlen >= 3; inlen -= 3)
+		{
+			*out++ = base64digits[in[0] >> 2];
+			*out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
+			*out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
+			*out++ = base64digits[in[2] & 0x3f];
+			in += 3;
+		}
+		if (inlen > 0)
+		{
+			unsigned char fragment;
+
+			*out++ = base64digits[in[0] >> 2];
+			fragment = (in[0] << 4) & 0x30;
+			if (inlen > 1)
+				fragment |= in[1] >> 4;
+			*out++ = base64digits[fragment];
+			*out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
+			*out++ = '=';
+		}
+		*out = '\0';
+	}
+
+	unsigned char *decode(char *base64code, int base64length, unsigned char *out, int &outlen)
+	{
+		unsigned char *pCode = (unsigned char *)base64code;
+		unsigned char *pBegin = out;
+		unsigned char *pEnd = out + outlen;  
+		unsigned char uCode;
+		for (int i = 0; (i < base64length) && (out < pEnd); i++)
+		{
+			uCode = BASE64DECODE[pCode[i]];
+			if (uCode >= 64)
+				break;
+			switch( i%4 )
+			{
+				case 0:
+					*out = uCode<<2;
+					break;
+				case 1:
+					*out = *out | (uCode >> 4);
+					out++;
+					if (out >= pEnd)
+						break;
+					*out = uCode << 4;
+					break;
+				case 2:
+					*out = *out | (uCode >> 2);
+					out++;
+					if (out >= pEnd)
+						break;
+					*out = uCode << 6;
+					break;
+				case 3:
+					*out = *out | uCode;
+					out++;
+					break;
+			}
+		}
+		outlen = out - pBegin;
+		return pBegin;
+	}
+}

+ 9 - 0
base64.h

@@ -0,0 +1,9 @@
+#ifndef __base64__hpp__
+#define __base64__hpp__
+namespace base64
+{
+	void encode(const unsigned char* in,int inlen,unsigned char* out);
+	unsigned char *decode(char *base64code, int base64length, unsigned char *out, int &outlen);
+}
+#endif
+

+ 126 - 0
c2.cpp

@@ -0,0 +1,126 @@
+
+struct rect
+{
+
+};
+
+struct area_interface
+{
+	uint32_t    m_id;
+	std::string m_name;
+	std::atomic<int> m_card_count;
+
+	int id();
+	std::string name();
+	int  get_card_count();
+
+	double get_limit_speed();
+	double get_limit_time_second();
+	double get_limit_card_count();
+
+
+	virtual int type()=0;//site:0,normal:1
+
+	void inc_card_count(int deta)
+	{
+	
+	}
+
+	virtual ~area_interface(){}
+};
+
+struct normal_area:area_interface
+{
+	rect        m_bound;
+};
+
+struct site_area:area_interface
+{
+	uint32_t   m_site_id;
+};
+
+struct area_main
+{
+	std::vector<area_interface*> m_normal_list,m_site_list;
+
+	area_interface*get_normal_area(int id);
+
+	area_interface*get_normal_area(const point&pt);
+	area_interface*get_site_area(int site_id);
+};
+
+struct area_hover
+{
+	area*  m_area;
+	time_t m_enter_time,m_last_time,m_leave_time;
+};
+
+struct card_area_tool
+{
+	area_hover m_prev,m_last;
+	area_hover m_prev_site,m_last_site;
+
+	void on_point(const char* card_id,int site_id,const point&pt,double speed)
+	{
+		{
+			area_interface *a=area_main_inst->get_site_area(site_id);
+			on_site_area_point(a,card_id);
+		}
+
+		{
+			area_interface *a=area_main_inst->get_normal_area(pt);
+			on_site_area_point(a,card_id);
+		}
+	}
+
+	//插入进入新分站记录 //离开分站时更新记录//本版本只在数据库生成记录
+	void on_site_area_point(a,card_id,site_id,speed)
+	{
+		if(enter) do_att_biz(a,card_id);
+	}
+
+	//人卡考勤
+	void do_att_biz(a,card_id)
+	{
+	
+	
+	}
+
+	//生成卡进入区域、在区域活跃和离开区域的调用
+	void on_normal_area_point(a,card_id,pt,speed)
+	{
+		if(hover) do_hover_biz(a,card_id,pt,speed);
+		if(enter) do_enter_biz(a,card_id,pt,speed);
+	}
+
+	//检测是否超时
+	void on_timer(card_id)
+	{
+	
+	}
+
+	void do_hover_biz(a,card_id,pt,speed)
+	{
+		//区域超时超时检测
+		//区域超速检测
+		//电子围栏检测
+	}
+
+	void do_enter_biz(a,card_id,pt,speed)
+	{
+		//当前区域超员检测
+		//车卡考勤逻辑检测
+		//电子围栏检测
+	}
+};
+
+struct person_card:card
+{
+	card_area_tool*m_area_tool;
+
+	void on_point(int site_id,const point&pt,double speed)
+	{
+		m_area_tool->on_point(m_id,site_id,pt,speed);
+	}
+};
+

+ 194 - 0
card.cpp

@@ -0,0 +1,194 @@
+#include <memory>
+#include <ant.h>
+#include <log.h>
+#include <card.h>
+#include <zloop.h>
+#include <ev++.h>
+
+struct card_location_base
+{
+	virtual void on_location(const std::vector<point>&vp)=0;
+	virtual ~card_location_base(){};
+};
+
+//一张卡一个ct的所有不同天线的信息
+struct one_ct_message_handle
+{
+	static loc_tool_main m_loc_tool;
+	ev::timer m_min_timer,m_max_timer;
+	std::vector<loc_message> m_msg_list;
+	card_location_base*m_card;
+	const algo_config*m_ac=nullptr;
+	int  m_ct;
+	bool m_min_timeout=false;
+	one_ct_message_handle(ev::dynamic_loop&loop,card_location_base*card)
+	{
+		m_card=card;
+		m_ct=-1;
+
+		m_min_timer.set(loop);
+		m_min_timer.set<one_ct_message_handle,&one_ct_message_handle::on_min_timer>(this);
+		m_max_timer.set(loop);
+		m_max_timer.set<one_ct_message_handle,&one_ct_message_handle::on_max_timer>(this);
+	}
+
+	void reset()
+	{
+		m_ct=-1;
+		m_min_timeout=false;
+		m_msg_list.clear();
+	}
+
+	void on_min_timer()
+	{
+		m_min_timer.stop();
+
+		if((int)m_msg_list.size()>=m_ac->best_msg_cnt)
+		{
+			m_max_timer.stop();
+			calc_location();
+		}
+	}
+
+	void on_max_timer()
+	{
+		m_max_timer.stop();
+		calc_location();
+	}
+
+	void on_message(const message_locinfo&loc)
+	{
+		if(!m_msg_list.empty()&& m_ct!=loc.m_card_ct)
+			m_msg_list.clear();
+
+		ant*a=ant_list::instance()->get(loc.m_site_id, loc.m_ant_id);
+		if(m_msg_list.empty())
+		{
+			m_ct=loc.m_card_ct;
+			m_ac=&a->config();
+			m_min_timeout=false;
+
+			m_msg_list.push_back(loc_message(a,loc.m_tof));
+
+			//启动本CT的最小、最大两个定时器
+			m_min_timer.start(m_ac->min_wait_time);
+			m_max_timer.start(m_ac->min_wait_time);
+			return;
+		}
+
+		m_msg_list.push_back(loc_message(a,loc.m_tof));
+
+		if(m_min_timeout && (int)m_msg_list.size()>=m_ac->best_msg_cnt)
+		{
+			calc_location();
+			m_max_timer.stop();
+		}
+	}
+
+    void calc_location()
+	{
+		std::vector<point> rc=std::move(m_loc_tool.calc_location(m_msg_list));
+
+		if(!rc.empty()) m_card->on_location(std::move(rc));
+
+		reset();
+	}
+};
+
+struct card_message_handle
+{
+	card_location_base*m_card;
+	std::vector<loc_message> m_msg_list;
+	std::array<one_ct_message_handle*,16> m_ct_list;
+
+	card_message_handle(zloop_base&loop,card_location_base*card)
+	{
+		m_card=card;
+
+		for(size_t i=0;i<m_ct_list.size();i++)
+		{
+			m_ct_list[i]=new one_ct_message_handle(loop,card);
+		}
+	}
+
+	void on_message(const message_locinfo&loc,bool is_history)
+	{
+		if(is_history)
+		{
+			log_warn("%s","当前代码没有处理历史消息记录。");
+			return;
+		}
+
+		m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loc);
+	}
+};
+
+struct card:card_location_base
+{
+	card_message_handle m_message_handle;
+	card(zloop_base&loop)
+		:m_message_handle(loop,this)
+	{
+	}
+
+	void on_message(const message_locinfo&loc,bool is_history)
+	{
+		m_message_handle.on_message(loc,is_history);
+	}
+
+	void on_location(const std::vector<point>&points)
+	{
+	}
+
+	~card(){}
+};
+
+loc_tool_main one_ct_message_handle::m_loc_tool;
+struct card_list_impl:card_list
+{
+	zloop<task*>&m_loop;
+	std::vector<card*> m_list;
+	card_list_impl(zloop<task*>&loop)
+		:m_loop(loop)
+	{
+		m_list.reserve(1<<16);
+	}
+
+	void init_card_from_db()
+	{
+		card _(m_loop);
+	}
+
+	card*get(uint64_t card_id)const
+	{
+		uint32_t cid=0xFFFF&card_id;
+
+		if(cid>=m_list.size())
+			return nullptr;
+
+		return m_list[cid];
+	}
+
+	void on_message(const message_locinfo&loc,bool is_history)
+	{
+		card*c=get(loc.m_card_id);
+
+		if(c==nullptr)
+		{
+			log_warn("数据库中未定义该卡的信息,card_id=%d", loc.m_card_id);
+			return;
+		}
+
+		log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d",
+				loc.m_site_id,loc.m_ant_id,loc.m_card_id,loc.m_tof,loc.m_rav,loc.m_acc,loc.m_rssi);
+
+		c->on_message(loc,is_history);
+	}
+};
+
+card_list *card_list::instance(zloop<task*>&loop)
+{
+	static card_list_impl _impl(loop);
+	return &_impl;
+}
+

+ 19 - 0
card.h

@@ -0,0 +1,19 @@
+#ifndef _CARD_HPP_
+#define _CARD_HPP_
+#include <message.h>
+#include <ev++.h>
+
+struct task;
+template<typename T> struct zloop;
+
+struct card_list
+{
+	virtual void on_message(const message_locinfo&loc,bool is_history)=0;
+	virtual ~card_list(){}
+
+	static card_list *instance(zloop<task*>&loop);
+};
+
+#endif
+
+

+ 64 - 0
card_timer.xx

@@ -0,0 +1,64 @@
+struct card_timer
+{
+	ev::dynamic_loop&m_loop;
+	std::vector<ct_timer*> m_timers;
+	std::vector<int> m_timers_free;
+
+	card_timer(ev::dynamic_loop&loop)
+		:m_loop(loop)
+	{
+		grow();
+	}
+
+	~card_timer()
+	{
+		for(auto&i:m_timers)
+			delete i;
+	}
+
+	void grow()
+	{
+		int on=m_timers.size();
+		int n=on<<1;
+		if(n==0) 	
+			n=4;
+
+		m_timers.resize(n);
+		for(int i=on;i<n;i++)
+		{
+			m_timers[i]=new ct_timer();
+			m_timers[i]->m_id=i;
+			m_timers_free.push_back(i);
+		}
+	}
+
+	void alloc_timer(int delay_ms,int ct,int type)
+	{
+		if(m_timers_free.empty())
+			grow();
+
+		int id=m_timers_free.back(); m_timers_free.pop_back();
+		m_timers[id]->start<card_timer,&card_timer::on_timer>(m_loop,this,delay_ms,ct,type);
+	}
+
+	void free_timer(int ct,int type)
+	{
+		for(int i=0,len=m_timers.size();i<len;i++)
+		{
+			if(m_timers[i]->m_ct==ct && m_timers[i]->m_type==type)
+			{
+				m_timers[i]->stop();
+				m_timers_free.push_back(i);
+				break;
+			}
+		}
+	}
+
+	virtual void on_ct_timer(int ct,int type)=0;
+
+	void on_timer(ev::timer&t,int)
+	{
+		ct_timer&tmp=*(ct_timer*)&t;
+		on_ct_timer(tmp.m_ct,tmp.m_type);
+	}
+};

+ 64 - 0
client.cpp

@@ -0,0 +1,64 @@
+
+#include "log.h"
+#include "zio.h"
+#include "message_file.h"
+
+int main()
+{
+	int sock=zio::build_stream();
+
+	if(zio::connect(sock,"127.0.0.1",4000))
+	{
+		return -1;
+	}
+
+	zio::setiobuf(sock,32<<10,64<<10);
+	zio::setblocking(sock,false);
+	int len=1;
+	int count=0x400+2;
+	char buf[8192];
+	uint64_t time;
+#if 1
+
+	for(int i=0;i<8000;i++)
+	{
+		buf[i]='1';
+	}
+
+	buf[0]=0x04;
+	buf[1]=0x00;
+
+
+
+	char recv_buf[8192];
+	for(;;)
+	{
+		while(zio::read(sock,recv_buf,sizeof(recv_buf))>0);
+		if(count!=zio::writev(sock,buf,count))
+			break;
+	}
+#else
+	message_file mf(stdin);
+	count=0;
+	while(len>0)
+	{
+		while((len=mf.get_line(&time,&buf[count],sizeof(buf)-count)))
+		{
+			count+=len;
+			if(count>1024)
+				break;
+		}
+
+		log_info("count=%d",count);
+		if(count!=zio::writev(sock,buf,count))
+			break;
+
+		count=0;
+	}
+#endif
+
+	zio::close(sock);
+
+	return 0;
+}
+

+ 92 - 0
clock.h

@@ -0,0 +1,92 @@
+#ifndef _clock_hpp_zzj_
+#define _clock_hpp_zzj_
+
+#include <time.h>
+
+#ifdef _MSC_VER
+struct zclock
+{
+	unsigned m_start;
+	zclock()
+	{
+		m_start=GetTickCount ();
+	}
+
+	long long count_us() const
+	{
+		return 1000L*count_ms();
+	}
+
+	unsigned count_ms()const
+	{
+		return (GetTickCount()-m_start);
+	}
+
+	void reset()
+	{
+		m_start=GetTickCount ();
+	}
+	
+	long long pin_us()
+	{
+		return 1000L*pin_ms();
+	}
+
+	unsigned pin_ms()
+	{
+		unsigned rc=count_ms();
+		m_start=GetTickCount();
+		return rc;
+	}
+};
+#else
+struct zclock
+{
+	struct timespec m_start;
+
+	zclock()
+	{
+		clock_gettime(CLOCK_MONOTONIC,&m_start);
+	}
+
+	void reset()
+	{
+		clock_gettime(CLOCK_MONOTONIC,&m_start);
+	}
+
+	long long count_us() const
+	{
+		struct timespec m_tmp;
+		clock_gettime(CLOCK_MONOTONIC,&m_tmp);
+
+		long long ret=(m_tmp.tv_sec-m_start.tv_sec)*1000000;
+		ret+=(m_tmp.tv_nsec-m_start.tv_nsec)/1000;
+
+		return ret;
+	}
+
+	unsigned count_ms()const
+	{
+		return count_us()/1000;	
+	}
+	
+	long long pin_us()
+	{
+		struct timespec m_tmp;
+		clock_gettime(CLOCK_MONOTONIC,&m_tmp);
+
+		long long ret=(m_tmp.tv_sec-m_start.tv_sec)*1000000;
+		ret+=(m_tmp.tv_nsec-m_start.tv_nsec)/1000;
+
+		m_start=m_tmp;
+
+		return ret;
+	}
+
+	unsigned pin_ms()
+	{
+		return pin_us()/1000;
+	}
+};
+#endif
+#endif

Diff do ficheiro suprimidas por serem muito extensas
+ 6454 - 0
configure


+ 44 - 0
configure.ac

@@ -0,0 +1,44 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([yals], [1.0], [BUG-REPORT-ADDRESS])
+AC_CONFIG_SRCDIR([main.cpp])
+
+AM_INIT_AUTOMAKE([foreign -Wall])
+AC_CONFIG_MACRO_DIR([m4])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+
+# Checks for libraries.
+# FIXME: Replace `main' with a function in `-lev':
+AC_CHECK_LIB([ev], [main])
+# FIXME: Replace `main' with a function in `-lzlog':
+AC_CHECK_LIB([zlog], [main])
+
+# Checks for header files.
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdint.h string.h sys/socket.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_CHECK_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_SIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([inet_ntoa memset socket])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+

+ 1 - 0
depcomp

@@ -0,0 +1 @@
+/usr/share/automake-1.12/depcomp

+ 1 - 0
install-sh

@@ -0,0 +1 @@
+/usr/share/automake-1.12/install-sh

+ 350 - 0
io_buf.h

@@ -0,0 +1,350 @@
+#ifndef _in_buff_hpp_
+#define _in_buff_hpp_
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include "clock.h"
+
+struct buff_t
+{
+private:
+	char*ptr_;
+	int len_;
+	int owner_;
+public:
+	buff_t(const buff_t&);
+	buff_t() :ptr_(0) ,len_(0) ,owner_(0)
+	{
+	}
+
+	buff_t(char*ptr,int len,bool owner=false)
+		:ptr_(ptr) ,len_(len) ,owner_(owner?1:0)
+	{
+	}
+
+	char*ptr()const
+	{
+		return ptr_;
+	}
+
+	bool empty()const
+	{
+		return len_==0;
+	}
+
+	int size()const
+	{
+		return len_;
+	}
+
+	int len()const
+	{
+		return len_;
+	}
+
+	void set(int len)
+	{
+		len_=len;
+	}
+
+	void reset(void*ptr,int len,bool owner)
+	{
+		if(owner_) ::free(ptr_);
+
+		ptr_=(char*)ptr;
+		len_=len;
+		owner_=owner?1:0;
+	}
+
+	void clear()
+	{
+		reset(0,0,0);
+	}
+
+	~buff_t()
+	{
+		if(owner_)
+		{
+			::free(ptr_);
+		}
+	}
+};
+
+struct buf_base
+{
+private:
+	buf_base(const buf_base&);
+protected:
+	char*m_base;
+	int  m_mask,m_size;
+	int64_t m_ppos,m_gpos;
+public:
+
+	buf_base(int size)
+	{
+		m_size=256;
+		while(m_size<size)
+			m_size<<=1;
+
+		m_base=(char*)::malloc(m_size);
+		m_mask=m_size-1;
+
+		m_ppos=m_gpos=0;
+	}
+
+	void grow(int add_size)
+	{
+		int size=m_size;
+		while(size<m_size+add_size)
+			size<<=1;
+
+		m_gpos=pos(m_gpos);
+		m_ppos=pos(m_ppos);
+		if(m_ppos<m_gpos)
+			m_ppos+=size;
+
+		m_base=(char*)::realloc(m_base,size);
+		m_size=size;
+		m_mask=m_size-1;
+	}
+
+	~buf_base()
+	{
+		::free(m_base);
+	}
+
+	int size()const
+	{
+		return m_size;
+	}
+
+	inline int pos(int64_t p)const
+	{
+		return (int)p&m_mask;
+	}
+
+	int len_data() const
+	{
+		return m_ppos-m_gpos;
+	}
+
+	int len_free() const
+	{
+		return size()-len_data();
+	}
+
+	int operator[](int i)const
+	{
+		if(i>len_data())
+			return -1;
+
+		return (int)(uint8_t)m_base[pos(i+m_gpos)];
+	}
+
+	uint8_t& operator[](int i)
+	{
+		return *(uint8_t*)&m_base[pos(i+m_gpos)];
+	}
+};
+
+struct in_buff:buf_base
+{
+	in_buff(int size)
+		:buf_base(size)
+	{
+	}
+
+	~in_buff()
+	{
+	}
+
+	buff_t alloc()
+	{
+		const int ppos=pos(m_ppos);
+		const int gpos=pos(m_gpos);
+		int len=gpos<=ppos ?size()-ppos :gpos-ppos;
+
+		return len==0?buff_t(0,0):buff_t(m_base+ppos,len);
+	}
+
+	void commit(int len)
+	{
+		m_ppos+=len;
+	}
+
+	void free(int len)
+	{
+		m_gpos+=len;
+	}
+
+	buff_t peek()
+	{
+		const int ppos=pos(m_ppos);
+		const int gpos=pos(m_gpos);
+
+		return buff_t(m_base+gpos,gpos<=ppos?ppos-gpos:size()-gpos);
+	}
+
+/*
+	char*peek(char*buf,int len)
+	{
+		if(len>len_data())
+			return 0;
+
+		buff_t b=peek();
+
+		if(b.len()>=len)
+			return b.ptr();
+
+		memcpy(buf,b.ptr(),b.len());
+		memcpy(buf+b.len(),m_base,len-b.len());
+		return buf;
+	}
+	*/
+
+	buff_t get(int len)
+	{
+		if(len>len_data())
+			return buff_t(0,0);
+
+		buff_t b=peek();
+		if(b.len()>=len)
+		{
+			free(len);
+			return b;
+		}
+		else
+		{
+			buff_t r ((char*)malloc(len),len,1);
+			memcpy(r.ptr(),b.ptr(),b.len());
+			memcpy(r.ptr()+b.len(),m_base,len-b.len());
+			free(len);
+			return r;
+		}
+	}
+
+	buff_t get(const char*chim)
+	{
+		int len=find(chim);
+		if(len==0)
+			return buff_t();
+
+		return get(len);
+	}
+
+	char*get(char *buf,int len)
+	{
+		if(len>len_data())
+			return 0;
+
+		buff_t b=peek();
+		if(b.len()>=len)
+		{
+			memcpy(buf,b.ptr(),len);
+		}
+		else
+		{
+			memcpy(buf,b.ptr(),b.len());
+			memcpy(buf+b.len(),m_base,len-b.len());
+		}
+
+		free(len);
+		return buf;
+	}
+
+	void skip(int len)
+	{
+		free(len);
+	}
+
+	int find(const char*chim)const
+	{
+		int slen=strlen(chim);
+		for(int64_t p=m_gpos;p<m_ppos;)
+		{
+			if(m_base[this->pos(p++)]!=chim[0])
+				continue;
+
+			int j=1;
+			for(;j<slen;j++)
+			{
+				if(m_base[pos(p++)]!=chim[j])
+					break;
+			}
+
+			if(j==slen)
+				return p-m_gpos;
+		}
+
+		return 0;
+	}
+
+};
+/*
+struct out_buff:buf_base
+{
+	out_buff(int size)
+		:buf_base(size)
+	{
+	}
+
+	~out_buff()
+	{
+	}
+
+	bool push(const char*d,int len,unsigned time_out_ms=-1)
+	{
+		int counter=10000;
+
+		zclock c;
+		for(;;)
+		{
+			int64_t ppos=ztomic::load(&m_ppos);
+			int64_t gpos=ztomic::load(&m_gpos);
+
+			if(ppos-gpos+len>size()|| !ztomic::cas(&m_ppos,&ppos,ppos+len))
+			{
+				if(c.count_ms()>=time_out_ms)
+					return false;
+				
+				counter=yield(counter);
+				continue;
+			}
+
+			int p=pos(ppos);
+			int c=p+len-size();
+			if(c<=0)
+			{
+				memcpy(m_base+p,d,len);
+			}
+			else
+			{
+				memcpy(m_base+p,d,len-c);
+				memcpy(m_base,d+len-c,c);
+			}
+
+			break;
+		}
+
+		return true;
+	}
+
+	void free(int len)
+	{
+		ztomic::fetch_add(&m_gpos,len);
+	}
+
+	char*peek(int*len)
+	{
+		const int p=pos(m_ppos);
+		const int g=pos(m_gpos);
+
+		*len=g<=p?p-g:size()-g;
+		return m_base+g;
+	}
+
+};
+*/
+#endif
+

+ 1 - 0
libzlog.so

@@ -0,0 +1 @@
+../log/libzlog.so

+ 224 - 0
line.h

@@ -0,0 +1,224 @@
+#ifndef _LINE_HPP_
+#define _LINE_HPP_
+#include "point.h"
+struct line
+{
+	double a,b,c;
+	line()
+		:a(0)
+		,b(0)
+		,c(0)
+	{
+	}
+	line(double k,double b_)
+		:a(k)
+		,b(-1)
+		,c(b_)
+	{
+	}
+
+	line(double a_,double b_,double c_)
+		:a(a_)
+		,b(b_)
+		,c(c_)
+	{
+	}
+
+	line(const point&p0,const point&p1)
+	{
+		set(p0,p1);
+	}
+
+	void clear()
+	{
+		a=b=c=0;
+	}
+
+	bool empty() const
+	{
+		return a==0 && b==0 && c==0;
+	}
+
+	void set(const point&p0,const point&p1)
+	{
+		auto abc=p0.get_abc(p1);
+
+		a=std::get<0>(abc);
+		b=std::get<1>(abc);
+		c=std::get<2>(abc);
+	}
+
+	std::string to_string()const
+	{
+		char buf[256];
+		int len=sprintf(buf,"a=%.3lf,b=%.3lf,c=%.3lf",a,b,c);
+		return std::string(buf,len);
+	}
+
+	double cos_k()const
+	{
+		if(b==0) 
+			return 0;
+
+		double k=-a/b;
+
+		return 1/sqrt(1+k*k);
+	}
+
+	double sin_k()const
+	{
+		if(b==0) 
+			return 1;
+
+		double k=-a/b;
+
+		return k/sqrt(1+k*k);
+	}
+
+	double arg()const
+	{
+		return acos(cos_k())*(sin_k()>0?1:-1);
+	}
+
+	static bool eq(double a,double b,double e)
+	{
+		return fabs(a-b)<e;
+	}
+
+	point projection(const point&lv)const
+	{
+		line pp(-b,a,b*lv.x-a*lv.y);
+		return crossing(pp);
+	}
+
+	double dist(const point&v)const
+	{
+		return v.dist(projection(v));
+	}
+
+	bool parallel(const line&l2)const
+	{
+		return eq(cos_k(),l2.cos_k(),0.0001) && eq(sin_k(),l2.sin_k(),0.0001);
+	}
+
+	point  crossing(const line&l)const
+	{
+		if(parallel(l))
+			return point();
+
+		return point ( (c*l.b-l.c*b) /(l.a*b-a*l.b) ,
+			           (c*l.a-l.c*a) /(l.b*a-b*l.a) );
+	}
+
+	bool contain(const point&p,double e)const
+	{
+		return contain(p.x,p.y,e);
+	}
+
+	bool contain(double x,double y,double e)const
+	{
+		return fabs(a*x+b*y+c)<e;
+	}
+};
+struct line_v:line//线段
+{
+	std::array<point,2> v;
+	line_v()
+	{
+		v[0].set(0,0);
+		v[1].set(0,0);
+	}
+
+	line_v(const point&p0,const point&p1)
+		:line(p0,p1)
+	{
+		v[0]=p0;
+		v[1]=p1;
+	}
+
+	point&operator[](int i) { return v[i]; }
+	const point&operator[](int i)const { return v[i]; }
+
+	std::string to_string()const
+	{
+		char buf[256];
+		int len=sprintf(buf,"[(%.3lf,%.3lf),(%.3lf,%.3lf)]",v[0].x,v[0].y,v[1].x,v[1].y);
+
+		return std::string(buf,len);
+	}
+
+	point  crossing(const line&l)const
+	{
+		point pt=line::crossing(l);
+
+		return contain(pt)?pt:point();
+	}
+
+	point  crossing(const line_v&l)const
+	{
+		point pt=line::crossing(l);
+
+		return contain(pt)&&l.contain(pt)?pt:point();
+	}
+
+	bool is_same(const line_v&l,double e=0.0001)const
+	{
+		return line::contain(l[0],e) && line::contain(l[1],e);
+	}
+
+	point  projection(const point&p)const
+	{
+		point pt=line::projection(p);
+		return contain(pt)?pt:point();
+	}
+
+	line_v projection(const line_v&lv)const
+	{
+		std::array<point,2> o,t;
+
+		o[0]=line::projection(lv[0]);
+		o[1]=line::projection(lv[1]);
+		if(o[1]<o[0]) o[0].swap(o[1]);
+
+		t[0]=v[0];
+		t[1]=v[1];
+		if(t[1]<t[0]) t[0].swap(t[1]);
+		
+		if(o[1] < t[0] || t[1] < o[0])
+			return line_v(point(0,0),point(0,0));
+
+		return line_v(point::max(t[0],o[0]),point::min(t[1],o[1]));
+	}
+
+	bool empty()const
+	{
+		return length()<0.01;
+	}
+
+	double length()const
+	{
+		return v[0].dist(v[1]);
+	}
+
+	bool contain(const point&p,double e=0.0001)const
+	{
+		return contain(p.x,p.y,e);
+	}
+
+	bool contain(double x,double y,double e=0.0001)const
+	{
+		return eq(v[0].dist(v[1]),v[0].dist(x,y)+v[1].dist(x,y),0.0001);
+	}
+
+	double dist(const point&v)const
+	{
+		point p=projection(v);
+		if(p.empty())
+			return -1;
+
+		return v.dist(p);
+	}
+};
+#endif
+
+

+ 1 - 0
log.h

@@ -0,0 +1 @@
+../log/log.h

+ 27 - 0
log.ini

@@ -0,0 +1,27 @@
+
+main.fname=yals.log
+main.time_align=h	#m:分钟,h:小时,d:天
+main.min_size=1		#1M
+main.level=info	    #error,info,warn,debug
+main.queue_size=8192
+main.show_thread=0
+main.show_srcline=0
+main.show_level=1
+
+log1.fname=los.log
+log1.time_align=d	#m:分钟,h:小时,d:天
+log1.min_size=100		#1M
+log1.level=debug
+log1.show_thread=0
+log1.show_srcline=0
+log1.show_level=0
+log1.queue_size=8192
+
+log2.fname=
+log2.time_align=d	#m:分钟,h:小时,d:天
+log2.min_size=10		#1M
+log2.level=info
+log2.show_thread=1
+log2.show_srcline=0
+log2.show_level=0
+

+ 1 - 0
logger

@@ -0,0 +1 @@
+../log/logger

+ 14 - 0
main.cpp

@@ -0,0 +1,14 @@
+
+#include <log.h>
+#include <net-service.h>
+
+int main()
+{
+	log_init("log.ini");
+
+	net_service mh;
+	service_handle::instance(&mh)->run(4000);
+
+	return 0;
+}
+

+ 89 - 0
message.cpp

@@ -0,0 +1,89 @@
+#include <math.h>
+#include "zstream.h"
+#include "message.h"
+
+void message_locinfo::zero_this()
+{
+	memset(this,0,sizeof(*this));
+}
+
+void message_locinfo::load(zistream&is,bool tdoa)
+{
+	zero_this();
+	uint8_t b;
+	uint32_t i;
+	//卡类型、卡号、CT、电池状态
+	is>>b>>m_card_id>>m_card_ct>>m_batty_status;
+	m_card_type=b;
+	m_batty_status&=0xF;
+
+
+	//角度
+	is>>b;
+	if(m_card_type==1)
+	{
+		m_callinfo=b;
+	}
+	else
+	{
+		m_rav=((b&0x80)?-1.:1.)*(b&0x7f)*3;
+	}
+
+	//加速度
+	is>>b;
+	m_acc=((b&0x80)?-1.:1.)*(b&0x7f)*98;
+
+	//TOF
+	is>>b>>i; 	
+	m_tof=b;
+	m_tof=(m_tof<<32)|i;
+
+	//天线号
+	is>>m_ant_id;
+	--m_ant_id;
+
+	if(tdoa)
+	{
+		//同步序号,冲击响应丢弃
+		is>>m_sync_ct>>skip(2);
+	}
+
+	//信号电平值
+	uint16_t sp1=0,sp2=0;
+	is>>sp1>>sp2;
+	m_rssi=10*log10(1.*sp1*(1<<17)/pow(sp2-64.,2))-121.74;
+}
+
+void message_tdoasync::zero_this()
+{
+	memset(this,0,sizeof(*this));
+}
+
+void message_tdoasync::load(zistream&is)
+{
+	zero_this();
+	uint8_t b;
+
+	//本地分站ID和天线ID
+	is>>m_local_site_id>>b; m_local_ant_id=b;
+
+	//上级分站ID和天线ID
+	is>>m_parent_site_id>>b; m_parent_ant_id=b;
+
+	//根分站CT和本机级别
+	is>>m_sync_ct>>m_local_level;
+
+	uint32_t i;
+
+	//本级发出的时间
+	is>>b>>i; 	
+	m_send_time=b;
+	m_send_time=(m_send_time<<32)|i;
+
+	//本级收到的时间
+	is>>b>>i; 	
+	m_recv_time=b;
+	m_recv_time=(m_recv_time<<32)|i;
+}
+
+

+ 49 - 0
message.h

@@ -0,0 +1,49 @@
+#ifndef __MESSAGE_HPP__
+#define __MESSAGE_HPP__
+#include <stdint.h>
+#include <time.h>
+
+struct zistream;
+
+//	分站传上来的卡定位数据,包括tof,tdoa
+struct message_locinfo
+{
+	uint64_t m_time_stamp;
+	uint32_t m_site_id;
+	time_t   m_site_time;
+
+	uint32_t m_card_type;
+	uint32_t m_card_id;
+	uint64_t m_tof;
+	uint16_t m_card_ct;
+	uint16_t m_batty_status;
+	uint8_t  m_callinfo;//0x80-呼救,0x01-一般呼叫,0x02-紧急呼叫
+	uint8_t  m_rav;
+	uint8_t  m_acc;
+	uint8_t  m_ant_id;
+	uint16_t m_sync_ct;
+	uint16_t m_rssi;
+
+	void zero_this();
+    void load(zistream&is,bool tdoa);
+};
+
+//tdoa分站同步数据
+struct message_tdoasync
+{
+	uint32_t m_local_site_id;
+	uint32_t m_parent_site_id;
+	uint16_t m_local_ant_id;
+	uint16_t m_parent_ant_id;
+	uint16_t m_sync_ct;
+	uint16_t m_local_level;
+	uint64_t m_recv_time;
+	uint64_t m_send_time;
+
+	void zero_this();
+    void load(zistream&is);
+};
+
+#endif
+
+

+ 151 - 0
message_file.cpp

@@ -0,0 +1,151 @@
+#define _XOPEN_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <memory.h>
+#include <time.h>
+#include <stdint.h>
+#include "message_file.h"
+
+namespace
+{
+char decode[256];
+char encode[256][3];
+bool code_init_flag=false;
+
+void init_code()
+{
+	memset(decode,0,sizeof(decode));
+	memset(encode,0,sizeof(encode));
+	for(int c='A';c<='F';c++)
+		decode[c]=c-'A'+10;
+
+	for(int c='0';c<='9';c++)
+		decode[c]=c-'0';
+	
+	for(int i=0;i<256;i++)
+	{
+		sprintf(encode[i],"%02X",i);
+	}
+	
+	decode['\r']=-1;
+	decode['\n']=-1;
+	decode[' ']=-1;
+}
+
+inline int ch2int(const char c)
+{
+	return (int) (uint8_t) c;
+}
+
+inline int convert(const char*p,char*o)
+{
+	char c;
+	char*r=o;
+	for(;*p;p++)
+	{
+		if(decode[ch2int(*p)]<0)
+			continue;
+
+		 c=decode[ch2int(*p++)]<<4;
+		*o++=c+decode[ch2int(*p)];
+	}
+	return o-r;
+}
+}
+
+message_file::message_file(FILE*fp)
+{
+	m_last_line[0]=0;
+	m_file=fp;
+	m_owner=false;
+	
+	if(!code_init_flag)
+	{
+		init_code();
+		code_init_flag=true;
+	}
+}
+
+message_file::message_file(const char*fname)
+{
+	m_last_line[0]=0;
+	m_file=fopen(fname,"r");
+	m_owner=true;
+	
+	if(!code_init_flag)
+	{
+		init_code();
+		code_init_flag=true;
+	}
+}
+
+message_file::~message_file()
+{
+	if(m_owner)
+		fclose(m_file);
+}
+
+inline const char* now(char*date_str,uint64_t time)
+{
+	time_t ntime=time/1000;
+	struct tm buff;
+	const struct tm*t=localtime_r(&ntime, &buff);
+
+	sprintf(date_str,"%d-%02d-%02d %02d:%02d:%02d.%03d" ,
+			t->tm_year+1900,t->tm_mon+1,t->tm_mday,
+			t->tm_hour,t->tm_min,t->tm_sec,(int)(time%1000));
+
+	return date_str;
+}
+
+int message_file::put_line(uint64_t time,char*buf,int buflen)
+{
+	char b[8192];
+
+	printf("[%s]\n",now(b,time));
+	int n=0,t;
+	for(int i=0;i<buflen;i++)
+	{
+		t=(int)(unsigned char)buf[i];
+		n+=sprintf(&b[n],"%s ",encode[t]);
+	}
+
+	printf("%s\n",b);
+
+	return 0;
+}
+
+int message_file::get_line(uint64_t*time,char*buf,int buflen)
+{
+	const char*p;
+	while(m_last_line[0]!='[')
+	{ 
+		if(fgets(m_last_line,sizeof(m_last_line),m_file)==nullptr)
+			return 0;
+	}
+
+	{
+		struct tm tm;
+		memset(&tm, 0, sizeof(struct tm));
+		const char*ms=strptime(&m_last_line[1], "%Y-%m-%d %H:%M:%S", &tm);
+
+		*time=1000*mktime(&tm)+atoi(ms+1);
+	}
+
+	char*o=buf;
+	for(;;)
+	{
+		if(nullptr==(p=fgets(m_last_line,sizeof(m_last_line),m_file)))
+			return 0;
+
+		if(*p=='[')
+			break;
+
+		o+=convert(p,o);
+	}
+
+	return o-buf;
+}
+

+ 25 - 0
message_file.h

@@ -0,0 +1,25 @@
+#ifndef _MESSAGE_PARSE_HPP_
+#define _MESSAGE_PARSE_HPP_
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+struct message_file
+{
+private:
+	bool  m_owner;
+	FILE* m_file;
+	char  m_last_line[256];
+	message_file(const message_file&);
+public:
+
+	message_file(const char*fname);
+	message_file(FILE*fp);
+	~message_file();
+	
+	
+	int get_line(uint64_t*time,char*buf,int buflen);
+	int put_line(uint64_t time,char*buf,int buflen);
+};
+
+#endif
+

+ 1 - 0
missing

@@ -0,0 +1 @@
+/usr/share/automake-1.12/missing

+ 90 - 0
net-service.cpp

@@ -0,0 +1,90 @@
+
+#include <thread>
+#include <mutex>
+#include <atomic>
+#include <iostream>
+#include <memory>
+#include <string.h>
+#include <math.h>
+
+#include <log.h>
+#include <znet.h>
+#include <zstream.h>
+
+#include "worker.h"
+#include "tdoa_sync.h"
+#include "net-service.h"
+
+net_service::net_service()
+{
+	m_loc_worker=worker::instance();
+	m_sync_worker=tdoa_sync::instance();
+}
+
+net_service::~net_service()
+{
+	m_loc_worker->stop();
+}
+
+void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t len)
+{
+	std::vector<char> v(data,data+len);
+	clt->send(std::move(v));
+
+	//		log_info("recv a message ,len=%d",len);
+	//		logn_bin(1,"50ms .test",data,len);
+	return;
+
+	zistream is(data,len-2);
+	uint16_t cmd;
+	is>>skip(2)>>cmd;
+	switch(cmd)
+	{
+		case 0x843b://tof
+			{
+				uint32_t site_id;
+				is>>site_id>>skip(12);
+				while(!is.eof())
+				{
+					task*t=task::alloc<message_locinfo>();
+					message_locinfo&m=t->body<message_locinfo>();
+					m.load(is,cmd==0x863b);
+					m.m_site_id=site_id;
+					t->m_cmd_code=cmd;
+					t->m_hash_id=m.m_card_id;
+					m_loc_worker->request(t);
+				}
+			}
+			break;
+		case 0x863b://tdoa
+			{
+				uint32_t site_id;
+				is>>site_id>>skip(12);
+				while(!is.eof())
+				{
+					task*t=task::alloc<message_locinfo>();
+					message_locinfo&m=t->body<message_locinfo>();
+					m.load(is,cmd==0x863b);
+					m.m_site_id=site_id;
+					t->m_cmd_code=cmd;
+					t->m_hash_id=m.m_card_id;
+					m_sync_worker->translate(m);
+					m_loc_worker->request(t);
+				}
+			}
+			break;
+		case 0xa78d://time sync
+			{
+				message_tdoasync m;
+				m.load(is);
+				m_sync_worker->on_message(m);
+			}
+			//site_message::on_sync(this,t.m_param1);
+			break;
+		case 0x853b://tof his
+		case 0x873b://tdoa his
+			break;
+		case 0x804c://ctrl site message
+			break;
+	}
+}

+ 21 - 0
net-service.h

@@ -0,0 +1,21 @@
+#ifndef __net_service_hpp__
+#define __net_service_hpp__
+
+#include <znet.h>
+
+struct client;
+struct worker;
+struct tdoa_sync;
+
+struct net_service:service_callback
+{
+	worker*   m_loc_worker;
+	tdoa_sync*m_sync_worker;
+
+	net_service();
+	~net_service();
+	void on_message(std::shared_ptr<client> clt,const char*data,size_t len);
+};
+
+#endif
+

+ 20 - 0
point.cpp

@@ -0,0 +1,20 @@
+#include "point.h"
+
+point::point() 
+	:x(0) ,y(0)
+{
+}
+
+void point::set(double x_,double y_) 
+{
+	x=x_;
+	y=y_;
+}
+
+void point::swap(point&p)
+{
+	point tmp=*this;
+	*this=p;
+	p=tmp;
+}
+

+ 124 - 0
point.h

@@ -0,0 +1,124 @@
+#ifndef _POINT_HPP_
+#define _POINT_HPP_
+#include <math.h>
+#include <tuple>
+struct point
+{
+	point();
+	point(double x_,double y_)
+		:x(x_)
+		,y(y_)
+	{
+	
+	}
+
+	static point min(const point&a,const point&b)
+	{
+		return b<a?b:a;
+	}
+
+	static point max(const point&a,const point&b)
+	{
+		return a<b?b:a;
+	}
+
+	void set(const point&p)
+	{
+		x=p.x;
+		y=p.y;
+	}
+
+	void set(double,double);
+	void swap(point&p);
+
+	bool operator<(const point&p)const
+	{
+		double c=x-p.x;
+		if(c!=0) 
+			return c<0;
+
+		return y-p.y<0;
+	}
+
+	static bool eq(double l,double r,double deta)
+	{
+		return fabs(l-r)<=deta;
+	}
+
+	bool empty()const
+	{
+		return x==0 && y==0;
+	}
+
+	bool operator==(const point&r)const
+	{
+		return x==r.x && y==r.y;
+	}
+
+	double dist_direct(const point&o)const
+	{
+		double d=dist(o);
+		return o<*this?-d:d;
+	}
+
+	//计算this到(x,y)的距离
+	double dist_direct(double x,double y)const
+	{
+		return dist_direct(point(x,y));
+
+	}
+
+	double dist(const point&o)const
+	{
+		return dist(o.x,o.y);
+	}
+
+	//计算this到(x,y)的距离
+	double dist(double x,double y)const
+	{
+		double dx=this->x-x;
+		double dy=this->y-y;
+		return sqrt(dx*dx+dy*dy);
+	}
+
+	double cos_k(const point&o)const
+	{
+		double dx=o.x-x;
+		double dy=o.y-y;
+		return dx/sqrt(dx*dx+dy*dy);
+	}
+
+	double sin_k(const point&o)const
+	{
+		double dx=o.x-x;
+		double dy=o.y-y;
+		return dy/sqrt(dx*dx+dy*dy);
+	}
+
+	point middle(const point&o)const
+	{
+		return point((x+o.x)/2,(y+o.y)/2);
+	}
+
+	std::tuple<double,double,double> get_abc(const point&o)const
+	{
+		double cos=fabs(cos_k(o));
+		if(cos==0)
+			return std::make_tuple(1,0,-x);
+
+		if(cos==1)
+			return std::make_tuple(0,1,-y);
+
+		double dx=o.x-x;
+		double dy=o.y-y;
+		double k=dy/dx;
+		double deno=sqrt(k*k+1);
+		return std::make_tuple(k/deno,-1/deno,(y-k*x)/deno);
+		//return std::make_tuple(k,-1,y-k*x);
+	}
+
+public:
+	double x,y;
+};
+#endif
+

+ 25 - 0
tdoa_sync.cpp

@@ -0,0 +1,25 @@
+#include "tdoa_sync.h"
+
+
+struct tdoa_sync_impl:tdoa_sync
+{
+	virtual void on_message(message_tdoasync&msg)
+	{
+	
+	
+	}
+
+	virtual void translate(message_locinfo&tdoa_msg)
+	{
+	
+	
+	}
+};
+
+tdoa_sync*tdoa_sync::instance()
+{
+	static tdoa_sync_impl _impl;
+
+	return &_impl;
+}
+

+ 19 - 0
tdoa_sync.h

@@ -0,0 +1,19 @@
+#ifndef _TDOA_SYNC_HPP_
+#define _TDOA_SYNC_HPP_
+
+#include "message.h"
+
+struct tdoa_sync
+{
+	//分站TDOA同步消息发送到此接口
+	virtual void on_message(message_tdoasync&sync_msg)=0;
+
+	//将tdoa定位消息中的时间戳换算为同步链中最低级别的时间戳
+	virtual void translate(message_locinfo&tdoa_msg)=0;
+
+	//单例
+	static tdoa_sync*instance();
+};
+
+#endif
+

+ 353 - 0
test.cpp

@@ -0,0 +1,353 @@
+#include <unistd.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include <clock.h>
+#include <zio.h>
+#include <log.h>
+#include <zloop.h>
+
+#include "base64.h"
+#include "io_buf.h"
+
+struct web_client_http:ev::io
+{
+	in_buff m_buff;
+	int m_data_len=-1;
+	int m_mask_pos=-1;
+	int m_data_pos=-1;
+	int m_fd,m_status;
+
+	web_client_http()
+		:m_buff(8192)
+	{
+		m_fd=-1;
+	}
+
+	int connect_tcp(const char*ip,int port)
+	{
+		int fd=zio::build_stream();
+		if(zio::connect(fd,ip,port))
+		{
+			zio::close(fd);
+			return m_fd=-1;
+		}
+
+		zio::setiobuf(fd,16<<10,16<<10);
+		zio::setblocking(fd,false);
+
+		return m_fd=fd;
+	}
+
+	void ws_reset()
+	{
+		if(m_data_pos+m_data_len>0)
+		{
+			m_buff.free(m_data_len+m_data_pos);
+		}
+
+		m_data_len=-1;
+		m_mask_pos=-1;
+		m_data_pos=-1;
+	}
+
+	bool ws_fin()const
+	{
+		return (m_buff[0]&0x80) != 0;
+	}
+
+	bool ws_more()const
+	{
+		return (m_buff[0]&0xF) ==0 ;
+	}
+
+	bool ws_text()const
+	{
+		return (m_buff[0]&0xF) ==1 ;
+	}
+
+	bool ws_bin()const
+	{
+		return (m_buff[0]&0xF) ==2 ;
+	}
+
+	bool ws_ping()const
+	{
+		return (m_buff[0]&0xF) ==9 ;
+	}
+
+	bool ws_pong()const
+	{
+		return (m_buff[0]&0xF) ==10 ;
+	}
+
+	bool ws_close()const
+	{
+		return (m_buff[0]&0xF) ==8 ;
+	}
+
+	bool ws_mask()const
+	{
+		return (m_buff[1]&0x80) !=0 ;
+	}
+
+	int parse_length()
+	{
+		if(m_buff.len_data()<2)
+			return -1;
+
+		if(m_data_pos>0)
+			return 0;
+
+		if((m_buff[1]&0x7F)<=125)
+		{
+			m_mask_pos=ws_mask()?2:-1;
+			m_data_pos=ws_mask()?6:2;
+
+			m_data_len=m_buff[1]&0x7F;
+		}
+		else
+		if((m_buff[1]&0x7F)==126)
+		{
+			if(m_buff.len_data()<4)
+				return -1;
+
+			m_mask_pos=ws_mask()?4:-1;
+			m_data_pos=ws_mask()?8:4;
+
+			m_data_len=(m_buff[2]<<8) | m_buff[3];
+		}
+		else
+		{
+			if(m_buff.len_data()<9)
+				return -1;
+
+			m_mask_pos=ws_mask()?9:-1;
+			m_data_pos=ws_mask()?13:9;
+
+			//不考虑大于20G的数据
+			m_data_len=(m_buff[6]<<24)|(m_buff[7]<<16)|(m_buff[8]<<8)|(m_buff[9]);
+		}
+		
+		int i=0;
+		for(i=0;i<m_data_len;i++)
+		{
+			uint8_t b=m_buff[m_data_pos+i];
+			if(b>=0x30 && b<=0x39)
+				continue;
+			break;
+		}
+
+		m_data_len-=i;
+		m_data_pos+=i;
+
+		return 0;
+	}
+
+	void mask(const uint8_t*m,uint8_t*d,int len)
+	{
+		for(int i=0;i<len;i++)
+			d[i]=d[i]^m[i&3];
+	}
+
+	int ws_parse()
+	{
+		if(parse_length()<0)
+			return -1;
+
+		if(m_buff.len_data()<m_data_pos+m_data_len)
+			return -1;
+
+		if(ws_mask())
+		{
+			mask(&m_buff[m_mask_pos],&m_buff[m_data_pos],m_data_len);
+		}
+
+		for(int i=0;i<m_data_len;i++)
+		{
+			printf("%c",m_buff[m_data_pos+i]);
+		}
+
+		printf("\n\n");
+
+		return 0;
+	}
+
+
+	int connect_ws(const char*ip,int port)
+	{
+		unsigned char k[16], k6[128];
+
+		for(size_t i=0;i<sizeof(k);i++)
+			k[i]=rand();
+
+		base64::encode(k,sizeof(k),k6);
+
+		const char*fmt=
+			"GET /socket.io/?EIO=3&transport=websocket HTTP/1.1\r\n"
+			"Host: %s:%d\r\n"
+			"Connection: Upgrade\r\n"
+			"Pragma: no-cache\r\n"
+			"Cache-Control: no-cache\r\n"
+			"Upgrade: websocket\r\n"
+			"Origin: http://%s:%d\r\n"
+			"Sec-WebSocket-Version: 13\r\n"
+			"Accept-Encoding: gzip, deflate\r\n"
+			"Accept-Language: zh-CN,zh;q=0.9\r\n"
+			"Sec-WebSocket-Key: %s\r\n"
+			"Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n\r\n";
+
+		if(connect_tcp(ip,port)<0)	
+			return -1;
+
+		char buf[512];
+		int len=sprintf(buf,fmt,ip,port,ip,port,k6);
+
+		if(len!=zio::writev(m_fd, buf, len))
+		{
+			close();
+			return -1;
+		}
+
+		sleep(1);
+		if(read_until("\r\n\r\n")<=0)
+		{
+			close();
+			return -1;
+		}
+
+		if(m_buff.find("101 Switching Protocols\r\n"))
+		{
+			m_buff.skip(m_buff.find("\r\n\r\n"));
+			return 0;
+		}
+
+		close();
+		return -1;
+	}
+
+	int read_until(const char*what,int timeout=10*1000)
+	{
+		int rc=0;
+		zclock c;
+		for(;;)
+		{
+			buff_t b=m_buff.alloc();
+			if(b.empty())
+			{
+				m_buff.grow(1024);
+				b=m_buff.alloc();
+			}
+
+			int len=zio::read(m_fd,b.ptr(),b.len());
+
+			if((int)c.count_ms()>timeout)
+			{
+				log_error("websocket read timeout in %dms",timeout);
+				return -1;
+			}
+
+			if(len==-1)
+			{
+				return -1;
+			}
+
+			if(len==-2)
+				continue;
+
+			if(len==0)
+			{
+				log_info("remote close the socket");
+				return 0;
+			}
+
+			m_buff.commit(len);
+			rc+=len;
+
+			if(m_buff.find(what))
+				return rc;
+		}
+	}
+
+
+	void close()
+	{
+		zio::close(m_fd);
+	}
+
+	~web_client_http()
+	{
+		close();
+	}
+};
+
+int realpath_test()
+{
+	char buf[4096];
+
+	realpath(".",buf);
+	log_info("curpath=%s",buf);
+
+	return 0;
+}
+
+#if 0
+std::string test_json()
+{
+	struct json
+	{
+		json&put(const char*k,const json&n)
+		{
+		
+			return *this;
+		}
+	
+		json&put(const char*k,int v)
+		{
+		
+			return *this;
+		}
+		json&put(const char*k,const char*v)
+		{
+		
+			return *this;
+		}
+
+		std::string to_string()const
+		{
+			return std::string();
+		}
+	};
+
+	return json().put("cmd","login")
+				 .put("data",json()
+				 	 .put("uname","wyj")
+					 .put("passwd",111111)
+				  ).to_string();
+}
+#endif
+
+int main()
+{
+	unsigned char buf[32];
+	const char*s64="puVOuWb7rel6z2AVZBKnfw==";
+
+	int blen=32;
+	base64::decode((char*)s64,strlen(s64),buf,blen);
+
+	web_client_http client;
+	client.connect_ws("60.220.238.150",8086);
+
+	for(;;)
+	{
+		while(client.ws_parse()==0)
+			client.ws_reset();
+
+		client.read_until("\n");
+	}
+
+	return 0;
+}
+
+

+ 179 - 0
web-client.cpp

@@ -0,0 +1,179 @@
+
+#include <thread>
+#include <memory>
+#include <memory>
+#include <ev++.h>
+
+#include "zio.h"
+#include "log.h"
+#include "zloop.h"
+#include "web-client.h"
+
+struct web_client_http:ev::io
+{
+	char*m_buff;
+	int m_pos,m_size;
+	int m_fd,m_status;
+
+	web_client_http()
+	{
+		m_fd=-1;
+		m_pos=0;
+		m_size=4096;
+		m_buff=(char*)malloc(m_size);
+	}
+
+	int connect_tcp(const char*ip,int port)
+	{
+		int fd=zio::build_stream();
+		if(zio::connect(fd,"127.0.0.1",4000))
+		{
+			zio::close(fd);
+			return m_fd=-1;
+		}
+
+		zio::setiobuf(fd,16<<10,16<<10);
+		zio::setblocking(fd,false);
+
+		return m_fd=fd;
+	}
+
+	int connect_ws(const char*ip,int port)
+	{
+		const char*fmt=
+				"GET / HTTP/1.1\n"
+				"Connection:Upgrade\n"
+				"Host:127.0.0.1:8088\n"
+				"Sec-WebSocket-Extensions:x-webkit-deflate-frame\n"
+				"Sec-WebSocket-Key:puVOuWb7rel6z2AVZBKnfw==\n"
+				"Sec-WebSocket-Version:13\n"
+				"Upgrade:webet\n";
+
+		if(connect_tcp(ip,port)<0)	
+			return -1;
+
+		int len=strlen(fmt);
+		if(len!=zio::writev(m_fd,fmt,len))
+		{
+			close();
+			return -1;
+		}
+
+		for(;;)
+		{
+			len=zio::read(m_fd,m_buff+m_pos,m_size-m_pos);
+			if(len==-1)
+			{
+				close();
+				return -1;
+			}
+
+			if(len==-2)
+				continue;
+
+			m_pos+=len;
+			m_buff[m_pos]=0;
+			if(strstr(m_buff,"\n\n"))
+				break;
+		}
+
+		log_info("http debug:%s",m_buff);
+	}
+
+	void close()
+	{
+		zio::close(m_fd);
+	}
+
+	~web_client_http()
+	{
+		close();
+		::free(m_buff);
+	}
+};
+
+struct web_client_net_impl: web_client,zloop_base
+{
+	std::unique_ptr<std::thread> m_thread;
+
+	std::mutex m_mutex;
+	std::list<std::string> m_req_list;
+
+	ev::timer m_check_timer;
+
+	std::string m_ip;
+	int m_port;
+
+	web_client_net_impl ()
+	{
+		m_thread.reset(new std::thread(std::bind(&web_client_net_impl::run,this)));
+	}
+
+	virtual void on_async_0()
+	{
+		if(check_stop_flag()) 
+			return;
+
+		std::list<std::string> async_list;
+		{
+			std::unique_lock<std::mutex> _lock(m_mutex);
+			m_req_list.swap(async_list);
+		}
+		on_async(async_list);
+	}
+
+	void on_async(const std::list<std::string>&req)
+	{
+	
+	}
+
+
+	void on_check_timer(ev::timer&t,int)
+	{
+	
+	}
+
+	void run()
+	{
+		m_check_timer.set(*this);
+		m_check_timer.set<web_client_net_impl,&web_client_net_impl::on_check_timer>(this);
+		m_check_timer.start(0.,1.);
+
+		ev::dynamic_loop::run(0);
+		log_info("web_client_net_impl exit.");
+	}
+
+	void post(const char*m,int len)
+	{
+		{
+			std::unique_lock<std::mutex> _lock(m_mutex);
+			m_req_list.push_back(std::string(m,len));
+		}
+
+		m_async.send();
+	}
+
+	void stop()
+	{
+		async_stop();
+		m_thread->join();
+	}
+
+	std::atomic<bool> m_start_flag{false};
+	void start()
+	{
+		if(m_start_flag.load())
+			return;
+
+		m_start_flag.store(true);
+	}
+};
+
+
+web_client*web_client::instance(const char*ip,int port,const char*path)
+{
+	static web_client_net_impl impl;
+	impl.start();
+	return &impl;
+}
+

+ 14 - 0
web-client.h

@@ -0,0 +1,14 @@
+#ifndef _web_client_hpp_
+#define _web_client_hpp_
+
+struct web_client
+{
+	virtual void  post(const char*m,int mlen)=0;
+	virtual void stop()=0;
+
+	static web_client*instance(const char*ip,int port,const char*path);
+};
+
+#endif
+
+

+ 82 - 0
webc.i

@@ -0,0 +1,82 @@
+struct web_client_http:ev::io
+{
+	char*m_buff;
+	int m_pos,m_size;
+	int m_fd,m_status;
+
+	web_client_http()
+	{
+		m_fd=-1;
+		m_pos=0;
+		m_size=4096;
+		m_buff=(char*)malloc(m_size);
+	}
+
+	int connect_tcp(const char*ip,int port)
+	{
+		int fd=zio::build_stream();
+		if(zio::connect(fd,"127.0.0.1",4000))
+		{
+			zio::close(fd);
+			return m_fd=-1;
+		}
+
+		zio::setiobuf(fd,16<<10,16<<10);
+		zio::setblocking(fd,false);
+
+		return m_fd=fd;
+	}
+
+	int connect_ws(const char*ip,int port)
+	{
+		const char*fmt=
+				"GET / HTTP/1.1\n"
+				"Connection:Upgrade\n"
+				"Host:127.0.0.1:8088\n"
+				"Sec-WebSocket-Extensions:x-webkit-deflate-frame\n"
+				"Sec-WebSocket-Key:puVOuWb7rel6z2AVZBKnfw==\n"
+				"Sec-WebSocket-Version:13\n"
+				"Upgrade:webet\n";
+
+		if(connect_tcp(ip,port)<0)	
+			return -1;
+
+		int len=strlen(fmt);
+		if(len!=zio::writev(m_fd,fmt,len))
+		{
+			close();
+			return -1;
+		}
+
+		for(;;)
+		{
+			len=zio::read(m_fd,m_buff+m_pos,m_size-m_pos);
+			if(len==-1)
+			{
+				close();
+				return -1;
+			}
+
+			if(len==-2)
+				continue;
+
+			m_pos+=len;
+			m_buff[m_pos]=0;
+			if(strstr(m_buff,"\n\n"))
+				break;
+		}
+
+		log_info("http debug:%s",m_buff);
+	}
+
+	void close()
+	{
+		zio::close(m_fd);
+	}
+
+	~web_client_http()
+	{
+		close();
+		::free(m_buff);
+	}
+};

+ 127 - 0
worker.cpp

@@ -0,0 +1,127 @@
+#include <list>
+#include <vector>
+#include <mutex>
+#include <atomic>
+#include <memory>
+#include <thread>
+
+#include <ev++.h>
+
+#include "log.h"
+#include "worker.h"
+#include "message.h"
+#include "card.h"
+#include "zloop.h"
+
+struct worker_thread: zloop<task*>
+{
+	std::unique_ptr<std::thread> m_thread;
+
+	card_list*m_card_list;
+
+	worker_thread ()
+	{
+		m_thread.reset(new std::thread(std::bind(&worker_thread::run,this)));
+		m_card_list=card_list::instance(*this);//*********
+	}
+
+	void run()
+	{
+		ev::dynamic_loop::run(0);
+		log_info("worker_thread exit.");
+	}
+
+	virtual void on_async(const std::list<task*>&task_list)
+	{
+		for(task*t:task_list)
+		{
+			do_task(*t);
+			free(t);
+		}
+	}
+
+	void do_task(const task&t)
+	{
+		switch(t.m_cmd_code)
+		{
+			case 0x843b://tof
+			case 0x863b://tdoa
+				log_info("card loc message%04X",t.m_cmd_code);
+				m_card_list->on_message(t.body<message_locinfo>(),false);
+				//card_message::on_loc_message(this,t.m_param1);
+			break;
+			case 0x853b://tof his
+			case 0x873b://tdoa his
+				log_info("site history message%04X",t.m_cmd_code);
+				m_card_list->on_message(t.body<message_locinfo>(),true);
+				//site_message::on_sync(this,t.m_param1);
+			break;
+
+			case 0x804c://ctrl site message
+				log_info("ctrl site message%04X",t.m_cmd_code);
+			break;
+		}
+	}
+
+	void join()
+	{
+		m_thread->join();
+	}
+
+	void stop()
+	{
+		async_stop();
+	}
+};
+
+struct worker_impl:worker
+{
+	std::vector<std::shared_ptr<worker_thread>> m_threads;
+	std::atomic<int> m_init_flag{-2};
+	virtual void stop()
+	{
+		for(auto&thr:m_threads)
+			thr->stop();
+
+		for(auto&thr:m_threads)
+			thr->join();
+	}
+
+	worker_thread& hash(uint64_t i)
+	{
+		return *m_threads[i*2003%m_threads.size()].get();
+	}
+
+	virtual void request(task*t)
+	{
+		hash(t->m_hash_id).async_request(t);
+	}
+
+	void init(int num_thread)
+	{
+		int exp=-2;
+		if(m_init_flag.compare_exchange_strong (exp,-1))
+		{
+			m_threads.resize(num_thread);
+			for(int i=0;i<num_thread;i++)
+			{
+				m_threads[i].reset(new worker_thread());
+			}
+			m_init_flag.store(0);
+		}
+
+		while(0!=m_init_flag.load())
+			std::this_thread::yield();
+	}
+};
+
+worker_impl _worker_impl;
+worker*worker::instance()
+{
+	_worker_impl.init(4);
+	return &_worker_impl;
+}
+
+
+
+

+ 48 - 0
worker.h

@@ -0,0 +1,48 @@
+#ifndef _WORKER_HPP_
+#define _WORKER_HPP_
+#include <ev++.h>
+
+struct task
+{
+	uint32_t m_cmd_code;
+	uint32_t m_hash_id;
+	char     m_d[1];
+
+	void destroy()
+	{
+		free(this);
+	}
+
+	template<typename T> const T&body()const
+	{
+		const void*x=&m_d[0];
+		return *(T*)x;
+	}
+
+	template<typename T> T&body()
+	{
+		void*x=&m_d[0];
+		return *(T*)x;
+	}
+
+	static size_t align(size_t n)
+	{
+		return (n+31)&~0x1F;
+	}
+
+	template<typename T> static task*alloc()
+	{
+		return (task*)malloc(align(sizeof(T)+sizeof(task)));
+	}
+};
+
+struct worker
+{
+	virtual void stop()=0;
+	virtual void request(task*tk)=0;
+
+	static worker*instance();
+};
+
+#endif
+

+ 344 - 0
zio.h

@@ -0,0 +1,344 @@
+#ifndef _zio_hpp_z_
+#define _zio_hpp_z_
+
+#ifdef _MSC_VER
+ #include <WinSock2.h>
+ #include <Windows.h>
+#else
+ #include <unistd.h>
+ #include <fcntl.h>          
+ #include <sys/types.h>          
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <netinet/tcp.h>
+ #include <arpa/inet.h>
+ #include <errno.h>
+#endif
+
+#include <string.h>
+#include <string>
+
+#include "log.h"
+struct zio
+{
+private:
+	template<typename T> 
+	static int setoption(int fd,int level,int name,const T&opt)
+	{
+		return setsockopt(fd,level,name,(char*)&opt,sizeof(T));
+	}
+
+	static sockaddr* build_addr(sockaddr_in*addr,const char*ip,int port)
+	{
+		return build_addr(addr,ntohl(inet_addr(ip)),port);
+	}
+
+	static sockaddr* build_addr(sockaddr_in*addr,int ip,int port)
+	{
+		memset(addr, 0, sizeof(sockaddr_in));
+
+		addr->sin_family = AF_INET; 
+		addr->sin_addr.s_addr = htonl(ip); 
+		addr->sin_port = htons(port); 
+
+		return (sockaddr*)addr;
+	}
+
+	static int bind(int fd,sockaddr*sa)
+	{
+		return ::bind(fd,sa,sizeof(sockaddr));
+	}
+
+	static int bind(int fd,sockaddr_in*sa)
+	{
+		return zio::bind(fd,(sockaddr*)sa);
+	}
+
+	static int connect(int fd,sockaddr*sa)
+	{
+		int rc=::connect(fd,sa,sizeof(sockaddr));
+		if(rc<0)
+		{
+			char name[128];
+			sprintf(name,"%s:%d",inet_ntoa(((sockaddr_in*)sa)->sin_addr),ntohs(((sockaddr_in*)sa)->sin_port));
+			log_errno("zio:socket connect to %s",name);
+		}
+
+		return rc;
+	}
+
+	static int connect(int fd,sockaddr_in*sa)
+	{
+		return zio::connect(fd, (sockaddr*)sa);
+	}
+
+	static int bind(int fd,const char* ip,int port)
+	{
+		sockaddr_in si;
+		return zio::bind(fd,build_addr(&si,ip,port));
+	}
+
+	static int bind(int fd, int inaddr,int port)
+	{
+		sockaddr_in si;
+		return zio::bind(fd,build_addr(&si,inaddr,port));
+	}
+
+	static int connect(int fd,int inaddr,int port)
+	{
+		sockaddr_in si;
+		return zio::connect(fd,build_addr(&si,inaddr,port));
+	}
+public:
+
+	static int connect(int fd,const char*ip,int port)
+	{
+		sockaddr_in si;
+		return zio::connect(fd,build_addr(&si,ip,port));
+	}
+
+	static int listen(int fd,const char*ip,int port,int backlog=1024)
+	{
+		setnodelay(fd);
+		setreuseaddr(fd);
+
+		if(zio::bind(fd,ip,port)<0)
+		{
+			log_errno("zio:socket bind (%d,'%s',%d)",fd,ip,port);
+			return -1;
+		}
+
+		return ::listen(fd,backlog);
+	}
+
+	static int setnodelay (int fd, bool nodelay = true)
+	{
+		int v = nodelay ? 1 : 0;
+
+		return setoption (fd,IPPROTO_TCP, TCP_NODELAY, v);
+	}
+
+	static 	int setiobuf (int fd, int send_size,int recv_size)
+	{
+		if(send_size && setoption (fd, SOL_SOCKET, SO_SNDBUF, send_size)<0)
+		{
+			log_errno("zio:setoption(%d,SO_SNDBUF,%d)",fd,send_size);
+			return -1;
+		}
+
+		if(recv_size && setoption (fd, SOL_SOCKET, SO_RCVBUF, recv_size)<0)
+		{
+			log_errno("zio:setoption(%d,SO_RECBUF,%d)",fd,recv_size);
+			return -1;
+		}
+
+		return 0;
+	}
+
+	static 	int setreuseaddr (int fd, bool reuse = true)
+	{
+		int v = reuse ? 1 : 0;
+
+		return setoption (fd, SOL_SOCKET, SO_REUSEADDR, v);
+	}
+
+	static int setrecvtimeo (int fd, int tmout_ms)
+	{
+#ifdef _MSC_VER
+		int tv = tmout_ms;
+#else
+		struct timeval tv = { tmout_ms / 1000, tmout_ms % 1000 * 1000 };
+#endif
+
+		return setoption (fd,SOL_SOCKET, SO_RCVTIMEO, tv);
+	}
+
+	static int setsendtimeo (int fd, int tmout_ms)
+	{
+#ifdef _MSC_VER
+		int tv = tmout_ms;
+#else
+		struct timeval tv = { tmout_ms / 1000, tmout_ms % 1000 * 1000 };
+#endif
+
+		return setoption (fd,SOL_SOCKET, SO_SNDTIMEO, tv);
+	}
+
+	static int setblocking (int fd, bool b=true)
+	{
+#ifdef _MSC_VER
+#else
+		int opts = fcntl (fd, F_GETFL);
+		if (opts < 0)
+			return -1;
+
+		opts |= b ?(opts& ~O_NONBLOCK) :(opts|O_NONBLOCK);
+
+		if (fcntl (fd, F_SETFL, opts) < 0)
+			return -1;
+
+		return 0;
+#endif
+	}
+
+	static int close(int fd)
+	{
+		if(fd==-1)
+			return 0;
+
+#ifdef _MSC_VER
+		return ::closesocket(fd);
+#else
+		return ::close(fd);
+#endif
+	}
+
+	static int accept(int serv_fd,char *name)
+	{
+		struct sockaddr_in addr={0};
+		int fd=-1;
+		for(;;)
+		{
+			socklen_t addrlen=sizeof(struct sockaddr_in);
+			fd=(int)::accept(serv_fd,(sockaddr*)&addr,&addrlen);
+			if(fd<0)
+			{
+#ifdef _MSC_VER
+#else
+				if (errno == EINTR || errno == ECONNABORTED)
+					continue;
+#endif
+			}
+
+			if(fd>=0)
+			{
+				sprintf(name,"%s:%d",inet_ntoa(addr.sin_addr),ntohs(addr.sin_port));
+				log_info("zio:client %d(%s) connected",fd,name);
+			}
+			break;
+		}
+		return fd;
+	}
+
+	static int build_stream()
+	{
+		return (int)::socket(AF_INET,SOCK_STREAM,0);
+	}
+
+	static int write(int fd, const void *buff, int count)
+	{
+		const char*buf=(const char*)buff;
+		for(;;)
+		{
+			int rc  = ::write(fd,buf,count);
+			if (rc == -1) 
+			{
+				switch(errno)
+				{
+#ifndef _MSC_VER
+					case EINTR:
+						continue;
+#endif
+					case EAGAIN:
+#ifdef _MSC_VER
+					case EWOULDBLOCK:
+#endif
+						return -2;
+					default:
+						log_errno("zio:socket %d write",fd);
+						return -1;
+				}
+			}
+
+			return rc;
+		}
+	}
+
+	static int read(int fd, void *buff, int count)
+	{
+		char*buf=(char*)buff;
+		for(;;)
+		{
+			int rc = ::read(fd,buf,count);
+			if (rc == -1)
+			{
+				switch(errno)
+				{
+#ifndef _MSC_VER
+					case EINTR:
+						continue;
+#endif
+					case EAGAIN:
+#ifdef _MSC_VER
+					case EWOULDBLOCK:
+#endif
+						return -2;
+					default:
+						log_errno("zio:socket %d read",fd);
+						return -1;
+				}
+			}
+
+			return rc;
+		}
+	}
+	static int writev(int fd, const void*buff, int count)
+	{
+		const char*buf=(const char*)buff;
+		int rc, pos = 0;
+		while(pos != count) 
+		{
+			if((rc=zio::write(fd,buf,count-pos))>0)
+			{
+				pos += rc;
+				buf += rc;
+				continue;
+			}
+
+			if(rc==-1) 
+				break;
+		}
+
+		return pos==0?-1:pos;
+	}
+
+	static int readv(int fd, void *buff, int count)
+	{
+		char*buf=(char*)buff;
+		int rc, pos = 0;
+		while(pos != count) 
+		{
+			if((rc=zio::read(fd,buf,count-pos))>0)
+			{
+				pos += rc;
+				buf += rc;
+				continue;
+			}
+
+			if(rc==0)
+				return pos>0?pos:0;
+
+			if(rc==-1) 
+				break;
+		}
+
+		return pos==0?-1:pos;
+	}
+
+	static int listen_on(int port)
+	{
+		int fd=zio::build_stream();
+		zio::setreuseaddr(fd,true);
+		int rc=zio::listen(fd,"0.0.0.0",port,1024);
+		if(rc<0)
+		{
+			zio::close(fd);
+			return -1;
+		}
+
+		return fd;
+	}
+};
+
+#endif
+

+ 86 - 0
zloop.h

@@ -0,0 +1,86 @@
+#ifndef _zloop_hpp_
+#define _zloop_hpp_
+#include <vector>
+#include <list>
+#include <atomic>
+#include <mutex>
+#include <assert.h>
+#include <ev++.h>
+
+struct zloop_base:ev::dynamic_loop
+{
+	std::atomic<bool>  m_stop_flag{false};
+	ev::async m_async;
+
+	int check_stop_flag()
+	{
+		if(!m_stop_flag.load())
+			return 0;
+
+		break_loop(ev::ALL);
+		return 1;
+	}
+
+	virtual void on_async_0(){}
+
+	void async_stop()
+	{
+		m_stop_flag.store(true);
+		m_async.send();
+	}
+
+	zloop_base()
+	{
+		m_async.set(*this);
+		m_async.set<zloop_base,&zloop_base::on_async_0>(this);
+		m_async.start();
+	}
+
+	~zloop_base()
+	{
+		m_async.stop();
+	}
+};
+
+template<typename NT>
+struct zloop:zloop_base
+{
+	std::mutex m_mutex;
+	std::list<NT> m_async_list;
+
+	virtual void on_async_0()
+	{
+		if(check_stop_flag()) 
+			return;
+
+		std::list<NT> async_list;
+		{
+			std::unique_lock<std::mutex> _lock(m_mutex);
+			m_async_list.swap(async_list);
+		}
+		on_async(async_list);
+	
+	}
+
+	virtual void on_async(const std::list<NT>&nt){}
+
+	void async_request(NT tk)
+	{
+		{
+			std::unique_lock<std::mutex> _lock(m_mutex);
+			m_async_list.push_back(tk);
+		}
+
+		m_async.send();
+	}
+
+	zloop()
+	{
+	}
+
+	~zloop()
+	{
+	}
+};
+#endif
+

+ 492 - 0
znet.cpp

@@ -0,0 +1,492 @@
+#include <log.h>
+//#define EV_MULTIPLICITY 1
+//#define EV_SIGNAL_ENABLE 1
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <list>
+#include <vector>
+#include <set>
+#include <thread>
+#include <mutex>
+#include <atomic>
+#include <algorithm>
+#include <fstream>
+
+#include <ev++.h>
+
+#include <zio.h>
+#include <znet.h>
+#include <zloop.h>
+#include <clock.h>
+
+struct client_ex:client
+{
+	virtual void on_notify()=0;
+	virtual void close_impl()=0;
+};
+
+struct io_context: zloop<std::shared_ptr<client>> ,service_handle
+{
+private:
+	service_callback&m_serv;
+public:
+	
+	std::vector<std::shared_ptr<client>> m_thread_clts;
+	io_context(service_callback&serv)
+		:m_serv(serv)
+	{
+		m_thread_clts.reserve(2048);
+	}
+
+	virtual ~io_context()
+	{
+	}
+
+	void on_connect(std::shared_ptr<client> clt)
+	{
+		if(clt->handle()>=(int)m_thread_clts.size())
+		{
+			m_thread_clts.resize(clt->handle()+1);
+		}
+
+		m_thread_clts[clt->handle()]=clt;
+		m_serv.on_connect(clt);
+	}
+
+	void on_close(std::shared_ptr<client> clt)
+	{
+		m_serv.on_close(clt);
+		m_thread_clts[clt->handle()].reset();
+	}
+
+	void on_send_timeout(std::shared_ptr<client> clt)
+	{
+		m_serv.on_send_timeout(clt);
+	}
+
+	void on_recv_timeout(std::shared_ptr<client> clt)
+	{
+		m_serv.on_recv_timeout(clt);
+	}
+
+	void on_message(std::shared_ptr<client> clt,const char*data,size_t len)
+	{
+		m_serv.on_message(clt,data,len);
+	}
+
+	void close_all()
+	{
+		for(auto clt:m_thread_clts)
+		{
+			if(!clt)
+				continue;
+
+			((client_ex*)clt.get())->close_impl();
+		}
+	}
+
+	void on_async(const std::list<std::shared_ptr<client>>&notify_clts)
+	{
+		for(auto&clt:notify_clts)
+		{
+			((client_ex*)clt.get())->on_notify();
+		}
+	}
+
+	void stop()
+	{
+		async_stop();
+	}
+};
+
+struct fd_io:ev::io
+{
+	io_context&m_ic;
+	int m_fd;
+	fd_io(io_context&ic,int fd,int ev_flag=EV_READ)
+		:ev::io(ic)
+		,m_ic(ic)
+		,m_fd(fd)
+	{
+		zio::setblocking(fd,false);
+		this->set(this);
+		this->set(m_fd,ev_flag);
+		this->start();
+	}
+
+	void stop () throw ()                                                               \
+	{
+		ev::io::stop();
+	}
+
+	io_context&context()
+	{
+		return m_ic;
+	}
+
+	virtual void operator()(ev::io &w, int)=0;
+	virtual ~fd_io()
+	{
+		stop();
+		zio::close(m_fd);
+	}
+};
+
+struct sock_client:fd_io,client_ex
+{
+	io_context&m_ic;
+	std::string m_name;
+	std::atomic<bool> m_close_flag{false};
+	int   m_type=0;//site
+
+	char  *m_b{0};
+	int   m_size{1<<16};
+	int   m_clen{0};
+
+	ev::timer  m_recv_timer,m_send_timer;
+
+	std::mutex m_mutex;
+	std::list<std::vector<char>> m_olist;
+	std::vector<char> m_obuf;
+	size_t m_opos=0;
+
+	bool   m_can_write{false};
+
+	sock_client(io_context&ic,const char*name,int fd)
+		:fd_io(ic,fd,EV_READ|EV_WRITE)
+		,m_ic(ic)
+		,m_name(name)
+	{ 
+		m_recv_timer.set(ic);
+		m_recv_timer.set(5,0);
+		m_recv_timer.set<sock_client,&sock_client::on_recv_timeout>(this);
+		m_recv_timer.start();
+
+		m_send_timer.set(ic);
+		m_send_timer.set(5,0);
+		m_send_timer.set<sock_client,&sock_client::on_send_timeout>(this);
+		m_send_timer.start();
+
+		m_b=(char*)malloc(m_size);
+	}
+
+	~sock_client()
+	{
+		free(m_b);
+	}
+
+	int type()
+	{
+		return m_type;
+	}
+
+	void close()
+	{
+		m_close_flag.store(true);
+		m_ic.async_request(shared_from_this());
+	}
+
+	void send(std::vector<char>&&b)
+	{
+		{
+			std::unique_lock<std::mutex> _lock(m_mutex);
+			m_olist.push_back(std::move(b));
+		}
+		m_ic.async_request(shared_from_this());
+	}
+
+	void on_send_timeout()
+	{
+		m_ic.on_send_timeout(shared_from_this());
+	}
+
+	void on_recv_timeout()
+	{
+		m_ic.on_recv_timeout(shared_from_this());
+	}
+
+	std::string name()
+	{
+		return m_name;
+	}
+
+	int  handle()
+	{
+		return m_fd;
+	}
+
+	void grow_buf(int len)
+	{
+		if(m_size-m_clen>=len)
+			return;
+
+		int size=m_size;
+		while(m_size-m_clen<len)
+			size<<=1;
+
+		if(size!=m_size)
+		{
+			m_b=(char*)realloc(m_b,m_size=size);
+		}
+	}
+
+	int read_clt()
+	{
+		for(;m_clen<m_size;)
+		{
+			int rc=zio::read(m_fd,m_b+m_clen,m_size-m_clen);
+			if(rc>0)
+			{
+				m_clen+=rc;
+				continue;
+			}
+
+			if(rc==-2)
+				return 0;
+
+			if(rc==0)
+			{
+				log_info("socket %d(%s) close by remote",m_fd,m_name.c_str());
+			}
+			else if(rc==-1)
+			{
+				log_errno("hava a error on socket %d(%s)",m_fd,m_name.c_str());
+			}
+			return -1;
+		}
+
+		return 0;
+	}
+
+	void close_impl()
+	{
+		m_recv_timer.stop();
+		m_send_timer.stop();
+		fd_io::stop();
+		m_ic.on_close(shared_from_this());
+	}
+
+	size_t calc_length(uint8_t*b)const
+	{
+		return (b[0]<<8)|b[1];
+	}
+
+	int io_read()
+	{
+		if(read_clt()<0)
+			return -1;
+
+		int msg_len;
+		for(;m_clen>=2;)
+		{
+			msg_len=calc_length((uint8_t*)m_b)+2;
+
+			if(m_clen<msg_len)
+				break;
+
+			if(check_crc(m_b,msg_len))
+				on_message(m_b,msg_len);
+			else
+				log_errno("check_crc_error.");
+
+			memmove(m_b,&m_b[msg_len],m_clen-msg_len);
+			m_clen-=msg_len;
+		}
+
+		return 0;
+	}
+
+	int io_write()
+	{
+		if(! m_can_write)
+		{
+			set(EV_READ|EV_WRITE);
+			m_send_timer.set(5);
+			m_send_timer.start();
+			return 0;
+		}
+
+		for(;;)
+		{
+			if(m_obuf.size()==m_opos)
+			{
+				std::unique_lock<std::mutex> _lock(m_mutex);
+				if(m_olist.empty())
+					break;
+
+				m_obuf.swap(m_olist.front());
+				m_olist.pop_front();
+				m_opos=0;
+			}
+
+			int left=m_obuf.size()-m_opos;
+			int rc=zio::write(m_fd,&*m_obuf.begin()+m_opos,left);
+
+			if(rc>0)
+			{
+				m_opos+=rc;
+				if(m_opos==m_obuf.size()) 
+					continue;
+			}
+			else if(rc==0||rc==-2)//缓冲区满
+			{
+				m_can_write=false;
+				set(EV_READ|EV_WRITE);
+				m_send_timer.set(5);
+				m_send_timer.start();
+				break;
+			}
+			else
+			{
+				log_errno("zio::write(%d,ptr,%d)",m_fd,m_obuf.size()-m_opos);
+				return -1;
+			}
+		}
+
+		if(m_olist.empty() && m_can_write)
+		{
+			set(EV_READ);
+			m_send_timer.stop();
+		}
+
+		return 0;
+	}
+
+	void operator()(ev::io &w, int flag)
+	{
+		if(flag & EV_WRITE)
+		{
+			log_debug("socket %d(%s) can write,flag=%d." ,m_fd,m_name.c_str(),flag);
+			m_can_write=true;
+			m_send_timer.stop();
+			if(io_write()<0)
+			{
+				close_impl();
+				return;
+			}
+		}
+
+		if(flag & EV_READ)
+		{
+//			log_debug("socket %d(%s) can read,flag=%d." ,m_fd,m_name.c_str(),flag);
+//			zclock c;
+			if(io_read()<0)
+			{
+				close_impl();
+				return;
+			}
+
+//			log_info("use time %d ms.",c.count_us());
+			m_recv_timer.set(5);
+		}
+	}
+
+	bool check_crc(const char*b,size_t mlen)
+	{
+		return true;
+	}
+
+	void on_message(const char*m,int mlen)
+	{
+		m_ic.on_message(shared_from_this(),m,mlen);
+	}
+
+	void on_notify()
+	{
+		if(m_close_flag)
+		{
+			close_impl();
+			return;
+		}
+
+		io_write();
+	}
+
+};
+
+struct sock_listen: fd_io
+{
+	sock_listen(io_context&ic,int fd):fd_io(ic,fd){}
+
+	void operator()(ev::io &w, int)
+	{
+		char name[32];
+		int fd=zio::accept(m_fd,name);
+		if(fd<0)
+			return;
+
+		zio::setiobuf(fd,32<<10,32<<10);
+		m_ic.on_connect(std::make_shared<sock_client>(m_ic,name,fd));
+	}
+};
+
+struct signal_w:ev::sig
+{
+	io_context&m_ic;
+	signal_w(io_context&ic, int s)
+		:m_ic(ic)
+	{
+		this->set(m_ic);
+		this->set(this);
+		this->set(s);
+		this->start();
+	}
+
+	void operator()(ev::sig &w, int s)
+	{
+		stop();
+		log_info("recved signal %d",s);
+		m_ic.async_stop();
+	}
+};
+
+struct main_loop:io_context
+{
+	main_loop(service_callback&sc)
+		:io_context(sc)
+	{
+	}
+	virtual int run(int port)
+	{
+		int fd=zio::listen_on(port);
+		if(fd<0)
+		{
+			return -1;
+		}
+
+		sock_listen _1(*this,fd);
+
+		block_sig(SIGPIPE);
+		signal_w sint(*this,SIGINT),term(*this,SIGTERM);
+		ev::dynamic_loop::run(0);
+		_1.stop();
+		close_all();
+
+		return 0;
+	}
+
+	void block_sig(int sig)
+	{
+		sigset_t signal_mask; 
+		sigemptyset(&signal_mask); 
+		sigaddset(&signal_mask, sig); 
+		if(pthread_sigmask(SIG_BLOCK, &signal_mask, NULL) == -1) 
+		{
+			log_errno("block signal:%d",sig);
+		}
+	}
+	void boardcast(const std::vector<char>&msg)
+	{
+	
+	}
+};
+
+
+service_handle*service_handle::instance(service_callback*sc)
+{
+	static main_loop _impl(*sc);
+	sc->set_handle(&_impl);
+	return &_impl;
+}
+

+ 84 - 0
znet.h

@@ -0,0 +1,84 @@
+#ifndef __EVIO_HPP_
+#define __EVIO_HPP_
+
+#include <string>
+#include <vector>
+#include <memory>
+
+struct client:std::enable_shared_from_this<client>
+{
+	virtual std::string name()=0;
+	virtual int type()=0;			//分站:0,WEB:1
+	virtual int handle()=0;
+
+	virtual void close()=0;
+	virtual void send(std::vector<char>&&b)=0;
+
+	virtual ~client(){}
+};
+
+struct service_callback;
+struct service_handle
+{
+	virtual int run(int port)=0;
+	virtual void stop()=0;
+	virtual void boardcast(const std::vector<char>&msg)=0;
+
+	static service_handle*instance(service_callback*sc);
+};
+
+struct service_callback:service_handle
+{
+	service_handle*m_handle{nullptr};
+
+	void set_handle(service_handle*handle)
+	{
+		m_handle=handle;
+	}
+
+	int run(int port)
+	{
+		return m_handle->run(port);
+	}
+
+	void stop()
+	{
+		m_handle->stop();
+	}
+
+	void boardcast(const std::vector<char>&msg)
+	{
+		m_handle->boardcast(msg);
+	}
+
+	virtual void on_connect(std::shared_ptr<client> clt)
+	{
+	}
+
+	virtual void on_close(std::shared_ptr<client> clt)
+	{
+		log_info("client(%s) closed",clt->name().c_str());
+	}
+
+	virtual void on_error(std::shared_ptr<client> clt,const char*error)
+	{
+		log_info("client(%s) error with:%s",clt->name().c_str(),error);
+	}
+
+	virtual void on_send_timeout(std::shared_ptr<client> clt)
+	{
+		log_info("client(%s) send time out",clt->name().c_str());
+	}
+
+	virtual void on_recv_timeout(std::shared_ptr<client> clt)
+	{
+		log_info("client(%s) recv time out",clt->name().c_str());
+	}
+
+	virtual void on_message(std::shared_ptr<client> clt,const char*data,size_t len)=0;
+
+	virtual ~service_callback(){}
+};
+
+#endif
+

+ 333 - 0
zstream.h

@@ -0,0 +1,333 @@
+#ifndef __higinet_zistream_h__
+#define __higinet_zistream_h__
+
+#include <stdint.h>
+#include <string.h>
+#include <vector>
+#include <string>
+#include <stdexcept>
+
+struct stream_exception: public std::logic_error 
+{
+	explicit stream_exception(const char*e)
+		:std::logic_error(e)	
+	{
+	}
+	
+	explicit stream_exception(const std::string&e)
+		:std::logic_error(e)	
+	{
+	}
+};
+
+namespace endian
+{
+	struct flag
+	{
+#ifndef LITTLE_ENDIAN
+		static const bool little=true;
+#else
+		static const bool little=false;
+#endif
+	};
+
+	inline void cp_uint8_r(void*d,const void*s,size_t c)
+	{
+		uint8_t*di=(uint8_t*)d;
+		const uint8_t*si=(const uint8_t*)s;
+
+		while(c-->0)
+			*di++=*--si;
+	}
+
+
+	inline void cp_uint8(void*d,const void*s,size_t c)
+	{
+		memcpy(d,s,c);
+	}
+
+	template<bool little> struct copy_impl
+	{
+		void operator()(void*d,const void*s,size_t)const
+		{
+		}
+	};
+	
+	template<> struct copy_impl<true>
+	{
+		void operator()(void*d,const void*s,size_t count)const
+		{
+			cp_uint8 ((uint8_t*)d,(const uint8_t*)s,count);
+		}
+	};
+	
+	template<> struct copy_impl<false>
+	{
+		void operator()(void*d,const void*s,size_t count)const
+		{ 
+			cp_uint8_r (d, (const uint8_t*)s+count, count);
+		}
+	};
+
+	inline void copy(void*d,const void*s,size_t count)
+	{ 
+		copy_impl<endian::flag::little>()(d,s,count);
+	}
+}
+
+struct skip
+{
+	int m_count;
+	skip(int count):m_count(count){}
+};
+
+template<typename T,typename F>
+struct as
+{
+	T t;
+	F&f;
+	as(F&f_):f(f_){}
+};
+
+struct npc
+{
+	int m_count;
+	npc(int c=-1):m_count(c) {}
+	void reset(int count=-1){m_count=count;}
+	operator int()const {return m_count;}
+};
+
+struct zistream
+{
+private:
+	const uint8_t* m_buff;
+	size_t m_pos,m_size;
+	bool m_owner_buff;
+	npc m_np;
+
+	void assert_buff_size(size_t len)
+	{
+		if(len > m_size)
+		{
+			char buf[256];
+			sprintf(buf, "无更多的数据:%s(size=%d,pos=%d,fetch=%d).", __FUNCTION__,(int)m_size,(int)m_pos,(int)len);
+			throw stream_exception(buf);
+		}
+	}
+
+public:
+	const uint8_t*buff()const{return m_buff;}
+	const uint8_t*cur_data()const{return m_buff+m_pos;}
+	size_t pos()const{return m_pos;}
+
+	void load(void*d,size_t len,size_t pos)
+	{
+		assert_buff_size(pos+len);
+		endian::copy(d,m_buff+pos,len);
+	}
+
+	void load(void*d,size_t len)
+	{
+		load(d,len,m_pos);
+		m_pos+=len;
+	}
+	int32_t load_int8 (size_t pos){int8_t  rc;load(&rc,sizeof(rc),pos);return rc;}
+	int32_t load_int16(size_t pos){int16_t rc;load(&rc,sizeof(rc),pos);return rc;}
+	int32_t load_int32(size_t pos){int32_t rc;load(&rc,sizeof(rc),pos);return rc;}
+	int64_t load_int64(size_t pos){int64_t rc;load(&rc,sizeof(rc),pos);return rc;}
+
+	int32_t load_int8 (){int8_t  rc; load(&rc,sizeof(rc)); return rc;}
+	int32_t load_int16(){int16_t rc; load(&rc,sizeof(rc)); return rc;}
+	int32_t load_int32(){int32_t rc; load(&rc,sizeof(rc)); return rc;}
+	int64_t load_int64(){int64_t rc; load(&rc,sizeof(rc)); return rc;}
+
+
+	uint32_t load_uint8 (size_t pos){uint8_t  rc;load(&rc,sizeof(rc),pos);return rc;}
+	uint32_t load_uint16(size_t pos){uint16_t rc;load(&rc,sizeof(rc),pos);return rc;}
+	uint32_t load_uint32(size_t pos){uint32_t rc;load(&rc,sizeof(rc),pos);return rc;}
+	uint64_t load_uint64(size_t pos){uint64_t rc;load(&rc,sizeof(rc),pos);return rc;}
+
+	uint32_t load_uint8 (){uint8_t  rc; load(&rc,sizeof(rc)); return rc;}
+	uint32_t load_uint16(){uint16_t rc; load(&rc,sizeof(rc)); return rc;}
+	uint32_t load_uint32(){uint32_t rc; load(&rc,sizeof(rc)); return rc;}
+	uint64_t load_uint64(){uint64_t rc; load(&rc,sizeof(rc)); return rc;}
+
+	std::vector<uint8_t> load_bytes(size_t count)
+	{
+		std::vector<uint8_t> rc(count,0);
+
+		load(&*rc.begin(), count);
+
+		return std::move(rc);
+	}
+
+	std::string load_string(size_t count)
+	{
+		std::string rc(count,' ');
+
+		load(&*rc.begin(), count);
+
+		return std::move(rc);
+	}
+
+	bool   eof() const {return m_pos >= m_size; }
+	size_t size()const {return m_size;}
+	void   set_size(uint32_t size){m_size=size;}
+
+public:
+
+	zistream(const void*pbuf,size_t buf_size,bool owner_buff=false)
+		:m_buff((const uint8_t*)pbuf)
+		,m_pos(0)
+		,m_size(buf_size)
+		,m_owner_buff(owner_buff)
+	{
+	}
+
+	~zistream()
+	{
+		if(m_owner_buff && m_buff)
+		{
+			::free((void*)m_buff);
+		}
+	}
+
+	friend zistream& operator>>(zistream&is, uint8_t &i) { i=is.load_uint8 ();return is; }
+	friend zistream& operator>>(zistream&is, uint16_t&i) { i=is.load_uint16();return is; }
+	friend zistream& operator>>(zistream&is, uint32_t&i) { i=is.load_uint32();return is; }
+	friend zistream& operator>>(zistream&is, uint64_t&i) { i=is.load_uint64();return is; }
+
+	friend zistream& operator>>(zistream&is, int8_t &i) { i=is.load_int8 ();return is; }
+	friend zistream& operator>>(zistream&is, int16_t&i) { i=is.load_int16();return is; }
+	friend zistream& operator>>(zistream&is, int32_t&i) { i=is.load_int32();return is; }
+	friend zistream& operator>>(zistream&is, int64_t&i) { i=is.load_int64();return is; }
+
+
+	friend zistream& operator>>(zistream&is, const npc&i) { is.m_np.reset(i);return is;}
+	friend zistream& operator>>(zistream&is, void*x) 
+	{ 
+		if(is.m_np <= 0)
+			return is;
+		is.load(x,is.m_np);
+		is.m_np.reset();
+
+		return is;
+	}
+
+	friend zistream& operator>>(zistream&is, const skip&s)
+	{ 
+		is.m_pos+=s.m_count;
+
+		return is;
+	}
+};
+
+class zostream
+{
+private:
+	uint8_t*  m_buff;
+	size_t    m_pos,m_size;
+	int       m_owner_buff;
+
+	void grow(size_t nsize)
+	{
+		if(m_buff!=nullptr && nsize<m_size)
+			return;
+
+		while(m_size<nsize)
+			m_size<<=1;
+		
+		m_buff=(uint8_t*) realloc(m_buff,m_size);
+		m_owner_buff=1;
+	}
+
+public:
+	zostream& save(const void*pbuf,int len,size_t pos)
+	{
+		grow(len+pos);
+		endian::copy(m_buff+pos,pbuf,len);
+
+		if(len+pos>m_pos)
+			m_pos=len+pos;
+
+		return *this;
+	}
+
+	zostream& save(const void*pbuf,int len)
+	{
+		grow(len+m_pos);
+		endian::copy(m_buff+m_pos,pbuf,len);
+
+		m_pos+=len;
+
+		return *this;
+	}
+
+	zostream& save(int8_t   i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(int16_t  i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(int32_t  i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(int64_t  i,size_t pos){return save(&i,sizeof(i),pos);}
+
+	zostream& save(int8_t  i) {return save(&i,sizeof(i));}
+	zostream& save(int16_t i) {return save(&i,sizeof(i));}
+	zostream& save(int32_t i) {return save(&i,sizeof(i));}
+	zostream& save(int64_t i) {return save(&i,sizeof(i));}
+
+	zostream& save(uint8_t   i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(uint16_t  i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(uint32_t  i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(uint64_t  i,size_t pos){return save(&i,sizeof(i),pos);}
+	zostream& save(uint8_t  i) {return save(&i,sizeof(i));}
+	zostream& save(uint16_t i) {return save(&i,sizeof(i));}
+	zostream& save(uint32_t i) {return save(&i,sizeof(i));}
+	zostream& save(uint64_t i) {return save(&i,sizeof(i));}
+
+	zostream& save(const std::string&s)
+	{
+		return save(s.c_str(), s.size());
+	}
+
+	zostream& save(const char*s)
+	{
+		return save(s, strlen(s));
+	}
+
+	friend zostream& operator<<(zostream&os, uint8_t i)  { return os.save(i);}
+	friend zostream& operator<<(zostream&os, uint16_t i) { return os.save(i);}
+	friend zostream& operator<<(zostream&os, uint32_t i) { return os.save(i);}
+	friend zostream& operator<<(zostream&os, uint64_t i) { return os.save(i);}
+	friend zostream& operator<<(zostream&os, int8_t i)  { return os.save(i);}
+	friend zostream& operator<<(zostream&os, int16_t i) { return os.save(i);}
+	friend zostream& operator<<(zostream&os, int32_t i) { return os.save(i);}
+	friend zostream& operator<<(zostream&os, int64_t i) { return os.save(i);}
+
+	friend zostream& operator<<(zostream&os, const std::string &i) { return os.save(i);}
+	friend zostream& operator<<(zostream&os, const char*i) { return os.save(i);}
+
+public:
+	zostream(size_t buf_size,void*buf=nullptr)
+		:m_buff((uint8_t*)buf)
+		,m_pos(0)
+		,m_size(buf_size)
+	{
+		if(m_buff)
+		{
+			m_owner_buff=0;
+		}
+	}
+
+	~zostream()
+	{
+		if(m_owner_buff && m_buff)
+			free(m_buff);
+	}
+	
+	const uint8_t*data()const{return m_buff;}const
+	uint8_t      *data(){return m_buff;}
+
+	size_t size()const {return m_pos;}
+};
+
+#endif
+
+