OSDN Git Service

ソースコード登録
authorkoukou <koukou@users.sourceforge.jp>
Sun, 20 Feb 2011 11:31:28 +0000 (20:31 +0900)
committerkoukou <koukou@users.sourceforge.jp>
Mon, 21 Feb 2011 01:44:09 +0000 (10:44 +0900)
35 files changed:
LICENSE [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
README [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
config.h.in [new file with mode: 0644]
configure [new file with mode: 0755]
configure.ac [new file with mode: 0644]
depcomp [new file with mode: 0755]
install-sh [new file with mode: 0755]
missing [new file with mode: 0755]
src/ARIB/Makefile.am [new file with mode: 0644]
src/ARIB/Makefile.in [new file with mode: 0644]
src/ARIB/converter.h [new file with mode: 0644]
src/ARIB/descriptor.cpp [new file with mode: 0644]
src/ARIB/descriptor.h [new file with mode: 0644]
src/ARIB/si.cpp [new file with mode: 0644]
src/ARIB/si.h [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/Makefile.in [new file with mode: 0644]
src/TS/Makefile.am [new file with mode: 0644]
src/TS/Makefile.in [new file with mode: 0644]
src/TS/descriptor.cpp [new file with mode: 0644]
src/TS/descriptor.h [new file with mode: 0644]
src/TS/psi.cpp [new file with mode: 0644]
src/TS/psi.h [new file with mode: 0644]
src/TS/ts_packet.cpp [new file with mode: 0644]
src/TS/ts_packet.h [new file with mode: 0644]
src/TS/utils.h [new file with mode: 0644]
src/aribstr.cpp [new file with mode: 0644]
src/aribstr.h [new file with mode: 0644]
src/eit2xml.cpp [new file with mode: 0644]
src/epg.cpp [new file with mode: 0644]
src/epg.h [new file with mode: 0644]
src/tsparser.cpp [new file with mode: 0644]

diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..65c5ca8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,165 @@
+                   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..a7748f5
--- /dev/null
@@ -0,0 +1,4 @@
+SUBDIRS = src
+
+EXTRA_DIST = LICENSE
+
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..ddeb15d
--- /dev/null
@@ -0,0 +1,680 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  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@
+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 = :
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+       $(top_srcdir)/configure 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_HEADER = config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir dist dist-all distcheck
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+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 = @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@
+RANLIB = @RANLIB@
+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@
+SUBDIRS = src
+EXTRA_DIST = LICENSE
+all: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+am--refresh:
+       @:
+$(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):
+
+config.h: stamp-h1
+       @if test ! -f $@; then \
+         rm -f stamp-h1; \
+         $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+       else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+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: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(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: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS) config.h.in $(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"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+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
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || 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__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-lzma: distdir
+       tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+       $(am__remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__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.lzma*) \
+         lzma -dc $(distdir).tar.lzma | $(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 a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(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" \
+           $(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__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:
+       @$(am__cd) '$(distuninstallcheck_dir)' \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { 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-recursive
+all-am: Makefile config.h
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+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-recursive
+
+clean-am: clean-generic mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+       ctags-recursive install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am am--refresh check check-am clean clean-generic \
+       ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
+       dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \
+       distclean distclean-generic distclean-hdr distclean-tags \
+       distcleancheck distdir distuninstallcheck dvi dvi-am html \
+       html-am info info-am install install-am 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 installdirs-am maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+       pdf-am ps ps-am tags tags-recursive uninstall uninstall-am
+
+
+# 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:
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..4bab1fb
--- /dev/null
+++ b/README
@@ -0,0 +1,14 @@
+
+MPEG-2 TSを解析しTS内に含まれている情報等を取得するツールです。
+
+本パッケージに含まれているソースコードの
+・aribstr.cpp
+・aribstr.h
+は、tomy氏作成の「epgdumpr2」から流用および改変したものです。
+
+
+ライセンスについて
+ソースコードを流用している「epgdumpr2」のライセンスがLGPLと
+いうことなので、本パッケージもLGPLv3に準拠します。
+
+
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..e9b7b28
--- /dev/null
@@ -0,0 +1,951 @@
+# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  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.65],,
+[m4_warning([this file was generated for autoconf 2.65.
+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, 2003, 2005, 2006, 2007, 2008  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.11'
+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.11.1], [],
+      [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.11.1])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, 2003, 2005  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, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# 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.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$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, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# 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.
+
+# serial 10
+
+# 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", "GCJ", or "OBJC".
+# 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
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" 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'.
+  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 8's {/usr,}/bin/sh.
+      touch 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
+      ;;
+    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,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# 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.
+
+#serial 5
+
+# _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"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 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.
+
+# serial 16
+
+# 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],
+[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], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [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([AM_PROG_MKDIR_P])dnl
+# 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)],
+                 [define([AC_PROG_CC],
+                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES(CXX)],
+                 [define([AC_PROG_CXX],
+                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES(OBJC)],
+                 [define([AC_PROG_OBJC],
+                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])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, 2003, 2005, 2008  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, 2005  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.
+
+# serial 2
+
+# 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, 2002, 2003, 2005, 2009  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.
+
+# serial 4
+
+# 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, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# 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.
+
+# serial 6
+
+# 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
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  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_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  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.
+
+# serial 4
+
+# _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, 1997, 2000, 2001, 2003, 2005, 2008
+# 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.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# 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 (
+   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
+   rm -f conftest.file
+   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
+
+   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)])
+
+# Copyright (C) 2001, 2003, 2005  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, 2008  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.
+
+# serial 2
+
+# _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, 2005  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.
+
+# serial 2
+
+# _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.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} 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
+
diff --git a/config.h.in b/config.h.in
new file mode 100644 (file)
index 0000000..9a05b6c
--- /dev/null
@@ -0,0 +1,121 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the `alarm' function. */
+#undef HAVE_ALARM
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT8_T
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to the type of a signed integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int16_t
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int32_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef ssize_t
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint16_t
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint8_t
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..0fe6f4d
--- /dev/null
+++ b/configure
@@ -0,0 +1,6719 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.65 for tsparser 20110219.
+#
+# Report bugs to <koukou@users.sourceforge.jp>.
+#
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+        /*)
+          for as_base in sh bash ksh sh5; do
+            # Try only shells that exist, to save several forks.
+            as_shell=$as_dir/$as_base
+            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+          done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+       # neutralization value for shells without unset; and this also
+       # works around shells that cannot unset nonexistent variables.
+       BASH_ENV=/dev/null
+       ENV=/dev/null
+       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+       export CONFIG_SHELL
+       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: koukou@users.sourceforge.jp about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='tsparser'
+PACKAGE_TARNAME='tsparser'
+PACKAGE_VERSION='20110219'
+PACKAGE_STRING='tsparser 20110219'
+PACKAGE_BUGREPORT='koukou@users.sourceforge.jp'
+PACKAGE_URL=''
+
+ac_unique_file="src/tsparser.cpp"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_header_list=
+ac_func_list=
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+EGREP
+GREP
+CPP
+RANLIB
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+ac_ct_CC
+CFLAGS
+CC
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CXX
+CPPFLAGS
+LDFLAGS
+CXXFLAGS
+CXX
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_dependency_tracking
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CXX
+CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CCC
+CC
+CFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures tsparser 20110219 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/tsparser]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of tsparser 20110219:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+
+Some influential environment variables:
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <koukou@users.sourceforge.jp>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+tsparser configure 20110219
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_cxx_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to koukou@users.sourceforge.jp ##
+## ------------------------------------------ ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+
+# ac_fn_c_find_intX_t LINENO BITS VAR
+# -----------------------------------
+# Finds a signed integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_intX_t ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5
+$as_echo_n "checking for int$2_t... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+     # Order is important - never check a type that is potentially smaller
+     # than half of the expected target width.
+     for ac_type in int$2_t 'int' 'long int' \
+        'long long int' 'short int' 'signed char'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+            enum { N = $2 / 2 - 1 };
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+               enum { N = $2 / 2 - 1 };
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
+                < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  case $ac_type in #(
+  int$2_t) :
+    eval "$3=yes" ;; #(
+  *) :
+    eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       eval as_val=\$$3
+   if test "x$as_val" = x""no; then :
+
+else
+  break
+fi
+     done
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_find_intX_t
+
+# ac_fn_c_find_uintX_t LINENO BITS VAR
+# ------------------------------------
+# Finds an unsigned integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_uintX_t ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
+$as_echo_n "checking for uint$2_t... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+     # Order is important - never check a type that is potentially smaller
+     # than half of the expected target width.
+     for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
+        'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  case $ac_type in #(
+  uint$2_t) :
+    eval "$3=yes" ;; #(
+  *) :
+    eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       eval as_val=\$$3
+   if test "x$as_val" = x""no; then :
+
+else
+  break
+fi
+     done
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_find_uintX_t
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_func
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by tsparser $as_me 20110219, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+as_fn_append ac_header_list " sys/time.h"
+as_fn_append ac_header_list " unistd.h"
+as_fn_append ac_func_list " alarm"
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+am__api_version='1.11'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# 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]*)
+    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+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 (
+   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
+   rm -f conftest.file
+   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".
+      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" "$LINENO" 5
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+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=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+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
+
+# 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.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+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
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  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
+
+
+# Define the identity of the package.
+ PACKAGE='tsparser'
+ VERSION='20110219'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+# Checks for programs.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5
+$as_echo_n "checking whether the C++ compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "C++ compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5
+$as_echo_n "checking for C++ compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+        CXXFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+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.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+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
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CXX"  am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  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'.
+  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_CXX_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
+  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 8's {/usr,}/bin/sh.
+      touch 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
+      ;;
+    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_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  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'.
+  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_CC_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
+  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 8's {/usr,}/bin/sh.
+      touch 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
+      ;;
+    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_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+
+# Checks for libraries.
+
+# Checks for header files.
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in fcntl.h inttypes.h stdlib.h string.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+# Checks for typedefs, structures, and compiler characteristics.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
+$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
+if test "${ac_cv_header_stdbool_h+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <stdbool.h>
+#ifndef bool
+ "error: bool is not defined"
+#endif
+#ifndef false
+ "error: false is not defined"
+#endif
+#if false
+ "error: false is not 0"
+#endif
+#ifndef true
+ "error: true is not defined"
+#endif
+#if true != 1
+ "error: true is not 1"
+#endif
+#ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+#endif
+
+       struct s { _Bool s: 1; _Bool t; } s;
+
+       char a[true == 1 ? 1 : -1];
+       char b[false == 0 ? 1 : -1];
+       char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+       char d[(bool) 0.5 == true ? 1 : -1];
+       bool e = &s;
+       char f[(_Bool) 0.0 == false ? 1 : -1];
+       char g[true];
+       char h[sizeof (_Bool)];
+       char i[sizeof s.t];
+       enum { j = false, k = true, l = false * true, m = true * 256 };
+       /* The following fails for
+          HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+       _Bool n[m];
+       char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+       char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+#      if defined __xlc__ || defined __GNUC__
+        /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+           reported by James Lemley on 2005-10-05; see
+           http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+           This test is not quite right, since xlc is allowed to
+           reject this program, as the initializer for xlcbug is
+           not one of the forms that C requires support for.
+           However, doing the test right would require a runtime
+           test, and that would make cross-compilation harder.
+           Let us hope that IBM fixes the xlc bug, and also adds
+           support for this kind of constant expression.  In the
+           meantime, this test will reject xlc, which is OK, since
+           our stdbool.h substitute should suffice.  We also test
+           this with GCC, where it should work, to detect more
+           quickly whether someone messes up the test in the
+           future.  */
+        char digs[] = "0123456789";
+        int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+#      endif
+       /* Catch a bug in an HP-UX C compiler.  See
+          http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+          http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+        */
+       _Bool q = true;
+       _Bool *pq = &q;
+
+int
+main ()
+{
+
+       *pq |= q;
+       *pq |= ! q;
+       /* Refer to every declared value, to avoid compiler optimizations.  */
+       return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+               + !m + !n + !o + !p + !q + !pq);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdbool_h=yes
+else
+  ac_cv_header_stdbool_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
+$as_echo "$ac_cv_header_stdbool_h" >&6; }
+ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+if test "x$ac_cv_type__Bool" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+if test $ac_cv_header_stdbool_h = yes; then
+
+$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if test "${ac_cv_c_inline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t"
+case $ac_cv_c_int16_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int16_t $ac_cv_c_int16_t
+_ACEOF
+;;
+esac
+
+ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t"
+case $ac_cv_c_int32_t in #(
+  no|yes) ;; #(
+  *)
+
+cat >>confdefs.h <<_ACEOF
+#define int32_t $ac_cv_c_int32_t
+_ACEOF
+;;
+esac
+
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default"
+if test "x$ac_cv_type_ssize_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define ssize_t int
+_ACEOF
+
+fi
+
+ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
+case $ac_cv_c_uint16_t in #(
+  no|yes) ;; #(
+  *)
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint16_t $ac_cv_c_uint16_t
+_ACEOF
+;;
+  esac
+
+ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
+case $ac_cv_c_uint32_t in #(
+  no|yes) ;; #(
+  *)
+
+$as_echo "#define _UINT32_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
+_ACEOF
+;;
+  esac
+
+ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
+case $ac_cv_c_uint8_t in #(
+  no|yes) ;; #(
+  *)
+
+$as_echo "#define _UINT8_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint8_t $ac_cv_c_uint8_t
+_ACEOF
+;;
+  esac
+
+
+# Checks for library functions.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
+$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
+if test "${ac_cv_header_time+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_time=yes
+else
+  ac_cv_header_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
+$as_echo "$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
+
+fi
+
+
+
+
+  for ac_header in $ac_header_list
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+
+
+  for ac_func in $ac_func_list
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
+$as_echo_n "checking for working mktime... " >&6; }
+if test "${ac_cv_func_working_mktime+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_func_working_mktime=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Test program from Paul Eggert and Tony Leneis.  */
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#include <limits.h>
+#include <stdlib.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifndef HAVE_ALARM
+# define alarm(X) /* empty */
+#endif
+
+/* Work around redefinition to rpl_putenv by other config tests.  */
+#undef putenv
+
+static time_t time_t_max;
+static time_t time_t_min;
+
+/* Values we'll use to set the TZ environment variable.  */
+static char *tz_strings[] = {
+  (char *) 0, "TZ=GMT0", "TZ=JST-9",
+  "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
+};
+#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
+
+/* Return 0 if mktime fails to convert a date in the spring-forward gap.
+   Based on a problem report from Andreas Jaeger.  */
+static int
+spring_forward_gap ()
+{
+  /* glibc (up to about 1998-10-07) failed this test. */
+  struct tm tm;
+
+  /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
+     instead of "TZ=America/Vancouver" in order to detect the bug even
+     on systems that don't support the Olson extension, or don't have the
+     full zoneinfo tables installed.  */
+  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+
+  tm.tm_year = 98;
+  tm.tm_mon = 3;
+  tm.tm_mday = 5;
+  tm.tm_hour = 2;
+  tm.tm_min = 0;
+  tm.tm_sec = 0;
+  tm.tm_isdst = -1;
+  return mktime (&tm) != (time_t) -1;
+}
+
+static int
+mktime_test1 (now)
+     time_t now;
+{
+  struct tm *lt;
+  return ! (lt = localtime (&now)) || mktime (lt) == now;
+}
+
+static int
+mktime_test (now)
+     time_t now;
+{
+  return (mktime_test1 (now)
+         && mktime_test1 ((time_t) (time_t_max - now))
+         && mktime_test1 ((time_t) (time_t_min + now)));
+}
+
+static int
+irix_6_4_bug ()
+{
+  /* Based on code from Ariel Faigon.  */
+  struct tm tm;
+  tm.tm_year = 96;
+  tm.tm_mon = 3;
+  tm.tm_mday = 0;
+  tm.tm_hour = 0;
+  tm.tm_min = 0;
+  tm.tm_sec = 0;
+  tm.tm_isdst = -1;
+  mktime (&tm);
+  return tm.tm_mon == 2 && tm.tm_mday == 31;
+}
+
+static int
+bigtime_test (j)
+     int j;
+{
+  struct tm tm;
+  time_t now;
+  tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
+  now = mktime (&tm);
+  if (now != (time_t) -1)
+    {
+      struct tm *lt = localtime (&now);
+      if (! (lt
+            && lt->tm_year == tm.tm_year
+            && lt->tm_mon == tm.tm_mon
+            && lt->tm_mday == tm.tm_mday
+            && lt->tm_hour == tm.tm_hour
+            && lt->tm_min == tm.tm_min
+            && lt->tm_sec == tm.tm_sec
+            && lt->tm_yday == tm.tm_yday
+            && lt->tm_wday == tm.tm_wday
+            && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
+                 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
+       return 0;
+    }
+  return 1;
+}
+
+static int
+year_2050_test ()
+{
+  /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
+     ignoring leap seconds.  */
+  unsigned long int answer = 2527315200UL;
+
+  struct tm tm;
+  time_t t;
+  tm.tm_year = 2050 - 1900;
+  tm.tm_mon = 2 - 1;
+  tm.tm_mday = 1;
+  tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
+  tm.tm_isdst = -1;
+
+  /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
+     instead of "TZ=America/Vancouver" in order to detect the bug even
+     on systems that don't support the Olson extension, or don't have the
+     full zoneinfo tables installed.  */
+  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+
+  t = mktime (&tm);
+
+  /* Check that the result is either a failure, or close enough
+     to the correct answer that we can assume the discrepancy is
+     due to leap seconds.  */
+  return (t == (time_t) -1
+         || (0 < t && answer - 120 <= t && t <= answer + 120));
+}
+
+int
+main ()
+{
+  time_t t, delta;
+  int i, j;
+
+  /* This test makes some buggy mktime implementations loop.
+     Give up after 60 seconds; a mktime slower than that
+     isn't worth using anyway.  */
+  alarm (60);
+
+  for (;;)
+    {
+      t = (time_t_max << 1) + 1;
+      if (t <= time_t_max)
+       break;
+      time_t_max = t;
+    }
+  time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
+
+  delta = time_t_max / 997; /* a suitable prime number */
+  for (i = 0; i < N_STRINGS; i++)
+    {
+      if (tz_strings[i])
+       putenv (tz_strings[i]);
+
+      for (t = 0; t <= time_t_max - delta; t += delta)
+       if (! mktime_test (t))
+         return 1;
+      if (! (mktime_test ((time_t) 1)
+            && mktime_test ((time_t) (60 * 60))
+            && mktime_test ((time_t) (60 * 60 * 24))))
+       return 1;
+
+      for (j = 1; ; j <<= 1)
+       if (! bigtime_test (j))
+         return 1;
+       else if (INT_MAX / 2 < j)
+         break;
+      if (! bigtime_test (INT_MAX))
+       return 1;
+    }
+  return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_working_mktime=yes
+else
+  ac_cv_func_working_mktime=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5
+$as_echo "$ac_cv_func_working_mktime" >&6; }
+if test $ac_cv_func_working_mktime = no; then
+  case " $LIBOBJS " in
+  *" mktime.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS mktime.$ac_objext"
+ ;;
+esac
+
+fi
+
+for ac_func in memmove memset
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+ac_config_files="$ac_config_files Makefile src/ARIB/Makefile src/Makefile src/TS/Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by tsparser $as_me 20110219, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <koukou@users.sourceforge.jp>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+tsparser config.status 20110219
+configured by $0, generated by GNU Autoconf 2.65,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "src/ARIB/Makefile") CONFIG_FILES="$CONFIG_FILES src/ARIB/Makefile" ;;
+    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+    "src/TS/Makefile") CONFIG_FILES="$CONFIG_FILES src/TS/Makefile" ;;
+
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[    ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[    ]*#[    ]*define[       ][      ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file" \
+       || as_fn_error "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_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" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # 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" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    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"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit $?
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..bb39a11
--- /dev/null
@@ -0,0 +1,39 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.65])
+AC_INIT([tsparser], [20110219], [koukou@users.sourceforge.jp])
+AM_INIT_AUTOMAKE([foreign])
+AC_CONFIG_SRCDIR([src/tsparser.cpp])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_RANLIB
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_CHECK_HEADERS([fcntl.h inttypes.h stdlib.h string.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_MKTIME
+AC_CHECK_FUNCS([memmove memset])
+
+AC_CONFIG_FILES([Makefile
+                 src/ARIB/Makefile
+                 src/Makefile
+                 src/TS/Makefile])
+AC_OUTPUT
diff --git a/depcomp b/depcomp
new file mode 100755 (executable)
index 0000000..df8eea7
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,630 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s,\\\\\\\\,/,g"
+   depmode=msvisualcpp
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> "$depfile"
+    echo >> "$depfile"
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[     ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${
+              s/^ *//
+              s/ \\*$//
+              s/$/:/
+              p
+            }' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no eat=no
+  for arg
+  do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::     \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/install-sh b/install-sh
new file mode 100755 (executable)
index 0000000..6781b98
--- /dev/null
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""       $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+       shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+       case $mode in
+         *' '* | *'    '* | *'
+'*       | *'*'* | *'?'* | *'['*)
+           echo "$0: invalid mode: $mode" >&2
+           exit 1;;
+       esac
+       shift;;
+
+    -o) chowncmd="$chownprog $2"
+       shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+       shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)        shift
+       break;;
+
+    -*)        echo "$0: invalid option: $1" >&2
+       exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+       u_plus_rw=
+      else
+       u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dst_arg: Is a directory" >&2
+       exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+       (dirname "$dst") 2>/dev/null ||
+       expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+            X"$dst" : 'X\(//\)[^/]' \| \
+            X"$dst" : 'X\(//\)$' \| \
+            X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+       echo X"$dst" |
+           sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)[^/].*/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\/\)$/{
+                  s//\1/
+                  q
+                }
+                /^X\(\/\).*/{
+                  s//\1/
+                  q
+                }
+                s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+       # Create intermediate dirs using mode 755 as modified by the umask.
+       # This is like FreeBSD 'install' as of 1997-10-28.
+       umask=`umask`
+       case $stripcmd.$umask in
+         # Optimize common cases.
+         *[2367][2367]) mkdir_umask=$umask;;
+         .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+         *[0-7])
+           mkdir_umask=`expr $umask + 22 \
+             - $umask % 100 % 40 + $umask % 20 \
+             - $umask % 10 % 4 + $umask % 2
+           `;;
+         *) mkdir_umask=$umask,go-w;;
+       esac
+
+       # With -d, create the new directory with the user-specified mode.
+       # Otherwise, rely on $mkdir_umask.
+       if test -n "$dir_arg"; then
+         mkdir_mode=-m$mode
+       else
+         mkdir_mode=
+       fi
+
+       posix_mkdir=false
+       case $umask in
+         *[123567][0-7][0-7])
+           # POSIX mkdir -p sets u+wx bits regardless of umask, which
+           # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+           ;;
+         *)
+           tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+           trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+           if (umask $mkdir_umask &&
+               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+           then
+             if test -z "$dir_arg" || {
+                  # Check for POSIX incompatibilities with -m.
+                  # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                  # other-writeable bit of parent directory when it shouldn't.
+                  # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                  ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                  case $ls_ld_tmpdir in
+                    d????-?r-*) different_mode=700;;
+                    d????-?--*) different_mode=755;;
+                    *) false;;
+                  esac &&
+                  $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                    ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                    test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                  }
+                }
+             then posix_mkdir=:
+             fi
+             rmdir "$tmpdir/d" "$tmpdir"
+           else
+             # Remove any dirs left behind by ancient mkdir implementations.
+             rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+           fi
+           trap '' 0;;
+       esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+       umask $mkdir_umask &&
+       $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+       /*) prefix='/';;
+       -*) prefix='./';;
+       *)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+       test -z "$d" && continue
+
+       prefix=$prefix$d
+       if test -d "$prefix"; then
+         prefixes=
+       else
+         if $posix_mkdir; then
+           (umask=$mkdir_umask &&
+            $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+           # Don't fail if two instances are running concurrently.
+           test -d "$prefix" || exit 1
+         else
+           case $prefix in
+             *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+             *) qprefix=$prefix;;
+           esac
+           prefixes="$prefixes '$qprefix'"
+         fi
+       fi
+       prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+       # Don't fail if two instances are running concurrently.
+       (umask $mkdir_umask &&
+        eval "\$doit_exec \$mkdirprog $prefixes") ||
+         test -d "$dstdir" || exit 1
+       obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"    2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+       # Now remove or move aside any old file at destination location.
+       # We try this two ways since rm can't unlink itself on some
+       # systems and the destination file might be busy for other
+       # reasons.  In this case, the final cleanup might fail but the new
+       # file should still install successfully.
+       {
+         test ! -f "$dst" ||
+         $doit $rmcmd -f "$dst" 2>/dev/null ||
+         { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+           { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+         } ||
+         { echo "$0: cannot unlink or rename $dst" >&2
+           (exit 1); exit 1
+         }
+       } &&
+
+       # Now rename the file to the real destination.
+       $doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/missing b/missing
new file mode 100755 (executable)
index 0000000..28055d2
--- /dev/null
+++ b/missing
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  autom4te     touch the output file, or create a stub one
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).  This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+  lex*|yacc*)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar*)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case $f in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te*)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison*|yacc*)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+       case $LASTARG in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if test ! -f y.tab.h; then
+       echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex*|flex*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+       case $LASTARG in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if test -f "$SRCFILE"; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if test ! -f lex.yy.c; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit $?
+    fi
+    ;;
+
+  makeinfo*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+       /^@setfilename/{
+         s/.* \([^ ]*\) *$/\1/
+         p
+         q
+       }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar*)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case $firstarg in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case $firstarg in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/src/ARIB/Makefile.am b/src/ARIB/Makefile.am
new file mode 100644 (file)
index 0000000..e62bad8
--- /dev/null
@@ -0,0 +1,4 @@
+#SUBDIRS = ../TS
+noinst_LIBRARIES = libarib.a
+libarib_a_SOURCES = si.cpp si.h descriptor.cpp descriptor.h converter.h
+libarib_a_LIBADD = ../TS/libts.a
diff --git a/src/ARIB/Makefile.in b/src/ARIB/Makefile.in
new file mode 100644 (file)
index 0000000..70955de
--- /dev/null
@@ -0,0 +1,429 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  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@
+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 = :
+subdir = src/ARIB
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+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)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libarib_a_AR = $(AR) $(ARFLAGS)
+libarib_a_DEPENDENCIES = ../TS/libts.a
+am_libarib_a_OBJECTS = si.$(OBJEXT) descriptor.$(OBJEXT)
+libarib_a_OBJECTS = $(am_libarib_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+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 = $(libarib_a_SOURCES)
+DIST_SOURCES = $(libarib_a_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+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 = @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@
+RANLIB = @RANLIB@
+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@
+
+#SUBDIRS = ../TS
+noinst_LIBRARIES = libarib.a
+libarib_a_SOURCES = si.cpp si.h descriptor.cpp descriptor.h converter.h
+libarib_a_LIBADD = ../TS/libts.a
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/ARIB/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign src/ARIB/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libarib.a: $(libarib_a_OBJECTS) $(libarib_a_DEPENDENCIES) 
+       -rm -f libarib.a
+       $(libarib_a_AR) libarib.a $(libarib_a_OBJECTS) $(libarib_a_LIBADD)
+       $(RANLIB) libarib.a
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/descriptor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/si.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) '$<'`
+
+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"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @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
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+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:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+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-generic clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -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-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 -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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-noinstLIBRARIES ctags distclean distclean-compile \
+       distclean-generic distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am 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
+
+
+# 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:
diff --git a/src/ARIB/converter.h b/src/ARIB/converter.h
new file mode 100644 (file)
index 0000000..83aa35f
--- /dev/null
@@ -0,0 +1,70 @@
+#pragma once
+
+#include <inttypes.h>
+#include <time.h>
+#include <stdlib.h>
+
+
+namespace TS {
+       namespace PSI {
+               namespace ARIB {
+
+class Converter
+{
+public:
+       static time_t   date( const uint8_t *d) {
+               tm t;
+               int Y, M, D;
+               int K = 0;
+               char str[ 3];
+               const uint16_t mdj = (d[ 0] << 8) + d[ 1];
+               
+               Y = (int)((mdj - 15078.2) / 365.25);
+               M = (int)((mdj - 14956.1 - (int)(Y * 365.25)) / 30.6001);
+               D = mdj - 14956 - (int)(Y * 365.25) - (int)(M * 30.6001);
+               if( M == 14 || M == 15) {
+                       K = 1;
+               }
+               Y += K;
+               M = M - 1 - K * 12;
+               
+               t.tm_year       = Y;
+               t.tm_mon        = M - 1;
+               t.tm_mday       = D;
+
+               sprintf( str, "%02X", d[ 2]);
+               t.tm_hour = atoi( str);
+               sprintf( str, "%02X", d[ 3]);
+               t.tm_min = atoi( str);
+               sprintf( str, "%02X", d[ 4]);
+               t.tm_sec = atoi( str);
+               
+               return mktime( &t);
+       }
+       
+       static int32_t  time( const uint8_t *d) {
+               int32_t buf;
+               int32_t time = 0;
+               char str[ 3];
+               
+               sprintf( str, "%02X", d[ 0]);
+               buf = atoi( str);
+               time += buf * 3600;
+               
+               sprintf( str, "%02X", d[ 1]);
+               buf = atoi( str);
+               time += buf * 60;
+               
+               sprintf( str, "%02X", d[ 2]);
+               buf = atoi( str);
+               time += buf;
+               
+               return time;
+       }
+
+};
+
+               }
+       }
+}
+
diff --git a/src/ARIB/descriptor.cpp b/src/ARIB/descriptor.cpp
new file mode 100644 (file)
index 0000000..2b7fe19
--- /dev/null
@@ -0,0 +1,426 @@
+\r
+#include <stdio.h>\r
+#include "descriptor.h"\r
+
+using namespace TS::Description;\r
+using namespace TS::Description::ARIB;
+
+Descriptor* AribDescriptorParser::create( const uint8_t tag, const uint8_t length)
+{
+       Descriptor *p = NULL;
+
+       switch( tag) {
+       case NetworkName::TAG:
+               p = new NetworkName( length);
+               break;
+       case ServiceList::TAG:
+               p = new ServiceList( length);
+               break;
+       case Service::TAG:
+               p = new Service( length);
+               break;
+       case ShortEvent::TAG:
+               p = new ShortEvent( length);
+               break;
+       case ExtendedEvent::TAG:
+               p = new ExtendedEvent( length);
+               break;
+       case Component::TAG:
+               p = new Component( length);
+               break;
+       case Content::TAG:
+               p = new Content( length);
+               break;
+       case AudioComponent::TAG:
+               p = new AudioComponent( length);
+               break;
+       case EventGroup::TAG:
+               p = new EventGroup( length);
+               break;
+       default:
+               p = DescriptorParser::create( tag, length);
+       }
+
+       return p;
+}
+
+
+NetworkName::NetworkName( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+NetworkName::~NetworkName()
+{
+}\r
+\rint16_t NetworkName::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t index = 0;
+
+       if( descriptor_length > 0) {
+               name.assign( (char *)&data[ index], descriptor_length);
+               index += descriptor_length;
+       }
+       else {
+               name = "";
+       }
+\r
+       return Descriptor::parse( data, len);\r
+//     return index;
+}
+
+
+ServiceList::ServiceList( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+ServiceList::~ServiceList()
+{
+       services.clear();
+}\r
+\rint16_t ServiceList::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t index = 0;
+       SERVICE s;
+
+       services.clear();
+
+       while( descriptor_length > index && descriptor_length - index >= 3) {
+               s.service_id    = (data[ index] << 8) + data[ index + 1];
+               s.service_type  =  data[ index + 2];
+               index += 3;
+               
+               services.push_back( s);
+       }\r
+\r
+       return Descriptor::parse( data, len);\r
+//     return index;
+}
+
+
+
+Service::Service( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+Service::~Service()
+{
+}\r
+\rint16_t Service::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t index = 0;
+
+       service_type                                    = data[ index++];
+       service_provider_name_length    = data[ index++];
+       if( service_provider_name_length > 0) {\r
+               if( descriptor_length - index >= service_provider_name_length) {
+                       service_provider_name.assign( (char *)&data[ index], service_provider_name_length);
+                       index += service_provider_name_length;\r
+               }\r
+               else {\r
+                       return -1;\r
+               }
+       }
+       else {
+               service_provider_name = "";
+       }
+
+       service_name_length                             = data[ index++];
+       if( service_name_length > 0) {\r
+               if( descriptor_length - index >= service_name_length) {
+                       service_name.assign( (char *)&data[ index], service_name_length);
+                       index += service_name_length;\r
+               }\r
+               else {\r
+                       return -1;\r
+               }
+       }
+       else {
+               service_name = "";
+       }
+\r
+       return Descriptor::parse( data, len);\r
+//     return index;
+}
+
+ShortEvent::ShortEvent( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+ShortEvent::~ShortEvent()
+{
+}\r
+\rint16_t ShortEvent::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t index = 0;
+
+       ISO_639_language_code.assign( (char *)&data[ index], 3);
+       index += 3;
+       event_name_length =  data[ index++];
+       if( event_name_length > 0) {\r
+               if( descriptor_length - index >= event_name_length) {
+                       event_name_char.assign( (char *)&data[ index], event_name_length);
+                       index += event_name_length;\r
+               }\r
+               else {\r
+                       return -1;\r
+               }
+       }
+       else {
+               event_name_char = "";
+       }
+
+       text_length                             = data[ index++];
+       if( text_length > 0) {\r
+               if( descriptor_length - index >= text_length) {
+                       text_char.assign( (char *)&data[ index], text_length);
+                       index += text_length;\r
+               }\r
+               else {\r
+                       return -1;\r
+               }
+       }
+       else {
+               text_char = "";
+       }\r
+\r
+       return Descriptor::parse( data, len);\r
+//     return index;
+}
+
+
+ExtendedEvent::ExtendedEvent( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+ExtendedEvent::~ExtendedEvent()
+{
+       items.clear();
+}\r
+\rint16_t ExtendedEvent::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t                 index = 0;
+       int16_t                 item_index = 0;
+       const uint8_t   *buf;
+       ITEM                    item;
+
+       items.clear();
+
+       descriptor_number               = (data[ index  ] >> 4) & 0x0f;
+       last_descriptor_number  = (data[ index++] >> 0) & 0x0f;
+       ISO_639_language_code.assign( (char *)&data[ index], 3);
+       index += 3;
+       length_of_items                 =  data[ index++];
+
+       buf = &data[ index];
+       while( length_of_items > item_index) {
+               item.item_description_length = buf[ item_index++];
+               if( item.item_description_length > 0) {
+                       item.item_description_char.assign( (char *)&buf[ item_index], item.item_description_length);
+                       item_index += item.item_description_length;
+               }
+               else {
+                       item.item_description_char = "";
+               }
+               item.item_length = buf[ item_index++];
+               if( item.item_length > 0) {
+                       item.item_char.assign( (char *)&buf[ item_index], item.item_length);
+                       item_index += item.item_length;
+               }
+               else {
+                       item.item_char = "";
+               }
+               items.push_back( item);
+       }
+       index += item_index;
+       
+       text_length                             = data[ index++];
+       if( text_length > 0) {
+               text_char.assign( (char *)&data[ index], text_length);
+               index += text_length;
+       }
+       else {
+               text_char = "";
+       }\r
+\r
+       return Descriptor::parse( data, len);\r
+//     return index;
+}
+
+
+Component::Component( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+Component::~Component()
+{
+}
+
+int16_t Component::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t index = 0;
+       int16_t text_len;
+       
+       reserved_future_use     = (data[ index  ] >> 4) & 0x0f;
+       stream_content          = (data[ index++] >> 0) & 0x0f;
+       component_type          =  data[ index++];
+       component_tag           =  data[ index++];
+
+       ISO_639_language_code.assign( (char *)&data[ index], 3);
+       index += 3;
+       
+       text_len = descriptor_length - index;
+       if( text_len > 0) {
+               text_char.assign( (char *)&data[ index], text_len);
+               index += text_len;
+       }
+       else {
+               text_char = "";
+       }
+
+       return Descriptor::parse( data, len);
+//     return index;
+}
+
+
+Content::Content( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+Content::~Content()
+{
+       contents.clear();
+}\r
+\rint16_t Content::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t                 index = 0;
+       CONTENT                 content;
+
+       contents.clear();
+
+       while( descriptor_length > index) {
+               content.content_nibble_level_1  = (data[ index] >> 4) & 0x0f;
+               content.content_nibble_level_2  = (data[ index] >> 0) & 0x0f;
+               index++;
+
+               content.user_nibble_1                   = (data[ index] >> 4) & 0x0f;
+               content.user_nibble_2                   = (data[ index] >> 0) & 0x0f;
+               index++;
+
+               contents.push_back( content);
+       }\r
+\r
+       return Descriptor::parse( data, len);\r
+//     return index;
+}
+
+
+AudioComponent::AudioComponent( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+AudioComponent::~AudioComponent()
+{
+}
+
+int16_t AudioComponent::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t index = 0;
+       int16_t text_len;
+       
+       reserved_future_use_1   = (data[ index  ] >> 4) & 0x0f;
+       stream_content                  = (data[ index++] >> 0) & 0x0f;
+       component_type                  =  data[ index++];
+       component_tag                   =  data[ index++];
+       stream_type                             =  data[ index++];
+       simulcast_group_tag             =  data[ index++];
+       ES_multi_lingual_flag   = (data[ index  ] >> 7) & 0x01;
+       main_component_flag             = (data[ index  ] >> 6) & 0x01;
+       quality_indicator               = (data[ index  ] >> 4) & 0x03;
+       sampling_rate                   = (data[ index  ] >> 1) & 0x07;
+       reserved_future_use_2   = (data[ index++] >> 0) & 0x01;
+
+       ISO_639_language_code.assign( (char *)&data[ index], 3);
+       index += 3;
+       if( ES_multi_lingual_flag) {
+               ISO_639_language_code_2.assign( (char *)&data[ index], 3);
+               index += 3;
+       }
+       
+       text_len = descriptor_length - index;
+       if( text_len > 0) {
+               text_char.assign( (char *)&data[ index], text_len);
+               index += text_len;
+       }
+       else {
+               text_char = "";
+       }
+
+       return Descriptor::parse( data, len);
+//     return index;
+}
+
+
+EventGroup::EventGroup( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+EventGroup::~EventGroup()
+{
+       events.clear();
+       network_events.clear();\r
+       private_data.clear();
+}
+
+const TS::SectionBuffer* EventGroup::getPrivateData()
+{
+       return &private_data;
+}\r
+\rint16_t EventGroup::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t                 index = 0;
+       int                             i;
+       EVENT                   e;
+       NETWORK_EVENT   n;
+
+       group_type      = (data[ index] >> 4) & 0x0f;
+       event_count     = (data[ index] >> 0) & 0x0f;
+       index++;
+
+       for( i = 0; i < event_count; i++) {
+               e.service_id    = (data[ index + 0] << 8) + data[ index + 1];
+               e.event_id              = (data[ index + 2] << 8) + data[ index + 3];
+               index += 4;
+               events.push_back( e);
+       }
+
+       if( group_type == 4 || group_type == 5) {
+               while( descriptor_length > index) {
+                       n.original_network_id   = (data[ index + 0] << 8) + data[ index + 1];
+                       n.transport_stream_id   = (data[ index + 2] << 8) + data[ index + 3];
+                       n.event.service_id              = (data[ index + 4] << 8) + data[ index + 5];
+                       n.event.event_id                = (data[ index + 6] << 8) + data[ index + 7];
+                       index += 8;
+                       network_events.push_back( n);
+               }
+       }
+       else {
+               if( !private_data.create( descriptor_length - index)) {
+                       return -1;
+               }
+               private_data.append( &data[ index], descriptor_length - index);
+               index = descriptor_length;
+       }\r
+\r
+       return Descriptor::parse( data, len);\r
+}
+
+
diff --git a/src/ARIB/descriptor.h b/src/ARIB/descriptor.h
new file mode 100644 (file)
index 0000000..c21969e
--- /dev/null
@@ -0,0 +1,235 @@
+#pragma once
+
+#include <inttypes.h>
+#include <list>
+#include <string>
+#include "../TS/descriptor.h"
+#include "../TS/utils.h"
+
+
+namespace TS {
+       namespace Description {
+               namespace ARIB {
+
+class AribDescriptorParser : public TS::Description::DescriptorParser
+{
+protected:
+       TS::Description::Descriptor*    create( const uint8_t tag, const uint8_t length);
+};
+
+
+class NetworkName : public TS::Description::Descriptor
+{
+public:
+       static const uint8_t    TAG     = 0x40;
+
+       std::string                             name;
+
+       NetworkName( const uint8_t length);
+       virtual ~NetworkName();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+
+class ServiceList : public TS::Description::Descriptor
+{
+public:
+       static const uint8_t    TAG = 0x41;
+       struct SERVICE {
+               uint16_t                                service_id;
+               uint8_t                                 service_type;
+       };
+
+       typedef std::list< SERVICE>     SERVICES;
+
+       SERVICES                                services;
+
+       ServiceList( const uint8_t length);
+       virtual ~ServiceList();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+
+class Service : public TS::Description::Descriptor
+{
+public:
+       static const uint8_t    TAG = 0x48;
+
+       uint8_t                                 service_type;
+       uint8_t                                 service_provider_name_length;
+       std::string                             service_provider_name;
+       uint8_t                                 service_name_length;
+       std::string                             service_name;
+
+       Service( const uint8_t length);
+       virtual ~Service();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+class ShortEvent : public TS::Description::Descriptor
+{
+public:
+       static const uint8_t    TAG     = 0x4D;
+
+       std::string                             ISO_639_language_code;
+       uint8_t                                 event_name_length;
+       std::string                             event_name_char;
+       uint8_t                                 text_length;
+       std::string                             text_char;
+
+       ShortEvent( uint8_t length);
+       virtual ~ShortEvent();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+class ExtendedEvent : public TS::Description::Descriptor
+{
+public:
+       struct ITEM {
+               uint8_t                         item_description_length;
+               std::string                     item_description_char;
+               uint8_t                         item_length;
+               std::string                     item_char;
+       };
+
+       typedef std::list< ITEM>        ITEMS;
+
+       static const uint8_t    TAG = 0x4E;
+
+       uint8_t                                 descriptor_number;
+       uint8_t                                 last_descriptor_number;
+       std::string                             ISO_639_language_code;
+       uint8_t                                 length_of_items;
+       ITEMS                                   items;
+       uint8_t                                 text_length;
+       std::string                             text_char;
+       
+       ExtendedEvent( const uint8_t length);
+       virtual ~ExtendedEvent();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+
+class Component : public TS::Description::Descriptor
+{
+public:
+       static const uint8_t    TAG     = 0x50;
+
+       uint8_t                                 reserved_future_use;
+       uint8_t                                 stream_content;
+       uint8_t                                 component_type;
+       uint8_t                                 component_tag;
+       std::string                             ISO_639_language_code;
+       std::string                             text_char;
+
+       Component( uint8_t length);
+       virtual ~Component();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+
+class Content : public TS::Description::Descriptor
+{
+public:
+       struct CONTENT {
+               uint8_t                         content_nibble_level_1;
+               uint8_t                         content_nibble_level_2;
+               uint8_t                         user_nibble_1;
+               uint8_t                         user_nibble_2;
+       };
+
+       typedef std::list< CONTENT>     CONTENTS;
+
+       static const uint8_t    TAG = 0x54;
+
+       CONTENTS                                contents;
+       
+       Content( const uint8_t length);
+       virtual ~Content();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+
+class AudioComponent : public TS::Description::Descriptor
+{
+public:
+       static const uint8_t    TAG     = 0xC4;
+
+       uint8_t                                 reserved_future_use_1;
+       uint8_t                                 stream_content;
+       uint8_t                                 component_type;
+       uint8_t                                 component_tag;
+       uint8_t                                 stream_type;
+       uint8_t                                 simulcast_group_tag;
+       uint8_t                                 ES_multi_lingual_flag;
+       uint8_t                                 main_component_flag;
+       uint8_t                                 quality_indicator;
+       uint8_t                                 sampling_rate;
+       uint8_t                                 reserved_future_use_2;
+       std::string                             ISO_639_language_code;
+       std::string                             ISO_639_language_code_2;
+       std::string                             text_char;
+
+       AudioComponent( uint8_t length);
+       virtual ~AudioComponent();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+
+class EventGroup : public TS::Description::Descriptor
+{
+public:
+       struct EVENT {
+               uint16_t                        service_id;
+               uint16_t                        event_id;
+       };
+
+       struct NETWORK_EVENT {
+               uint16_t                        original_network_id;
+               uint16_t                        transport_stream_id;
+               EVENT                           event;
+       };
+
+       typedef std::list< EVENT>                       EVENTS;
+       typedef std::list< NETWORK_EVENT>       NETWORK_EVENTS;
+
+       static const uint8_t    TAG     = 0xD6;
+
+       uint8_t                                 group_type;                     //  4bit
+       uint8_t                                 event_count;            //  4bit
+       EVENTS                                  events;
+       NETWORK_EVENTS                  network_events;
+
+private:
+       SectionBuffer                   private_data;
+       
+public:
+       EventGroup( const uint8_t length);
+       virtual ~EventGroup();
+
+       const SectionBuffer*    getPrivateData();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+               }
+       }
+}
+
diff --git a/src/ARIB/si.cpp b/src/ARIB/si.cpp
new file mode 100644 (file)
index 0000000..106a55e
--- /dev/null
@@ -0,0 +1,305 @@
+
+#include <stdio.h>
+#include "si.h"
+
+using namespace TS::PSI;
+using namespace TS::PSI::ARIB;
+using namespace TS::Description;
+using namespace TS::Description::ARIB;
+
+ServiceInformation::ServiceInformation( int32_t id,  DescriptorParser *des_parser)
+       : Section( id, des_parser)
+{
+       si_id.transport_stream_id       = 0x00;
+       reserved_2                                      = 0x00;
+       version_number                          = 0x00;
+       current_next_indicator          = 0x00;
+       section_number                          = 0x00;
+       last_section_number                     = 0x00;
+}
+
+ServiceInformation::~ServiceInformation()
+{
+}
+
+ServiceInformation::STATUS ServiceInformation::parse( SectionBuffer &sec)
+{
+       if( section_syntax_indicator != 0) {
+               if( sec.length() < SI_PARSE_SIZE) {
+                       return ERROR_PARSE_SECTION;
+               }
+
+               si_id.transport_stream_id       = (sec[ 0] << 8) + sec[ 1];
+               reserved_2                                      = (sec[ 2] >> 6) & 0x03;
+               version_number                          = (sec[ 2] >> 1) & 0x1f;
+               current_next_indicator          = (sec[ 2] >> 0) & 0x01;
+               section_number                          =  sec[ 3];
+               last_section_number                     =  sec[ 4];
+               
+               sec += SI_PARSE_SIZE;
+       }
+
+       return parseSection( sec);
+}
+
+ServiceInformation::STATUS ServiceInformation::parseSection( SectionBuffer &sec)
+{
+       erase_buffer = false;
+       return SUCCESS;
+}
+
+
+
+NIT::NIT( DescriptorParser *des_parser)
+       : ServiceInformation( -1, des_parser)
+{
+       reserved_future_use1                    = 0x00;
+       network_descriptors_length              = 0x00;
+       reserved_future_use2                    = 0x00;
+       transport_stream_loop_length    = 0x00;
+}
+
+NIT::~NIT()
+{
+       clearNIT();
+}
+
+void NIT::clear()
+{
+       clearNIT();
+       ServiceInformation::clear();
+}
+
+NIT::STATUS NIT::parseSection( SectionBuffer &sec)
+{
+       int32_t         size = 0;
+       STREAM          s;
+       
+       clearNIT();
+
+       if( sec.length() < 2) {
+               return ERROR_PARSE_SECTION;
+       }
+       reserved_future_use1                    = (sec[ 0] >> 4) & 0x0f;
+       network_descriptors_length              = ((sec[ 0] & 0x0f) << 8) + sec[ 1];
+       sec += 2;
+       if( sec.length() < network_descriptors_length) {
+               return ERROR_PARSE_SECTION;
+       }
+       size = parseDescriptors( sec, network_descriptors_length, &networks);
+       if( size == -1) {
+               return ERROR_PARSE_SECTION;
+       }
+       sec += size;
+       
+       if( sec.length() < 2) {
+               return ERROR_PARSE_SECTION;
+       }
+       reserved_future_use2                    = (sec[ 0] >> 4) & 0x0f;
+       transport_stream_loop_length    = ((sec[ 0] & 0x0f) << 8) + sec[ 1];
+       sec += 2;
+       
+       while( sec.length() >= STREAM_HEADER_SIZE) {
+               s.transport_stream_id                   = (sec[ 0] << 8) + sec[ 1];
+               s.original_network_id                   = (sec[ 2] << 8) + sec[ 3];
+               s.reserved_future_use                   = (sec[ 4] >> 4) & 0x0f;
+               s.transport_descriptors_length  = ((sec[ 4] & 0x0f) << 8) + sec[ 5];
+               sec += STREAM_HEADER_SIZE;
+               if( sec.length() < s.transport_descriptors_length) {
+                       return ERROR_PARSE_SECTION;
+               }
+
+               size = parseDescriptors( sec, s.transport_descriptors_length, &s.descriptors);
+               if( size == -1) {
+                       return ERROR_PARSE_SECTION;
+               }
+               sec += size;
+               streams.push_back( s);
+       }
+       
+       erase_buffer = true;
+       return SUCCESS;
+}
+
+bool NIT::checkID( uint8_t id)
+{
+       if( id == 0x40 || id <= 0x41) {
+               return true;
+       }
+       else {
+               return false;
+       }
+}
+
+void NIT::clearNIT()
+{
+       STREAMS::iterator               i;
+       
+       clearDescriptors( &networks);
+       
+       for( i = streams.begin(); i != streams.end(); i++) {
+               clearDescriptors( &i->descriptors);
+       }
+       streams.clear();
+}
+
+
+SDT::SDT( DescriptorParser *des_parser)
+       : ServiceInformation( -1, des_parser)
+{
+       original_network_id     = 0x00;\r
+       reserved_future_use     = 0x00;\r
+}\r
+\r
+SDT::~SDT()\r
+{
+       clearSDT();\r
+}
+
+void SDT::clear()
+{
+       clearSDT();
+       ServiceInformation::clear();
+}\r
+\r
+SDT::STATUS SDT::parseSection( SectionBuffer &sec)\r
+{
+       int32_t         size = 0;\r
+       SERVICE         s;
+       
+       clearSDT();\r
+       
+       if( sec.length() < SD_PARSE_SIZE) {
+               return ERROR_PARSE_SECTION;
+       }
+       original_network_id                     = (sec[ 0] << 8) + sec[ 1];
+       reserved_future_use                     =  sec[ 2];\r
+       sec += SD_PARSE_SIZE;
+       \r
+       while( sec.length() >= SERVICE_HEADER_SIZE) {\r
+               s.service_id                                    = (sec[ 0] << 8) + sec[ 1];\r
+               s.reserved_future_use                   = (sec[ 2] >> 5) & 0x07;\r
+               s.EIT_user_defined_flags                = (sec[ 2] >> 2) & 0x07;\r
+               s.EIT_schedule_flag                             = (sec[ 2] >> 1) & 0x01;\r
+               s.EIT_present_following_flag    = (sec[ 2] >> 0) & 0x01;\r
+               s.running_status                                = (sec[ 3] >> 5) & 0x07;\r
+               s.free_CA_mode                                  = (sec[ 3] >> 4) & 0x01;\r
+               s.descriptors_loop_length               = ((sec[ 3] & 0x0f) << 8) + sec[ 4];
+               sec += SERVICE_HEADER_SIZE;
+               if( sec.length() < s.descriptors_loop_length) {
+                       return ERROR_PARSE_SECTION;
+               }
+
+               size = parseDescriptors( sec, s.descriptors_loop_length, &s.descriptors);
+               if( size == -1) {
+                       return ERROR_PARSE_SECTION;
+               }
+               sec += size;\r
+               services.push_back( s);
+       }\r
+       \r
+       erase_buffer = true;\r
+       return SUCCESS;\r
+}
+
+bool SDT::checkID( uint8_t id)
+{
+       if( id == 0x42 || id <= 0x46) {
+               return true;
+       }
+       else {
+               return false;
+       }
+}
+
+void SDT::clearSDT()
+{
+       SERVICES::iterator              i;
+       
+       for( i = services.begin(); i != services.end(); i++) {
+               clearDescriptors( &i->descriptors);
+       }
+       services.clear();
+}
+
+
+
+EIT::EIT( DescriptorParser *des_parser)
+       : ServiceInformation( -1, des_parser)
+{
+       transport_stream_id                     = 0x00;\r
+       original_network_id                     = 0x00;\r
+       segment_last_section_number     = 0x00;\r
+       last_table_id                           = 0x00;\r
+}\r
+\r
+EIT::~EIT()\r
+{
+       clearEIT();\r
+}
+
+void EIT::clear()
+{
+       clearEIT();
+       ServiceInformation::clear();
+}\r
+\r
+EIT::STATUS EIT::parseSection( SectionBuffer &sec)\r
+{
+       int32_t         size = 0;\r
+       EVENT           e;
+       
+       clearEIT();\r
+       
+       if( sec.length() < EI_PARSE_SIZE) {
+               return ERROR_PARSE_SECTION;
+       }\r
+       transport_stream_id             = (sec[ 0] << 8) + sec[ 1];\r
+       original_network_id                     = (sec[ 2] << 8) + sec[ 3];\r
+       segment_last_section_number     =  sec[ 4];\r
+       last_table_id                           =  sec[ 5];\r
+       sec += EI_PARSE_SIZE;
+       \r
+       while( sec.length() >= EVENT_HEADER_SIZE) {\r
+               e.event_id                                      = (sec[ 0] << 8) + sec[ 1];\r
+               e.start_time                            = Converter::date( &sec[ 2]);\r
+               e.duration                                      = Converter::time( &sec[ 7]);\r
+               e.running_status                        = (sec[ 10] >> 5) & 0x07;\r
+               e.free_CA_mode                          = (sec[ 10] >> 4) & 0x01;\r
+               e.descriptors_loop_length       = ((sec[ 10] & 0x0f) << 8) + sec[ 11];
+               sec += EVENT_HEADER_SIZE;
+               if( sec.length() < e.descriptors_loop_length) {
+                       return ERROR_PARSE_SECTION;
+               }
+
+               size = parseDescriptors( sec, e.descriptors_loop_length, &e.descriptors);
+               if( size == -1) {
+                       return ERROR_PARSE_SECTION;
+               }
+               sec += size;\r
+               events.push_back( e);
+       }\r
+       \r
+       erase_buffer = true;\r
+       return SUCCESS;\r
+}
+
+bool EIT::checkID( uint8_t id)
+{
+       if( id >= 0x4E && id <= 0x6F) {
+               return true;
+       }
+       else {
+               return false;
+       }
+}
+
+void EIT::clearEIT()
+{
+       EVENTS::iterator                i;
+       
+       for( i = events.begin(); i != events.end(); i++) {
+               clearDescriptors( &i->descriptors);
+       }
+       events.clear();
+}\r
diff --git a/src/ARIB/si.h b/src/ARIB/si.h
new file mode 100644 (file)
index 0000000..e5cc77e
--- /dev/null
@@ -0,0 +1,206 @@
+#pragma once
+
+#include <inttypes.h>
+#include <list>
+#include "../TS/psi.h"
+#include "../TS/utils.h"
+#include "descriptor.h"
+#include "converter.h"
+
+namespace TS {
+       namespace PSI {
+               namespace ARIB {
+
+class ServiceInformation : public TS::PSI::Section
+{
+protected:
+       static const uint32_t           SI_PARSE_SIZE   = 5;
+
+public:
+       union ID {
+               uint16_t                network_id;                             // NIT, TLV-NIT
+               uint16_t                bouquet_id;                             // BAT
+               uint16_t                transport_stream_id;    // SDT
+               uint16_t                service_id;                             // EIT, PCAT
+               uint16_t                original_network_id;    // BIT, NBIT
+               uint16_t                original_service_id;    // LDT
+               uint16_t                table_id_extension;             // AMT
+       } si_id;                                                                        // 16bit
+
+       uint8_t                         reserved_2;                             //  2bit
+       uint8_t                         version_number;                 //  5bit
+       uint8_t                         current_next_indicator; //  1bit
+       uint8_t                         section_number;                 //  8bit
+       uint8_t                         last_section_number;    //  8bit
+
+       ServiceInformation( int32_t id = -1, TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~ServiceInformation();
+
+protected:
+       STATUS                  parse( SectionBuffer &sec);
+       virtual STATUS  parseSection( SectionBuffer &sec);
+};
+
+class NIT : public ServiceInformation
+{
+private:
+       static const uint32_t           STREAM_HEADER_SIZE              = 6;
+       
+public:
+       struct STREAM {
+               uint16_t                transport_stream_id;                    // 16bit
+               uint16_t                original_network_id;                    // 16bit
+               uint8_t                 reserved_future_use;                    //  4bit
+               uint16_t                transport_descriptors_length;   // 12bit
+               DESCRIPTORS             descriptors;
+       };
+       typedef std::list< STREAM>      STREAMS;
+       
+       uint8_t                         reserved_future_use1;                   //  4bit
+       uint16_t                        network_descriptors_length;             // 12bit
+       DESCRIPTORS                     networks;
+       uint8_t                         reserved_future_use2;                   //  4bit
+       uint16_t                        transport_stream_loop_length;   // 12bit
+       STREAMS                         streams;
+       
+public:
+       NIT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~NIT();
+
+       void    clear();
+       
+private:
+       STATUS  parseSection( SectionBuffer &sec);
+       bool    checkID( uint8_t id);
+
+       void    clearNIT();
+};
+
+
+// SDT 0x42, 0x46
+class SDT : public ServiceInformation
+{
+private:
+       static const uint32_t           SD_PARSE_SIZE           = 3;
+       static const uint32_t           SERVICE_HEADER_SIZE     = 5;
+
+public:
+       struct SERVICE {
+               uint16_t                service_id;                                             // 16bit
+               uint8_t                 reserved_future_use;                    //  3bit
+               uint8_t                 EIT_user_defined_flags;                 //  3bit
+               uint8_t                 EIT_schedule_flag;                              //  1bit
+               uint8_t                 EIT_present_following_flag;             //  1bit
+               uint8_t                 running_status;                                 //  3bit
+               uint8_t                 free_CA_mode;                                   //  1bit
+               uint16_t                descriptors_loop_length;                // 12bit
+               DESCRIPTORS             descriptors;
+       };
+       typedef std::list< SERVICE>     SERVICES;
+
+       uint16_t                        original_network_id;                    // 16bit
+       uint8_t                         reserved_future_use;                    //  8bit
+       SERVICES                        services;
+       
+public:
+       SDT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~SDT();
+
+       void    clear();
+       
+private:
+       STATUS  parseSection( SectionBuffer &sec);
+       bool    checkID( uint8_t id);
+
+       void    clearSDT();
+};
+
+
+// EIT
+class EIT : public ServiceInformation
+{
+private:
+       static const uint32_t   EI_PARSE_SIZE           = 6;
+       static const uint32_t   EVENT_HEADER_SIZE       = 12;
+
+public:
+       struct EVENT {
+       public:
+               uint16_t                event_id;                                               // 16bit
+               time_t                  start_time;                                             // 40bit
+               int32_t                 duration;                                               // 24bit sec
+               uint8_t                 running_status;                                 //  3bit
+               uint8_t                 free_CA_mode;                                   //  1bit
+               uint16_t                descriptors_loop_length;                // 12bit
+               DESCRIPTORS             descriptors;
+       };
+       typedef std::list< EVENT>       EVENTS;
+
+       uint16_t                        transport_stream_id;                    // 16bit
+       uint16_t                        original_network_id;                    // 16bit
+       uint8_t                         segment_last_section_number;    //  8bit
+       uint8_t                         last_table_id;                                  //  8bit
+       EVENTS                          events;
+       
+public:
+       EIT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~EIT();
+
+       void    clear();
+       
+private:
+       STATUS  parseSection( SectionBuffer &sec);
+       bool    checkID( uint8_t id);
+
+       void    clearEIT();
+};
+
+               }
+       }
+}
+
+/*
+network_information_section(){
+       reserved_future_use 4 bslbf
+       network_descriptors_length 12 uimsbf
+
+bouquet_association_section(){
+       reserved_future_use 4 bslbf
+       bouquet_descriptors_length 12 uimsbf
+
+service description section(){
+       original_network_id 16 uimsbf
+       reserved_future_use 8 bslbf
+
+event_information_section(){
+       transport_stream_id 16 uimsbf
+       original_network_id 16 uimsbf
+       segment_last_section_number 8 uimsbf
+       last_table_id 8 uimsbf
+
+partial_content_announcement_section(){
+       transport_stream_id 16 uimsbf
+       original_network_id 16 uimsbf
+       content_id 32 uimsbf
+       num_of_content_version 8 uimsbf
+
+broadcaster_information _section(){
+       reserved_future_use 3 bslbf
+       broadcast_view_propriety 1 bslbf
+       first_descriptors_length 12 uimsbf
+
+network_board_information_section()
+
+linked_description_section(){
+       transport_stream_id 16 uimsbf
+       original_network_id 16 uimsbf
+
+TLV_network_information_table( ){
+       reserved_future_use 4 bslbf
+       network_descriptors_length 12 bslbf
+
+address_map_table() {
+       num_of_service_id 10 uimsbf
+       reserved_future_use 6 bslbf
+
+*/
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..8010f16
--- /dev/null
@@ -0,0 +1,8 @@
+SUBDIRS = TS ARIB
+
+bin_PROGRAMS = tsparser eit2xml
+eit2xml_SOURCES = eit2xml.cpp epg.cpp epg.h aribstr.cpp aribstr.h
+eit2xml_LDADD = ARIB/libarib.a TS/libts.a
+
+tsparser_SOURCES = tsparser.cpp aribstr.cpp aribstr.h
+tsparser_LDADD = ARIB/libarib.a TS/libts.a
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644 (file)
index 0000000..d07418c
--- /dev/null
@@ -0,0 +1,625 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  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@
+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 = tsparser$(EXEEXT) eit2xml$(EXEEXT)
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+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)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_eit2xml_OBJECTS = eit2xml.$(OBJEXT) epg.$(OBJEXT) aribstr.$(OBJEXT)
+eit2xml_OBJECTS = $(am_eit2xml_OBJECTS)
+eit2xml_DEPENDENCIES = ARIB/libarib.a TS/libts.a
+am_tsparser_OBJECTS = tsparser.$(OBJEXT) aribstr.$(OBJEXT)
+tsparser_OBJECTS = $(am_tsparser_OBJECTS)
+tsparser_DEPENDENCIES = ARIB/libarib.a TS/libts.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+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 = $(eit2xml_SOURCES) $(tsparser_SOURCES)
+DIST_SOURCES = $(eit2xml_SOURCES) $(tsparser_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+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 = @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@
+RANLIB = @RANLIB@
+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@
+SUBDIRS = TS ARIB
+eit2xml_SOURCES = eit2xml.cpp epg.cpp epg.h aribstr.cpp aribstr.h
+eit2xml_LDADD = ARIB/libarib.a TS/libts.a
+tsparser_SOURCES = tsparser.cpp aribstr.cpp aribstr.h
+tsparser_LDADD = ARIB/libarib.a TS/libts.a
+all: all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       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)
+eit2xml$(EXEEXT): $(eit2xml_OBJECTS) $(eit2xml_DEPENDENCIES) 
+       @rm -f eit2xml$(EXEEXT)
+       $(CXXLINK) $(eit2xml_OBJECTS) $(eit2xml_LDADD) $(LIBS)
+tsparser$(EXEEXT): $(tsparser_OBJECTS) $(tsparser_DEPENDENCIES) 
+       @rm -f tsparser$(EXEEXT)
+       $(CXXLINK) $(tsparser_OBJECTS) $(tsparser_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aribstr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eit2xml.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epg.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsparser.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) '$<'`
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @fail= failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+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: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       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: ctags-recursive $(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"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @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
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(PROGRAMS)
+installdirs: installdirs-recursive
+installdirs-am:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+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-recursive
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic ctags ctags-recursive distclean \
+       distclean-compile distclean-generic distclean-tags distdir 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 \
+       installdirs-am maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
+       ps ps-am tags tags-recursive 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:
diff --git a/src/TS/Makefile.am b/src/TS/Makefile.am
new file mode 100644 (file)
index 0000000..e1f29ac
--- /dev/null
@@ -0,0 +1,2 @@
+noinst_LIBRARIES = libts.a
+libts_a_SOURCES = ts_packet.cpp ts_packet.h psi.cpp psi.h descriptor.cpp descriptor.h utils.h
diff --git a/src/TS/Makefile.in b/src/TS/Makefile.in
new file mode 100644 (file)
index 0000000..ed2ce3f
--- /dev/null
@@ -0,0 +1,428 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  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@
+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 = :
+subdir = src/TS
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+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)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libts_a_AR = $(AR) $(ARFLAGS)
+libts_a_LIBADD =
+am_libts_a_OBJECTS = ts_packet.$(OBJEXT) psi.$(OBJEXT) \
+       descriptor.$(OBJEXT)
+libts_a_OBJECTS = $(am_libts_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+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 = $(libts_a_SOURCES)
+DIST_SOURCES = $(libts_a_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+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 = @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@
+RANLIB = @RANLIB@
+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@
+noinst_LIBRARIES = libts.a
+libts_a_SOURCES = ts_packet.cpp ts_packet.h psi.cpp psi.h descriptor.cpp descriptor.h utils.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/TS/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign src/TS/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libts.a: $(libts_a_OBJECTS) $(libts_a_DEPENDENCIES) 
+       -rm -f libts.a
+       $(libts_a_AR) libts.a $(libts_a_OBJECTS) $(libts_a_LIBADD)
+       $(RANLIB) libts.a
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/descriptor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ts_packet.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) '$<'`
+
+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"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @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
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+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:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+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-generic clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -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-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 -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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-noinstLIBRARIES ctags distclean distclean-compile \
+       distclean-generic distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am 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
+
+
+# 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:
diff --git a/src/TS/descriptor.cpp b/src/TS/descriptor.cpp
new file mode 100644 (file)
index 0000000..3c519f3
--- /dev/null
@@ -0,0 +1,149 @@
+\r
+#include <stdio.h>\r
+#include "descriptor.h"\r
+\r
+using namespace TS::Description;
+
+Descriptor* DescriptorParser::parse( const uint8_t *data, const uint16_t len, uint16_t *parse_size)
+{
+       uint8_t         des_tag;
+       uint8_t         des_length;
+       int16_t         ret;
+       int16_t         index = 0;
+       Descriptor      *p = NULL;
+       
+       *parse_size = 0;
+
+       if( len < 2) {
+               return NULL;
+       }
+
+       des_tag         = data[ index++];
+       des_length      = data[ index++];
+       if( des_length > len - index) {
+               return NULL;
+       }
+
+       p = create( des_tag, des_length);
+       if( !p) {
+               return p;
+       }
+
+       ret = p->parse( &data[ index], len - index);
+       if( ret < 0) {\r
+               fprintf( stderr, "Descriptor parse error tag = 0x%02X, len = %d\n", des_tag, des_length);
+               delete p;
+               p = NULL;
+       }
+       else if( ret != des_length) {
+               fprintf( stderr, "des overflow tag = 0x%02X, len = %d, ret = %d\n", des_tag, des_length, ret);
+               for( int i = 0; i < des_length;) {
+                       for( int j = 0; j < 16 && i < des_length; j++, i++) {
+                               fprintf( stderr, "%02X ", data[ index + i]);
+                       }
+                       fprintf( stderr, "\n");
+               }
+               delete p;
+               p = NULL;
+       }
+       else {
+               index += ret;
+               *parse_size = index;
+       }
+
+       return p;
+}
+
+Descriptor* DescriptorParser::create( const uint8_t tag, const uint8_t length)
+{
+       Descriptor *p = NULL;
+
+       switch( tag) {
+       case ConditionalAccess::TAG:
+               p = new ConditionalAccess( length);
+               break;
+       default:
+               p = new Descriptor( tag, length);
+       }
+               
+       return p;
+}
+
+       \r
+\r
+Descriptor::Descriptor(  const uint8_t tag, const uint8_t length)
+       : descriptor_tag( tag), descriptor_length( length)\r
+{\r
+       descriptor.clear();\r
+}\r
+\r
+Descriptor::~Descriptor()\r
+{\r
+       descriptor.clear();\r
+}\r
+\r
+int16_t Descriptor::parse( const uint8_t *data, const uint16_t len)\r
+{\r
+       if( !descriptor.create( descriptor_length)) {\r
+               return -1;\r
+       }\r
+       descriptor.append( data, descriptor_length);\r
+       return descriptor_length;\r
+}\r
+\r
+int16_t Descriptor::getBytes( TS::SectionBuffer &buf)\r
+{\r
+       if( descriptor.size() != descriptor_length) {\r
+               return -1;\r
+       }\r
+\r
+       if( !buf.append( descriptor_tag)) {\r
+               return -1;\r
+       }\r
+       if( !buf.append( descriptor_length)) {\r
+               return -1;\r
+       }\r
+       if( !buf.append( descriptor.begin(), descriptor.size())) {\r
+               return -1;\r
+       }\r
+       buf += descriptor.size() + 2;\r
+\r
+       return descriptor.size() + 2;\r
+}
+
+
+ConditionalAccess::ConditionalAccess( const uint8_t length)
+       : Descriptor( TAG, length)
+{
+}
+
+ConditionalAccess::~ConditionalAccess()
+{\r
+       private_data.clear();
+}
+
+const TS::SectionBuffer* ConditionalAccess::getPrivateData()
+{
+       return &private_data;
+}\r
+\rint16_t ConditionalAccess::parse( const uint8_t *data, const uint16_t len)
+{
+       int16_t                 index = 0;
+
+       CA_system_ID    = (data[ index + 0] << 8) + data[ index + 1];
+       reserved                = (data[ index + 2] >> 5) & 0x07;
+       CA_PID                  = ((data[ index + 2] & 0x1f) << 8) + data[ index + 3];
+       index += 4;
+
+       if( !private_data.create( descriptor_length - index)) {
+               return -1;
+       }
+       private_data.append( &data[ index], descriptor_length - index);
+       index = descriptor_length;
+\r
+       return Descriptor::parse( data, len);
+//     return index;
+}
+
+
+
diff --git a/src/TS/descriptor.h b/src/TS/descriptor.h
new file mode 100644 (file)
index 0000000..6a429f6
--- /dev/null
@@ -0,0 +1,79 @@
+#pragma once
+
+#include <inttypes.h>
+#include <list>
+#include <string>
+#include "utils.h"
+
+
+namespace TS {
+       namespace Description {
+
+class Descriptor;
+
+class DescriptorParser
+{
+public:
+       Descriptor*     parse( const uint8_t *data, const uint16_t len, uint16_t *parse_size);
+
+protected:
+       virtual Descriptor*     create( const uint8_t tag, const uint8_t length);
+};
+
+
+class DescriptorList : public TS::List< Descriptor>
+{
+
+};
+
+
+class Descriptor
+{
+       friend class DescriptorParser;
+
+public:
+       static const uint8_t    TAG     = 0x00;
+       const uint8_t                   descriptor_tag;
+       const uint8_t                   descriptor_length;
+
+private:
+       TS::SectionBuffer               descriptor;
+
+protected:
+       Descriptor( const uint8_t tag, const uint8_t length);
+
+public:
+       virtual ~Descriptor();
+
+       virtual int16_t         getBytes( SectionBuffer &buf);
+
+protected:
+       virtual int16_t         parse( const uint8_t *data, const uint16_t len);
+
+};
+
+class ConditionalAccess : public Descriptor
+{
+public:
+       static const uint8_t    TAG     = 0x09;
+
+       uint16_t                                CA_system_ID;           // 16bit
+       uint8_t                                 reserved;                       //  3bit
+       uint16_t                                CA_PID;                         // 13bit
+
+private:
+       TS::SectionBuffer               private_data;
+       
+public:
+       ConditionalAccess( const uint8_t length);
+       virtual ~ConditionalAccess();
+
+       const SectionBuffer*    getPrivateData();
+
+private:
+       int16_t         parse( const uint8_t *data, const uint16_t len);
+};
+
+       }
+}
+
diff --git a/src/TS/psi.cpp b/src/TS/psi.cpp
new file mode 100644 (file)
index 0000000..e8de170
--- /dev/null
@@ -0,0 +1,811 @@
+
+#include <stdio.h>
+#include "psi.h"
+
+using namespace TS;
+using namespace TS::PSI;
+using namespace TS::Description;
+
+Section::Section( int32_t id, DescriptorParser *des_parser)
+       : check_id( id)
+{
+       descriptor_parser       = des_parser;
+       ts_packet                       = NULL;
+
+       clear();
+}
+
+Section::~Section()
+{
+       clear();
+}
+
+Section::STATUS Section::append( TSPacket *p, uint32_t *payload_index)
+{
+       uint8_t         *payload, *begin, *end;
+       uint32_t        payload_len;
+       uint32_t        i;
+       int                     pointer_field = -1;
+       uint8_t         *sec_buf;
+       uint16_t        sec_len;
+       uint32_t        len = 0;
+       STATUS          status;
+
+       if( !(p->getHeader()->getAdaptationFieldControl() & 0x01)) {
+               return NO_SECTION;
+       }
+       
+       payload_len = p->getPayload( &payload);
+       begin = payload;
+       end = payload + payload_len;
+
+       if( p->getHeader()->getPayloadUnitStartIndicator()) {
+               if( *payload_index == 0) {
+                       pointer_field = payload[ 0];
+                       payload++;
+                       payload_len--;
+               }
+               else {
+                       pointer_field = *payload_index;
+               }
+       }
+       
+       if( !section_continue) {
+               if( pointer_field == -1) {
+                       return ERROR_START_SECTION;
+               }
+               if( payload_len < pointer_field) {
+                       return ERROR_PAYLOAD_LENGTH;
+               }
+               payload += pointer_field;
+               payload_len -= pointer_field;
+
+               if( !checkID( payload[ 0])) {
+                       return ERROR_TABLE_ID;
+               }
+
+               clear();
+               
+               if( !section_buffer.create()) {
+                       return ERROR_ALLOCATE_MEMORY;
+               }
+       }
+
+       if( (status = checkTSPacket( p)) != SUCCESS) {
+               return status;
+       }
+       
+       if( section_buffer.size() < SECTION_PARSE_SIZE) {
+               len = SECTION_PARSE_SIZE - section_buffer.size();
+               if( len > payload_len) {
+                       section_buffer.append( payload, payload_len);
+                       section_continue = true;
+                       return CONTINUE;
+               }
+               section_buffer.append( payload, len);
+               payload += len;
+               payload_len -= len;
+               parseHeader( section_buffer);
+       }
+       
+       len = section_length + SECTION_PARSE_SIZE - section_buffer.size();
+       if( len > payload_len) {
+               section_continue = true;
+               len = payload_len;
+       }
+       else {
+               section_continue = false;
+       }
+       if( !section_buffer.append( payload, len)) {
+               return ERROR_SECTION_OVERFLOW;
+       }
+       payload += len;
+       payload_len -= len;
+       
+       if( section_continue) {
+               return CONTINUE;
+       }
+
+       if( (status = parse( section_buffer)) != SUCCESS) {
+               return status;
+       }
+       
+       if( section_syntax_indicator) {
+               if( section_buffer.length() < 4) {
+                       return ERROR_PARSE_SECTION;
+               }
+               CRC_32 = 0;
+               for( i = 0; i < CRC32_SIZE; i++) {
+                       CRC_32 |= section_buffer[ i] << ((CRC32_SIZE - 1 - i) * 8);
+               }
+               section_buffer.reset();
+               CRC crc;
+               if( check_crc && crc( section_buffer, section_buffer.size())) {
+                       return ERROR_CRC;
+               }
+       }
+       
+       if( erase_buffer) {
+               section_buffer.clear();
+       }
+       else {
+               section_buffer.reset();
+       }
+
+       if( payload_len > 0 && payload[ 0] != 0xFF) {
+               *payload_index = payload - begin;
+               return INCLUDE_NEW_SECTION;
+       }
+       return SUCCESS;
+}
+
+bool Section::finish()
+{
+       return !section_continue;
+}
+
+Section::STATUS Section::getTSPacket( TSPacket **packet, uint8_t *counter, AdaptationField *af, bool next)
+{
+       STATUS          status;
+       uint8_t         afc = 0;
+
+       TSPacket        *tmp = NULL;
+       Header          *h = new Header();
+       uint32_t        payload_len = TSPacket::TS_PACKET_SIZE;
+
+       if( next && !ts_packet) {
+               next = false;
+       }
+
+       if( ts_packet) {
+               delete ts_packet;
+               ts_packet = NULL;
+       }
+
+       if( !next) {
+               status = createBytes();
+               if( status != SUCCESS) {
+#if 0
+                       if( !af) {
+                               return status;
+                       }
+#else
+                       return status;
+#endif
+               }
+               section_buffer.reset();
+       }
+
+       payload_len -= h->size();
+       if( af) {
+               // アダプテーション有り
+               afc |= 0x02;
+               payload_len -= af->getAdaptationFieldLength();
+       }
+       if( section_buffer.size() > 0) {
+               // ペイロード有り
+               if( !next) {
+                       payload_len -= 1;               // pointer_field
+               }
+
+               if( payload_len > 0) {
+                       afc |= 0x01;
+               }
+       }
+
+       h->setPid( ts_pid);
+       h->setPayloadUnitStartIndicator( next ? 0x00 : 0x01);
+       h->setAdaptationFieldControl( afc);
+       h->setContinuityCounter( *counter);
+
+       if( (afc & 0x01)) {
+               uint8_t payload[ TSPacket::TS_PACKET_SIZE];
+               if( payload_len > section_buffer.length()) {
+                       payload_len = section_buffer.length();
+               }
+               if( !next) {
+                       payload[ 0] = 0x00;
+                       memcpy( &payload[ 1], section_buffer, payload_len);
+                       section_buffer += payload_len;
+                       payload_len += 1;
+               }
+               else {
+                       memcpy( &payload[ 0], section_buffer, payload_len);
+                       section_buffer += payload_len;
+               }
+               ts_packet = TSPacket::create( h, af, payload, payload_len);
+//             section_buffer += payload_len;
+               (*counter)++;
+               (*counter) &= 0x0f;
+       }
+       else {
+               ts_packet = TSPacket::create( h, af, NULL, 0);
+       }
+
+       *packet = ts_packet;
+
+       return SUCCESS;
+}
+
+void Section::clear()
+{
+       table_id                                        = 0x00;
+       section_syntax_indicator        = 0x00;
+       private_indicator                       = 0x00;
+       reserved_1                                      = 0x00;
+       section_length                          = 0x00;
+
+       CRC_32                                          = 0x00;
+
+       ts_pid                          = 0;
+       prev_ts_counter         = 0;
+
+       section_continue        = false;
+       erase_buffer            = true;
+       check_crc                       = true;
+
+       if( ts_packet) {
+               delete ts_packet;
+       }
+       ts_packet                       = NULL;
+
+       section_buffer.clear();
+}
+
+int32_t Section::parseDescriptors( const uint8_t *data, const uint16_t len, DESCRIPTORS *list)
+{
+       int16_t                                 index = 0;
+       uint16_t                                size = 0;
+
+       DescriptorParser                parser;
+       DescriptorParser                *p = descriptor_parser;
+       Descriptor                              *des;
+
+       if( !p) {
+               p = &parser;
+       }
+
+       list->clear();
+       while( len - index > 0) {
+               des = p->parse( &data[ index], len - index, &size);
+               if( !des) {
+                       fprintf( stderr, "sec_len = %d, des_loop_len = %d, parse_index = %d, tag = 0x%02X, des_len = %d\n",
+                                        section_length, len, index, data[ index], data[ index + 1]);
+
+                       DESCRIPTORS::iterator d;
+                       for( d = list->begin(); d != list->end(); d++) {
+                               fprintf( stderr, "0x%02X, %d\n", (*d)->descriptor_tag, (*d)->descriptor_length);
+                       }
+                       fprintf( stderr, "\n");
+                       fprintf( stderr, "Descriptor err\n");
+                       clearDescriptors( list);
+                       return -1;
+               }
+               index += size;
+               list->push_back( des);
+       }
+
+       return index;
+}
+
+void Section::clearDescriptors( DESCRIPTORS *list)
+{
+       DESCRIPTORS::iterator i;
+       for( i = list->begin(); i != list->end(); i++) {
+               if( *i) {
+                       delete *i;
+                       *i = NULL;
+               }
+       }
+       list->clear();
+}
+
+Section::STATUS Section::checkTSPacket( TSPacket *p)
+{
+       uint16_t        pid             = p->getPID();
+       uint8_t         counter = p->getHeader()->getContinuityCounter();
+
+       if( section_continue) {
+               if( pid != ts_pid) {
+                       return ERROR_TS_PID;
+               }
+               if( counter != ((prev_ts_counter + 1) & 0x0f)) {
+                       fprintf( stderr, "prev = %2d, cur = %2d, cal = %2d\n", prev_ts_counter, counter, (prev_ts_counter + 1)& 0x0f);
+                       return ERROR_TS_COUNTER;
+               }
+       }
+       else {
+               ts_pid = pid;
+       }
+       prev_ts_counter = counter;
+       return SUCCESS;
+}
+
+void Section::parseHeader( SectionBuffer &sec)
+{
+       table_id                                        =  sec[ 0];
+       section_syntax_indicator        = (sec[ 1] >> 7) & 0x01;
+       private_indicator                       = (sec[ 1] >> 6) & 0x01;
+       reserved_1                                      = (sec[ 1] >> 4) & 0x03;
+       section_length                          = ((sec[ 1] & 0x0f) << 8) + sec[ 2];
+       sec += SECTION_PARSE_SIZE;
+}
+
+Section::STATUS Section::parse( SectionBuffer &sec)
+{
+       erase_buffer = false;
+       return SUCCESS;
+}
+
+bool Section::checkID( uint8_t id)
+{
+       if( check_id != -1) {
+               if( check_id != id) {
+                       return false;
+               }
+       }
+       return true;
+}
+
+Section::STATUS Section::createBytes()
+{
+       STATUS                  status;
+       SectionBuffer   buf;
+       CRC                             crc;
+
+       if( !erase_buffer) {
+               return SUCCESS;
+       }
+
+       if( !buf.create()) {
+               return ERROR_ALLOCATE_MEMORY;
+       }
+       status = getBytes( buf);
+       if( status != SUCCESS) {
+               return status;
+       }
+       section_length = buf.size() + CRC32_SIZE;
+
+       if( !section_buffer.create()) {
+               return ERROR_ALLOCATE_MEMORY;
+       }
+       if( !section_buffer.reserve( SECTION_PARSE_SIZE)) {
+               return ERROR_GETBYTES_OVERFLOW;
+       }
+       section_buffer[ 0] = table_id;
+       Bits::set( &section_buffer[ 1], section_syntax_indicator      ,  7, 0x01);
+       Bits::set( &section_buffer[ 1], private_indicator             ,  6, 0x01);
+       Bits::set( &section_buffer[ 1], private_indicator             ,  4, 0x03);
+       Bits::set( &section_buffer[ 1], (uint8_t)(section_length >> 8),  0, 0x0f);
+       section_buffer[ 2] = section_length & 0xff;
+       section_buffer += SECTION_PARSE_SIZE;
+
+       if( !section_buffer.append( buf.begin(), buf.size())) {
+               return ERROR_GETBYTES_OVERFLOW;
+       }
+
+       uint32_t        crc32 = crc( section_buffer.begin(), section_buffer.size());
+       uint8_t         crc_buf[ CRC32_SIZE];
+       int i;
+       for( i = 0; i < CRC32_SIZE; i++) {
+               crc_buf[ i] = (uint8_t)(crc32 >> ((CRC32_SIZE - 1 - i) * 8));
+               if( !section_buffer.append( (uint8_t)(crc32 >> ((CRC32_SIZE - 1 - i) * 8)))) {
+                       return ERROR_GETBYTES_OVERFLOW;
+               }
+       }
+       return SUCCESS;
+}
+
+Section::STATUS Section::getBytes( SectionBuffer &buf)
+{
+       return ERROR_NOT_IMPLEMENT_GETBYTES;
+}
+
+
+ProgramSpecificInfomation::ProgramSpecificInfomation( int32_t id, DescriptorParser *des_parser)
+       : Section( id, des_parser)
+{
+       psi_id.transport_stream_id      = 0x00;
+       reserved_2                                      = 0x00;
+       version_number                          = 0x00;
+       current_next_indicator          = 0x00;
+       section_number                          = 0x00;
+       last_section_number                     = 0x00;
+}
+
+ProgramSpecificInfomation::~ProgramSpecificInfomation()
+{
+}
+
+ProgramSpecificInfomation::STATUS ProgramSpecificInfomation::parse( SectionBuffer &sec)
+{
+       if( section_syntax_indicator != 0) {
+               if( sec.length() < PSI_HEADER_SIZE) {
+                       return ERROR_PARSE_SECTION;
+               }
+
+               psi_id.transport_stream_id      = (sec[ 0] << 8) + sec[ 1];
+               reserved_2                                      = (sec[ 2] >> 6) & 0x03;
+               version_number                          = (sec[ 2] >> 1) & 0x1f;
+               current_next_indicator          = (sec[ 2] >> 0) & 0x01;
+               section_number                          =  sec[ 3];
+               last_section_number                     =  sec[ 4];
+               
+               sec += PSI_HEADER_SIZE;
+       }
+
+       return parseSection( sec);
+}
+
+ProgramSpecificInfomation::STATUS ProgramSpecificInfomation::parseSection( SectionBuffer &sec)
+{
+       erase_buffer = true;
+       return SUCCESS;
+}
+
+ProgramSpecificInfomation::STATUS ProgramSpecificInfomation::getBytes( SectionBuffer &buf)
+{
+       uint16_t id = psi_id.transport_stream_id;
+
+       if( !buf.reserve( PSI_HEADER_SIZE)) {
+               return ERROR_GETBYTES_OVERFLOW;
+       }
+
+       buf[ 0] = (uint8_t)((id >> 8) & 0xff);
+       buf[ 1] = (uint8_t)(id & 0xff);
+
+       Bits::set( &buf[ 2], reserved_2            , 6, 0x03);
+       Bits::set( &buf[ 2], version_number        , 1, 0x1f);
+       Bits::set( &buf[ 2], current_next_indicator, 0, 0x01);
+
+       buf[ 3] = section_number;
+       buf[ 4] = last_section_number;
+
+       buf += PSI_HEADER_SIZE;
+
+       return SUCCESS;
+}
+
+
+
+PAT::PAT( DescriptorParser *des_parser)
+       : ProgramSpecificInfomation( ID, des_parser)
+{
+       network_PID = 0;
+       program_map_PID.clear();
+}
+
+PAT::~PAT()
+{
+       program_map_PID.clear();
+}
+
+void PAT::clear()
+{
+       program_map_PID.clear();
+       ProgramSpecificInfomation::clear();
+}
+
+PAT::STATUS PAT::parseSection( SectionBuffer &sec)
+{
+       uint32_t        i;
+       uint16_t        prog_num, pid;
+
+       for( i = 0; i < sec.length() - CRC32_SIZE; i += 4) {
+               prog_num        =  (sec[ i + 0] << 8) + sec[ i + 1];
+               pid                     = ((sec[ i + 2] << 8) + sec[ i + 3]) & 0x1fff;
+               if( prog_num == 0x0000) {
+                       network_PID = pid;
+               }
+               else {
+                       program_map_PID[ prog_num] = pid;
+               }
+       }
+       
+       sec += i;
+
+       erase_buffer = true;
+       return SUCCESS;
+}
+
+PAT::STATUS PAT::getBytes( SectionBuffer &buf)
+{
+       STATUS  status;
+       PROGRAM_MAP::iterator   it;
+
+       status = ProgramSpecificInfomation::getBytes( buf);
+       if( status != SUCCESS) {
+               return status;
+       }
+
+       if( network_PID != 0x0000) {
+               if( !buf.reserve( 4)) {
+                       return ERROR_GETBYTES_OVERFLOW;
+               }
+
+               buf[ 0] = 0x00;
+               buf[ 1] = 0x00;
+               buf[ 2] = (uint8_t)((network_PID >> 8) & 0xff);
+               buf[ 3] = (uint8_t)(network_PID & 0x1f);
+               buf += 4;
+       }
+
+       for( it = program_map_PID.begin(); it != program_map_PID.end(); it++) {
+               if( !buf.reserve( 4)) {
+                       return ERROR_GETBYTES_OVERFLOW;
+               }
+
+               buf[ 0] = (uint8_t)((it->first >> 8) & 0xff);
+               buf[ 1] = (uint8_t)(it->first & 0xff);
+               buf[ 2] = (uint8_t)((it->second >> 8) & 0x1f);
+               buf[ 3] = (uint8_t)(it->second & 0xff);
+               buf += 4;
+       }
+
+       return SUCCESS;
+}
+
+
+
+
+
+PMT::PMT( DescriptorParser *des_parser)
+       : ProgramSpecificInfomation( ID, des_parser)
+{
+}
+
+PMT::~PMT()
+{
+       clearPMT();
+}
+
+void PMT::clear()
+{
+       clearPMT();
+       ProgramSpecificInfomation::clear();
+}
+
+PMT::STATUS PMT::parseSection( SectionBuffer &sec)
+{
+       int32_t         size = 0;
+       ELEMENT         e;
+       
+       clearPMT();
+
+       if( sec.length() < PMS_HEADER_SIZE) {
+               return ERROR_PARSE_SECTION;
+       }
+       reserved_3                                      = (sec[ 0] >> 5) & 0x07;
+       PCR_PID                                         = ((sec[ 0] & 0x1f) << 8) + sec[ 1];
+       reserved_4                                      = (sec[ 2] >> 4) & 0x0f;
+       program_info_length                     = ((sec[ 2] & 0x0f) << 8) + sec[ 3];
+       sec += PMS_HEADER_SIZE;
+
+       if( sec.length() < program_info_length) {
+               return ERROR_PARSE_SECTION;
+       }
+       size = parseDescriptors( sec, program_info_length, &program_info_descriptors);
+       if( size == -1) {
+               return ERROR_PARSE_SECTION;
+       }
+       sec += size;
+       
+       while( sec.length() > ELEMENT_HEADER_SIZE) {
+               e.stream_type                   = (sec[ 0] >> 0) & 0xff;
+               e.reserved_1                    = (sec[ 1] >> 5) & 0x07;
+               e.elementary_PID                = ((sec[ 1] & 0x1f) << 8) + sec[ 2];
+               e.reserved_2                    = (sec[ 3] >> 4) & 0x0f;
+               e.ES_info_length                = ((sec[ 3] & 0x0f) << 8) + sec[ 4];
+               sec += ELEMENT_HEADER_SIZE;
+               if( sec.length() < e.ES_info_length) {
+                       return ERROR_PARSE_SECTION;
+               }
+
+               size = parseDescriptors( sec, e.ES_info_length, &e.descriptors);
+               if( size == -1) {
+                       return ERROR_PARSE_SECTION;
+               }
+               sec += size;
+               elements.push_back( e);
+       }
+       
+       erase_buffer = true;
+       return SUCCESS;
+}
+
+void PMT::clearPMT()
+{
+       ELEMENTS::iterator              i;
+       
+       clearDescriptors( &program_info_descriptors);
+       
+       for( i = elements.begin(); i != elements.end(); i++) {
+               clearDescriptors( &i->descriptors);
+       }
+       elements.clear();
+}
+
+void PMT::eraseElement( uint8_t stream_type)
+{
+       ELEMENTS::iterator      e = elements.begin();
+
+       while( e != elements.end()) {
+               if( e->stream_type == stream_type) {
+                       e = elements.erase( e);
+               }
+               else {
+                       e++;
+               }
+       }
+
+       /*
+       for( e = elements.begin(); e != elements.end(); e++) {
+               if( e->stream_type == stream_type) {
+                       e = elements.erase( e);
+                       continue;
+               }
+       }
+       */
+}
+
+PMT::STATUS PMT::getBytes( SectionBuffer &buf)
+{
+       STATUS  status;
+
+       status = ProgramSpecificInfomation::getBytes( buf);
+       if( status != SUCCESS) {
+               return status;
+       }
+
+       DESCRIPTORS::iterator   d;
+       SectionBuffer                   des;
+       int32_t                                 len;
+       uint16_t                                d_len;
+
+       if( !des.create()) {
+               return ERROR_ALLOCATE_MEMORY;
+       }
+       d_len = 0;
+       for( d = program_info_descriptors.begin(); d != program_info_descriptors.end(); d++) {
+               len = (*d)->getBytes( des);
+               if( len == -1) {
+                       return ERROR_GETBYTES_DESCRIPTOR;
+               }
+               d_len += len;
+       }
+       program_info_length = d_len;
+
+       if( !buf.reserve( PMS_HEADER_SIZE)) {
+               return ERROR_GETBYTES_OVERFLOW;
+       }
+       Bits::set( &buf[ 0], reserved_3                         , 5, 0x07);
+       Bits::set( &buf[ 0], (uint8_t)(PCR_PID >> 8)            , 0, 0x1f);
+       buf[ 1] = (uint8_t)(PCR_PID & 0xff);
+       Bits::set( &buf[ 2], reserved_4                         , 4, 0x0f);
+       Bits::set( &buf[ 2], (uint8_t)(program_info_length >> 8), 0, 0x0f);
+       buf[ 3] = (uint8_t)(program_info_length & 0xff);
+       buf += PMS_HEADER_SIZE;
+
+       if( !buf.append( des.begin(), des.size())) {
+               return ERROR_GETBYTES_OVERFLOW;
+       }
+       buf += des.size();
+
+       ELEMENTS::iterator      e;
+
+       for( e = elements.begin(); e != elements.end(); e++) {
+               des.wipe();
+               d_len = 0;
+               for( d = e->descriptors.begin(); d != e->descriptors.end(); d++) {
+                       len = (*d)->getBytes( des);
+                       if( len == -1) {
+                               return ERROR_GETBYTES_DESCRIPTOR;
+                       }
+                       d_len += len;
+               }
+               e->ES_info_length = d_len;
+
+               if( !buf.reserve( ELEMENT_HEADER_SIZE)) {
+                       return ERROR_GETBYTES_OVERFLOW;
+               }
+               buf[ 0] = e->stream_type;
+               Bits::set( &buf[ 1], e->reserved_1                    , 5, 0x07);
+               Bits::set( &buf[ 1], (uint8_t)(e->elementary_PID >> 8), 0, 0x1f);
+               buf[ 2] = (uint8_t)(e->elementary_PID & 0xff);
+               Bits::set( &buf[ 3], e->reserved_2                    , 4, 0x0f);
+               Bits::set( &buf[ 3], (uint8_t)(e->ES_info_length >> 8), 0, 0x0f);
+               buf[ 4] = (uint8_t)(e->ES_info_length & 0xff);
+               buf += ELEMENT_HEADER_SIZE;
+
+               if( !buf.append( des.begin(), des.size())) {
+                       return ERROR_GETBYTES_OVERFLOW;
+               }
+               buf += des.size();
+       }
+
+       return SUCCESS;
+}
+
+
+
+CAT::CAT( DescriptorParser *des_parser)
+       : ProgramSpecificInfomation( ID, des_parser)
+{
+}
+
+CAT::~CAT()
+{
+       clearCAT();
+}
+
+void CAT::clear()
+{
+       clearCAT();
+       ProgramSpecificInfomation::clear();
+}
+
+CAT::STATUS CAT::parseSection( SectionBuffer &sec)
+{
+       int32_t         size = 0;
+
+       clearCAT();
+
+       while( sec.length() > CRC32_SIZE) {
+               size = parseDescriptors( sec, sec.length() - CRC32_SIZE, &descriptors);
+               if( size == -1) {
+                       return ERROR_PARSE_SECTION;
+               }
+               sec += size;
+       }
+
+       erase_buffer = true;
+       return SUCCESS;
+}
+
+void CAT::clearCAT()
+{
+       clearDescriptors( &descriptors);
+}
+
+
+
+
+
+TSDT::TSDT( DescriptorParser *des_parser)
+       : ProgramSpecificInfomation( ID, des_parser)
+{
+}
+
+TSDT::~TSDT()
+{
+       clearTSDT();
+}
+
+void TSDT::clear()
+{
+       clearTSDT();
+       ProgramSpecificInfomation::clear();
+}
+
+TSDT::STATUS TSDT::parseSection( SectionBuffer &sec)
+{
+       int32_t         size = 0;
+
+       clearTSDT();
+
+       while( sec.length() > CRC32_SIZE) {
+               size = parseDescriptors( sec, sec.length() - CRC32_SIZE, &descriptors);
+               if( size == -1) {
+                       return ERROR_PARSE_SECTION;
+               }
+               sec += size;
+       }
+
+       erase_buffer = true;
+       return SUCCESS;
+}
+
+void TSDT::clearTSDT()
+{
+       clearDescriptors( &descriptors);
+}
diff --git a/src/TS/psi.h b/src/TS/psi.h
new file mode 100644 (file)
index 0000000..921b1e4
--- /dev/null
@@ -0,0 +1,224 @@
+#pragma once
+
+#include <inttypes.h>
+#include <string.h>
+#include <list>
+#include <map>
+#include "ts_packet.h"
+#include "descriptor.h"
+#include "utils.h"
+
+namespace TS {
+       namespace PSI {
+
+class Section {
+protected:
+       static const uint32_t   SECTION_PARSE_SIZE      = 3;
+       static const uint32_t   CRC32_SIZE                      = 4;
+
+private:
+       const int32_t           check_id;
+
+public:
+       typedef std::list< TS::Description::Descriptor *>       DESCRIPTORS;
+       enum STATUS {
+               SUCCESS,
+               CONTINUE,
+               INCLUDE_NEW_SECTION,
+               NO_SECTION,
+
+               ERROR_TS_PID,
+               ERROR_TS_COUNTER,
+               ERROR_TABLE_ID,
+               ERROR_PAYLOAD_LENGTH,
+               ERROR_START_SECTION,
+               ERROR_ALLOCATE_MEMORY,
+               ERROR_SECTION_OVERFLOW,
+               ERROR_PARSE_SECTION,
+               ERROR_CRC,
+
+               ERROR_NOT_IMPLEMENT_GETBYTES,
+               ERROR_GETBYTES_DESCRIPTOR,
+               ERROR_GETBYTES_OVERFLOW,
+       };
+               
+       uint8_t                         table_id;                                       //  8bit
+       uint8_t                         section_syntax_indicator;       //  1bit
+       uint8_t                         private_indicator;                      //  1bit
+       uint8_t                         reserved_1;                                     //  2bit
+       uint16_t                        section_length;                         // 12bit
+
+       uint32_t                        CRC_32;                                         // 32bit;
+
+protected:
+       bool                            section_continue;
+       bool                            erase_buffer;
+       bool                            check_crc;
+
+        TS::Description::DescriptorParser      *descriptor_parser;
+
+private:
+       uint16_t                        ts_pid;
+       uint8_t                         prev_ts_counter;
+       SectionBuffer           section_buffer;
+
+       TSPacket*                       ts_packet;
+
+public:
+       Section( int32_t id = -1, TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~Section();
+
+       STATUS                          append( TSPacket *p, uint32_t *payload_index);
+       bool                            finish();
+       virtual void            clear();
+
+       STATUS                          getTSPacket( TSPacket **packet, uint8_t *counter, AdaptationField *af, bool next = true);
+
+protected:
+       int32_t                         parseDescriptors( const uint8_t *data, const uint16_t len, DESCRIPTORS *list);
+       void                            clearDescriptors( DESCRIPTORS *list);
+
+private:
+       STATUS                          checkTSPacket( TSPacket *p);
+       void                            parseHeader( SectionBuffer &sec);
+
+       virtual STATUS          parse( SectionBuffer &sec);
+       virtual bool            checkID( uint8_t id);
+
+       STATUS                          createBytes();
+       virtual STATUS          getBytes( SectionBuffer &buf);
+};
+
+
+class ProgramSpecificInfomation : public Section
+{
+protected:
+       static const uint32_t   PSI_HEADER_SIZE = 5;
+
+public:
+       union ID {
+               uint16_t        transport_stream_id;            // PAT
+               uint16_t        reserved;                                       // CAT, TSDT
+               uint16_t        program_number;                         // PMT
+               //uint16_t      table_id_extension;                     // private section
+       } psi_id;                                                                       // 16bit
+       
+       uint8_t                 reserved_2;                                     //  2bit
+       uint8_t                 version_number;                         //  5bit
+       uint8_t                 current_next_indicator;         //  1bit
+       uint8_t                 section_number;                         //  8bit
+       uint8_t                 last_section_number;            //  8bit
+
+       ProgramSpecificInfomation( int32_t id = -1, TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~ProgramSpecificInfomation();
+
+
+protected:
+       STATUS                  parse( SectionBuffer &sec);
+       virtual STATUS  parseSection( SectionBuffer &sec);
+
+       virtual STATUS  getBytes( SectionBuffer &buf);
+};
+
+
+// PAT
+class PAT : public ProgramSpecificInfomation
+{
+public:
+       static const int32_t    ID = 0x00;
+       typedef std::map< uint16_t, uint16_t>   PROGRAM_MAP;
+
+       uint16_t        network_PID;
+       PROGRAM_MAP     program_map_PID;
+
+       PAT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~PAT();
+
+       void                    clear();
+
+private:
+       STATUS                  parseSection( SectionBuffer &sec);
+
+       STATUS                  getBytes( SectionBuffer &buf);
+};
+
+
+// PMT
+class PMT : public ProgramSpecificInfomation
+{
+public:
+       static const int32_t    ID                                      = 0x02;
+       static const uint32_t   PMS_HEADER_SIZE         = 4;
+       static const uint32_t   ELEMENT_HEADER_SIZE     = 5;
+
+       struct ELEMENT {
+               uint8_t                 stream_type;                                    //  8bit
+               uint8_t                 reserved_1;                                             //  3bit
+               uint16_t                elementary_PID;                                 // 13bit
+               uint8_t                 reserved_2;                                             //  4bit
+               uint16_t                ES_info_length;                                 // 12bit
+               DESCRIPTORS             descriptors;
+       };
+       typedef std::list< ELEMENT>     ELEMENTS;
+
+       uint8_t                         reserved_3;                                             //  3bit
+       uint16_t                        PCR_PID;                                                // 13bit
+       uint8_t                         reserved_4;                                             //  4bit
+       uint16_t                        program_info_length;                    // 12bit
+       DESCRIPTORS                     program_info_descriptors;
+       ELEMENTS                        elements;
+
+       PMT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~PMT();
+
+       void                    clear();
+       void                    eraseElement( uint8_t stream_type);
+
+private:
+       STATUS                  parseSection( SectionBuffer &sec);
+       void                    clearPMT();
+
+       STATUS                  getBytes( SectionBuffer &buf);
+
+};
+
+// CAT
+class CAT : public ProgramSpecificInfomation
+{
+public:
+       static const int32_t    ID = 0x01;
+
+       DESCRIPTORS                             descriptors;
+
+       CAT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~CAT();
+
+       void                    clear();
+
+private:
+    STATUS                     parseSection( SectionBuffer &sec);
+    void                       clearCAT();
+};
+
+// TSDT
+class TSDT : public ProgramSpecificInfomation
+{
+public:
+       static const int32_t    ID = 0x03;
+
+       DESCRIPTORS                             descriptors;
+
+       TSDT( TS::Description::DescriptorParser *des_parser = NULL);
+       virtual ~TSDT();
+
+       void                    clear();
+
+private:
+    STATUS                     parseSection( SectionBuffer &sec);
+    void                       clearTSDT();
+};
+
+
+       }
+}
+
diff --git a/src/TS/ts_packet.cpp b/src/TS/ts_packet.cpp
new file mode 100644 (file)
index 0000000..4b054e5
--- /dev/null
@@ -0,0 +1,382 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "ts_packet.h"
+
+using namespace TS;
+
+Header::Header()
+{
+       memset( header, 0x00, TS_HEADER_SZIE);
+       header[ 0] = SYNC;
+}
+
+Header::~Header()
+{
+}
+
+int Header::getBytes( uint8_t *buf, uint32_t size)
+{
+       if( size < TS_HEADER_SZIE) {
+               return -1;
+       }
+
+       memcpy( buf, header, TS_HEADER_SZIE);
+
+       return TS_HEADER_SZIE;
+}
+
+int Header::parse( const uint8_t *buf, uint32_t len)
+{
+       if( len < TS_HEADER_SZIE) {
+               return -1;
+       }
+
+       memcpy( header, buf, TS_HEADER_SZIE);
+
+#ifdef PACKET_DEBUG
+       sync_byte                                               = (buf[ 0] >> 0) & 0xff;
+       transport_error_indicator               = (buf[ 1] >> 7) & 0x01;
+       payload_unit_start_indicator    = (buf[ 1] >> 6) & 0x01;
+       transport_priority                              = (buf[ 1] >> 5) & 0x01;
+       pid                                                             = ((buf[ 1] & 0x1f) << 8) + buf[ 2];
+       transport_scrambling_control    = (buf[ 3] >> 6) & 0x03;
+       adaptation_field_control                = (buf[ 3] >> 4) & 0x03;
+       continuity_counter                              = (buf[ 3] >> 0) & 0x0f;
+#endif
+
+       return TS_HEADER_SZIE;
+}
+
+AdaptationField::AdaptationField()
+{
+       adaptation_field        = NULL;
+
+       field_data                      = NULL;
+       field_data_length       = 0;
+
+#ifdef PACKET_DEBUG
+       adaptation_field_length                                 = 0x00;
+       discontinuity_indicator                                 = 0x00;
+       random_access_indicator                                 = 0x00;
+       elementary_stream_priority_indicator    = 0x00;
+       PCR_flag                                                                = 0x00;
+       OPCR_flag                                                               = 0x00;
+       splicing_point_flag                                             = 0x00;
+       transport_private_data_flag                             = 0x00;
+       adaptation_field_extension_flag                 = 0x00;
+#endif
+}
+
+AdaptationField::AdaptationField( AdaptationField &src)
+{
+       src.copy( *this);
+}
+
+AdaptationField::~AdaptationField()
+{
+       clear();
+}
+
+AdaptationField& AdaptationField::operator=( AdaptationField &src)
+{
+       src.copy( *this);
+       return *this;
+}
+
+int AdaptationField::getBytes( uint8_t *buf, uint32_t size)
+{
+       int      index = 0;
+       const uint8_t af_len = getAdaptationFieldLength();
+
+       if( size < af_len + 1) {
+               return -1;
+       }
+
+       memcpy( buf, adaptation_field, af_len + 1);
+
+       return af_len + 1;
+}
+
+int AdaptationField::parse( uint8_t *buf, uint32_t len)
+{
+       int                     index = 0;
+       uint8_t         af_len;
+
+       if( len < 1) {
+               return -1;
+       }
+
+       af_len = buf[ 0];
+       index++;
+       if( len < af_len + index) {
+               return -1;
+       }
+
+       clear();
+       adaptation_field = new uint8_t[ af_len + index];
+       memcpy( adaptation_field, buf, af_len + index);
+
+#ifdef PACKET_DEBUG
+       adaptation_field_length                                 = af_len;
+#endif
+
+       if( af_len > 0) {
+#ifdef PACKET_DEBUG
+               discontinuity_indicator                                 = (buf[ index] >> 7) & 0x01;
+               random_access_indicator                                 = (buf[ index] >> 6) & 0x01;
+               elementary_stream_priority_indicator    = (buf[ index] >> 5) & 0x01;
+               PCR_flag                                                                = (buf[ index] >> 4) & 0x01;
+               OPCR_flag                                                               = (buf[ index] >> 3) & 0x01;
+               splicing_point_flag                                             = (buf[ index] >> 2) & 0x01;
+               transport_private_data_flag                             = (buf[ index] >> 1) & 0x01;
+               adaptation_field_extension_flag                 = (buf[ index] >> 0) & 0x01;
+#endif
+               index++;
+
+               field_data_length = af_len - 1;
+               if( field_data_length > 0) {
+                       field_data = &adaptation_field[ index];
+               }
+               index += field_data_length;
+       }
+
+       return index;
+}
+
+
+void AdaptationField::copy( AdaptationField &dst)
+{
+       const uint8_t af_len = getAdaptationFieldLength();
+
+       dst.clear();
+       if( adaptation_field) {
+               dst.adaptation_field = new uint8_t[ af_len + 1];
+               memcpy( dst.adaptation_field, adaptation_field, af_len + 1);
+
+               if( field_data_length > 0) {
+                       dst.field_data_length   = field_data_length;
+                       dst.field_data                  = &dst.adaptation_field[ 2];
+               }
+       }
+
+#ifdef PACKET_DEBUG
+       dst.adaptation_field_length                                     = adaptation_field_length;
+       dst.discontinuity_indicator                                     = discontinuity_indicator;
+       dst.random_access_indicator                                     = random_access_indicator;
+       dst.elementary_stream_priority_indicator        = elementary_stream_priority_indicator;
+       dst.PCR_flag                                                            = PCR_flag;
+       dst.OPCR_flag                                                           = OPCR_flag;
+       dst.splicing_point_flag                                         = splicing_point_flag;
+       dst.transport_private_data_flag                         = transport_private_data_flag;
+       dst.adaptation_field_extension_flag                     = adaptation_field_extension_flag;
+#endif
+}
+
+void AdaptationField::clear()
+{
+       if( adaptation_field) {
+               delete[] adaptation_field;
+       }
+       adaptation_field        = NULL;
+       field_data                      = NULL;
+       field_data_length       = 0;
+}
+
+TSPacket::TSPacket( Header *h, AdaptationField *af, uint8_t *p, uint32_t p_len)
+{
+       header                          = h;
+       adaptation_field        = af;
+       
+       if( p_len > 0) {
+               payload = new uint8_t[ p_len];
+               memcpy( payload, p, p_len);
+               payload_length = p_len;
+       }
+       else {
+               payload                 = NULL;
+               payload_length  = 0;
+       }
+}
+
+TSPacket::~TSPacket()
+{
+       if( header) {
+               delete header;
+               header = NULL;
+       }
+       if( adaptation_field) {
+               delete adaptation_field;
+               adaptation_field = NULL;
+       }
+       if( payload) {
+               delete[] payload;
+               payload = NULL;
+       }
+       payload_length = 0;
+}
+
+uint16_t TSPacket::getPID()
+{
+       return header->getPid();
+}
+
+Header* TSPacket::getHeader()
+{
+       return header;
+}
+
+AdaptationField* TSPacket::getAdaptationField()
+{
+       return adaptation_field;
+}
+uint32_t TSPacket::getPayloadLength()
+{
+       return payload_length;
+}
+
+uint32_t TSPacket::getPayload( uint8_t **p)
+{
+       *p = payload;
+       return payload_length;
+}
+
+int TSPacket::getBytes( uint8_t *buf, uint32_t size)
+{
+       int     index = 0;
+       int w;
+
+       if( size < TS_PACKET_SIZE) {
+               return -1;
+       }
+
+       w = header->getBytes( &buf[ index], size - index);
+       if( w != Header::TS_HEADER_SZIE) {
+               return -1;
+       }
+       index += w;
+
+       if( adaptation_field) {
+               w = adaptation_field->getBytes( &buf[ index], size - index);
+               if( w < 0) {
+                       return -1;
+               }
+               index += w;
+       }
+
+       if( index + payload_length > TS_PACKET_SIZE) {
+               return -1;
+       }
+       memcpy( &buf[ index], payload, payload_length);
+       index += payload_length;
+
+       if( index < TS_PACKET_SIZE) {
+               memset( &buf[ index], 0xff, TS_PACKET_SIZE - index);
+               index += (TS_PACKET_SIZE - index);
+       }
+
+       return index;
+}
+
+
+TSPacket* TSPacket::parse( uint8_t *buf, uint32_t len, uint32_t *read_len)
+{
+       TSPacket                *p      = NULL;
+       Header                  *h      = NULL;
+       AdaptationField *af     = NULL;
+       int index                       = 0;
+       int sync_index          = 0;
+       int payload_len         = 0;
+       int read;
+       
+       *read_len = 0;
+
+       if( (index = TSPacket::sync( buf, len)) == -1) {
+               goto ERR;
+       }
+       if( sync_index != 0) {
+               fprintf( stderr, "sync index = %d\n", sync_index);
+       }
+
+       if( len - index < TS_PACKET_SIZE) {
+               goto ERR;
+       }
+       sync_index = index;
+
+       h = new Header();
+       if( !h) {
+               goto ERR;
+       }
+       if( (read = h->parse( &buf[ index], len - index)) == -1) {
+               goto ERR;
+       }
+       index += read;
+
+       if( h->getTransportErrorIndicator()) {
+               //fprintf( stderr, "transport_error_indicator = 1, PID = 0x%04X\n", h->getPid());
+               goto ERR;
+       }
+
+       if( h->getAdaptationFieldControl() == 0x02 || h->getAdaptationFieldControl() == 0x03) {
+               af      = new AdaptationField();
+               if( !af) {
+                       goto ERR;
+               }
+               if( (read = af->parse( &buf[ index], len - index)) == -1) {
+                       goto ERR;
+               }
+               index += read;
+       }
+       payload_len = TS_PACKET_SIZE - (index - sync_index);
+       if( payload_len < 0) {
+               payload_len = 0;
+       }
+
+       p = new TSPacket( h, af, &buf[ index], payload_len);
+       if( !p) {
+               goto ERR;
+       }
+       index += payload_len;
+       *read_len = index;
+
+       return p;
+
+ERR:
+       if( h) {
+               delete h;
+       }
+       if( af) {
+               delete af;
+       }
+       if( p) {
+               delete p;
+       }
+
+       return NULL;
+
+}
+
+TSPacket* TSPacket::create( Header *h, AdaptationField *af, uint8_t *p, uint32_t p_len)
+{
+       TSPacket *ts = new TSPacket( h, af, p, p_len);
+
+       return ts;
+}
+
+int TSPacket::sync( uint8_t *buf, uint32_t len)
+{
+       uint32_t        i;
+       int                     sync_index = -1;
+       for( i = 0; i < len; i++) {
+               if( buf[ i] == Header::SYNC) {
+                       sync_index = (int)i;
+                       break;
+               }
+       }
+       return sync_index;
+}
+
+
+
diff --git a/src/TS/ts_packet.h b/src/TS/ts_packet.h
new file mode 100644 (file)
index 0000000..8d7b984
--- /dev/null
@@ -0,0 +1,310 @@
+#pragma once
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include "utils.h"
+
+namespace TS {
+
+class Header {
+public:
+       static const int                TS_HEADER_SZIE  = 4;
+       static const uint8_t    SYNC                    = 0x47;
+
+private:
+       uint8_t                         header[ TS_HEADER_SZIE];
+
+#ifdef PACKET_DEBUG
+       uint8_t                         sync_byte;                                                              //  8bit
+       uint8_t                         transport_error_indicator;                              //  1bit
+       uint8_t                         payload_unit_start_indicator;                   //  1bit
+       uint8_t                         transport_priority;                                             //  1bit
+       uint16_t                        pid;                                                                    // 13bit
+       uint8_t                         transport_scrambling_control;                   //  2bit
+       uint8_t                         adaptation_field_control;                               //  2bit
+       uint8_t                         continuity_counter;                                             //  4bit
+#endif
+
+public:
+       Header();
+       virtual ~Header();
+
+       int                                     getBytes( uint8_t *buf, uint32_t size);
+       int                                     parse( const uint8_t *buf, uint32_t len);
+
+       uint32_t                        size();
+
+       uint8_t                         getTransportErrorIndicator();
+       uint8_t                         getPayloadUnitStartIndicator();
+       uint8_t                         getTransportPriority();
+       uint16_t                        getPid();
+       uint8_t                         getTransportScramblingControl();
+       uint8_t                         getAdaptationFieldControl();
+       uint8_t                         getContinuityCounter();
+
+       void                            setTransportErrorIndicator( uint8_t val);
+       void                            setPayloadUnitStartIndicator( uint8_t val);
+       void                            setTransportPriority( uint8_t val);
+       void                            setPid( uint16_t val);
+       void                            setTransportScramblingControl( uint8_t val);
+       void                            setAdaptationFieldControl( uint8_t val);
+       void                            setContinuityCounter( uint8_t val) ;
+};
+
+class AdaptationField {
+private:
+       uint8_t                         *adaptation_field;
+
+#ifdef PACKET_DEBUG
+       uint8_t                         adaptation_field_length;                                //  8bit
+       uint8_t                         discontinuity_indicator;                                //  1bit
+       uint8_t                         random_access_indicator;                                //  1bit
+       uint8_t                         elementary_stream_priority_indicator;   //  1bit
+       uint8_t                         PCR_flag;                                                               //  1bit
+       uint8_t                         OPCR_flag;                                                              //  1bit
+       uint8_t                         splicing_point_flag;                                    //  1bit
+       uint8_t                         transport_private_data_flag;                    //  1bit
+       uint8_t                         adaptation_field_extension_flag;                //  1bit
+#endif
+
+       uint8_t                         *field_data;
+       uint32_t                        field_data_length;
+       
+public:
+       AdaptationField();
+       AdaptationField( AdaptationField &src);
+       virtual ~AdaptationField();
+
+       int                                     getBytes( uint8_t *buf, uint32_t size);
+       int                                     parse( uint8_t *buf, uint32_t len);
+
+       uint32_t                        size();
+
+       uint8_t                         getAdaptationFieldLength();                                     //  8bit
+       uint8_t                         getDiscontinuityIndicator();                                    //  1bit
+       uint8_t                         getRandomAccessIndicator();                                     //  1bit
+       uint8_t                         getElementaryStreamPriorityIndicator(); //  1bit
+       uint8_t                         getPCRFlag();                                                                   //  1bit
+       uint8_t                         getOPCRFlag();                                                                  //  1bit
+       uint8_t                         getSplicingPointFlag();                                         //  1bit
+       uint8_t                         getTransportPrivateDataFlag();                          //  1bit
+       uint8_t                         getAdaptationFieldExtensionFlag();                      //  1bit
+
+
+       AdaptationField&        operator=( AdaptationField &src);
+
+private:
+       void                    copy( AdaptationField &dst);
+       void                    clear();
+};
+
+
+class TSPacket {
+public:
+       static const int TS_PACKET_SIZE = 188;
+
+private:
+       Header                          *header;
+       AdaptationField         *adaptation_field;
+    uint8_t                            *payload;
+       uint32_t                        payload_length;
+
+private:
+       TSPacket( Header *h, AdaptationField *af, uint8_t *p, uint32_t p_len);
+
+public:
+       virtual ~TSPacket();
+
+public:
+       uint16_t                        getPID();
+       Header*                         getHeader();
+       AdaptationField*        getAdaptationField();
+       uint32_t                        getPayloadLength();
+       uint32_t                        getPayload( uint8_t **p);
+
+       int                                     getBytes( uint8_t *buf, uint32_t size);
+
+       static TSPacket*        parse( uint8_t *buf, uint32_t len, uint32_t *read_len);
+       static TSPacket*        create( Header *h, AdaptationField *af, uint8_t *p, uint32_t p_len);
+
+private:
+       static int                      sync( uint8_t *buf, uint32_t len) ;
+};
+
+
+
+inline uint32_t Header::size()
+{
+       return TS_HEADER_SZIE;
+}
+
+inline uint8_t Header::getTransportErrorIndicator()
+{
+       return Bits::get( header[ 1], 7, 0x01);
+}
+
+inline void Header::setTransportErrorIndicator( uint8_t val)
+{
+       Bits::set( &header[ 1], val, 7, 0x01);
+}
+
+inline uint8_t Header::getPayloadUnitStartIndicator()
+{
+       return Bits::get( header[ 1], 6, 0x01);
+}
+
+inline void Header::setPayloadUnitStartIndicator( uint8_t val)
+{
+       Bits::set( &header[ 1], val, 6, 0x01);
+}
+
+inline uint8_t Header::getTransportPriority()
+{
+       return Bits::get( header[ 1], 5, 0x01);
+}
+
+inline void Header::setTransportPriority( uint8_t val)
+{
+       Bits::set( &header[ 1], val, 5, 0x01);
+}
+
+inline uint16_t Header::getPid()
+{
+       return (Bits::get( header[ 1], 0, 0x1f) << 8) + header[ 2];
+}
+
+inline void Header::setPid( uint16_t val)
+{
+       Bits::set( &header[ 1], (uint8_t)(val >> 8), 0, 0x1f);
+       header[ 2] = val & 0xff;
+}
+
+inline uint8_t Header::getTransportScramblingControl()
+{
+       return Bits::get( header[ 3], 6, 0x03);
+}
+
+inline void Header::setTransportScramblingControl( uint8_t val)
+{
+       Bits::set( &header[ 3], val, 6, 0x03);
+}
+
+inline uint8_t Header::getAdaptationFieldControl()
+{
+       return Bits::get( header[ 3], 4, 0x03);
+}
+
+inline void Header::setAdaptationFieldControl( uint8_t val)
+{
+       Bits::set( &header[ 3], val, 4, 0x03);
+}
+
+inline uint8_t Header::getContinuityCounter()
+{
+       return Bits::get( header[ 3], 0, 0x0f);
+}
+
+inline void Header::setContinuityCounter( uint8_t val)
+{
+       Bits::set( &header[ 3], val, 0, 0x0f);
+}
+
+
+
+inline uint32_t AdaptationField::size()
+{
+       return getAdaptationFieldLength() + 1;
+}
+
+inline uint8_t AdaptationField::getAdaptationFieldLength()
+{
+       if( adaptation_field) {
+               return adaptation_field[ 0];
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getDiscontinuityIndicator()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 7, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getRandomAccessIndicator()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 6, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getElementaryStreamPriorityIndicator()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 5, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getPCRFlag()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 4, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getOPCRFlag()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 3, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getSplicingPointFlag()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 2, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getTransportPrivateDataFlag()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 1, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+inline uint8_t AdaptationField::getAdaptationFieldExtensionFlag()
+{
+       if( adaptation_field) {
+               return Bits::get( adaptation_field[ 1], 0, 0x01);
+       }
+       else {
+               return 0;
+       }
+}
+
+}
+
diff --git a/src/TS/utils.h b/src/TS/utils.h
new file mode 100644 (file)
index 0000000..0734721
--- /dev/null
@@ -0,0 +1,318 @@
+#pragma once
+
+#include <inttypes.h>
+#include <string.h>
+#include <assert.h>
+#include <list>
+
+namespace TS {
+
+class SectionBuffer
+{
+private:
+       static const uint32_t MAX_SECTION_SIZE = 4096;
+       uint8_t         *_data;
+       uint32_t        _current;
+       uint32_t        _set_size;
+       uint32_t        _max_size;
+       
+
+public:
+       SectionBuffer() {
+               _data = NULL;
+               _current = 0;
+               _set_size = 0;
+               _max_size = 0;
+       };
+       
+       SectionBuffer( SectionBuffer &src) {
+               copy( &src);
+       }
+       
+       ~SectionBuffer() {
+               clear();
+       }
+       
+       bool            create( uint32_t size = MAX_SECTION_SIZE) {
+               clear();
+               if( size == 0) {
+                       return true;
+               }
+               _data = new uint8_t[ size];
+               if( _data) {
+                       _max_size = size;
+                       wipe();
+                       return true;
+               }
+               else {
+                       return false;
+               }
+       }
+       
+       void            clear() {
+               if( _data) {
+                       delete[] _data;
+               }
+               _data = NULL;
+               _current = 0;
+               _max_size = 0;
+               _set_size = 0;
+       }
+       
+       bool            append( const uint8_t *val, const uint32_t len) {
+               if( _set_size + len > _max_size) {
+                       return false;
+               }
+               if( len > 0) {
+                       memcpy( &_data[ _set_size], val, len);
+                       _set_size += len;
+               }
+               return true;
+       }
+       
+       bool            append( uint8_t val) {
+               return append( &val, 1);
+       }
+       
+       bool            reserve( const uint32_t len) {
+               if( _set_size + len > _max_size) {
+                       return false;
+               }
+               if( len > 0) {
+                       _set_size += len;
+               }
+               return true;
+       }
+
+       void            wipe() {
+               if( _data) {
+                       memset( _data, 0x00, _max_size);
+                       _current = 0;
+                       _set_size = 0;
+               }
+       }
+
+       uint8_t*        begin() {
+               return _data;
+       }
+
+       uint32_t        size() const {
+               return _set_size;
+       }
+
+       uint32_t        length() const {
+               return _set_size - _current;
+       }
+
+       void            reset() {
+               _current = 0;
+       }
+
+       void            set_current( const uint32_t index) {
+               assert( index <= _set_size);
+               _current = index;
+       }
+       
+       uint8_t&        operator[]( uint32_t index) {
+               uint32_t i = _current + index;
+               assert( i < _set_size);
+               return _data[ i];
+       }
+       
+       const uint8_t&  operator[]( uint32_t index) const {
+               uint32_t i = _current + index;
+               assert( i < _set_size);
+               return _data[ i];
+       }
+       
+       operator uint8_t*() {
+               assert( _current < _set_size);
+               return &_data[ _current];
+       }
+
+       operator const uint8_t*() const {
+               assert( _current < _set_size);
+               return &_data[ _current];
+       }
+       
+       uint8_t*        operator+( const uint32_t a) {
+               uint32_t i = _current + a;
+               assert( i < _set_size);
+               return _data + i;
+       }
+       
+       uint8_t*        operator-( const uint32_t a) {
+               uint32_t i = _current - a;
+               assert( i < _set_size);
+               return _data + i;
+       }
+       
+       const uint8_t*  operator+( const uint32_t a) const {
+               uint32_t i = _current + a;
+               assert( i < _set_size);
+               return _data + i;
+       }
+       
+       const uint8_t*  operator-( const uint32_t a) const {
+               uint32_t i = _current - a;
+               assert( i < _set_size);
+               return _data + i;
+       }
+
+       SectionBuffer& operator+=( const uint32_t a) {
+               set_current( _current + a);
+               return *this;
+       }
+
+       SectionBuffer& operator++() {
+               set_current( _current + 1);
+               return *this;
+       }
+
+       SectionBuffer& operator-=( const uint32_t a) {
+               set_current( _current - a);
+               return *this;
+       }
+
+       SectionBuffer& operator--() {
+               set_current( _current - 1);
+               return *this;
+       }
+       
+       SectionBuffer& operator=( SectionBuffer& src) {
+               copy( &src);
+               return *this;
+       }
+       
+private:
+       void            copy( SectionBuffer *p) {
+               create( p->_max_size);
+               append( p->_data, p->_set_size);
+               _current = 0;
+       }
+};
+
+
+template< class T>
+class List
+{
+public:
+       typedef T                               LIST_TYPE;
+private:
+       typedef std::list< T>   __LIST;
+
+       __LIST          list;
+
+public:
+       List() {
+               clear();
+       }
+
+       ~List() {
+               clear();
+       }
+
+       void            clear() {
+               list.clear();
+       }
+
+       int                     size() {
+               return (int)list.size();
+       }
+
+       void            add( LIST_TYPE &val) {
+               list.push_back( val);
+       }
+
+       void            insert( int index, LIST_TYPE &val) {
+               typename __LIST::iterator i;
+               if( index < 0) {
+                       i = list.end();
+               }
+               else {
+                       i = list.begin();
+                       std::advance( i, index);
+               }
+               list.insert( i, val);
+       }
+
+       void            erase( int index) {
+               assert( index < list.size());
+               typename __LIST::iterator i = list.begin();
+               std::advance( i, index);
+               list.erase( i);
+       }
+
+       LIST_TYPE&      at( int index) {
+               assert( index < list.size());
+               typename __LIST::iterator i = list.begin();
+               std::advance( i, index);
+               return *i;
+       }
+};
+
+class CRC {
+public:
+       uint32_t operator()( uint8_t *p, uint32_t len) {
+               const uint32_t t[ 256] = {
+                       0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
+                       0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
+                       0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75,
+                       0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD,
+                       0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039, 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5,
+                       0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D,
+                       0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
+                       0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D,
+                       0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072,
+                       0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA,
+                       0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02,
+                       0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
+                       0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692,
+                       0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A,
+                       0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E, 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2,
+                       0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A,
+                       0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
+                       0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53,
+                       0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B,
+                       0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF, 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623,
+                       0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B,
+                       0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
+                       0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B,
+                       0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3,
+                       0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C,
+                       0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24,
+                       0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
+                       0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654,
+                       0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C,
+                       0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18, 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4,
+                       0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C,
+                       0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4,
+               };
+               uint32_t i;
+               uint32_t c = 0xffffffff;
+               for( i = 0; i < len; i++) {
+                       c = t[ ((c >> 24) ^ p[ i]) & 0xff] ^ (c << 8);
+               }
+               return c;
+       }
+};
+
+
+class Bits {
+public:
+       static uint8_t get( uint8_t val, uint8_t offset, uint8_t mask) {
+               return (val >> offset) & mask;
+       }
+       
+       static void set( uint8_t *addr, uint8_t val, uint8_t offset, uint8_t mask) {
+               uint8_t e = ~(mask << offset);
+               uint8_t tmp = (val & mask) << offset;
+
+               *addr &= e;
+               *addr |= tmp;
+       }
+};
+
+
+}
+
diff --git a/src/aribstr.cpp b/src/aribstr.cpp
new file mode 100644 (file)
index 0000000..497b2c1
--- /dev/null
@@ -0,0 +1,697 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <string.h>
+#include <iconv.h>
+
+#include "aribstr.h"
+
+#define CODE_UNKNOWN           0       // 不明なグラフィックセット(非対応)
+#define CODE_KANJI             1       // Kanji
+#define CODE_ALPHANUMERIC      2       // Alphanumeric
+#define CODE_HIRAGANA          3       // Hiragana
+#define CODE_KATAKANA          4       // Katakana
+#define CODE_MOSAIC_A          5       // Mosaic A
+#define CODE_MOSAIC_B          6       // Mosaic B
+#define CODE_MOSAIC_C          7       // Mosaic C
+#define CODE_MOSAIC_D          8       // Mosaic D
+#define CODE_PROP_ALPHANUMERIC         9       // Proportional Alphanumeric
+#define CODE_PROP_HIRAGANA     10      // Proportional Hiragana
+#define CODE_PROP_KATAKANA     11      // Proportional Katakana
+#define CODE_JIS_X0201_KATAKANA 12     // JIS X 0201 Katakana
+#define CODE_JIS_KANJI_PLANE_1         13      // JIS compatible Kanji Plane 1
+#define CODE_JIS_KANJI_PLANE_2         14      // JIS compatible Kanji Plane 2
+#define CODE_ADDITIONAL_SYMBOLS        15      // Additional symbols
+
+
+#define TCHAR char
+#define BYTE  uint8_t
+#define WORD  uint16_t
+#define DWORD uint32_t
+//#define bool  int
+//#define true  1
+//#define false 0
+#define TEXT(a) a
+#define _T(a) a
+#define CODE_SET int
+
+static int m_CodeG[4];
+static int *m_pLockingGL;
+static int *m_pLockingGR;
+static int *m_pSingleGL;
+       
+static BYTE m_byEscSeqCount;
+static BYTE m_byEscSeqIndex;
+static bool m_bIsEscSeqDrcs;
+
+
+static const DWORD AribToStringInternal( std::string *dst, const std::string *src);
+static const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET CodeSet);
+
+static const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode);
+static const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode);
+//static       const DWORD PutAlphanumericHankakuChar(TCHAR *lpszDst, const WORD wCode);
+static const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode);
+static const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode);
+static const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode);
+static const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode);
+
+static void ProcessEscapeSeq(const BYTE byCode);
+
+static void LockingShiftGL(const BYTE byIndexG);
+static void LockingShiftGR(const BYTE byIndexG);
+static void SingleShiftGL(const BYTE byIndexG);
+
+static const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode);
+static const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode);
+
+static const bool abCharSizeTable[] =
+{
+       false,  // CODE_UNKNOWN                                 不明なグラフィックセット(非対応)
+       true,   // CODE_KANJI                                   Kanji
+       false,  // CODE_ALPHANUMERIC                    Alphanumeric
+       false,  // CODE_HIRAGANA                                Hiragana
+       false,  // CODE_KATAKANA                                Katakana
+       false,  // CODE_MOSAIC_A                                Mosaic A
+       false,  // CODE_MOSAIC_B                                Mosaic B
+       false,  // CODE_MOSAIC_C                                Mosaic C
+       false,  // CODE_MOSAIC_D                                Mosaic D
+       false,  // CODE_PROP_ALPHANUMERIC               Proportional Alphanumeric
+       false,  // CODE_PROP_HIRAGANA                   Proportional Hiragana
+       false,  // CODE_PROP_KATAKANA                   Proportional Katakana
+       false,  // CODE_JIS_X0201_KATAKANA              JIS X 0201 Katakana
+       true,   // CODE_JIS_KANJI_PLANE_1               JIS compatible Kanji Plane 1
+       true,   // CODE_JIS_KANJI_PLANE_2               JIS compatible Kanji Plane 2
+       true    // CODE_ADDITIONAL_SYMBOLS              Additional symbols
+};
+
+typedef enum{
+       STR_SMALL = 0,  //SSZ
+       STR_MEDIUM,             //MSZ
+       STR_NORMAL,             //NSZ
+       STR_MICRO,              //SZX 0x60
+       STR_HIGH_W,             //SZX 0x41
+       STR_WIDTH_W,    //SZX 0x44
+       STR_W,                  //SZX 0x45
+       STR_SPECIAL_1,  //SZX 0x6B
+       STR_SPECIAL_2,  //SZX 0x64
+} STRING_SIZE;
+
+STRING_SIZE m_emStrSize;
+
+bool IsSmallCharMode(void)
+{
+       bool bRet = false;
+       switch(m_emStrSize){
+               case STR_SMALL:
+                       bRet = true;
+                       break;
+               case STR_MEDIUM:
+                       bRet = true;
+                       break;
+               case STR_NORMAL:
+                       bRet = false;
+                       break;
+               case STR_MICRO:
+                       bRet = true;
+                       break;
+               case STR_HIGH_W:
+                       bRet = false;
+                       break;
+               case STR_WIDTH_W:
+                       bRet = false;
+                       break;
+               case STR_W:
+                       bRet = false;
+                       break;
+               case STR_SPECIAL_1:
+                       bRet = false;
+                       break;
+               case STR_SPECIAL_2:
+                       bRet = false;
+                       break;
+               default:
+                       break;
+       }
+       return bRet;
+}
+
+int AribToString(
+       std::string *dst, 
+       const std::string *src) {
+  
+       return AribToStringInternal(dst, src);
+}
+
+
+const DWORD AribToStringInternal( std::string *dst, const std::string *src)
+{
+       if(!src ||  !dst)return 0UL;
+  
+       TCHAR buf[ 128];
+       DWORD dwSrcPos = 0UL;
+       DWORD dwDstLen = 0UL;
+       int   dwSrcData;
+  
+       // 状態初期設定
+       m_byEscSeqCount = 0U;
+       m_pSingleGL = NULL;
+
+       m_CodeG[0] = CODE_KANJI;
+       m_CodeG[1] = CODE_ALPHANUMERIC;
+       m_CodeG[2] = CODE_HIRAGANA;
+       m_CodeG[3] = CODE_KATAKANA;
+
+       m_pLockingGL = &m_CodeG[0];
+       m_pLockingGR = &m_CodeG[2];
+
+       m_emStrSize = STR_NORMAL;
+
+       dst->erase();
+       dst->reserve( src->size());
+
+       while(dwSrcPos < src->size()){
+               dwSrcData = (BYTE)src->at( dwSrcPos) & 0xFF;
+
+               if(!m_byEscSeqCount){
+      
+                       // GL/GR領域
+                       if((dwSrcData >= 0x21U) && (dwSrcData <= 0x7EU)){
+                               // GL領域
+                               const CODE_SET CurCodeSet = (m_pSingleGL)? *m_pSingleGL : *m_pLockingGL;
+                               m_pSingleGL = NULL;
+                               
+                               if(abCharSizeTable[CurCodeSet]){
+                                       // 2バイトコード
+                                       if((src->size() - dwSrcPos) < 2UL)break;
+                                       
+                                       dwDstLen = ProcessCharCode(buf, ((WORD)src->at( dwSrcPos + 0) << 8) | (WORD)src->at( dwSrcPos + 1), CurCodeSet);
+                                       buf[ dwDstLen] = '\0';
+                                       dst->append( buf);
+                                       dwSrcPos++;
+                               }
+                               else{
+                                       // 1バイトコード
+                                       dwDstLen = ProcessCharCode(buf, (WORD)dwSrcData, CurCodeSet);
+                                       buf[ dwDstLen] = '\0';
+                                       dst->append( buf);
+                               }
+                       }
+                       else if((dwSrcData >= 0xA1U) && (dwSrcData <= 0xFEU)){
+                               // GR領域
+                               const CODE_SET CurCodeSet = *m_pLockingGR;
+                               
+                               if(abCharSizeTable[CurCodeSet]){
+                                       // 2バイトコード
+                                       if((src->size() - dwSrcPos) < 2UL)break;
+                                       
+                                       dwDstLen = ProcessCharCode(buf, ((WORD)(src->at( dwSrcPos + 0) & 0x7FU) << 8) | (WORD)(src->at( dwSrcPos + 1) & 0x7FU), CurCodeSet);
+                                       buf[ dwDstLen] = '\0';
+                                       dst->append( buf);
+                                       dwSrcPos++;
+                               }
+                               else{
+                                       // 1バイトコード
+                                       dwDstLen = ProcessCharCode(buf, (WORD)(dwSrcData & 0x7FU), CurCodeSet);
+                                       buf[ dwDstLen] = '\0';
+                                       dst->append( buf);
+                               }
+                       }
+                       else{
+                               // 制御コード
+                               switch(dwSrcData){
+                               case 0x0FU      : LockingShiftGL(0U);                           break;  // LS0
+                               case 0x0EU      : LockingShiftGL(1U);                           break;  // LS1
+                               case 0x19U      : SingleShiftGL(2U);                            break;  // SS2
+                               case 0x1DU      : SingleShiftGL(3U);                            break;  // SS3
+                               case 0x1BU      : m_byEscSeqCount = 1U;                         break;  // ESC
+                               case 0x89U      : m_emStrSize = STR_MEDIUM;                     break;  // MSZ
+                               case 0x8AU      : m_emStrSize = STR_NORMAL;                     break;  // NSZ
+                               case 0x20U      :
+                               case 0xA0U      :
+                                       //SP 空白
+                                       //空白は文字サイズの影響あり
+                                       if( IsSmallCharMode() == false ){
+                                               strcpy(buf, " ");
+                                       } else {
+                                               strcpy(buf, " ");
+                                       }
+                                       dst->append( buf);
+                                       break;
+                               default         : break;        // 非対応
+                               }
+                       }
+               }
+               else{
+                       // エスケープシーケンス処理
+                       ProcessEscapeSeq(dwSrcData);
+               }
+               
+               dwSrcPos++;
+       }
+
+       // 終端文字
+       //lpszDst[dwDstLen] = TEXT('\0');
+
+       return dst->size();
+}
+
+const DWORD ProcessCharCode(TCHAR *lpszDst, const WORD wCode, const CODE_SET CodeSet)
+{
+       switch(CodeSet){
+       case CODE_KANJI :
+       case CODE_JIS_KANJI_PLANE_1 :
+       case CODE_JIS_KANJI_PLANE_2 :
+               // 漢字コード出力
+               return PutKanjiChar(lpszDst, wCode);
+
+       case CODE_ALPHANUMERIC :
+       case CODE_PROP_ALPHANUMERIC :
+               // 英数字コード出力
+               if( IsSmallCharMode() == false ){
+                       //全角テーブルコード取得
+               return PutAlphanumericChar(lpszDst, wCode);
+               } else {
+                       //半角はそのまま出力
+                       lpszDst[0] = wCode;
+                       return 1UL;
+               }
+
+       case CODE_HIRAGANA :
+       case CODE_PROP_HIRAGANA :
+               // ひらがなコード出力
+               return PutHiraganaChar(lpszDst, wCode);
+
+       case CODE_PROP_KATAKANA :
+       case CODE_KATAKANA :
+               // カタカナコード出力
+               return PutKatakanaChar(lpszDst, wCode);
+
+       case CODE_JIS_X0201_KATAKANA :
+               // JISカタカナコード出力
+               return PutJisKatakanaChar(lpszDst, wCode);
+
+       case CODE_ADDITIONAL_SYMBOLS :
+               // 追加シンボルコード出力
+               return PutSymbolsChar(lpszDst, wCode);
+
+       default :
+               return 0UL;
+       }
+}
+
+const DWORD PutKanjiChar(TCHAR *lpszDst, const WORD wCode)
+{
+       char code[9];
+       char xcode[16];
+       iconv_t cd;
+
+       size_t inbyte = 8;
+       size_t outbyte = sizeof(xcode - 1);
+
+       memset(xcode, '\0', sizeof(xcode));
+  
+       char *fptr;
+       char *tptr;
+
+       code[0] = 0x1BU;
+       code[1] = 0x24U;
+       code[2] = 0x40U;
+       code[3] = wCode >> 8;
+       code[4] = wCode & 0xFF;
+       code[5] = 0x1BU;
+       code[6] = 0x28U;
+       code[7] = 0x4AU;
+       code[8] = '\0';
+
+       cd = iconv_open("UTF-8","ISO-2022-JP");
+
+       fptr = code;
+       tptr = xcode;
+       iconv(cd, &fptr, &inbyte, &tptr, &outbyte);
+
+       iconv_close(cd);
+
+       strcpy(lpszDst, xcode);
+
+       return strlen(lpszDst);
+}
+
+const DWORD PutAlphanumericChar(TCHAR *lpszDst, const WORD wCode)
+{
+       // 英数字全角文字コード変換
+       static const TCHAR *acAlphanumericTable = 
+               TEXT("                ")
+               TEXT("                ")
+               TEXT(" !”#$%&’()*+,-./")
+               TEXT("0123456789:;<=>?")
+               TEXT("@ABCDEFGHIJKLMNO")
+               TEXT("PQRSTUVWXYZ[¥]^_")
+               TEXT(" abcdefghijklmno")
+               TEXT("pqrstuvwxyz{|} ̄ ");
+
+#ifdef _UNICODE
+       lpszDst[0] = acAlphanumericTableZenkaku[wCode];
+
+       return 1UL;
+#else
+       lpszDst[0] = acAlphanumericTable[wCode * 3U + 0U];
+       lpszDst[1] = acAlphanumericTable[wCode * 3U + 1U];
+       lpszDst[2] = acAlphanumericTable[wCode * 3U + 2U];
+
+       return 3UL;
+#endif
+}
+
+const DWORD PutHiraganaChar(TCHAR *lpszDst, const WORD wCode)
+{
+       // ひらがな文字コード変換
+       static const TCHAR *acHiraganaTable = 
+               TEXT("                ")
+               TEXT("                ")
+               TEXT(" ぁあぃいぅうぇえぉおかがきぎく")
+               TEXT("ぐけげこごさざしじすずせぜそぞた")
+               TEXT("だちぢっつづてでとどなにぬねのは")
+               TEXT("ばぱひびぴふぶぷへべぺほぼぽまみ")
+               TEXT("むめもゃやゅゆょよらりるれろゎわ")
+               TEXT("ゐゑをん   ゝゞー。「」、・ ");
+       
+#ifdef _UNICODE
+       lpszDst[0] = acHiraganaTable[wCode];
+
+       return 1UL;
+#else
+       lpszDst[0] = acHiraganaTable[wCode * 3U + 0U];
+       lpszDst[1] = acHiraganaTable[wCode * 3U + 1U];
+       lpszDst[2] = acHiraganaTable[wCode * 3U + 2U];
+
+       return 3UL;
+#endif
+}
+
+const DWORD PutKatakanaChar(TCHAR *lpszDst, const WORD wCode)
+{
+       // カタカナ英数字文字コード変換
+       static const TCHAR *acKatakanaTable = 
+               TEXT("                ")
+               TEXT("                ")
+               TEXT(" ァアィイゥウェエォオカガキギク")
+               TEXT("グケゲコゴサザシジスズセゼソゾタ")
+               TEXT("ダチヂッツヅテデトドナニヌネノハ")
+               TEXT("バパヒビピフブプヘベペホボポマミ")
+               TEXT("ムメモャヤュユョヨラリルレロヮワ")
+               TEXT("ヰヱヲンヴヵヶヽヾー。「」、・ ");
+       
+#ifdef _UNICODE
+       lpszDst[0] = acKatakanaTable[wCode];
+
+       return 1UL;
+#else
+       lpszDst[0] = acKatakanaTable[wCode * 3U + 0U];
+       lpszDst[1] = acKatakanaTable[wCode * 3U + 1U];
+       lpszDst[2] = acKatakanaTable[wCode * 3U + 2U];
+
+       return 3UL;
+#endif
+}
+
+const DWORD PutJisKatakanaChar(TCHAR *lpszDst, const WORD wCode)
+{
+       // JISカタカナ文字コード変換
+       static const TCHAR *acJisKatakanaTable = 
+               TEXT("                ")
+               TEXT("                ")
+               TEXT(" 。「」、・ヲァィゥェォャュョッ")
+               TEXT("ーアイウエオカキクケコサシスセソ")
+               TEXT("タチツテトナニヌネノハヒフヘホマ")
+               TEXT("ミムメモヤユヨラリルレロワン゛゜")
+               TEXT("                ")
+               TEXT("                ");
+       
+#ifdef _UNICODE
+       lpszDst[0] = acJisKatakanaTable[wCode];
+
+       return 1UL;
+#else
+       lpszDst[0] = acJisKatakanaTable[wCode * 3U + 0U];
+       lpszDst[1] = acJisKatakanaTable[wCode * 3U + 1U];
+       lpszDst[2] = acJisKatakanaTable[wCode * 3U + 2U];
+
+       return 3UL;
+#endif
+}
+
+const DWORD PutSymbolsChar(TCHAR *lpszDst, const WORD wCode)
+{
+       // 追加シンボル文字コード変換(とりあえず必要そうなものだけ)
+       static const TCHAR *aszSymbolsTable1[] =
+               {
+                       _T("【HV】"), _T("【SD】"), _T("【P】"),        _T("【W】"),        _T("【MV】"), _T("【手】"),        _T("【字】"),        _T("【双】"),                // 0x7A50 - 0x7A57      90/48 - 90/55
+                       _T("【デ】"),        _T("【S】"),        _T("【二】"),        _T("【多】"),        _T("【解】"),        _T("【SS】"), _T("【B】"),        _T("【N】"),                // 0x7A58 - 0x7A5F      90/56 - 90/63
+                       _T("■"),              _T("●"),              _T("【天】"),        _T("【交】"),        _T("【映】"),        _T("【無】"),        _T("【料】"),        _T("【年齢制限】"),       // 0x7A60 - 0x7A67      90/64 - 90/71
+                       _T("【前】"),        _T("【後】"),        _T("【再】"),        _T("【新】"),        _T("【初】"),        _T("【終】"),        _T("【生】"),        _T("【販】"),                // 0x7A68 - 0x7A6F      90/72 - 90/79
+                       _T("【声】"),        _T("【吹】"),        _T("【PPV】"),        _T("(秘)"),        _T("ほか")                                                                                                                    // 0x7A70 - 0x7A74      90/80 - 90/84
+               };
+
+       static const TCHAR *aszSymbolsTable2[] =
+               {
+                       _T("→"),              _T("←"),              _T("↑"),              _T("↓"),              _T("●"),              _T("○"),              _T("年"),              _T("月"),                      // 0x7C21 - 0x7C28      92/01 - 92/08
+                       _T("日"),              _T("円"),              _T("㎡"),              _T("㎥"),              _T("㎝"),              _T("㎠"),              _T("㎤"),              _T("0."),                     // 0x7C29 - 0x7C30      92/09 - 92/16
+                       _T("1."),             _T("2."),             _T("3."),             _T("4."),             _T("5."),             _T("6."),             _T("7."),             _T("8."),                     // 0x7C31 - 0x7C38      92/17 - 92/24
+                       _T("9."),             _T("氏"),              _T("副"),              _T("元"),              _T("故"),              _T("前"),              _T("新"),              _T("0,"),                     // 0x7C39 - 0x7C40      92/25 - 92/32
+                       _T("1,"),             _T("2,"),             _T("3,"),             _T("4,"),             _T("5,"),             _T("6,"),             _T("7,"),             _T("8,"),                     // 0x7C41 - 0x7C48      92/33 - 92/40
+                       _T("9,"),             _T("(社)"),            _T("(財)"),            _T("(有)"),            _T("(株)"),            _T("(代)"),            _T("(問)"),            _T("▶"),                      // 0x7C49 - 0x7C50      92/41 - 92/48
+                       _T("◀"),              _T("〖"),              _T("〗"),              _T("⟐"),              _T("^2"),               _T("^3"),               _T("(CD)"),             _T("(vn)"),                     // 0x7C51 - 0x7C58      92/49 - 92/56
+                       _T("(ob)"),             _T("(cb)"),             _T("(ce"),              _T("mb)"),              _T("(hp)"),             _T("(br)"),             _T("(p)"),              _T("(s)"),                      // 0x7C59 - 0x7C60      92/57 - 92/64
+                       _T("(ms)"),             _T("(t)"),              _T("(bs)"),             _T("(b)"),              _T("(tb)"),             _T("(tp)"),             _T("(ds)"),             _T("(ag)"),                     // 0x7C61 - 0x7C68      92/65 - 92/72
+                       _T("(eg)"),             _T("(vo)"),             _T("(fl)"),             _T("(ke"),              _T("y)"),               _T("(sa"),              _T("x)"),               _T("(sy"),                      // 0x7C69 - 0x7C70      92/73 - 92/80
+                       _T("n)"),               _T("(or"),              _T("g)"),               _T("(pe"),              _T("r)"),               _T("(R)"),              _T("(C)"),              _T("(箏)"),                    // 0x7C71 - 0x7C78      92/81 - 92/88
+                       _T("DJ"),               _T("[演]"),            _T("Fax")                                                                                                                                                                                       // 0x7C79 - 0x7C7B      92/89 - 92/91
+               };
+
+       static const TCHAR *aszSymbolsTable3[] =
+               {
+                       _T("㈪"),              _T("㈫"),              _T("㈬"),              _T("㈭"),              _T("㈮"),              _T("㈯"),              _T("㈰"),              _T("㈷"),                      // 0x7D21 - 0x7D28      93/01 - 93/08
+                       _T("㍾"),              _T("㍽"),              _T("㍼"),              _T("㍻"),              _T("№"),              _T("℡"),              _T("〶"),              _T("○"),                      // 0x7D29 - 0x7D30      93/09 - 93/16
+                       _T("〔本〕"),        _T("〔三〕"),        _T("〔二〕"),        _T("〔安〕"),        _T("〔点〕"),        _T("〔打〕"),        _T("〔盗〕"),        _T("〔勝〕"),                // 0x7D31 - 0x7D38      93/17 - 93/24
+                       _T("〔敗〕"),        _T("〔S〕"),        _T("[投]"),        _T("[捕]"),        _T("[一]"),        _T("[二]"),        _T("[三]"),        _T("[遊]"),                // 0x7D39 - 0x7D40      93/25 - 93/32
+                       _T("[左]"),        _T("[中]"),        _T("[右]"),        _T("[指]"),        _T("[走]"),        _T("[打]"),        _T("㍑"),              _T("㎏"),                      // 0x7D41 - 0x7D48      93/33 - 93/40
+                       _T("㎐"),              _T("ha"),               _T("㎞"),              _T("㎢"),              _T("㍱"),              _T("・"),              _T("・"),              _T("1/2"),                      // 0x7D49 - 0x7D50      93/41 - 93/48
+                       _T("0/3"),              _T("1/3"),              _T("2/3"),              _T("1/4"),              _T("3/4"),              _T("1/5"),              _T("2/5"),              _T("3/5"),                      // 0x7D51 - 0x7D58      93/49 - 93/56
+                       _T("4/5"),              _T("1/6"),              _T("5/6"),              _T("1/7"),              _T("1/8"),              _T("1/9"),              _T("1/10"),             _T("☀"),                      // 0x7D59 - 0x7D60      93/57 - 93/64
+                       _T("☁"),              _T("☂"),              _T("☃"),              _T("☖"),              _T("☗"),              _T("▽"),              _T("▼"),              _T("♦"),                      // 0x7D61 - 0x7D68      93/65 - 93/72
+                       _T("♥"),              _T("♣"),              _T("♠"),              _T("⌺"),              _T("⦿"),              _T("‼"),              _T("⁉"),              _T("(曇/晴)"),                // 0x7D69 - 0x7D70      93/73 - 93/80
+                       _T("☔"),              _T("(雨)"),            _T("(雪)"),            _T("(大雪)"), _T("⚡"),              _T("(雷雨)"), _T(" "),              _T("・"),                      // 0x7D71 - 0x7D78      93/81 - 93/88
+                       _T("・"),              _T("♬"),              _T("☎")                                                                                                                                                                                       // 0x7D79 - 0x7D7B      93/89 - 93/91
+               };
+
+       static const TCHAR *aszSymbolsTable4[] =
+               {
+                       _T("Ⅰ"),              _T("Ⅱ"),              _T("Ⅲ"),              _T("Ⅳ"),              _T("Ⅴ"),              _T("Ⅵ"),              _T("Ⅶ"),              _T("Ⅷ"),                      // 0x7E21 - 0x7E28      94/01 - 94/08
+                       _T("Ⅸ"),              _T("Ⅹ"),              _T("Ⅺ"),              _T("Ⅻ"),              _T("⑰"),              _T("⑱"),              _T("⑲"),              _T("⑳"),                      // 0x7E29 - 0x7E30      94/09 - 94/16
+                       _T("⑴"),              _T("⑵"),              _T("⑶"),              _T("⑷"),              _T("⑸"),              _T("⑹"),              _T("⑺"),              _T("⑻"),                      // 0x7E31 - 0x7E38      94/17 - 94/24
+                       _T("⑼"),              _T("⑽"),              _T("⑾"),              _T("⑿"),              _T("㉑"),              _T("㉒"),              _T("㉓"),              _T("㉔"),                      // 0x7E39 - 0x7E40      94/25 - 94/32
+                       _T("(A)"),              _T("(B)"),              _T("(C)"),              _T("(D)"),              _T("(E)"),              _T("(F)"),              _T("(G)"),              _T("(H)"),                      // 0x7E41 - 0x7E48      94/33 - 94/40
+                       _T("(I)"),              _T("(J)"),              _T("(K)"),              _T("(L)"),              _T("(M)"),              _T("(N)"),              _T("(O)"),              _T("(P)"),                      // 0x7E49 - 0x7E50      94/41 - 94/48
+                       _T("(Q)"),              _T("(R)"),              _T("(S)"),              _T("(T)"),              _T("(U)"),              _T("(V)"),              _T("(W)"),              _T("(X)"),                      // 0x7E51 - 0x7E58      94/49 - 94/56
+                       _T("(Y)"),              _T("(Z)"),              _T("㉕"),              _T("㉖"),              _T("㉗"),              _T("㉘"),              _T("㉙"),              _T("㉚"),                      // 0x7E59 - 0x7E60      94/57 - 94/64
+                       _T("①"),              _T("②"),              _T("③"),              _T("④"),              _T("⑤"),              _T("⑥"),              _T("⑦"),              _T("⑧"),                      // 0x7E61 - 0x7E68      94/65 - 94/72
+                       _T("⑨"),              _T("⑩"),              _T("⑪"),              _T("⑫"),              _T("⑬"),              _T("⑭"),              _T("⑮"),              _T("⑯"),                      // 0x7E69 - 0x7E70      94/73 - 94/80
+                       _T("❶"),              _T("❷"),              _T("❸"),              _T("❹"),              _T("❺"),              _T("❻"),              _T("❼"),              _T("❽"),                      // 0x7E71 - 0x7E78      94/81 - 94/88
+                       _T("❾"),              _T("❿"),              _T("⓫"),              _T("⓬"),              _T("㉛")                                                                                                                       // 0x7E79 - 0x7E7D      94/89 - 94/93
+               };
+
+       static const TCHAR *aszSymbolsTable5[] =
+               {
+                       _T("㐂"),              _T("亭"),              _T("份"),              _T("仿"),              _T("侚"),              _T("俉"),              _T("傜"),              _T("儞"),                      // 0x7521 - 0x7528      85/01 - 85/08
+                       _T("冼"),              _T("㔟"),              _T("匇"),              _T("卡"),              _T("卬"),              _T("詹"),              _T("吉"),              _T("呍"),                      // 0x7529 - 0x7530      85/09 - 85/16
+                       _T("咖"),              _T("咜"),              _T("咩"),              _T("唎"),              _T("啊"),              _T("噲"),              _T("囤"),              _T("圳"),                      // 0x7531 - 0x7538      85/17 - 85/24
+                       _T("圴"),              _T("塚"),              _T("墀"),              _T("姤"),              _T("娣"),              _T("婕"),              _T("寬"),              _T("﨑"),                      // 0x7539 - 0x7540      85/25 - 85/32
+                       _T("㟢"),              _T("庬"),              _T("弴"),              _T("彅"),              _T("德"),              _T("怗"),              _T("恵"),              _T("愰"),                      // 0x7541 - 0x7548      85/33 - 85/40
+                       _T("昤"),              _T("曈"),              _T("曙"),              _T("曺"),              _T("曻"),              _T("桒"),              _T("・"),              _T("椑"),                      // 0x7549 - 0x7550      85/41 - 85/48
+                       _T("椻"),              _T("橅"),              _T("檑"),              _T("櫛"),              _T("・"),              _T("・"),              _T("・"),              _T("毱"),                      // 0x7551 - 0x7558      85/49 - 85/56
+                       _T("泠"),              _T("洮"),              _T("海"),              _T("涿"),              _T("淊"),              _T("淸"),              _T("渚"),              _T("潞"),                      // 0x7559 - 0x7560      85/57 - 85/64
+                       _T("濹"),              _T("灤"),              _T("・"),              _T("・"),              _T("煇"),              _T("燁"),              _T("爀"),              _T("玟"),                      // 0x7561 - 0x7568      85/65 - 85/72
+                       _T("・"),              _T("珉"),              _T("珖"),              _T("琛"),              _T("琡"),              _T("琢"),              _T("琦"),              _T("琪"),                      // 0x7569 - 0x7570      85/73 - 85/80
+                       _T("琬"),              _T("琹"),              _T("瑋"),              _T("㻚"),              _T("畵"),              _T("疁"),              _T("睲"),              _T("䂓"),                      // 0x7571 - 0x7578      85/81 - 85/88
+                       _T("磈"),              _T("磠"),              _T("祇"),              _T("禮"),              _T("・"),              _T("・")                                                                                       // 0x7579 - 0x757E      85/89 - 85/94
+               };
+
+       static const TCHAR *aszSymbolsTable6[] =
+               {
+                       _T("・"),              _T("秚"),              _T("稞"),              _T("筿"),              _T("簱"),              _T("䉤"),              _T("綋"),              _T("羡"),                      // 0x7621 - 0x7628      86/01 - 86/08
+                       _T("脘"),              _T("脺"),              _T("・"),              _T("芮"),              _T("葛"),              _T("蓜"),              _T("蓬"),              _T("蕙"),                      // 0x7629 - 0x7630      86/09 - 86/16
+                       _T("藎"),              _T("蝕"),              _T("蟬"),              _T("蠋"),              _T("裵"),              _T("角"),              _T("諶"),              _T("跎"),                      // 0x7631 - 0x7638      86/17 - 86/24
+                       _T("辻"),              _T("迶"),              _T("郝"),              _T("鄧"),              _T("鄭"),              _T("醲"),              _T("鈳"),              _T("銈"),                      // 0x7639 - 0x7640      86/25 - 86/32
+                       _T("錡"),              _T("鍈"),              _T("閒"),              _T("雞"),              _T("餃"),              _T("饀"),              _T("髙"),              _T("鯖"),                      // 0x7641 - 0x7648      86/33 - 86/40
+                       _T("鷗"),              _T("麴"),              _T("麵")                                                                                                                                                                                       // 0x7649 - 0x764B      86/41 - 86/43
+               };
+
+       // シンボルを変換する
+       if((wCode >= 0x7A50U) && (wCode <= 0x7A74U)){
+               strcpy(lpszDst, aszSymbolsTable1[wCode - 0x7A50U]);
+       }
+       else if((wCode >= 0x7C21U) && (wCode <= 0x7C7BU)){
+               strcpy(lpszDst, aszSymbolsTable2[wCode - 0x7C21U]);
+       }
+       else if((wCode >= 0x7D21U) && (wCode <= 0x7D7BU)){
+               strcpy(lpszDst, aszSymbolsTable3[wCode - 0x7D21U]);
+       }
+       else if((wCode >= 0x7E21U) && (wCode <= 0x7E7DU)){
+               strcpy(lpszDst, aszSymbolsTable4[wCode - 0x7E21U]);
+       }
+       else if((wCode >= 0x7521U) && (wCode <= 0x757EU)){
+               strcpy(lpszDst, aszSymbolsTable5[wCode - 0x7521U]);
+       }
+       else if((wCode >= 0x7621U) && (wCode <= 0x764BU)){
+               strcpy(lpszDst, aszSymbolsTable6[wCode - 0x7621U]);
+       }
+       else{
+               strcpy(lpszDst, TEXT("・"));
+       }
+
+       return strlen(lpszDst);
+}
+
+void ProcessEscapeSeq(const BYTE byCode)
+{
+       // エスケープシーケンス処理
+       switch(m_byEscSeqCount){
+               // 1バイト目
+       case 1U :
+               switch(byCode){
+                       // Invocation of code elements
+               case 0x6EU      : LockingShiftGL(2U);   m_byEscSeqCount = 0U;   return;         // LS2
+               case 0x6FU      : LockingShiftGL(3U);   m_byEscSeqCount = 0U;   return;         // LS3
+               case 0x7EU      : LockingShiftGR(1U);   m_byEscSeqCount = 0U;   return;         // LS1R
+               case 0x7DU      : LockingShiftGR(2U);   m_byEscSeqCount = 0U;   return;         // LS2R
+               case 0x7CU      : LockingShiftGR(3U);   m_byEscSeqCount = 0U;   return;         // LS3R
+
+                       // Designation of graphic sets
+               case 0x24U      :       
+               case 0x28U      : m_byEscSeqIndex = 0U;         break;
+               case 0x29U      : m_byEscSeqIndex = 1U;         break;
+               case 0x2AU      : m_byEscSeqIndex = 2U;         break;
+               case 0x2BU      : m_byEscSeqIndex = 3U;         break;
+               default         : m_byEscSeqCount = 0U;         return;         // エラー
+               }
+               break;
+
+               // 2バイト目
+       case 2U :
+               if(DesignationGSET(m_byEscSeqIndex, byCode)){
+                       m_byEscSeqCount = 0U;
+                       return;
+               }
+                       
+               switch(byCode){
+               case 0x20       : m_bIsEscSeqDrcs = true;       break;
+               case 0x28       : m_bIsEscSeqDrcs = true;       m_byEscSeqIndex = 0U;   break;
+               case 0x29       : m_bIsEscSeqDrcs = false;      m_byEscSeqIndex = 1U;   break;
+               case 0x2A       : m_bIsEscSeqDrcs = false;      m_byEscSeqIndex = 2U;   break;
+               case 0x2B       : m_bIsEscSeqDrcs = false;      m_byEscSeqIndex = 3U;   break;
+               default         : m_byEscSeqCount = 0U;         return;         // エラー
+               }
+               break;
+
+               // 3バイト目
+       case 3U :
+               if(!m_bIsEscSeqDrcs){
+                       if(DesignationGSET(m_byEscSeqIndex, byCode)){
+                               m_byEscSeqCount = 0U;
+                               return;
+                       }
+               }
+               else{
+                       if(DesignationDRCS(m_byEscSeqIndex, byCode)){
+                               m_byEscSeqCount = 0U;
+                               return;
+                       }
+               }
+
+               if(byCode == 0x20U){
+                       m_bIsEscSeqDrcs = true;
+               }
+               else{
+                       // エラー
+                       m_byEscSeqCount = 0U;
+                       return;
+               }
+               break;
+
+               // 4バイト目
+       case 4U :
+               DesignationDRCS(m_byEscSeqIndex, byCode);
+               m_byEscSeqCount = 0U;
+               return;
+       }
+
+       m_byEscSeqCount++;
+}
+
+void LockingShiftGL(const BYTE byIndexG)
+{
+       // LSx
+       m_pLockingGL = &m_CodeG[byIndexG];
+}
+
+void LockingShiftGR(const BYTE byIndexG)
+{
+       // LSxR
+       m_pLockingGR = &m_CodeG[byIndexG];
+}
+
+void SingleShiftGL(const BYTE byIndexG)
+{
+       // SSx
+       m_pSingleGL  = &m_CodeG[byIndexG];
+}
+
+const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode)
+{
+       // Gのグラフィックセットを割り当てる
+       switch(byCode){
+       case 0x42U      : m_CodeG[byIndexG] = CODE_KANJI;                               return true;    // Kanji
+       case 0x4AU      : m_CodeG[byIndexG] = CODE_ALPHANUMERIC;                return true;    // Alphanumeric
+       case 0x30U      : m_CodeG[byIndexG] = CODE_HIRAGANA;                    return true;    // Hiragana
+       case 0x31U      : m_CodeG[byIndexG] = CODE_KATAKANA;                    return true;    // Katakana
+       case 0x32U      : m_CodeG[byIndexG] = CODE_MOSAIC_A;                    return true;    // Mosaic A
+       case 0x33U      : m_CodeG[byIndexG] = CODE_MOSAIC_B;                    return true;    // Mosaic B
+       case 0x34U      : m_CodeG[byIndexG] = CODE_MOSAIC_C;                    return true;    // Mosaic C
+       case 0x35U      : m_CodeG[byIndexG] = CODE_MOSAIC_D;                    return true;    // Mosaic D
+       case 0x36U      : m_CodeG[byIndexG] = CODE_PROP_ALPHANUMERIC;   return true;    // Proportional Alphanumeric
+       case 0x37U      : m_CodeG[byIndexG] = CODE_PROP_HIRAGANA;               return true;    // Proportional Hiragana
+       case 0x38U      : m_CodeG[byIndexG] = CODE_PROP_KATAKANA;               return true;    // Proportional Katakana
+       case 0x49U      : m_CodeG[byIndexG] = CODE_JIS_X0201_KATAKANA;  return true;    // JIS X 0201 Katakana
+       case 0x39U      : m_CodeG[byIndexG] = CODE_JIS_KANJI_PLANE_1;   return true;    // JIS compatible Kanji Plane 1
+       case 0x3AU      : m_CodeG[byIndexG] = CODE_JIS_KANJI_PLANE_2;   return true;    // JIS compatible Kanji Plane 2
+       case 0x3BU      : m_CodeG[byIndexG] = CODE_ADDITIONAL_SYMBOLS;  return true;    // Additional symbols
+       default         : return false;         // 不明なグラフィックセット
+       }
+}
+
+const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode)
+{
+       // DRCSのグラフィックセットを割り当てる
+       switch(byCode){
+       case 0x40U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-0
+       case 0x41U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-1
+       case 0x42U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-2
+       case 0x43U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-3
+       case 0x44U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-4
+       case 0x45U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-5
+       case 0x46U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-6
+       case 0x47U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-7
+       case 0x48U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-8
+       case 0x49U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-9
+       case 0x4AU      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-10
+       case 0x4BU      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-11
+       case 0x4CU      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-12
+       case 0x4DU      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-13
+       case 0x4EU      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-14
+       case 0x4FU      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // DRCS-15
+       case 0x70U      : m_CodeG[byIndexG] = CODE_UNKNOWN;                             return true;    // Macro
+       default         : return false;         // 不明なグラフィックセット
+}
+}
diff --git a/src/aribstr.h b/src/aribstr.h
new file mode 100644 (file)
index 0000000..df8066a
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef ARIBSTR_H
+#define ARIBSTR_H 1
+
+#include <string>
+
+       //int AribToString(char *lpszDst, const char *pSrcData, const int dwSrcLen);
+int AribToString( std::string *dst, const std::string *src);
+
+#endif
diff --git a/src/eit2xml.cpp b/src/eit2xml.cpp
new file mode 100644 (file)
index 0000000..689a03d
--- /dev/null
@@ -0,0 +1,114 @@
+
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include "epg.h"
+
+
+void printUsage( void)
+{
+       const char *usage = 
+               "Usage:\n"
+               "  eit2xml < BS | CS > < TS file > < XML file >\n"
+               "  eit2xml < channel > < TS file > < XML file >\n" 
+               "      BS   :         BS\n"
+               "      CS   :         CS\n"
+               "    channel:         channel id";
+
+       fprintf( stdout, "%s\n", usage);
+}
+
+
+int main( int argc, char **argv)
+{
+       int ts_fd, xml_fd;
+       char *channel;
+       char *ts_file;
+       char *xml_file;
+       
+       const uint32_t buf_size = TS::TSPacket::TS_PACKET_SIZE * 20;
+
+       uint8_t         buf[ buf_size];
+       uint32_t        index = 0;
+       uint32_t        read_len;
+       int32_t         offset = 0;
+       ssize_t         file_read_size;
+       bool            err = false;
+       TSPacket        *ts = NULL;
+       EPG                     *epg = NULL;
+
+       if( argc != 4) {
+               printUsage();
+               return 1;
+       }
+       
+       channel = argv[ 1];
+       ts_file = argv[ 2];
+       xml_file = argv[ 3];
+
+       if( strcmp( ts_file, "-") == 0) {
+               ts_fd = 0;
+       }
+       else {
+               ts_fd = open( ts_file, O_RDONLY);
+               if( ts_fd == -1) {
+                       fprintf( stderr, "Cannot open %s.\n", ts_file);
+                       return 1;
+               }
+       }
+
+       epg = new EPG( channel);
+
+       while( (file_read_size = read( ts_fd, buf + offset, buf_size - offset) + offset) > 0 ) {
+               index = 0;
+               while( index + TS::TSPacket::TS_PACKET_SIZE <= file_read_size) {
+                       if( ts) {
+                               delete ts;
+                       }
+
+                       ts = TS::TSPacket::parse( &buf[ index], file_read_size - index, &read_len);
+                       if( !ts) {
+                               if( file_read_size - index <= TS::TSPacket::TS_PACKET_SIZE) {
+                                       break;
+                               }
+                               index += TS::TSPacket::TS_PACKET_SIZE;
+                       }
+                       else {
+                               index += read_len;
+                               if( !epg->append( ts)) {
+                                       //err = true;
+                                       //break;
+                               }
+                       }
+               }
+               if( err) {
+                       break;
+               }
+
+               offset = file_read_size - index;
+               if( offset > 0) {
+                       memmove( buf, buf + index, offset);
+               }
+       }
+
+EXIT:
+       if( ts) {
+               delete ts;
+               ts = NULL;
+       }
+       if( epg) {
+               epg->write( xml_file);
+               delete epg;
+       }
+
+       if( ts_fd != 0) {
+               close( ts_fd);
+       }
+
+       return 0;
+}
+
diff --git a/src/epg.cpp b/src/epg.cpp
new file mode 100644 (file)
index 0000000..2d89f04
--- /dev/null
@@ -0,0 +1,554 @@
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sstream>
+
+#include "epg.h"
+#include "aribstr.h"
+
+
+const uint16_t EPG::EIT_PID[ EIT_PID_NUM] = {
+       0x0012, 0x0026, 0x0027,
+};
+
+const EPG::CONTENT     EPG::contents[ CONTENT_NUM] = {
+       { "ニュース・報道"        , "news"       , },
+       { "スポーツ"              , "sports"     , },
+       { "情報"                  , "information", },
+       { "ドラマ"                , "drama"      , },
+       { "音楽"                  , "music"      , },
+       { "バラエティ"            , "variety"    , },
+       { "映画"                  , "cinema"     , },
+       { "アニメ・特撮"          , "anime"      , },
+       { "ドキュメンタリー・教養", "documentary", },
+       { "演劇"                  , "stage"      , },
+       { "趣味・実用"            , "hobby"      , },
+       { "福祉"                  , "etc"        , },
+       { "予備"                  , "etc"        , },
+       { "予備"                  , "etc"        , },
+       { "予備"                  , "etc"        , },
+       { "その他"                , "etc"        , },
+};
+
+EPG::EPG( std::string ch)
+       : channel( ch)
+{
+       int32_t i;
+
+       sdt = new SDT( &descriptor_parser);
+
+       for( i = 0; i < EIT_PID_NUM; i++) {
+               eits[ EIT_PID[ i]] = new EIT( &descriptor_parser);
+       }
+}
+
+EPG::~EPG()
+{
+       EITS::iterator  e;
+
+       if( sdt) {
+               delete sdt;
+       }
+
+       for( e = eits.begin(); e != eits.end(); e++) {
+               if( e->second)  {
+                       delete e->second;
+               }
+       }
+       eits.clear();
+}
+
+bool EPG::append( TSPacket *ts)
+{
+       int32_t         i;
+       uint16_t        pid = ts->getPID();
+
+       Section::STATUS status;
+
+       if( pid == SDT_PID) {
+               return appendSDT( ts);
+       }
+
+       for( i = 0; i < EIT_PID_NUM; i++) {
+               if( pid == EIT_PID[ i]) {
+                       return appendEIT( ts);
+               }
+       }
+
+       return true;
+}
+
+
+bool EPG::appendSDT( TS::TSPacket *ts)
+{
+       Section::STATUS status;
+       uint32_t                index = 0;
+
+       do {
+               status = sdt->append( ts, &index);
+               if( status == Section::SUCCESS || status == Section::INCLUDE_NEW_SECTION) {
+                       SDT::SERVICES::iterator         s;
+                       SDT::DESCRIPTORS::iterator      d;
+                       for( s = sdt->services.begin(); s != sdt->services.end(); s++) {
+                               if( s->EIT_schedule_flag != 0x01) {
+                                       continue;
+                               }
+
+                               for( d = s->descriptors.begin(); d != s->descriptors.end(); d++) {
+                                       if( (*d)->descriptor_tag == Service::TAG) {
+                                               Service *des = (Service *)*d;
+                                               if( des->service_type == 0x01) {
+                                                       SERVICE tmp;
+
+                                                       tmp.transport_stream_id = sdt->si_id.transport_stream_id;
+                                                       tmp.original_network_id = sdt->original_network_id;
+                                                       tmp.service_id                  = s->service_id;
+
+                                                       if( services.find( tmp) == services.end()) {
+                                                               std::string name = "";
+
+                                                               if( des->service_name_length != 0) {
+                                                                       AribToString( &name, &des->service_name);
+                                                               }
+                                                               else if( des->service_provider_name_length != 0) {
+                                                                       AribToString( &name, &des->service_provider_name);
+                                                               }
+                                                               services[ tmp] = name;
+                                                       }
+                                               }
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               else if( status == Section::CONTINUE) {
+                       return true;
+               }
+               else if( status == Section::ERROR_START_SECTION) {
+                       return true;
+               }
+               else {
+                       sdt->clear();
+                       return false;
+               }
+       } while( status == Section::INCLUDE_NEW_SECTION);
+
+       return true;
+}
+
+bool EPG::appendEIT( TS::TSPacket *ts)
+{
+       Section::STATUS status;
+       uint16_t                pid = ts->getPID();
+       uint32_t                index = 0;
+
+       do {
+               status = eits[ pid]->append( ts, &index);
+               if( status == Section::SUCCESS || status == Section::INCLUDE_NEW_SECTION) {
+                       appendEvnet((EIT*)eits[ pid]);
+                       if( status == Section::SUCCESS) {
+                               return true;
+                       }
+               }
+               else if( status == Section::CONTINUE) {
+                       return true;
+               }
+               else if( status == Section::ERROR_START_SECTION) {
+                       return true;
+               }
+               else if( status == Section::ERROR_TS_COUNTER) {
+                       eits[ pid]->clear();
+                       index = 0;
+                       fprintf( stderr, "TS COUNTER ERROR: ch = %s\n", channel.c_str());
+                       continue;
+               }
+               else {
+                       fprintf( stderr, "parse err: %d, ch = %s\n", status, channel.c_str());
+                       eits[ pid]->clear();
+                       return false;
+                       //return true;
+               }
+       } while( status == Section::INCLUDE_NEW_SECTION);
+
+       return true;
+}
+
+void EPG::appendEvnet( EIT *p)
+{
+       ShortEvent              *se;
+       Content                 *c;
+       ExtendedEvent   *ee;
+       SERVICE                 s;
+
+       s.transport_stream_id   = p->transport_stream_id;
+       s.original_network_id   = p->original_network_id;
+       s.service_id                    = p->si_id.service_id;
+
+       EIT::EVENTS::iterator it;
+       EIT::DESCRIPTORS::iterator d;
+
+       for( it = p->events.begin(); it != p->events.end(); it++) {
+#if 0
+               for( d = it->descriptors.begin(); d != it->descriptors.end(); d++) {
+                       if( (*d)->descriptor_tag == ShortEvent::TAG) {
+                               break;
+                       }
+               }
+               if( d == it->descriptors.end()) {
+                       continue;
+               }
+#endif
+
+               EXTEND::ITEM    item, item_tmp;
+               std::string             ext_text;
+               
+               EVENT                   *e = &epg_data[ s][ it->event_id];
+               bool                    ext_flag = e->extend_flag;
+               
+               e->event_id             = it->event_id;
+               e->start_time   = it->start_time;
+               if( it->duration == 0) {
+                       // とりあえず5分後
+                       e->end_time     = it->start_time + 5 * 60;
+               }
+               else {
+                       e->end_time     = it->start_time + it->duration;
+               }
+               
+               for( d = it->descriptors.begin() ; d != it->descriptors.end(); d++) {
+                       if( (*d)->descriptor_tag == ShortEvent::TAG) {
+                               se = (ShortEvent*)*d;
+                               AribToString( &e->title, &se->event_name_char);
+                               AribToString( &e->desc , &se->text_char);
+                       }
+                       else if( (*d)->descriptor_tag == Content::TAG) {
+                               c = (Content*)*d;
+                               Content::CONTENTS::iterator c_it;
+                               for( c_it = c->contents.begin(); c_it != c->contents.end(); c_it++) {
+                                       e->categorys.push_back( c_it->content_nibble_level_1);
+                               }
+                       }
+                       else if( (*d)->descriptor_tag == ExtendedEvent::TAG) {
+                               ExtendedEvent::ITEMS::iterator  i_it;
+                               ee = (ExtendedEvent*)*d;
+                               
+                               if( e->extend_flag) {
+                                       e->extend.clear();
+                                       e->extend_flag = false;
+                               }
+
+                               for( i_it = ee->items.begin(); i_it != ee->items.end(); i_it++) {
+                                       if( !i_it->item_description_char.empty()) {
+                                               
+                                               if( !item.description.empty()) {
+                                                       ext_flag = true;
+                                                       AribToString( &item_tmp.description, &item.description);
+                                                       AribToString( &item_tmp.item       , &item.item);
+                                                       e->extend.items.push_back( item_tmp);
+                                                       item.clear();
+                                               }
+
+                                               item.description        = i_it->item_description_char;
+                                               item.item                       = i_it->item_char;
+                                       }
+                                       else {
+                                               if( !i_it->item_char.empty()) {
+                                                       item.item += i_it->item_char;
+                                               }
+                                       }
+                               }
+                               // とりあえず格納
+                               ext_text += ee->text_char;
+                       }
+               }
+
+               if( !item.description.empty()) {
+                       ext_flag = true;
+                       AribToString( &item_tmp.description, &item.description);
+                       AribToString( &item_tmp.item       , &item.item);
+                       e->extend.items.push_back( item_tmp);
+                       item.clear();
+               }
+               if( !ext_text.empty()) {
+                       ext_flag = true;
+                       AribToString( &e->extend.text, &ext_text);
+               }
+               e->extend_flag = ext_flag;
+
+               e->table_id =  p->table_id;
+
+#if 0
+               if( !e.title.empty()) { 
+                       epg_data[ s].insert( e);
+               }
+#endif
+       }
+}
+
+const std::string      EPG::createChannelID( const SERVICE *s)
+{
+       std::ostringstream      id;
+
+       if( channel.compare( "BS") == 0) {
+               id << "BS" << s->service_id;
+       }
+       else if( channel.compare( "CS") == 0) {
+               id << "CS" << s->service_id;
+       }
+       else {
+               id << channel;
+       }
+
+       return id.str();
+}
+
+bool EPG::write( const char *xml_file)
+{
+       char                            start_time[ 64];
+       char                            end_time[ 64];
+       int                                     fd;
+       int                                     i;
+       int                                     category;
+
+       std::string                     str;
+       std::ostringstream      buf;
+
+       EVENTS                          *p;
+       EVENT                           *e;
+       SERVICES::iterator      s;
+       EVENTS::iterator        e_it;
+
+       if( strcmp( xml_file, "-") == 0) {
+               fd = 1;
+       }
+       else {
+               fd = open( xml_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+               if( fd == -1) {
+                       fprintf( stderr, "%s is not opened.\n", xml_file);
+                       return false;
+               }
+       }
+
+#if 0
+       for( s = services.begin(); s != services.end(); s++) {
+               fprintf( stderr, "on = %d, ts = %d, sid = %d, %s\n",
+                                 s->first.original_network_id, s->first.transport_stream_id,
+                                 s->first.service_id, s->second.c_str()
+                                );
+       }
+#endif
+
+#if 1
+       if( channel.compare( "BS") != 0 && channel.compare( "CS") != 0 && services.size() > 1) {
+               SERVICES::iterator index = services.begin();
+               std::advance( index, 1);
+               services.erase( index, services.end());
+       }
+#endif
+
+       if( !writeHeader( fd)) {
+               goto ERR;
+       }
+       if( !writeChannel( fd)) {
+               goto ERR;
+       }
+
+       for( s = services.begin(); s != services.end(); s++) {
+               p = &epg_data[ s->first];
+               for( e_it = p->begin(); e_it != p->end(); e_it++) {
+                       e = &e_it->second;
+                       if( e->title.empty()) {
+                               continue;
+                       }
+
+                       strftime( start_time, sizeof( start_time), "%Y%m%d%H%M%S", localtime( &e->start_time));
+                       strftime(   end_time, sizeof(   end_time), "%Y%m%d%H%M%S", localtime( &e->end_time));
+
+                       if( e->categorys.size() == 0) {
+                               category = CONTENT_NUM - 1;
+                       }
+                       else {
+                               category = e->categorys[ 0];
+                       }
+               
+                       buf.str( "");
+                       buf << "\t<programme "
+                               << "start=\"" << start_time << " +0900\" "
+                               << "stop=\"" << end_time << " +0900\" "
+                               << "channel=\"" << createChannelID( &s->first) << "\" "
+#if 0
+                               << "sid=\"" << s->first.service_id << "\" "
+                               << "eid=\"" << e->event_id << "\" "
+#endif
+                               << ">\n";
+                       if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                               goto ERR;
+                       }
+
+                       str = e->title;
+                       convertCharactor( &str);
+                       buf.str( "");
+                       buf << "\t\t<title lang=\"ja_JP\">" << str << "</title>\n";
+                       if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                               goto ERR;
+                       }
+
+                       str = e->desc;
+                       convertCharactor( &str);
+                       buf.str( "");
+                       buf << "\t\t<desc lang=\"ja_JP\">" << str << "</desc>\n";
+                       if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                               goto ERR;
+                       }
+
+                       buf.str( "");
+                       buf << "\t\t<category lang=\"ja_JP\">" << contents[ category].jpn << "</category>\n";
+                       if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                               goto ERR;
+                       }
+
+                       buf.str( "");
+                       buf << "\t\t<category lang=\"en\">" << contents[ category].eng << "</category>\n";
+                       if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                               goto ERR;
+                       }
+
+                       if( e->extend_flag) {
+                               EXTEND::ITEMS::const_iterator item;
+
+                               buf.str( "");
+                               buf << "\t\t<desc lang=\"ja_JP\">";
+                               for( item = e->extend.items.begin(); item != e->extend.items.end(); item++) {
+                                       str = item->description;
+                                       convertCharactor( &str);
+                                       buf << str << "\n";
+
+                                       str = item->item;
+                                       convertCharactor( &str);
+                                       buf << str << "\n";
+                               }
+                               if( !e->extend.text.empty()) {
+                                       str = item->item;
+                                       convertCharactor( &str);
+                                       buf << str << "\n";
+                               }
+
+                               buf << "</desc>\n";
+                               if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                                       goto ERR;
+                               }
+                       }
+
+                       buf.str( "");
+                       buf << "\t</programme>\n";
+                       if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                               goto ERR;
+                       }
+               }
+       }
+       if( !writeFooter( fd)) {
+               goto ERR;
+       }
+
+       if( fd != 1) {
+               close( fd);
+       }
+       return true;
+
+ERR:
+       if( fd != 1) {
+               close( fd);
+       }
+       return false;
+}
+
+bool EPG::writeHeader( int fd)
+{
+       const char *header;
+       header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
+                    "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n"                   \
+                    "<tv generator-info-name=\"eit2xml\" generator-info-url=\"http://localhost/\">\n";
+
+       if( ::write( fd, header, strlen( header)) != strlen( header)) {
+               return false;
+       }
+
+       return true;
+}
+
+bool EPG::writeChannel( int fd)
+{
+       std::ostringstream buf;
+       std::string ch_id;
+       std::string     str;
+
+       SERVICES::iterator      s;
+       for( s = services.begin(); s != services.end(); s++) {
+               ch_id = createChannelID( &s->first);
+               buf.str( "");
+               buf << " \t<channel id=\"" << ch_id << "\">\n";
+               if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                       return false;
+               }
+
+               str = s->second;
+               convertCharactor( &str);
+               buf.str( "");
+               buf << "\t\t<display-name lang=\"ja_JP\">" << str << "</display-name>\n";
+               if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                       return false;
+               }
+#if 0
+               buf.str( "");
+               buf << "\t\t<sid>" << s->first.service_id << "</sid>";
+               if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                       return false;
+               }
+#endif
+               buf.str( "");
+               buf << "\t</channel>\n";
+               if( ::write( fd, buf.str().c_str(), buf.str().length()) != buf.str().length()) {
+                       return false;
+               }
+       }
+       return true;
+}
+
+bool EPG::writeFooter( int fd)
+{
+       const char *footer = "</tv>\n";
+       if( ::write( fd, footer, strlen( footer)) != strlen( footer)) {
+               return false;
+       }
+       return true;
+}
+
+void EPG::convertCharactor(std::string *str)
+{
+       const char *rep[][2] = {
+               { "&" , "&amp;" , },
+               { "'" , "&apos;", },
+               { "\"", "&quot;", },
+               { "<" , "&lt;"  , },
+               { ">" , "&gt;"  , },
+               { NULL, NULL    , },
+       };
+
+       const char *from, *to;
+       int             i;
+
+       std::string::size_type pos;
+
+       for( i = 0, from = rep[ i][ 0], to = rep[ i][ 1]; from && to; i++, from = rep[ i][ 0], to = rep[ i][ 1]) {
+               pos = 0;
+               while( (pos = str->find( from, pos)) != std::string::npos) {
+                       str->replace( pos, strlen( from), to);
+                       pos += strlen( to);
+               }
+       }
+}
+
+
diff --git a/src/epg.h b/src/epg.h
new file mode 100644 (file)
index 0000000..77d4014
--- /dev/null
+++ b/src/epg.h
@@ -0,0 +1,142 @@
+#pragma once
+
+#include <inttypes.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <set>
+#include "TS/ts_packet.h"
+#include "TS/psi.h"
+#include "ARIB/si.h"
+
+using namespace TS;
+using namespace TS::PSI;
+using namespace TS::PSI::ARIB;
+using namespace TS::Description::ARIB;
+
+class EPG
+{
+private:
+       struct CONTENT {
+               const char *jpn;
+               const char *eng;
+       };
+
+       struct SERVICE {
+               uint16_t                                transport_stream_id;
+               uint16_t                                original_network_id;
+               uint16_t                                service_id;
+
+               struct Less : public std::binary_function< SERVICE, SERVICE, bool> {
+                       bool operator()( const SERVICE &a, const SERVICE &b) const {
+                               if( a.original_network_id < b.original_network_id) {
+                                       return true;
+                               }
+                               else if( a.transport_stream_id < a.transport_stream_id) {
+                                       return true;
+                               }
+                               else if( a.service_id < b.service_id) {
+                                       return true;
+                               }
+                               else {
+                                       return false;
+                               }
+                       }
+               };
+       };
+
+       struct EXTEND {
+               struct ITEM {
+                       std::string                             description;
+                       std::string                             item;
+                       
+                       void clear() {
+                               description.clear();
+                               item.clear();
+                       }
+               };
+
+               typedef std::list< ITEM>        ITEMS;
+
+               ITEMS                                           items;
+               std::string                                     text;
+               
+               void clear() {
+                       items.clear();
+                       text.clear();
+               }
+       };
+
+       struct EVENT {
+               typedef std::vector< uint8_t>   CATEGORYS;
+
+               uint16_t                                event_id;
+               time_t                                  start_time;
+               time_t                                  end_time;
+               std::string                             title;
+               std::string                             desc;
+               CATEGORYS                               categorys;
+
+               uint8_t                                 table_id;
+
+               bool                                    extend_flag;
+               EXTEND                                  extend;
+
+               EVENT() {
+                       extend_flag = false;
+               }
+#if 0
+               struct Less : public std::binary_function< EVENT, EVENT, bool> {
+                       bool operator()( const EVENT &a, const EVENT &b) const {
+                               return (a.start_time < b.start_time);
+                       }
+               };
+#endif
+       };
+
+       typedef std::map< uint8_t , EIT*>                       EITS;
+
+       typedef std::map< SERVICE, std::string, SERVICE::Less>  SERVICES;
+//     typedef std::set< EVENT, EVENT::Less>                                   EVENTS;
+       typedef std::map< uint16_t, EVENT>                                              EVENTS;
+       typedef std::map< SERVICE, EVENTS, SERVICE::Less>               EPG_DATA;
+
+       static const int32_t            EIT_PID_NUM     = 3;
+       static const uint16_t           SDT_PID         = 0x0011;
+       static const uint16_t           EIT_PID[ EIT_PID_NUM];
+       static const int32_t            CONTENT_NUM = 16;
+               
+       static const CONTENT            contents[ CONTENT_NUM];
+
+       AribDescriptorParser            descriptor_parser;
+       SDT                                                     *sdt;
+       EITS                                            eits;
+
+       SERVICES                                        services;
+//     EVENTS                                          events;
+       EPG_DATA                                        epg_data;
+
+       const   std::string                     channel;
+
+public:
+       EPG( std::string ch);
+       ~EPG();
+
+       bool    append( TSPacket *ts);
+       bool    write( const char *xml_file);
+
+private:
+       bool    appendSDT( TSPacket *ts);
+       bool    appendEIT( TSPacket *ts);
+
+       void    appendEvnet( EIT *p);
+
+       const std::string       createChannelID( const SERVICE *s);
+
+       void    convertCharactor( std::string *str);
+
+       bool    writeHeader( int fd);
+       bool    writeChannel( int fd);
+       bool    writeFooter( int fd);
+};
+
diff --git a/src/tsparser.cpp b/src/tsparser.cpp
new file mode 100644 (file)
index 0000000..2d70cff
--- /dev/null
@@ -0,0 +1,629 @@
+
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <map>
+#include <set>
+#include "TS/ts_packet.h"
+#include "TS/psi.h"
+#include "ARIB/si.h"
+#include "aribstr.h"
+
+using namespace TS;
+using namespace TS::PSI;
+using namespace TS::PSI::ARIB;
+using namespace TS::Description;
+using namespace TS::Description::ARIB;
+
+typedef std::map< uint16_t, Section*>  SECTIONS;
+
+
+void printPAT( Section *sec)
+{
+       PAT *pat = (PAT *)sec;
+
+       fprintf( stdout, "\n[ PAT ]\n");
+       fprintf( stdout, "table id                           = %5u\n", pat->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", pat->section_syntax_indicator);
+       fprintf( stdout, "section length                     = %5u\n", pat->section_length);
+       fprintf( stdout, "transport stream id                = %5u\n", pat->psi_id.transport_stream_id);
+       fprintf( stdout, "version number                     = %5u\n", pat->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", pat->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", pat->section_number);
+       fprintf( stdout, "last section number                = %5u\n", pat->last_section_number);
+       fprintf( stdout, "network PID                        = %5u\n", pat->network_PID);
+
+       PAT::PROGRAM_MAP::iterator it;
+       for( it = pat->program_map_PID.begin(); it != pat->program_map_PID.end(); it++) {
+               fprintf( stdout, "  program number = 0x%04X, program map PID = 0x%04X\n", it->first, it->second);
+       }
+}
+
+void printCAT( Section *sec)
+{
+       CAT *cat = (CAT *)sec;
+
+       fprintf( stdout, "\n[ CAT ]\n");
+       fprintf( stdout, "table id                           = %5u\n", cat->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", cat->section_syntax_indicator);
+       fprintf( stdout, "section length                     = %5u\n", cat->section_length);
+       fprintf( stdout, "version number                     = %5u\n", cat->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", cat->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", cat->section_number);
+       fprintf( stdout, "last section number                = %5u\n", cat->last_section_number);
+
+       CAT::DESCRIPTORS::iterator d;
+       for( d = cat->descriptors.begin(); d != cat->descriptors.end(); d++) {
+               fprintf( stdout, "  descriptor_tag                   = 0x%02X\n", (*d)->descriptor_tag);
+               fprintf( stdout, "  descriptor_length                = %5u\n", (*d)->descriptor_length);
+       }
+}
+
+void printTSDT( Section *sec)
+{
+       TSDT *tsdt = (TSDT *)sec;
+
+       fprintf( stdout, "\n[ TSDT ]\n");
+       fprintf( stdout, "table id                           = %5u\n", tsdt->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", tsdt->section_syntax_indicator);
+       fprintf( stdout, "section length                     = %5u\n", tsdt->section_length);
+       fprintf( stdout, "version number                     = %5u\n", tsdt->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", tsdt->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", tsdt->section_number);
+       fprintf( stdout, "last section number                = %5u\n", tsdt->last_section_number);
+
+       TSDT::DESCRIPTORS::iterator d;
+       for( d = tsdt->descriptors.begin(); d != tsdt->descriptors.end(); d++) {
+               fprintf( stdout, "  descriptor_tag                   = 0x%02X\n", (*d)->descriptor_tag);
+               fprintf( stdout, "  descriptor_length                = %5u\n", (*d)->descriptor_length);
+       }
+}
+
+void printPMT( Section *sec)
+{
+       PMT *pmt = (PMT *)sec;
+       PMT::DESCRIPTORS::iterator d;
+
+       fprintf( stdout, "\n[ PMT ]\n");
+       fprintf( stdout, "table id                           = %5u\n", pmt->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", pmt->section_syntax_indicator);
+       fprintf( stdout, "section length                     = %5u\n", pmt->section_length);
+       fprintf( stdout, "program number                     = %5u\n", pmt->psi_id.program_number);
+       fprintf( stdout, "version number                     = %5u\n", pmt->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", pmt->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", pmt->section_number);
+       fprintf( stdout, "last section number                = %5u\n", pmt->last_section_number);
+       fprintf( stdout, "PCR_PID                            = 0x%04X\n", pmt->PCR_PID);
+       fprintf( stdout, "program_info_length                = %5u\n", pmt->program_info_length);
+
+       for( d = pmt->program_info_descriptors.begin(); d != pmt->program_info_descriptors.end(); d++) {
+               fprintf( stdout, "descriptor_tag                     = 0x%02X\n", (*d)->descriptor_tag);
+               fprintf( stdout, "descriptor_length                  = %5u\n", (*d)->descriptor_length);
+
+               if( (*d)->descriptor_tag == ConditionalAccess::TAG) {
+                       ConditionalAccess *ca = (ConditionalAccess *)*d;
+                       fprintf( stdout, "CA_system_ID                       = %5u\n", ca->CA_system_ID);
+                       fprintf( stdout, "CA_PID                             = 0x%04X\n", ca->CA_PID);
+               }
+       }
+
+       PMT::ELEMENTS::iterator e;
+       for( e = pmt->elements.begin(); e != pmt->elements.end(); e++) {
+               fprintf( stdout, "  stream_type                      = 0x%02X\n", e->stream_type);
+               fprintf( stdout, "  elementary_PID                   = 0x%04X\n", e->elementary_PID);
+               fprintf( stdout, "  ES_info_length                   = %5u\n", e->ES_info_length);
+
+               PMT::DESCRIPTORS::iterator d;
+               for( d = e->descriptors.begin(); d != e->descriptors.end(); d++) {
+                       fprintf( stdout, "    descriptor_tag                 = 0x%02X\n", (*d)->descriptor_tag);
+                       fprintf( stdout, "    descriptor_length              = %5u\n", (*d)->descriptor_length);        
+
+                       if( (*d)->descriptor_tag == ConditionalAccess::TAG) {
+                               ConditionalAccess *ca = (ConditionalAccess *)*d;
+                               fprintf( stdout, "    CA_system_ID                   = %5u\n", ca->CA_system_ID);
+                               fprintf( stdout, "    CA_PID                         = 0x%04X\n", ca->CA_PID);
+                       }
+               }
+       }
+}
+       
+
+void printEIT( Section *sec)
+{
+       EIT *eit = (EIT *)sec;
+
+       fprintf( stdout, "\n[ EIT ]\n");
+       fprintf( stdout, "table id                           = 0x%02X\n", eit->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", eit->section_syntax_indicator);
+       fprintf( stdout, "private indicator                  = %5u\n", eit->private_indicator);
+       fprintf( stdout, "section length                     = %5u\n", eit->section_length);
+       fprintf( stdout, "service_id                         = %5u\n", eit->si_id.service_id);
+       fprintf( stdout, "version number                     = %5u\n", eit->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", eit->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", eit->section_number);
+       fprintf( stdout, "last section number                = %5u\n", eit->last_section_number);
+       fprintf( stdout, "transport_stream_id                = %5u\n", eit->transport_stream_id);
+       fprintf( stdout, "original_network_id                = %5u\n", eit->original_network_id);
+       fprintf( stdout, "segment_last_section_number        = %5u\n", eit->segment_last_section_number);
+       fprintf( stdout, "last_table_id                      = %5u\n", eit->last_table_id);
+
+       EIT::EVENTS::iterator e;
+       for( e = eit->events.begin(); e != eit->events.end(); e++) {
+               fprintf( stdout, "  event_id                         = %5u\n", e->event_id);
+               fprintf( stdout, "  start_time                       = %s", asctime( localtime( &e->start_time)));
+               fprintf( stdout, "  duration                         = %5d\n", e->duration);
+               fprintf( stdout, "  running_status                   = %5u\n", e->running_status);
+               fprintf( stdout, "  free_CA_mode                     = %5u\n", e->free_CA_mode);
+               fprintf( stdout, "  descriptors_loop_length          = %5u\n", e->descriptors_loop_length);                                     
+
+               EIT::DESCRIPTORS::iterator d;
+               for( d = e->descriptors.begin(); d != e->descriptors.end(); d++) {
+                       fprintf( stdout, "    descriptor_tag                 = 0x%02X\n", (*d)->descriptor_tag);
+                       fprintf( stdout, "    descriptor_length              = %5u\n", (*d)->descriptor_length);        
+#if 1
+                       if( (*d)->descriptor_tag == ShortEvent::TAG) {
+                               ShortEvent *des = (ShortEvent*)*d;
+                               std::string str;
+                               AribToString( &str, &des->event_name_char);
+                               fprintf( stdout, "    event_name                     = %s\n", str.c_str());
+                               AribToString( &str, &des->text_char);
+                               fprintf( stdout, "    text                           = %s\n", str.c_str());
+
+                       }
+                       if( (*d)->descriptor_tag == ExtendedEvent::TAG) {
+                               ExtendedEvent *des = (ExtendedEvent *)*d;
+                               fprintf( stdout, "    descriptor_number              = %d\n", des->descriptor_number);
+                               fprintf( stdout, "    last_descriptor_number         = %d\n", des->last_descriptor_number);
+                               fprintf( stdout, "    length_of_items                = %d\n", des->length_of_items);
+
+                               ExtendedEvent::ITEMS::iterator it;
+                               std::string str;
+                               for( it = des->items.begin(); it != des->items.end(); it++) {
+                                       AribToString( &str, &it->item_description_char);
+                                       fprintf( stdout, "    item_description               = %s\n", str.c_str());
+                                       AribToString( &str, &it->item_char);
+                                       fprintf( stdout, "    item                           = %s\n", str.c_str());
+                               }
+                               AribToString( &str, &des->text_char);
+                               fprintf( stdout, "    text_char                      = %s\n", str.c_str());
+                       }
+                       if( (*d)->descriptor_tag == Component::TAG) {
+                               Component *des = (Component *)*d;
+                               std::string str;
+                               fprintf( stdout, "    stream_content                 = 0x%02X\n", des->stream_content);
+                               fprintf( stdout, "    component_type                 = 0x%02X\n", des->component_type);
+                               fprintf( stdout, "    component_tag                  = 0x%02X\n", des->component_tag);
+                               AribToString( &str, &des->text_char);
+                               fprintf( stdout, "    text                           = %s\n", str.c_str());
+                       }
+                       if( (*d)->descriptor_tag == Content::TAG) {
+                               Content *des = (Content *)*d;
+                               Content::CONTENTS::iterator it;
+                               for( it = des->contents.begin(); it != des->contents.end(); it++) {
+                                       fprintf( stdout, "    content_nibble_level_1         = %d\n", it->content_nibble_level_1);
+                                       fprintf( stdout, "    content_nibble_level_2         = %d\n", it->content_nibble_level_2);
+                                       fprintf( stdout, "    user_nibble_1                  = %d\n", it->user_nibble_1);
+                                       fprintf( stdout, "    user_nibble_2                  = %d\n", it->user_nibble_2);
+                               }
+                       }
+                       if( (*d)->descriptor_tag == AudioComponent::TAG) {
+                               AudioComponent *des = (AudioComponent *)*d;
+                               std::string str;
+                               fprintf( stdout, "    stream_content                 = 0x%02X\n", des->stream_content);
+                               fprintf( stdout, "    component_type                 = 0x%02X\n", des->component_type);
+                               fprintf( stdout, "    component_tag                  = 0x%02X\n", des->component_tag);
+                               fprintf( stdout, "    stream_type                    = 0x%02X\n", des->stream_type);
+                               fprintf( stdout, "    simulcast_group_tag            = 0x%02X\n", des->simulcast_group_tag);
+                               fprintf( stdout, "    ES_multi_lingual_flag          = %2d\n", des->ES_multi_lingual_flag);
+                               fprintf( stdout, "    main_component_flag            = %2d\n", des->main_component_flag);
+                               fprintf( stdout, "    quality_indicator              = 0x%02X\n", des->quality_indicator);
+                               fprintf( stdout, "    sampling_rate                  = 0x%02X\n", des->sampling_rate);
+                               fprintf( stdout, "    component_tag                  = 0x%02X\n", des->component_tag);
+                               fprintf( stdout, "    ISO_639_language_code          = %s\n", des->ISO_639_language_code.c_str());
+                               if( des->ES_multi_lingual_flag) {
+                                       fprintf( stdout, "    ISO_639_language_code_2        = %s\n", des->ISO_639_language_code_2.c_str());
+                               }
+                               AribToString( &str, &des->text_char);
+                               fprintf( stdout, "    text                           = %s\n", str.c_str());
+                       }
+                       if( (*d)->descriptor_tag == EventGroup::TAG) {
+                               EventGroup *des = (EventGroup *)*d;
+                               EventGroup::EVENTS::iterator                    e;
+                               EventGroup::NETWORK_EVENTS::iterator    n;
+                               fprintf( stdout, "    group_type                     = %X\n", des->group_type);
+                               fprintf( stdout, "    event_count                    = %d\n", des->event_count);
+                               for( e = des->events.begin(); e != des->events.end(); e++) {
+                                       fprintf( stdout, "    service_id                     = %d\n", e->service_id);
+                                       fprintf( stdout, "    event_id                       = %d\n", e->event_id);
+                               }
+                               if( des->group_type == 4 || des->group_type == 5) {
+                                       for( n = des->network_events.begin(); n != des->network_events.end(); n++) {
+                                               fprintf( stdout, "    original_network_id            = %d\n", n->original_network_id);
+                                               fprintf( stdout, "    transport_stream_id            = %d\n", n->transport_stream_id);
+                                               fprintf( stdout, "    service_id                     = %d\n", n->event.service_id);
+                                               fprintf( stdout, "    event_id                       = %d\n", n->event.event_id);
+                                       }
+                               }
+                               else {
+                                       fprintf( stdout, "    private_data_length            = %d\n", des->getPrivateData()->size());
+                               }
+                       }
+#endif
+               }
+       }
+}
+
+void printNIT( Section *sec)
+{
+       NIT *nit = (NIT *)sec;
+
+       fprintf( stdout, "\n[ NIT ]\n");
+       fprintf( stdout, "table id                           = 0x%02X\n", nit->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", nit->section_syntax_indicator);
+       fprintf( stdout, "private indicator                  = %5u\n", nit->private_indicator);
+       fprintf( stdout, "section length                     = %5u\n", nit->section_length);
+       fprintf( stdout, "network_id                         = %5u\n", nit->si_id.network_id);
+       fprintf( stdout, "version number                     = %5u\n", nit->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", nit->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", nit->section_number);
+       fprintf( stdout, "last section number                = %5u\n", nit->last_section_number);
+       fprintf( stdout, "network_descriptors_length         = %5u\n", nit->network_descriptors_length);
+
+       NIT::DESCRIPTORS::iterator d;
+       for( d = nit->networks.begin(); d != nit->networks.end(); d++) {
+               fprintf( stdout, "  descriptor_tag                   = 0x%02X\n", (*d)->descriptor_tag);
+               fprintf( stdout, "  descriptor_length                = %5u\n", (*d)->descriptor_length);
+               if( (*d)->descriptor_tag == NetworkName::TAG) {
+                       NetworkName *des = (NetworkName *)*d;
+                       std::string str;
+                       AribToString( &str, &des->name);
+                       fprintf( stdout, "  name                             = %s\n", str.c_str());
+               }
+       }
+
+       fprintf( stdout, "transport_stream_loop_length       = %5u\n", nit->transport_stream_loop_length);
+       NIT::STREAMS::iterator s;
+       for( s = nit->streams.begin(); s != nit->streams.end(); s++) {
+               fprintf( stdout, "  transport_stream_id              = %5u\n", s->transport_stream_id);
+               fprintf( stdout, "  original_network_id              = %5u\n", s->original_network_id);
+               fprintf( stdout, "  transport_descriptors_length     = %5u\n", s->transport_descriptors_length);
+               for( d = s->descriptors.begin(); d != s->descriptors.end(); d++) {
+                       fprintf( stdout, "    descriptor_tag                 = 0x%02X\n", (*d)->descriptor_tag);
+                       fprintf( stdout, "    descriptor_length              = %5u\n", (*d)->descriptor_length);
+                       if( (*d)->descriptor_tag == ServiceList::TAG) {
+                               ServiceList *des = (ServiceList *)*d;
+                               ServiceList::SERVICES::iterator it;
+                               for( it = des->services.begin(); it != des->services.end(); it++) {
+                                       fprintf( stdout, "    service_id                     = %5u\n", it->service_id);
+                                       fprintf( stdout, "    service_type                   = %5u\n", it->service_type);
+                               }
+                       }
+               }
+       }
+}
+
+void printSDT( Section *sec)
+{
+       SDT *sdt = (SDT *)sec;
+       std::string str;
+
+       fprintf( stdout, "\n[ SDT ]\n");
+       fprintf( stdout, "table id                           = 0x%02X\n", sdt->table_id);
+       fprintf( stdout, "section syntax indicator           = %5u\n", sdt->section_syntax_indicator);
+       fprintf( stdout, "private indicator                  = %5u\n", sdt->private_indicator);
+       fprintf( stdout, "section length                     = %5u\n", sdt->section_length);
+       fprintf( stdout, "transport_stream_id                = %5u\n", sdt->si_id.transport_stream_id);
+       fprintf( stdout, "version number                     = %5u\n", sdt->version_number);
+       fprintf( stdout, "current next indicator             = %5u\n", sdt->current_next_indicator);
+       fprintf( stdout, "section number                     = %5u\n", sdt->section_number);
+       fprintf( stdout, "last section number                = %5u\n", sdt->last_section_number);
+       fprintf( stdout, "original_network_id                = %5u\n", sdt->original_network_id);
+
+       SDT::SERVICES::iterator s;
+       for( s = sdt->services.begin(); s != sdt->services.end(); s++) {
+               fprintf( stdout, "  service_id                       = %5u\n", s->service_id);
+               fprintf( stdout, "  EIT_user_defined_flags           = %d\n", s->EIT_user_defined_flags);
+               fprintf( stdout, "  EIT_schedule_flag                = %d\n", s->EIT_schedule_flag);
+               fprintf( stdout, "  EIT_present_following_flag       = %d\n", s->EIT_present_following_flag);
+               fprintf( stdout, "  running_status                   = %5u\n", s->running_status);
+               fprintf( stdout, "  free_CA_mode                     = %5u\n", s->free_CA_mode);
+               fprintf( stdout, "  descriptors_loop_length          = %5u\n", s->descriptors_loop_length);
+       
+               SDT::DESCRIPTORS::iterator d;
+               for( d = s->descriptors.begin(); d != s->descriptors.end(); d++) {
+                       fprintf( stdout, "    descriptor_tag                 = 0x%02X\n", (*d)->descriptor_tag);
+                       fprintf( stdout, "    descriptor_length              = %5u\n", (*d)->descriptor_length);
+                       if( (*d)->descriptor_tag == Service::TAG) {
+                               Service *p = (Service *)*d;
+                               fprintf( stdout, "    service_type                   = %d\n", p->service_type);
+#if 1
+                               AribToString( &str, &p->service_provider_name);
+                               fprintf( stdout, "    service_provider_name          = %s\n", str.c_str());
+                               AribToString( &str, &p->service_name);
+                               fprintf( stdout, "    service_name                   = %s\n", str.c_str());
+#endif
+                       }
+               }
+       }
+}
+
+
+int main( int argc, char **argv)
+{
+       int fd;
+       char *filename;
+       
+       const uint32_t buf_size = TS::TSPacket::TS_PACKET_SIZE * 10;
+
+       uint16_t        pid;
+       uint8_t         buf[ buf_size];
+       uint32_t        index = 0;
+       uint32_t        read_len;
+       uint32_t        offset = 0;
+       ssize_t         file_read_size;
+       bool            output_ts = false;
+
+       TSPacket                        *ts = NULL;
+       Section::STATUS         status;
+       SECTIONS                        secs;
+       SECTIONS::iterator      sec_it;
+
+       AribDescriptorParser    des_parser;
+       
+       uint32_t payload_index = 0;
+
+       if( argc <2) {
+               fprintf( stderr, "required TS file\n");
+               return 1;
+       }
+
+       filename = argv[ 1];
+#if 0
+       if( argc >= 3) {
+               output_ts = true;
+       }
+#endif
+
+       if( strcmp( filename, "-") == 0) {
+               fd = 0;
+       }
+       else {
+               fd = open( filename, O_RDONLY);
+       }
+       if( fd == -1) {
+               fprintf( stderr, "%s is not opened.\n", filename);
+               return 1;
+       }
+
+       secs[ 0x0000] = new PAT( &des_parser);
+       secs[ 0x0001] = new CAT( &des_parser);
+       secs[ 0x0002] = new TSDT( &des_parser);
+       secs[ 0x0010] = new NIT( &des_parser);
+       secs[ 0x0011] = new SDT( &des_parser);
+       secs[ 0x0012] = new EIT( &des_parser);
+       secs[ 0x0026] = new EIT( &des_parser);
+       secs[ 0x0027] = new EIT( &des_parser);
+
+       int32_t t_err_pid;
+
+       int ofd = -1;
+       uint8_t write_buf[ 1024];
+       bool    save_flag = false;
+       uint16_t                        pmt_pid = 0;
+       uint8_t                         pat_counter = 0;
+       uint8_t                         pmt_counter = 0;
+       std::set< uint16_t>     save_pid;
+
+       save_pid.insert( 0x0000);
+       save_pid.insert( 0x0001);
+       save_pid.insert( 0x0010);
+       save_pid.insert( 0x0011);
+
+       while( (file_read_size = read( fd, buf + offset, buf_size - offset) + offset) > 0 ) {
+               index = 0;
+               while( index + TS::TSPacket::TS_PACKET_SIZE <= file_read_size) {
+                       if( ts) {
+                               delete ts;
+                       }
+
+                       ts = TS::TSPacket::parse( &buf[ index], file_read_size, &read_len);
+                       if( !ts) {
+                               fprintf( stderr, "TS Packet parse error\n");
+                               index += TS::TSPacket::TS_PACKET_SIZE;
+                               continue;
+                       }
+//                     index += read_len;
+                       pid = ts->getPID();
+                       sec_it = secs.find( pid);
+                       if( sec_it != secs.end()) {
+                               payload_index = 0;
+                               do {
+                                       status = sec_it->second->append( ts, &payload_index);
+                                       if( status == Section::SUCCESS || status == Section::INCLUDE_NEW_SECTION) {
+                                               if( sec_it->first == 0x0000) {
+                                                       //printPAT( sec_it->second);
+
+                                                       PAT *pat = (PAT *)sec_it->second;
+                                                       PAT::PROGRAM_MAP::iterator it;
+                                                       SECTIONS::iterator pmt;
+#if 0
+                                                       for( it = pat->program_map_PID.begin(); it != pat->program_map_PID.end(); it++) {
+                                                               pmt = secs.find( it->second);
+                                                               if( pmt == secs.end()) {
+                                                                       secs[ it->second] = new PMT( &des_parser);
+                                                                       save_pid.insert( it->second);
+                                                                       fprintf( stderr, "new pid 0x%04X, program number %u\n", it->second, it->first);
+                                                                       if( pmt_pid == 0) {
+                                                                               pmt_pid = it->second;
+                                                                       }
+                                                               }
+                                                       }
+#else
+                                                       save_pid.insert( pat->network_PID);
+                                                       it = pat->program_map_PID.begin();
+                                                       std::advance( it, 1);
+                                                       pat->program_map_PID.erase( it, pat->program_map_PID.end());
+                                                       it = pat->program_map_PID.begin();
+                                                       if( secs.find( it->second) == secs.end()) {
+                                                               secs[ it->second] = new PMT( &des_parser);
+                                                               save_pid.insert( it->second);
+                                                               fprintf( stderr, "new pid 0x%04X, program number %u\n", it->second, it->first);
+                                                               pmt_pid = it->second;
+                                                       }
+#endif
+                                               }
+                                               else if( sec_it->first == 0x0001) {
+                                                       //printCAT( sec_it->second);
+                                               }
+                                               else if( sec_it->first == 0x0002) {
+                                                       //printTSDT( sec_it->second);
+                                               }
+                                               else if( sec_it->first == 0x0010) {
+                                                       //printNIT( sec_it->second);
+                                               }
+                                               else if( sec_it->first == 0x0011) {
+                                                       ///printSDT( sec_it->second);
+                                               }
+                                               else if( (sec_it->first == 0x0012 || sec_it->first == 0x0026 || sec_it->first == 0x0027)) {
+                                                       printEIT( sec_it->second);
+                                               }
+                                               else {
+                                                       if( sec_it->second->table_id == PMT::ID) {
+                                                               //printPMT( sec_it->second);
+
+                                                               PMT *pmt = (PMT *)sec_it->second;
+                                                               PMT::DESCRIPTORS::iterator      d;
+                                                               PMT::ELEMENTS::iterator e;
+
+                                                               //if( pmt_pid == sec_it->first) {
+                                                                       if( save_pid.find( pmt->PCR_PID) == save_pid.end()) {
+                                                                               save_pid.insert( pmt->PCR_PID);
+                                                                               fprintf( stderr, "new pid 0x%04X, PCR, cur pid 0x%04X\n", pmt->PCR_PID, sec_it->first);
+                                                                       }
+
+                                                                       for( d = pmt->program_info_descriptors.begin(); d != pmt->program_info_descriptors.end(); d++) {
+                                                                               if( (*d)->descriptor_tag == ConditionalAccess::TAG) {
+                                                                                       ConditionalAccess *ca = (ConditionalAccess *)*d;
+                                                                                       if( save_pid.find( ca->CA_PID) == save_pid.end()) {
+                                                                                               //secs[ ca->CA_PID] = new CAT( &des_parser);
+                                                                                               if( ca->CA_PID != 0x1FFF) {
+                                                                                                       save_pid.insert( ca->CA_PID);
+                                                                                                       fprintf( stderr, "new pid 0x%04X, CA ID %u, cur pid 0x%04X\n", ca->CA_PID, ca->CA_system_ID, sec_it->first);
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+
+                                                                       pmt->eraseElement( 0x0D);
+
+                                                                       for( e = pmt->elements.begin(); e != pmt->elements.end(); e++) {
+                                                                               if( save_pid.find( e->elementary_PID) == save_pid.end()) {
+                                                                                       save_pid.insert( e->elementary_PID);
+                                                                                       fprintf( stderr, "new pid 0x%04X, stream_type 0x%02X, cur pid 0x%04X\n", e->elementary_PID, e->stream_type, sec_it->first);
+                                                                               }
+
+                                                                               for( d = e->descriptors.begin(); d != e->descriptors.end(); d++) {
+                                                                                       if( (*d)->descriptor_tag == ConditionalAccess::TAG) {
+                                                                                               ConditionalAccess *ca = (ConditionalAccess *)*d;
+                                                                                               if( save_pid.find( ca->CA_PID) == save_pid.end()) {
+                                                                                                       //secs[ ca->CA_PID] = new CAT( &des_parser);
+                                                                                                       if( ca->CA_PID != 0x1FFF) {
+                                                                                                               save_pid.insert( ca->CA_PID);
+                                                                                                               fprintf( stderr, "new pid 0x%04X, CA ID %u, cur pid 0x%04X\n", ca->CA_PID, ca->CA_system_ID, sec_it->first);
+                                                                                                       }
+                                                                                               }
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                                       save_flag = true;
+                                                               //}
+                                                       }
+                                               }
+                                       }
+                                       else if( status != Section::CONTINUE) {
+                                               fprintf( stderr, "Section parse error = %d, PID = 0x%04X\n", status, ts->getPID());
+                                       }
+                               } while( status == Section::INCLUDE_NEW_SECTION);
+                       }
+#if 0
+                       if( ofd == -1 && output_ts) {
+                               ofd = open( "output.ts", O_WRONLY | O_CREAT | O_TRUNC, 0644);
+                       }
+
+                       if( ofd > 0) {
+                               if( ts->getPID() == 0x0000) {
+                                       PAT *pat = (PAT *)secs[ 0x0000];
+                                       if( pat->finish()) {
+                                               TSPacket *tmp_ts;
+                                               status = pat->getTSPacket( &tmp_ts, &pat_counter, ts->getAdaptationField());
+                                               if( status != Section::SUCCESS) {
+                                                       fprintf( stderr, "PAT TS Packet rebuild error: %d\n", status);
+                                               }
+                                               else {
+                                                       int w = tmp_ts->getBytes( write_buf, 1024);
+                                                       if( w > 0) {
+                                                               ::write( ofd, &write_buf, w);
+                                                       }
+                                               }
+                                       }
+                               }
+                               else if( ts->getPID() == pmt_pid) {
+                                       PMT *pmt = (PMT *)secs[ pmt_pid];
+                                       if( pmt->finish()) {
+                                               TSPacket *tmp_ts;
+                                               status = pmt->getTSPacket( &tmp_ts, &pmt_counter, ts->getAdaptationField());
+                                               if( status != Section::SUCCESS) {
+                                                       fprintf( stderr, "PMT TS Packet rebuild error: %d\n", status);
+                                               }
+                                               else {
+                                                       int w = tmp_ts->getBytes( write_buf, 1024);
+                                                       if( w > 0) {
+                                                               ::write( ofd, &write_buf, w);
+                                                       }
+                                               }
+                                       }
+                               }
+                               else if( save_pid.find( ts->getPID()) != save_pid.end()) {
+                                       int w = ts->getBytes( write_buf, 1024);
+                                       if( memcmp( write_buf, &buf[ index], w) != 0) {
+                                               fprintf( stderr, "TS Packet rebuild error: PID = 0x%04X\n", ts->getPID());
+                                               int i;
+                                               for( i = 0; i < w; i++) {
+                                                       if( write_buf[ i] != buf[ index + i]) {
+                                                               fprintf( stderr, "TS Packet rebuild error index = %d\n", i);
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                                       if( w > 0) {
+                                               ::write( ofd, &write_buf, w);
+                                       }
+                               }
+                       }
+#endif
+                       index += read_len;
+               }
+               offset = file_read_size - index;
+               memmove( buf, buf + index, offset);
+       }
+       
+EXIT:
+       if( fd > 0) {
+               close( fd);
+       }
+       if( ofd > 0) {
+               close( ofd);
+       }
+
+       for( sec_it = secs.begin(); sec_it != secs.end(); sec_it++) {
+               delete sec_it->second;
+       }
+       secs.clear();
+
+       return 0;
+}