Initial WebM release
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..ffc6912
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,18 @@
+*.[chs]      filter=fixtabswsp
+*.[ch]pp     filter=fixtabswsp
+*.[ch]xx     filter=fixtabswsp
+*.asm        filter=fixtabswsp
+*.php        filter=fixtabswsp
+*.pl         filter=fixtabswsp
+*.sh         filter=fixtabswsp
+*.txt	     filter=fixwsp
+[Mm]akefile  filter=fixwsp
+*.mk         filter=fixwsp
+*.rc         -crlf
+*.ds[pw]     -crlf
+*.bat        -crlf
+*.mmp        -crlf
+*.dpj        -crlf
+*.pjt        -crlf
+*.vcp        -crlf
+*.inf        -crlf
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..9686ac1
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+# Names should be added to this file like so:
+# Name or Organization <email address>
+
+Google Inc.
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..d6c8ce8
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,3 @@
+2010-05-18 v0.9.0
+  - Initial open source release. Welcome to WebM and VP8!
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6b0e867
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,48 @@
+Copyright (c) 2010, Google, Inc.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+- Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+- Neither the name of Google nor the names of its contributors may
+  be used to endorse or promote products derived from this software
+  without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Subject to the terms and conditions of the above License, Google
+hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this
+section) patent license to make, have made, use, offer to sell, sell,
+import, and otherwise transfer this implementation of VP8, where such
+license applies only to those patent claims, both currently owned by
+Google and acquired in the future, licensable by Google that are
+necessarily infringed by this implementation of VP8. If You or your
+agent or exclusive licensee institute or order or agree to the
+institution of patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that this
+implementation of VP8 or any code incorporated within this
+implementation of VP8 constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any rights
+granted to You under this License for this implementation of VP8
+shall terminate as of the date such litigation is filed.
diff --git a/README b/README
new file mode 100644
index 0000000..cfaf4cc
--- /dev/null
+++ b/README
@@ -0,0 +1,106 @@
+vpx Multi-Format Codec SDK
+README - 19 May 2010
+
+Welcome to the WebM VP8 Codec SDK!
+
+COMPILING THE APPLICATIONS/LIBRARIES:
+  The build system used is similar to autotools. Building generally consists of
+  "configuring" with your desired build options, then using GNU make to build
+  the application.
+
+  1. Prerequisites
+  
+    * All x86 targets require the Yasm[1] assembler be installed.
+    * All Windows builds require that Cygwin[2] be installed.
+    * Building the documentation requires PHP[3] and Doxygen[4]. If you do not
+      have these packages, you must pass --disable-install-docs to the
+      configure script.
+    
+    [1]: http://www.tortall.net/projects/yasm
+    [2]: http://www.cygwin.com
+    [3]: http://php.net
+    [4]: http://www.doxygen.org
+    
+  2. Out-of-tree builds
+  Out of tree builds are a supported method of building the application. For
+  an out of tree build, the source tree is kept separate from the object
+  files produced during compilation. For instance:
+
+    $ mkdir build
+    $ cd build
+    $ ../libvpx/configure <options>
+    $ make
+
+  3. Configuration options
+  The 'configure' script supports a number of options. The --help option can be
+  used to get a list of supported options:
+    $ ../libvpx/configure --help
+
+  4. Cross development
+  For cross development, the most notable option is the --target option. The
+  most up-to-date list of supported targets can be found at the bottom of the
+  --help output of the configure script. As of this writing, the list of
+  available targets is:
+
+    armv5te-linux-rvct
+    armv5te-linux-gcc
+    armv5te-symbian-gcc
+    armv5te-wince-vs8
+    armv6-darwin-gcc
+    armv6-linux-rvct
+    armv6-linux-gcc
+    armv6-symbian-gcc
+    armv6-wince-vs8
+    iwmmxt-linux-rvct
+    iwmmxt-linux-gcc
+    iwmmxt-wince-vs8
+    iwmmxt2-linux-rvct
+    iwmmxt2-linux-gcc
+    iwmmxt2-wince-vs8
+    armv7-linux-rvct
+    armv7-linux-gcc
+    mips32-linux-gcc
+    ppc32-darwin8-gcc
+    ppc32-darwin9-gcc
+    ppc64-darwin8-gcc
+    ppc64-darwin9-gcc
+    ppc64-linux-gcc
+    x86-darwin8-gcc
+    x86-darwin8-icc
+    x86-darwin9-gcc
+    x86-darwin9-icc
+    x86-linux-gcc
+    x86-linux-icc
+    x86-solaris-gcc
+    x86-win32-vs7
+    x86-win32-vs8
+    x86_64-darwin9-gcc
+    x86_64-linux-gcc
+    x86_64-solaris-gcc
+    x86_64-win64-vs8
+    universal-darwin8-gcc
+    universal-darwin9-gcc
+    generic-gnu
+
+  The generic-gnu target, in conjunction with the CROSS environment variable,
+  can be used to cross compile architectures that aren't explicitly listed, if
+  the toolchain is a cross GNU (gcc/binutils) toolchain. Other POSIX toolchains
+  will likely work as well. For instance, to build using the mipsel-linux-uclibc
+  toolchain, the following command could be used (note, POSIX SH syntax, adapt
+  to your shell as necessary):
+
+    $ CROSS=mipsel-linux-uclibc- ../libvpx/src/configure
+
+  In addition, the executables to be invoked can be overridden by specifying the
+  environment variables: CC, AR, LD, AS, STRIP, NM. Additional flags can be
+  passed to these executables with CFLAGS, LDFLAGS, and ASFLAGS.
+
+  5. Configuration errors
+  If the configuration step fails, the first step is to look in the error log.
+  This defaults to config.err. This should give a good indication of what went
+  wrong. If not, contact us for support.
+
+SUPPORT
+  This library is an open source project supported by its community. Please
+  please email webm-users@webmproject.org for help.
+
diff --git a/args.c b/args.c
new file mode 100644
index 0000000..f2ad697
--- /dev/null
+++ b/args.c
@@ -0,0 +1,215 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include "args.h"
+
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
+#if defined(__GNUC__) && __GNUC__
+extern void die(const char *fmt, ...) __attribute__((noreturn));
+#else
+extern void die(const char *fmt, ...);
+#endif
+
+
+struct arg arg_init(char **argv)
+{
+    struct arg a;
+
+    a.argv      = argv;
+    a.argv_step = 1;
+    a.name      = NULL;
+    a.val       = NULL;
+    a.def       = NULL;
+    return a;
+}
+
+int arg_match(struct arg *arg_, const struct arg_def *def, char **argv)
+{
+    struct arg arg;
+
+    if (!argv[0] || argv[0][0] != '-')
+        return 0;
+
+    arg = arg_init(argv);
+
+    if (def->short_name
+        && strlen(arg.argv[0]) == strlen(def->short_name) + 1
+        && !strcmp(arg.argv[0] + 1, def->short_name))
+    {
+
+        arg.name = arg.argv[0] + 1;
+        arg.val = def->has_val ? arg.argv[1] : NULL;
+        arg.argv_step = def->has_val ? 2 : 1;
+    }
+    else if (def->long_name)
+    {
+        int name_len = strlen(def->long_name);
+
+        if (strlen(arg.argv[0]) >= name_len + 2
+            && arg.argv[0][1] == '-'
+            && !strncmp(arg.argv[0] + 2, def->long_name, name_len)
+            && (arg.argv[0][name_len+2] == '='
+                || arg.argv[0][name_len+2] == '\0'))
+        {
+
+            arg.name = arg.argv[0] + 2;
+            arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL;
+            arg.argv_step = 1;
+        }
+    }
+
+    if (arg.name && !arg.val && def->has_val)
+        die("Error: option %s requires argument.\n", arg.name);
+
+    if (arg.name && arg.val && !def->has_val)
+        die("Error: option %s requires no argument.\n", arg.name);
+
+    if (arg.name
+        && (arg.val || !def->has_val))
+    {
+        arg.def = def;
+        *arg_ = arg;
+        return 1;
+    }
+
+    return 0;
+}
+
+
+const char *arg_next(struct arg *arg)
+{
+    if (arg->argv[0])
+        arg->argv += arg->argv_step;
+
+    return *arg->argv;
+}
+
+
+char **argv_dup(int argc, const char **argv)
+{
+    char **new_argv = malloc((argc + 1) * sizeof(*argv));
+
+    memcpy(new_argv, argv, argc * sizeof(*argv));
+    new_argv[argc] = NULL;
+    return new_argv;
+}
+
+
+void arg_show_usage(FILE *fp, const struct arg_def *const *defs)
+{
+    char option_text[40] = {0};
+
+    for (; *defs; defs++)
+    {
+        const struct arg_def *def = *defs;
+        char *short_val = def->has_val ? " <arg>" : "";
+        char *long_val = def->has_val ? "=<arg>" : "";
+
+        if (def->short_name && def->long_name)
+            snprintf(option_text, 37, "-%s%s, --%s%s",
+                     def->short_name, short_val,
+                     def->long_name, long_val);
+        else if (def->short_name)
+            snprintf(option_text, 37, "-%s%s",
+                     def->short_name, short_val);
+        else if (def->long_name)
+            snprintf(option_text, 37, "          --%s%s",
+                     def->long_name, long_val);
+
+        fprintf(fp, "  %-37s\t%s\n", option_text, def->desc);
+    }
+}
+
+
+unsigned int arg_parse_uint(const struct arg *arg)
+{
+    long int   rawval;
+    char      *endptr;
+
+    rawval = strtol(arg->val, &endptr, 10);
+
+    if (arg->val[0] != '\0' && endptr[0] == '\0')
+    {
+        if (rawval >= 0 && rawval <= UINT_MAX)
+            return rawval;
+
+        die("Option %s: Value %ld out of range for unsigned int\n",
+            arg->name, rawval);
+    }
+
+    die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
+    return 0;
+}
+
+
+int arg_parse_int(const struct arg *arg)
+{
+    long int   rawval;
+    char      *endptr;
+
+    rawval = strtol(arg->val, &endptr, 10);
+
+    if (arg->val[0] != '\0' && endptr[0] == '\0')
+    {
+        if (rawval >= INT_MIN && rawval <= INT_MAX)
+            return rawval;
+
+        die("Option %s: Value %ld out of range for signed int\n",
+            arg->name, rawval);
+    }
+
+    die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
+    return 0;
+}
+
+
+struct vpx_rational
+{
+    int num; /**< fraction numerator */
+    int den; /**< fraction denominator */
+};
+struct vpx_rational arg_parse_rational(const struct arg *arg)
+{
+    long int             rawval;
+    char                *endptr;
+    struct vpx_rational  rat;
+
+    /* parse numerator */
+    rawval = strtol(arg->val, &endptr, 10);
+
+    if (arg->val[0] != '\0' && endptr[0] == '/')
+    {
+        if (rawval >= INT_MIN && rawval <= INT_MAX)
+            rat.num = rawval;
+        else die("Option %s: Value %ld out of range for signed int\n",
+                     arg->name, rawval);
+    }
+    else die("Option %s: Expected / at '%c'\n", arg->name, *endptr);
+
+    /* parse denominator */
+    rawval = strtol(endptr + 1, &endptr, 10);
+
+    if (arg->val[0] != '\0' && endptr[0] == '\0')
+    {
+        if (rawval >= INT_MIN && rawval <= INT_MAX)
+            rat.den = rawval;
+        else die("Option %s: Value %ld out of range for signed int\n",
+                     arg->name, rawval);
+    }
+    else die("Option %s: Invalid character '%c'\n", arg->name, *endptr);
+
+    return rat;
+}
diff --git a/args.h b/args.h
new file mode 100644
index 0000000..c063f53
--- /dev/null
+++ b/args.h
@@ -0,0 +1,43 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+#ifndef ARGS_H
+#define ARGS_H
+#include <stdio.h>
+
+struct arg
+{
+    char                 **argv;
+    const char            *name;
+    const char            *val;
+    unsigned int           argv_step;
+    const struct arg_def  *def;
+};
+
+typedef struct arg_def
+{
+    const char *short_name;
+    const char *long_name;
+    int         has_val;
+    const char *desc;
+} arg_def_t;
+#define ARG_DEF(s,l,v,d) {s,l,v,d}
+#define ARG_DEF_LIST_END {0}
+
+struct arg arg_init(char **argv);
+int arg_match(struct arg *arg_, const struct arg_def *def, char **argv);
+const char *arg_next(struct arg *arg);
+void arg_show_usage(FILE *fp, const struct arg_def *const *defs);
+char **argv_dup(int argc, const char **argv);
+
+unsigned int arg_parse_uint(const struct arg *arg);
+int arg_parse_int(const struct arg *arg);
+struct vpx_rational arg_parse_rational(const struct arg *arg);
+#endif
diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..1350fcb
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1 @@
+x86*-win32-vs*
diff --git a/build/arm-wince-vs8/.gitattributes b/build/arm-wince-vs8/.gitattributes
new file mode 100644
index 0000000..be1eeb9
--- /dev/null
+++ b/build/arm-wince-vs8/.gitattributes
@@ -0,0 +1 @@
+*.rules -crlf
diff --git a/build/arm-wince-vs8/armasmv5.rules b/build/arm-wince-vs8/armasmv5.rules
new file mode 100644
index 0000000..efb80bc
--- /dev/null
+++ b/build/arm-wince-vs8/armasmv5.rules
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>

+<VisualStudioToolFile

+	Name="armasm"

+	Version="8.00"

+	>

+	<Rules>

+		<CustomBuildRule

+			Name="ARMASM"

+			DisplayName="Armasm Assembler"

+			CommandLine="armasm -o &quot;$(IntDir)\$(InputName).obj&quot; $(InputPath) -32 -ARCH 5&#x0D;&#x0A;"

+			Outputs="$(IntDir)\$(InputName).obj"

+			FileExtensions="*.asm"

+			ExecutionDescription="Assembling $(InputName).asm"

+			ShowOnlyRuleProperties="false"

+			>

+			<Properties>

+			</Properties>

+		</CustomBuildRule>

+	</Rules>

+</VisualStudioToolFile>

diff --git a/build/arm-wince-vs8/armasmv6.rules b/build/arm-wince-vs8/armasmv6.rules
new file mode 100644
index 0000000..67c6bc9
--- /dev/null
+++ b/build/arm-wince-vs8/armasmv6.rules
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>

+<VisualStudioToolFile

+	Name="armasm"

+	Version="8.00"

+	>

+	<Rules>

+		<CustomBuildRule

+			Name="ARMASM"

+			DisplayName="Armasm Assembler"

+			CommandLine="armasm -o &quot;$(IntDir)\$(InputName).obj&quot; $(InputPath) -32 -ARCH 6&#x0D;&#x0A;"

+			Outputs="$(IntDir)\$(InputName).obj"

+			FileExtensions="*.asm"

+			ExecutionDescription="Assembling $(InputName).asm"

+			ShowOnlyRuleProperties="false"

+			>

+			<Properties>

+			</Properties>

+		</CustomBuildRule>

+	</Rules>

+</VisualStudioToolFile>

diff --git a/build/arm-wince-vs8/armasmxscale.rules b/build/arm-wince-vs8/armasmxscale.rules
new file mode 100644
index 0000000..4da9d1e
--- /dev/null
+++ b/build/arm-wince-vs8/armasmxscale.rules
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>

+<VisualStudioToolFile

+	Name="armasm"

+	Version="8.00"

+	>

+	<Rules>

+		<CustomBuildRule

+			Name="ARMASM"

+			DisplayName="Armasm Assembler"

+			CommandLine="armasm -o &quot;$(IntDir)\$(InputName).obj&quot; $(InputPath) -32 -cpu XSCALE&#x0D;&#x0A;"

+			Outputs="$(IntDir)\$(InputName).obj"

+			FileExtensions="*.asm"

+			ExecutionDescription="Assembling $(InputName).asm"

+			ShowOnlyRuleProperties="false"

+			>

+			<Properties>

+			</Properties>

+		</CustomBuildRule>

+	</Rules>

+</VisualStudioToolFile>

diff --git a/build/arm-wince-vs8/obj_int_extract.bat b/build/arm-wince-vs8/obj_int_extract.bat
new file mode 100644
index 0000000..e58bdd6
--- /dev/null
+++ b/build/arm-wince-vs8/obj_int_extract.bat
@@ -0,0 +1,12 @@
+@echo off
+REM   Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+REM 
+REM   Use of this source code is governed by a BSD-style license and patent
+REM   grant that can be found in the LICENSE file in the root of the source
+REM   tree. All contributing project authors may be found in the AUTHORS
+REM   file in the root of the source tree.
+echo on
+
+
+cl /I ".\\" /I "..\vp6_decoder_sdk" /I "..\vp6_decoder_sdk\vpx_ports" /D "NDEBUG" /D "_WIN32_WCE=0x420" /D "UNDER_CE" /D "WIN32_PLATFORM_PSPC" /D "WINCE" /D "_LIB" /D "ARM" /D "_ARM_" /D "_UNICODE" /D "UNICODE" /D "HAVE_CONFIG_H" /FD /EHsc /MT /GS- /fp:fast /GR- /Fo"Pocket_PC_2003__ARMV4_\%1/" /Fd"Pocket_PC_2003__ARMV4_\%1/vc80.pdb" /W3 /nologo /c /TC ..\vp6_decoder_sdk\vp6_decoder\algo\common\arm\dec_asm_offsets_arm.c

+obj_int_extract.exe rvds "Pocket_PC_2003__ARMV4_\%1/dec_asm_offsets_arm.obj"

diff --git a/build/arm-wince-vs8/vpx_decoder.sln b/build/arm-wince-vs8/vpx_decoder.sln
new file mode 100644
index 0000000..2262057
--- /dev/null
+++ b/build/arm-wince-vs8/vpx_decoder.sln
@@ -0,0 +1,88 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcproj", "{BA5FE66F-38DD-E034-F542-B1578C5FB950}"
+	ProjectSection(ProjectDependencies) = postProject
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74} = {DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2} = {E1360C65-D375-4335-8057-7ED99CC3F9B2}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "obj_int_extract", "obj_int_extract.vcproj", "{E1360C65-D375-4335-8057-7ED99CC3F9B2}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vpx_decoder", "vpx_decoder.vcproj", "{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}"
+	ProjectSection(ProjectDependencies) = postProject
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2} = {E1360C65-D375-4335-8057-7ED99CC3F9B2}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xma", "xma.vcproj", "{A955FC4A-73F1-44F7-135E-30D84D32F022}"
+	ProjectSection(ProjectDependencies) = postProject
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2} = {E1360C65-D375-4335-8057-7ED99CC3F9B2}
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74} = {DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Mixed Platforms = Debug|Mixed Platforms
+		Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4)
+		Debug|Win32 = Debug|Win32
+		Release|Mixed Platforms = Release|Mixed Platforms
+		Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4)
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Mixed Platforms.ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Mixed Platforms.Build.0 = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Mixed Platforms.Deploy.0 = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Debug|Win32.ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Mixed Platforms.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Mixed Platforms.Build.0 = Release|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Mixed Platforms.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
+		{BA5FE66F-38DD-E034-F542-B1578C5FB950}.Release|Win32.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Debug|Mixed Platforms.ActiveCfg = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Debug|Mixed Platforms.Build.0 = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Debug|Win32.ActiveCfg = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Debug|Win32.Build.0 = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Release|Win32.ActiveCfg = Release|Win32
+		{E1360C65-D375-4335-8057-7ED99CC3F9B2}.Release|Win32.Build.0 = Release|Win32
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Mixed Platforms.ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Mixed Platforms.Build.0 = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Mixed Platforms.Deploy.0 = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Debug|Win32.ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Mixed Platforms.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Mixed Platforms.Build.0 = Release|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Mixed Platforms.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
+		{DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74}.Release|Win32.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Mixed Platforms.ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Mixed Platforms.Build.0 = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Mixed Platforms.Deploy.0 = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Debug|Win32.ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Mixed Platforms.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Mixed Platforms.Build.0 = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Mixed Platforms.Deploy.0 = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
+		{A955FC4A-73F1-44F7-135E-30D84D32F022}.Release|Win32.ActiveCfg = Release|Pocket PC 2003 (ARMV4)
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
diff --git a/build/make/Makefile b/build/make/Makefile
new file mode 100755
index 0000000..412629e
--- /dev/null
+++ b/build/make/Makefile
@@ -0,0 +1,341 @@
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+include config.mk
+quiet?=true
+ifeq ($(target),)
+# If a target wasn't specified, invoke for all enabled targets.
+.DEFAULT:
+	@for t in $(ALL_TARGETS); do \
+	     $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
+        done
+all: .DEFAULT
+clean:: .DEFAULT
+
+
+# Note: md5sum is not installed on OS X, but openssl is. Openssl may not be
+# installed on cygwin, so we need to autodetect here.
+md5sum := $(firstword $(wildcard \
+          $(foreach e,md5sum openssl,\
+          $(foreach p,$(subst :, ,$(PATH)),$(p)/$(e)*))\
+          ))
+md5sum := $(if $(filter %openssl,$(md5sum)),$(md5sum) dgst -md5,$(md5sum))
+
+TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
+install:
+	@for t in $(ALL_TARGETS); do \
+	     $(MAKE) --no-print-directory target=$$t $(MAKECMDGOALS) || exit $$?;\
+        done
+        # Run configure for the user with the current toolchain.
+	@if [ -d "$(DIST_DIR)/src" ]; then \
+            mkdir -p "$(DIST_DIR)/build"; \
+            cd "$(DIST_DIR)/build"; \
+            if [ $(TGT_CC) = "rvct" ] ; then \
+				echo "../src/configure --target=$(TOOLCHAIN) --libc=$(ALT_LIBC)"; \
+				../src/configure --target=$(TOOLCHAIN) --libc=$(ALT_LIBC); \
+			else \
+				echo "../src/configure --target=$(TOOLCHAIN)"; \
+				../src/configure --target=$(TOOLCHAIN); \
+			fi; \
+            $(if $(filter vs%,$(TGT_CC)),make NO_LAUNCH_DEVENV=1;) \
+        fi
+	@if [ -d "$(DIST_DIR)" ]; then \
+            echo "    [MD5SUM] $(DIST_DIR)"; \
+	    cd $(DIST_DIR) && \
+	    $(md5sum) `find . -name md5sums.txt -prune -o -type f -print` \
+                | sed -e 's/MD5(\(.*\))= \([0-9a-f]\{32\}\)/\2  \1/' \
+                > md5sums.txt;\
+        fi
+
+
+svnstat: ALL_TARGETS:=$(firstword $(ALL_TARGETS))
+endif
+
+ifneq ($(target),)
+# Normally, we want to build the filename from the target and the toolchain.
+# This disambiguates from the $(target).mk file that exists in the source tree.
+# However, the toolchain is part of the target in universal builds, so we
+# don't want to include TOOLCHAIN in that case. FAT_ARCHS is used to test
+# if we're in the universal case.
+include $(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk
+endif
+BUILD_ROOT?=.
+VPATH=$(SRC_PATH_BARE)
+CFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
+ASFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
+DIST_DIR?=dist
+HOSTCC?=gcc
+TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
+TGT_OS:=$(word 2, $(subst -, ,$(TOOLCHAIN)))
+TGT_CC:=$(word 3, $(subst -, ,$(TOOLCHAIN)))
+quiet:=$(if $(verbose),,yes)
+qexec=$(if $(quiet),@)
+
+# Cancel built-in implicit rules
+%: %.o
+%.asm:
+%.a:
+
+#
+# Common rules"
+#
+.PHONY: all-$(target)
+all-$(target):
+
+.PHONY: clean
+clean::
+	rm -f $(OBJS-yes) $(OBJS-yes:.o=.d) $(OBJS-yes:.asm.s.o=.asm.s)
+	rm -f $(CLEAN-OBJS)
+
+.PHONY: install
+install:
+.PHONY: install-helper
+install-helper:
+
+$(BUILD_PFX)%.c.d: %.c
+	$(if $(quiet),@echo "    [DEP] $@")
+	$(qexec)mkdir -p $(dir $@)
+	$(qexec)$(CC) $(CFLAGS) -M $< | $(fmt_deps) > $@
+
+$(BUILD_PFX)%.c.o: %.c
+	$(if $(quiet),@echo "    [CC] $@")
+	$(qexec)$(CC) $(CFLAGS) -c -o $@ $<
+
+$(BUILD_PFX)%.asm.d: %.asm
+	$(if $(quiet),@echo "    [DEP] $@")
+	$(qexec)mkdir -p $(dir $@)
+	$(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
+            --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
+
+$(BUILD_PFX)%.asm.o: %.asm
+	$(if $(quiet),@echo "    [AS] $@")
+	$(qexec)$(AS) $(ASFLAGS) -o $@ $<
+
+$(BUILD_PFX)%.s.d: %.s
+	$(if $(quiet),@echo "    [DEP] $@")
+	$(qexec)mkdir -p $(dir $@)
+	$(qexec)$(SRC_PATH_BARE)/build/make/gen_asm_deps.sh \
+            --build-pfx=$(BUILD_PFX) --depfile=$@ $(ASFLAGS) $< > $@
+
+$(BUILD_PFX)%.s.o: %.s
+	$(if $(quiet),@echo "    [AS] $@")
+	$(qexec)$(AS) $(ASFLAGS) -o $@ $<
+
+.PRECIOUS: %.asm.s
+$(BUILD_PFX)%.asm.s: %.asm
+	$(if $(quiet),@echo "    [ASM CONVERSION] $@")
+	$(qexec)mkdir -p $(dir $@)
+	$(qexec)$(ASM_CONVERSION) <$< >$@
+
+# If we're in debug mode, pretend we don't have GNU strip, to fall back to
+# the copy implementation
+HAVE_GNU_STRIP := $(if $(CONFIG_DEBUG),,$(HAVE_GNU_STRIP))
+ifeq ($(HAVE_GNU_STRIP),yes)
+# Older binutils strip global sybols not needed for relocation processing
+# when given --strip-unneeded. Use nm and awk to identify globals and
+# keep them.
+%.a: %_g.a
+	$(if $(quiet),@echo "    [STRIP] $@ < $<")
+	$(qexec)$(STRIP) --strip-unneeded \
+         `$(NM) $< | grep ' [A-TV-Z] ' | awk '{print "-K"$$3'}`\
+          -o $@ $<
+else
+%.a: %_g.a
+	$(if $(quiet),@echo "    [CP] $@ < $<")
+	$(qexec)cp $< $@
+endif
+
+#
+# Rule to extract assembly constants from C sources
+#
+obj_int_extract: build/make/obj_int_extract.c
+	$(if $(quiet),echo "    [HOSTCC] $@")
+	$(qexec)$(HOSTCC) -I. -o $@ $<
+CLEAN-OBJS += obj_int_extract
+
+#
+# Utility functions
+#
+pairmap=$(if $(strip $(2)),\
+    $(call $(1),$(word 1,$(2)),$(word 2,$(2)))\
+    $(call pairmap,$(1),$(wordlist 3,$(words $(2)),$(2)))\
+)
+
+enabled=$(filter-out $($(1)-no),$($(1)-yes))
+cond_enabled=$(if $(filter yes,$($(1))), $(call enabled,$(2)))
+
+find_file1=$(word 1,$(wildcard $(subst //,/,$(addsuffix /$(1),$(2)))))
+find_file=$(foreach f,$(1),$(call find_file1,$(strip $(f)),$(strip $(2))) )
+obj_pats=.c=.c.o $(AS_SFX)=$(AS_SFX).o
+objs=$(addprefix $(BUILD_PFX),$(foreach p,$(obj_pats),$(filter %.o,$(1:$(p))) ))
+
+install_map_templates=$(eval $(call install_map_template,$(1),$(2)))
+
+not=$(subst yes,no,$(1))
+
+ifeq ($(CONFIG_MSVS),yes)
+lib_file_name=$(1).lib
+else
+lib_file_name=lib$(1).a
+endif
+#
+# Rule Templates
+#
+define linker_template
+$(1): $(filter-out -%,$(2))
+$(1):
+	$(if $(quiet),@echo    "    [LD] $$@")
+	$(qexec)$$(LD) $$(strip $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs))
+endef
+# make-3.80 has a bug with expanding large input strings to the eval function,
+# which was triggered in some cases by the following component of
+# linker_template:
+#   $(1): $$(call find_file, $(patsubst -l%,lib%.a,$(filter -l%,$(2))),\
+#                           $$(patsubst -L%,%,$$(filter -L%,$$(LDFLAGS) $(2))))
+# This may be useful to revisit in the future (it tries to locate libraries
+# in a search path and add them as prerequisites
+
+define install_map_template
+$(DIST_DIR)/$(1): $(2)
+	$(if $(quiet),@echo "    [INSTALL] $$@")
+	$(qexec)mkdir -p $$(dir $$@)
+	$(qexec)cp -p $$< $$@
+endef
+
+define archive_template
+# Not using a pattern rule here because we don't want to generate empty
+# archives when they are listed as a dependency in files not responsible
+# for creating them.
+$(1):
+	$(if $(quiet),@echo "    [AR] $$@")
+	$(qexec)$$(AR) $$(ARFLAGS) $$@ $$?
+endef
+
+define lipo_lib_template
+$(1): $(addsuffix /$(1),$(FAT_ARCHS))
+	$(if $(quiet),@echo "    [LIPO] $$@")
+	$(qexec)libtool -static -o $$@ $$?
+endef
+
+define lipo_bin_template
+$(1): $(addsuffix /$(1),$(FAT_ARCHS))
+	$(if $(quiet),@echo "    [LIPO] $$@")
+	$(qexec)lipo -output $$@ -create $$?
+endef
+
+
+#
+# Get current configuration
+#
+ifneq ($(target),)
+include $(SRC_PATH_BARE)/$(target:-$(TOOLCHAIN)=).mk
+endif
+ifeq ($(filter clean,$(MAKECMDGOALS)),)
+  # Older versions of make don't like -include directives with no arguments
+  ifneq ($(filter %.d,$(OBJS-yes:.o=.d)),)
+    -include $(filter %.d,$(OBJS-yes:.o=.d))
+  endif
+endif
+
+#
+# Configuration dependant rules
+#
+$(call pairmap,install_map_templates,$(INSTALL_MAPS))
+
+DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,DOCS)
+.docs: $(DOCS)
+	@touch $@
+
+INSTALL-DOCS=$(call cond_enabled,CONFIG_INSTALL_DOCS,INSTALL-DOCS)
+.install-docs: .docs $(addprefix $(DIST_DIR)/,$(INSTALL-DOCS))
+	@touch $@
+
+clean::
+	rm -f .docs .install-docs $(DOCS)
+
+BINS=$(call enabled,BINS)
+.bins: $(BINS)
+	@touch $@
+
+INSTALL-BINS=$(call cond_enabled,CONFIG_INSTALL_BINS,INSTALL-BINS)
+.install-bins: .bins $(addprefix $(DIST_DIR)/,$(INSTALL-BINS))
+	@touch $@
+
+clean::
+	rm -f .bins .install-bins $(BINS)
+
+LIBS=$(call enabled,LIBS)
+.libs: $(LIBS)
+	@touch $@
+$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
+
+INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
+.install-libs: .libs $(addprefix $(DIST_DIR)/,$(INSTALL-LIBS))
+	@touch $@
+
+clean::
+	rm -f .libs .install-libs $(LIBS)
+
+ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
+PROJECTS=$(call enabled,PROJECTS)
+.projects: $(PROJECTS)
+	@touch $@
+
+INSTALL-PROJECTS=$(call cond_enabled,CONFIG_INSTALL_PROJECTS,INSTALL-PROJECTS)
+.install-projects: .projects $(addprefix $(DIST_DIR)/,$(INSTALL-PROJECTS))
+	@touch $@
+
+clean::
+	rm -f .projects .install-projects $(PROJECTS)
+endif
+
+# If there are any source files to be installed, then include the build
+# system too.
+ifneq ($(call enabled,INSTALL-SRCS),)
+    INSTALL-SRCS-yes            += configure
+    INSTALL-SRCS-yes            += build/make/configure.sh
+    INSTALL-SRCS-yes            += build/make/gen_asm_deps.sh
+    INSTALL-SRCS-yes            += build/make/Makefile
+    INSTALL-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_def.sh
+    INSTALL-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_proj.sh
+    INSTALL-SRCS-$(CONFIG_MSVS)  += build/make/gen_msvs_sln.sh
+    INSTALL-SRCS-$(CONFIG_RVCT) += build/make/armlink_adapter.sh
+    #
+    # This isn't really ARCH_ARM dependent, it's dependant on whether we're
+    # using assembly code or not (CONFIG_OPTIMIZATIONS maybe). Just use
+    # this for now.
+    INSTALL-SRCS-$(ARCH_ARM)    += build/make/obj_int_extract.c
+    INSTALL-SRCS-$(ARCH_ARM)    += build/make/ads2gas.pl
+    INSTALL-SRCS-yes            += $(target:-$(TOOLCHAIN)=).mk
+endif
+INSTALL-SRCS := $(call cond_enabled,CONFIG_INSTALL_SRCS,INSTALL-SRCS)
+.install-srcs: $(addprefix $(DIST_DIR)/src/,$(INSTALL-SRCS))
+	@touch $@
+
+clean::
+	rm -f .install-srcs
+
+ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
+    BUILD_TARGETS += .projects
+    INSTALL_TARGETS += .install-projects
+endif
+BUILD_TARGETS += .docs .libs .bins
+INSTALL_TARGETS += .install-docs .install-srcs .install-libs .install-bins
+all-$(target): $(BUILD_TARGETS)
+install: $(INSTALL_TARGETS)
+
+#
+# Development helper targets
+#
+ifneq ($(SRC_PATH_BARE),)
+.PHONY: svnstat
+svnstat:
+	svn stat $(SRC_PATH_BARE)
+endif
diff --git a/build/make/ads2gas.pl b/build/make/ads2gas.pl
new file mode 100755
index 0000000..6fcba84
--- /dev/null
+++ b/build/make/ads2gas.pl
@@ -0,0 +1,149 @@
+#!/usr/bin/perl
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+# ads2gas.pl
+# Author: Eric Fung (efung (at) acm.org)
+#
+# Convert ARM Developer Suite 1.0.1 syntax assembly source to GNU as format
+#
+# Usage: cat inputfile | perl ads2gas.pl > outputfile
+#
+print "@ This file was created from a .asm file\n";
+print "@  using the ads2gas.pl script.\n";
+print "\t.equ DO1STROUNDING, 0\n";
+
+while (<STDIN>)
+{
+    # Comment character
+    s/;/@/g;
+
+    # Hexadecimal constants prefaced by 0x
+    s/#&/#0x/g;
+
+    # Convert :OR: to |
+    s/:OR:/ | /g;
+
+    # Convert :AND: to &
+    s/:AND:/ & /g;
+
+    # Convert :NOT: to ~
+    s/:NOT:/ ~ /g;
+
+    # Convert :SHL: to <<
+    s/:SHL:/ << /g;
+
+    # Convert :SHR: to >>
+    s/:SHR:/ >> /g;
+
+    # Convert ELSE to .else
+    s/ELSE/.else/g;
+
+    # Convert ENDIF to .endif
+    s/ENDIF/.endif/g;
+
+    # Convert ELSEIF to .elseif
+    s/ELSEIF/.elseif/g;
+
+    # Convert LTORG to .ltorg
+    s/LTORG/.ltorg/g;
+
+    # Convert IF :DEF:to .if
+    # gcc doesn't have the ability to do a conditional
+    # if defined variable that is set by IF :DEF: on
+    # armasm, so convert it to a normal .if and then
+    # make sure to define a value elesewhere
+    if (s/\bIF :DEF:\b/.if /g)
+    {
+        s/=/==/g;
+    }
+
+    # Convert IF to .if
+    if (s/\bIF\b/.if/g)
+    {
+        s/=+/==/g;
+    }
+
+    # Convert INCLUDE to .INCLUDE "file"
+    s/INCLUDE(\s*)(.*)$/.include $1\"$2\"/;
+
+    # Code directive (ARM vs Thumb)
+    s/CODE([0-9][0-9])/.code $1/;
+
+    # No AREA required
+    s/^\s*AREA.*$/.text/;
+
+    # DCD to .word
+    # This one is for incoming symbols
+    s/DCD\s+\|(\w*)\|/.long $1/;
+
+    # DCW to .short
+    s/DCW\s+\|(\w*)\|/.short $1/;
+    s/DCW(.*)/.short $1/;
+
+    # Constants defined in scope
+    s/DCD(.*)/.long $1/;
+    s/DCB(.*)/.byte $1/;
+
+    # RN to .req
+    if (s/RN\s+([Rr]\d+|lr)/.req $1/)
+    {
+        print;
+        next;
+    }
+
+    # Make function visible to linker, and make additional symbol with
+    # prepended underscore
+    s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/;
+    s/IMPORT\s+\|([\$\w]*)\|/.global $1/;
+
+    # No vertical bars required; make additional symbol with prepended
+    # underscore
+    s/^\|(\$?\w+)\|/_$1\n\t$1:/g;
+
+    # Labels need trailing colon
+#   s/^(\w+)/$1:/ if !/EQU/;
+    # put the colon at the end of the line in the macro
+    s/^([a-zA-Z_0-9\$]+)/$1:/ if !/EQU/;
+
+    # Strip ALIGN
+    s/\sALIGN/@ ALIGN/g;
+
+    # Strip ARM
+    s/\sARM/@ ARM/g;
+
+    # Strip REQUIRE8
+    #s/\sREQUIRE8/@ REQUIRE8/g;
+    s/\sREQUIRE8/@ /g;      #EQU cause problem
+
+    # Strip PRESERVE8
+    s/\sPRESERVE8/@ PRESERVE8/g;
+
+    # Strip PROC and ENDPROC
+    s/\sPROC/@/g;
+    s/\sENDP/@/g;
+
+    # EQU directive
+    s/(.*)EQU(.*)/.equ $1, $2/;
+
+    # Begin macro definition
+    if (/MACRO/) {
+        $_ = <STDIN>;
+        s/^/.macro/;
+        s/\$//g;                # remove formal param reference
+        s/;/@/g;                # change comment characters
+    }
+
+    # For macros, use \ to reference formal params
+    s/\$/\\/g;                  # End macro definition
+    s/MEND/.endm/;              # No need to tell it where to stop assembling
+    next if /^\s*END\s*$/;
+    print;
+}
diff --git a/build/make/ads2gas_apple.pl b/build/make/ads2gas_apple.pl
new file mode 100755
index 0000000..569c3e7
--- /dev/null
+++ b/build/make/ads2gas_apple.pl
@@ -0,0 +1,194 @@
+#!/usr/bin/env perl
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+# ads2gas.pl
+# Author: Eric Fung (efung (at) acm.org)
+#
+# Convert ARM Developer Suite 1.0.1 syntax assembly source to GNU as format
+#
+# Usage: cat inputfile | perl ads2gas.pl > outputfile
+#
+print "@ This file was created from a .asm file\n";
+print "@  using the ads2gas_apple.pl script.\n\n";
+print "\t.set WIDE_REFERENCE, 0\n";
+print "\t.set ARCHITECTURE, 5\n";
+print "\t.set DO1STROUNDING, 0\n";
+
+my %register_aliases;
+my %macro_aliases;
+
+my @mapping_list = ("\$0", "\$1", "\$2", "\$3", "\$4", "\$5", "\$6", "\$7", "\$8", "\$9");
+
+my @incoming_array;
+
+# Perl trim function to remove whitespace from the start and end of the string
+sub trim($)
+{
+    my $string = shift;
+    $string =~ s/^\s+//;
+    $string =~ s/\s+$//;
+    return $string;
+}
+
+while (<STDIN>)
+{
+    # Comment character
+    s/;/@/g;
+
+    # Hexadecimal constants prefaced by 0x
+    s/#&/#0x/g;
+
+    # Convert :OR: to |
+    s/:OR:/ | /g;
+
+    # Convert :AND: to &
+    s/:AND:/ & /g;
+
+    # Convert :NOT: to ~
+    s/:NOT:/ ~ /g;
+
+    # Convert :SHL: to <<
+    s/:SHL:/ << /g;
+
+    # Convert :SHR: to >>
+    s/:SHR:/ >> /g;
+
+    # Convert ELSE to .else
+    s/ELSE/.else/g;
+
+    # Convert ENDIF to .endif
+    s/ENDIF/.endif/g;
+
+    # Convert ELSEIF to .elseif
+    s/ELSEIF/.elseif/g;
+
+    # Convert LTORG to .ltorg
+    s/LTORG/.ltorg/g;
+
+    # Convert IF :DEF:to .if
+    # gcc doesn't have the ability to do a conditional
+    # if defined variable that is set by IF :DEF: on
+    # armasm, so convert it to a normal .if and then
+    # make sure to define a value elesewhere
+    if (s/\bIF :DEF:\b/.if /g)
+    {
+        s/=/==/g;
+    }
+
+    # Convert IF to .if
+    if (s/\bIF\b/.if/g)
+    {
+        s/=/==/g;
+    }
+
+    # Convert INCLUDE to .INCLUDE "file"
+    s/INCLUDE(\s*)(.*)$/.include $1\"$2\"/;
+
+    # Code directive (ARM vs Thumb)
+    s/CODE([0-9][0-9])/.code $1/;
+
+    # No AREA required
+    s/^\s*AREA.*$/.text/;
+
+    # DCD to .word
+    # This one is for incoming symbols
+    s/DCD\s+\|(\w*)\|/.long $1/;
+
+    # DCW to .short
+    s/DCW\s+\|(\w*)\|/.short $1/;
+    s/DCW(.*)/.short $1/;
+
+    # Constants defined in scope
+    s/DCD(.*)/.long $1/;
+    s/DCB(.*)/.byte $1/;
+
+    # Build a hash of all the register - alias pairs.
+    if (s/(.*)RN(.*)/$1 .req $2/g)
+    {
+        $register_aliases{trim($1)} = trim($2);
+        next;
+    }
+
+    while (($key, $value) = each(%register_aliases))
+    {
+        s/\b$key\b/$value/g;
+    }
+
+    # Make function visible to linker, and make additional symbol with
+    # prepended underscore
+    s/EXPORT\s+\|([\$\w]*)\|/.globl _$1\n\t.globl $1/;
+    s/IMPORT\s+\|([\$\w]*)\|/.globl $1/;
+
+    # No vertical bars required; make additional symbol with prepended
+    # underscore
+    s/^\|(\$?\w+)\|/_$1\n\t$1:/g;
+
+    # Labels need trailing colon
+#   s/^(\w+)/$1:/ if !/EQU/;
+    # put the colon at the end of the line in the macro
+    s/^([a-zA-Z_0-9\$]+)/$1:/ if !/EQU/;
+
+    # Strip ALIGN
+    s/\sALIGN/@ ALIGN/g;
+
+    # Strip ARM
+    s/\sARM/@ ARM/g;
+
+    # Strip REQUIRE8
+    #s/\sREQUIRE8/@ REQUIRE8/g;
+    s/\sREQUIRE8/@ /g;
+
+    # Strip PRESERVE8
+    s/\sPRESERVE8/@ PRESERVE8/g;
+
+    # Strip PROC and ENDPROC
+    s/PROC/@/g;
+    s/ENDP/@/g;
+
+    # EQU directive
+    s/(.*)EQU(.*)/.set $1, $2/;
+
+    # Begin macro definition
+    if (/MACRO/)
+    {
+        # Process next line down, which will be the macro definition
+        $_ = <STDIN>;
+
+        $trimmed = trim($_);
+
+        # remove commas that are separating list
+        $trimmed =~ s/,//g;
+
+        # string to array
+        @incoming_array = split(/ /, $trimmed);
+
+        print ".macro @incoming_array[0]\n";
+
+        # remove the first element, as that is the name of the macro
+        shift (@incoming_array);
+
+        @macro_aliases{@incoming_array} = @mapping_list;
+
+        next;
+    }
+
+    while (($key, $value) = each(%macro_aliases))
+    {
+        $key =~ s/\$/\\\$/;
+        s/$key\b/$value/g;
+    }
+
+    # For macros, use \ to reference formal params
+#   s/\$/\\/g;                  # End macro definition
+    s/MEND/.endm/;              # No need to tell it where to stop assembling
+    next if /^\s*END\s*$/;
+    print;
+}
diff --git a/build/make/armlink_adapter.sh b/build/make/armlink_adapter.sh
new file mode 100755
index 0000000..dcaa82c
--- /dev/null
+++ b/build/make/armlink_adapter.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+verbose=0
+set -- $*
+for i; do
+    if [ "$i" == "-o" ]; then
+        on_of=1
+    elif [ "$i" == "-v" ]; then
+        verbose=1
+    elif [ "$on_of" == "1" ]; then
+        outfile=$i
+    on_of=0
+    elif [ -f "$i" ]; then
+        infiles="$infiles $i"
+    elif [ "${i:0:2}" == "-l" ]; then
+        libs="$libs ${i#-l}"
+    elif [ "${i:0:2}" == "-L" ]; then
+    libpaths="${libpaths} ${i#-L}"
+    else
+        args="${args} ${i}"
+    fi
+    shift
+done
+
+# Absolutize library file names
+for f in $libs; do
+    found=0
+    for d in $libpaths; do
+        [ -f "$d/$f" ] && infiles="$infiles $d/$f" && found=1 && break
+        [ -f "$d/lib${f}.so" ] && infiles="$infiles $d/lib${f}.so" && found=1 && break
+        [ -f "$d/lib${f}.a" ] && infiles="$infiles $d/lib${f}.a" && found=1 && break
+    done
+    [ $found -eq 0 ] && infiles="$infiles $f"
+done
+for d in $libpaths; do
+    [ -n "$libsearchpath" ] && libsearchpath="${libsearchpath},"
+    libsearchpath="${libsearchpath}$d"
+done
+
+cmd="armlink $args --userlibpath=$libsearchpath --output=$outfile $infiles"
+[ $verbose -eq 1 ] && echo $cmd
+$cmd
diff --git a/build/make/configure.sh b/build/make/configure.sh
new file mode 100755
index 0000000..ed3a34f
--- /dev/null
+++ b/build/make/configure.sh
@@ -0,0 +1,907 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+
+#
+# Logging / Output Functions
+#
+die_unknown(){
+    echo "Unknown option \"$1\"."
+    echo "See $0 --help for available options."
+    clean_temp_files
+    exit 1
+}
+
+
+die() {
+    echo "$@"
+    echo
+    echo "Configuration failed. This could reflect a misconfiguration of your"
+    echo "toolchains, improper options selected, or another problem. If you"
+    echo "don't see any useful error messages above, the next step is to look"
+    echo "at the configure error log file ($logfile) to determine what"
+    echo "configure was trying to do when it died."
+    clean_temp_files
+    exit 1
+}
+
+
+log(){
+    echo "$@" >>$logfile
+}
+
+
+log_file(){
+    log BEGIN $1
+    pr -n -t $1 >>$logfile
+    log END $1
+}
+
+
+log_echo() {
+    echo "$@"
+    log "$@"
+}
+
+
+fwrite () {
+    outfile=$1
+    shift
+    echo "$@" >> ${outfile}
+}
+
+
+show_help_pre(){
+    for opt in ${CMDLINE_SELECT}; do
+        opt2=`echo $opt | sed -e 's;_;-;g'`
+        if enabled $opt; then
+            eval "toggle_${opt}=\"--disable-${opt2}\""
+        else
+            eval "toggle_${opt}=\"--enable-${opt2} \""
+        fi
+    done
+
+    cat <<EOF
+Usage: configure [options]
+Options:
+
+Build options:
+  --help                      print this message
+  --log=yes|no|FILE           file configure log is written to [config.err]
+  --target=TARGET             target platform tuple [generic-gnu]
+  --cpu=CPU                   optimize for a specific cpu rather than a family
+  ${toggle_extra_warnings}    emit harmless warnings (always non-fatal)
+  ${toggle_werror}            treat warnings as errors, if possible
+                              (not available with all compilers)
+  ${toggle_optimizations}     turn on/off compiler optimization flags
+  ${toggle_pic}               turn on/off Position Independant Code
+  ${toggle_ccache}            turn on/off compiler cache
+  ${toggle_debug}             enable/disable debug mode
+  ${toggle_gprof}             enable/disable gprof profiling instrumentation
+  ${toggle_gcov}              enable/disable gcov coverage instrumentation
+
+Install options:
+  ${toggle_install_docs}      control whether docs are installed
+  ${toggle_install_bins}      control whether binaries are installed
+  ${toggle_install_libs}      control whether libraries are installed
+  ${toggle_install_srcs}      control whether sources are installed
+
+
+EOF
+}
+
+
+show_help_post(){
+    cat <<EOF
+
+
+NOTES:
+    Object files are built at the place where configure is launched.
+
+    All boolean options can be negated. The default value is the opposite
+    of that shown above. If the option --disable-foo is listed, then
+    the default value for foo is enabled.
+
+Supported targets:
+EOF
+  show_targets ${all_platforms}
+  echo
+  exit 1
+}
+
+
+show_targets() {
+    while [ -n "$*" ]; do
+        if [ "${1%%-*}" == "${2%%-*}" ]; then
+            if [ "${2%%-*}" == "${3%%-*}" ]; then
+                printf "    %-24s %-24s %-24s\n" "$1" "$2" "$3"
+                shift; shift; shift
+            else
+                printf "    %-24s %-24s\n" "$1" "$2"
+                shift; shift
+            fi
+        else
+            printf "    %-24s\n" "$1"
+            shift
+        fi
+    done
+}
+
+
+show_help() {
+    show_help_pre
+    show_help_post
+}
+
+#
+# List Processing Functions
+#
+set_all(){
+    value=$1
+    shift
+    for var in $*; do
+        eval $var=$value
+    done
+}
+
+
+is_in(){
+    value=$1
+    shift
+    for var in $*; do
+        [ $var = $value ] && return 0
+    done
+    return 1
+}
+
+
+add_cflags() {
+    CFLAGS="${CFLAGS} $@"
+}
+
+
+add_ldflags() {
+    LDFLAGS="${LDFLAGS} $@"
+}
+
+
+add_asflags() {
+    ASFLAGS="${ASFLAGS} $@"
+}
+
+
+add_extralibs() {
+    extralibs="${extralibs} $@"
+}
+
+#
+# Boolean Manipulation Functions
+#
+enable(){
+    set_all yes $*
+}
+
+disable(){
+    set_all no $*
+}
+
+enabled(){
+    eval test "x\$$1" = "xyes"
+}
+
+disabled(){
+    eval test "x\$$1" = "xno"
+}
+
+
+soft_enable() {
+    for var in $*; do
+        if ! disabled $var; then
+            log_echo "  enabling $var"
+            enable $var
+        fi
+    done
+}
+
+soft_disable() {
+    for var in $*; do
+        if ! enabled $var; then
+            log_echo "  disabling $var"
+            disable $var
+        fi
+    done
+}
+
+
+#
+# Text Processing Functions
+#
+toupper(){
+    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
+}
+
+
+tolower(){
+    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
+}
+
+
+#
+# Temporary File Functions
+#
+source_path=${0%/*}
+enable source_path_used
+if test -z "$source_path" -o "$source_path" = "." ; then
+    source_path="`pwd`"
+    disable source_path_used
+fi
+
+if test ! -z "$TMPDIR" ; then
+    TMPDIRx="${TMPDIR}"
+elif test ! -z "$TEMPDIR" ; then
+    TMPDIRx="${TEMPDIR}"
+else
+    TMPDIRx="/tmp"
+fi
+TMP_H="${TMPDIRx}/vpx-conf-$$-${RANDOM}.h"
+TMP_C="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c"
+TMP_O="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o"
+TMP_X="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x"
+
+clean_temp_files() {
+    rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X}
+}
+
+#
+# Toolchain Check Functions
+#
+check_cmd() {
+    log "$@"
+    "$@" >>${logfile} 2>&1
+}
+
+check_cc() {
+    log check_cc "$@"
+    cat >${TMP_C}
+    log_file ${TMP_C}
+    check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
+}
+
+check_cpp() {
+    log check_cpp "$@"
+    cat > ${TMP_C}
+    log_file ${TMP_C}
+    check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
+}
+
+check_ld() {
+    log check_ld "$@"
+    check_cc $@ \
+        && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
+}
+
+check_header(){
+    log check_header "$@"
+    header=$1
+    shift
+    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
+    disable $var
+    check_cpp "$@" <<EOF && enable $var
+#include "$header"
+int x;
+EOF
+}
+
+
+check_cflags() {
+    log check_cflags "$@"
+    check_cc "$@" <<EOF
+int x;
+EOF
+}
+
+check_add_cflags() {
+    check_cflags "$@" && add_cflags "$@"
+}
+
+check_add_asflags() {
+    log add_asflags "$@"
+    add_asflags "$@"
+}
+
+check_add_ldflags() {
+    log add_ldflags "$@"
+    add_ldflags "$@"
+}
+
+write_common_config_banner() {
+    echo '# This file automatically generated by configure. Do not edit!' > config.mk
+    echo "TOOLCHAIN := ${toolchain}" >> config.mk
+
+    case ${toolchain} in
+        *-linux-rvct)
+            echo "ALT_LIBC := ${alt_libc}" >> config.mk
+            ;;
+    esac
+}
+
+write_common_config_targets() {
+    for t in ${all_targets}; do
+        if enabled ${t}; then
+            if enabled universal || enabled child; then
+                fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
+            else
+                fwrite config.mk "ALL_TARGETS += ${t}"
+            fi
+        fi
+    true;
+    done
+true
+}
+
+write_common_target_config_mk() {
+    [ -n "$2" ] && local have_config_h="-DHAVE_CONFIG_H=\"${2##*/}\""
+    local CC=${CC}
+    enabled ccache && CC="ccache ${CC}"
+
+    cat > $1 << EOF
+# This file automatically generated by configure. Do not edit!
+SRC_PATH="$source_path"
+SRC_PATH_BARE=$source_path
+BUILD_PFX=${BUILD_PFX}
+TOOLCHAIN=${toolchain}
+ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
+
+CC=${CC}
+AR=${AR}
+LD=${LD}
+AS=${AS}
+STRIP=${STRIP}
+NM=${NM}
+
+CFLAGS  = ${CFLAGS} ${have_config_h}
+ARFLAGS = -rus\$(if \$(quiet),c,v)
+LDFLAGS = ${LDFLAGS}
+ASFLAGS = ${ASFLAGS}
+extralibs = ${extralibs}
+AS_SFX    = ${AS_SFX:-.asm}
+EOF
+
+    if enabled rvct; then cat >> $1 << EOF
+fmt_deps = sed -e 's;^__image.axf;\$(dir \$@)\$(notdir \$<).o \$@;' #hide
+EOF
+    else cat >> $1 << EOF
+fmt_deps = sed -e 's;^\(.*\)\.o;\$(dir \$@)\1\$(suffix \$<).o \$@;' #hide
+EOF
+    fi
+
+    print_config_mk ARCH   "${1}" ${ARCH_LIST}
+    print_config_mk HAVE   "${1}" ${HAVE_LIST}
+    print_config_mk CONFIG "${1}" ${CONFIG_LIST}
+    print_config_mk HAVE   "${1}" gnu_strip
+
+    enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
+
+}
+
+
+write_common_target_config_h() {
+    cat > ${TMP_H} << EOF
+/* This file automatically generated by configure. Do not edit! */
+#define INLINE      ${INLINE}
+#define FORCEINLINE ${FORCEINLINE:-${INLINE}}
+#define RESTRICT    ${RESTRICT}
+EOF
+    print_config_h ARCH   "${TMP_H}" ${ARCH_LIST}
+    print_config_h HAVE   "${TMP_H}" ${HAVE_LIST}
+    print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
+    mkdir -p `dirname "$1"`
+    cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
+}
+
+process_common_cmdline() {
+    for opt in "$@"; do
+        optval="${opt#*=}"
+        case "$opt" in
+        --child) enable child
+        ;;
+        --log*)
+        logging="$optval"
+        if ! disabled logging ; then
+            enabled logging || logfile="$logging"
+        else
+            logfile=/dev/null
+        fi
+        ;;
+        --target=*) toolchain="${toolchain:-${optval}}"
+        ;;
+        --force-target=*) toolchain="${toolchain:-${optval}}"; enable force_toolchain
+        ;;
+        --cpu)
+        ;;
+        --cpu=*) tune_cpu="$optval"
+        ;;
+        --enable-?*|--disable-?*)
+        eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
+        echo "${CMDLINE_SELECT} ${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null || die_unknown $opt
+        $action $option
+        ;;
+        --force-enable-?*|--force-disable-?*)
+        eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
+        $action $option
+        ;;
+        --libc=*)
+        [ -d "${optval}" ] || die "Not a directory: ${optval}"
+        disable builtin_libc
+        alt_libc="${optval}"
+        ;;
+        --libc)
+        die "Option ${opt} requires argument"
+        ;;
+        --help|-h) show_help
+        ;;
+        *) die_unknown $opt
+        ;;
+        esac
+    done
+}
+
+process_cmdline() {
+    for opt do
+        optval="${opt#*=}"
+        case "$opt" in
+        *) process_common_cmdline $opt
+        ;;
+        esac
+    done
+}
+
+post_process_cmdline() {
+    true;
+}
+
+setup_gnu_toolchain() {
+        CC=${CC:-${CROSS}gcc}
+        AR=${AR:-${CROSS}ar}
+        LD=${LD:-${CROSS}${link_with_cc:-ld}}
+        AS=${AS:-${CROSS}as}
+    STRIP=${STRIP:-${CROSS}strip}
+    NM=${NM:-${CROSS}nm}
+        AS_SFX=.s
+}
+
+process_common_toolchain() {
+    toolchain=${toolchain:-generic-gnu}
+
+    is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
+        || die "Unrecognized toolchain '${toolchain}'"
+
+    enabled child || log_echo "Configuring for target '${toolchain}'"
+
+    #
+    # Set up toolchain variables
+    #
+    tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
+    tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
+    tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
+
+    # Mark the specific ISA requested as enabled
+    soft_enable ${tgt_isa}
+    enable ${tgt_os}
+    enable ${tgt_cc}
+
+    # Enable the architecture family
+    case ${tgt_isa} in
+        arm*|iwmmxt*) enable arm;;
+    mips*)        enable mips;;
+    esac
+
+    # Handle darwin variants
+    case ${toolchain} in
+        *-darwin8-gcc)
+            add_cflags  "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+            add_cflags  "-mmacosx-version-min=10.4"
+            add_ldflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+            add_ldflags "-mmacosx-version-min=10.4"
+            ;;
+        *-darwin9-gcc)
+            add_cflags  "-isysroot /Developer/SDKs/MacOSX10.5.sdk"
+            add_cflags  "-mmacosx-version-min=10.5"
+            add_ldflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk"
+            add_ldflags "-mmacosx-version-min=10.5"
+            ;;
+    esac
+
+    # Process ARM architecture variants
+    case ${toolchain} in
+    arm*|iwmmxt*)
+    # on arm, isa versions are supersets
+    enabled armv7a && soft_enable armv7 ### DEBUG
+    enabled armv7 && soft_enable armv6
+    enabled armv6 && soft_enable armv5te
+    enabled armv6 && soft_enable fast_unaligned
+    enabled iwmmxt2 && soft_enable iwmmxt
+    enabled iwmmxt && soft_enable armv5te
+
+    asm_conversion_cmd="cat"
+
+        case ${tgt_cc} in
+        gcc)
+        if enabled iwmmxt || enabled iwmmxt2
+            then
+                CROSS=${CROSS:-arm-iwmmxt-linux-gnueabi-}
+            elif enabled symbian; then
+                CROSS=${CROSS:-arm-none-symbianelf-}
+            else
+                CROSS=${CROSS:-arm-none-linux-gnueabi-}
+            fi
+            link_with_cc=gcc
+            setup_gnu_toolchain
+            arch_int=${tgt_isa##armv}
+            arch_int=${arch_int%%te}
+            check_add_asflags --defsym ARCHITECTURE=${arch_int}
+            tune_cflags="-mtune="
+        if enabled iwmmxt || enabled iwmmxt2
+            then
+                check_add_asflags -mcpu=${tgt_isa}
+            elif enabled armv7
+            then
+                check_add_cflags -march=armv7-a -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp  #-ftree-vectorize
+        check_add_asflags -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp  #-march=armv7-a
+            else
+                check_add_cflags -march=${tgt_isa}
+                check_add_asflags -march=${tgt_isa}
+            fi
+
+            asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
+            ;;
+        rvct)
+            CC=armcc
+            AR=armar
+            AS=armasm
+            LD=${source_path}/build/make/armlink_adapter.sh
+            STRIP=arm-none-linux-gnueabi-strip
+            NM=arm-none-linux-gnueabi-nm
+            tune_cflags="--cpu="
+            tune_asflags="--cpu="
+            if [ -z "${tune_cpu}" ]; then
+            if enabled armv7
+                then
+                    check_add_cflags --cpu=Cortex-A8 --fpu=softvfp+vfpv3
+                    check_add_asflags --cpu=Cortex-A8 --fpu=none
+                else
+                    check_add_cflags --cpu=${tgt_isa##armv}
+                    check_add_asflags --cpu=${tgt_isa##armv}
+                fi
+            fi
+            arch_int=${tgt_isa##armv}
+            arch_int=${arch_int%%te}
+            check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
+        ;;
+        esac
+
+        case ${tgt_os} in
+        darwin*)
+            SDK_PATH=/Developer/Platforms/iPhoneOS.platform/Developer
+            TOOLCHAIN_PATH=${SDK_PATH}/usr/bin
+            CC=${TOOLCHAIN_PATH}/gcc
+            AR=${TOOLCHAIN_PATH}/ar
+            LD=${TOOLCHAIN_PATH}/arm-apple-darwin9-gcc-4.2.1
+            AS=${TOOLCHAIN_PATH}/as
+            STRIP=${TOOLCHAIN_PATH}/strip
+            NM=${TOOLCHAIN_PATH}/nm
+            AS_SFX=.s
+
+            # ASFLAGS is written here instead of using check_add_asflags
+            # because we need to overwrite all of ASFLAGS and purge the
+            # options that were put in above
+            ASFLAGS="-version -arch ${tgt_isa} -g"
+
+            add_cflags -arch ${tgt_isa}
+            add_ldflags -arch_only ${tgt_isa}
+
+            add_cflags  "-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk"
+
+            # This should be overridable
+            alt_libc=${SDK_PATH}/SDKs/iPhoneOS3.1.sdk
+
+            # Add the paths for the alternate libc
+#            for d in usr/include usr/include/gcc/darwin/4.0/; do
+            for d in usr/include usr/include/gcc/darwin/4.0/ usr/lib/gcc/arm-apple-darwin9/4.0.1/include/; do
+                try_dir="${alt_libc}/${d}"
+                [ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
+            done
+
+            for d in lib usr/lib; do
+                try_dir="${alt_libc}/${d}"
+                [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
+            done
+
+            asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
+         ;;
+
+        linux*)
+            enable linux
+            if enabled rvct; then
+                # Compiling with RVCT requires an alternate libc (glibc) when
+                # targetting linux.
+                disabled builtin_libc \
+                    || die "Must supply --libc when targetting *-linux-rvct"
+
+                # Set up compiler
+                add_cflags --gnu
+                add_cflags --enum_is_int
+                add_cflags --library_interface=aeabi_glibc
+                add_cflags --no_hide_all
+                add_cflags --wchar32
+                add_cflags --dwarf2
+                add_cflags --gnu
+
+                # Set up linker
+                add_ldflags --sysv --no_startup --no_ref_cpp_init
+                add_ldflags --entry=_start
+                add_ldflags --keep '"*(.init)"' --keep '"*(.fini)"'
+                add_ldflags --keep '"*(.init_array)"' --keep '"*(.fini_array)"'
+                add_ldflags --dynamiclinker=/lib/ld-linux.so.3
+                add_extralibs libc.so.6 -lc_nonshared crt1.o crti.o crtn.o
+
+                # Add the paths for the alternate libc
+                for d in usr/include; do
+                    try_dir="${alt_libc}/${d}"
+                    [ -d "${try_dir}" ] && add_cflags -J"${try_dir}"
+                done
+                add_cflags -J"${RVCT31INC}"
+                for d in lib usr/lib; do
+                    try_dir="${alt_libc}/${d}"
+                    [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
+                done
+
+
+                # glibc has some struct members named __align, which is a
+                # storage modifier in RVCT. If we need to use this modifier,
+                # we'll have to #undef it in our code. Note that this must
+                # happen AFTER all libc inclues.
+                add_cflags -D__align=x_align_x
+            fi
+        ;;
+
+        symbian*)
+            enable symbian
+            # Add the paths for the alternate libc
+            for d in include/libc; do
+                try_dir="${alt_libc}/${d}"
+                [ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
+            done
+            for d in release/armv5/urel; do
+                try_dir="${alt_libc}/${d}"
+                [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
+            done
+            add_cflags -DIMPORT_C=
+
+        esac
+    ;;
+    mips*)
+        CROSS=${CROSS:-mipsel-linux-uclibc-}
+        link_with_cc=gcc
+        setup_gnu_toolchain
+        tune_cflags="-mtune="
+        check_add_cflags -march=${tgt_isa}
+    check_add_asflags -march=${tgt_isa}
+    check_add_asflags -KPIC
+    ;;
+    ppc*)
+        enable ppc
+        bits=${tgt_isa##ppc}
+        link_with_cc=gcc
+        setup_gnu_toolchain
+        add_asflags -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
+        add_cflags -maltivec -faltivec
+        soft_enable altivec
+
+        case "$tgt_os" in
+        linux*)
+            add_asflags -maltivec -mregnames -I"\$(dir \$<)linux"
+        ;;
+        darwin*)
+            darwin_arch="-arch ppc"
+            enabled ppc64 && darwin_arch="${darwin_arch}64"
+            add_cflags  ${darwin_arch} -m${bits} -fasm-blocks
+            add_asflags ${darwin_arch} -force_cpusubtype_ALL -I"\$(dir \$<)darwin"
+            add_ldflags ${darwin_arch} -m${bits}
+        ;;
+        esac
+    ;;
+    x86*)
+        bits=32
+        enabled x86_64 && bits=64
+        soft_enable runtime_cpu_detect
+        soft_enable mmx
+        soft_enable sse
+        soft_enable sse2
+        soft_enable sse3
+        soft_enable ssse3
+
+        case  ${tgt_os} in
+            solaris*)
+                CC=${CC:-${CROSS}gcc}
+                LD=${LD:-${CROSS}gcc}
+                CROSS=${CROSS:-g}
+                ;;
+        esac
+
+        case  ${tgt_cc} in
+            icc*)
+                CC=${CC:-icc}
+                LD=${LD:-icc}
+                setup_gnu_toolchain
+                add_cflags -use-msasm -use-asm
+                add_ldflags -i-static
+                ;;
+            gcc*)
+                add_cflags  -m${bits}
+                add_ldflags -m${bits}
+                link_with_cc=gcc
+            setup_gnu_toolchain
+                ;;
+        esac
+
+        AS=yasm
+        AS_SFX=.asm
+        case  ${tgt_os} in
+            win*)
+                add_asflags -f win${bits}
+                enabled debug && add_asflags -g dwarf2
+            ;;
+            linux*|solaris*)
+                add_asflags -f elf${bits}
+                enabled debug && add_asflags -g dwarf2
+            ;;
+            darwin*)
+                add_asflags -f macho${bits}
+                enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
+                add_cflags  ${darwin_arch}
+                add_ldflags ${darwin_arch}
+                # -mdynamic-no-pic is still a bit of voodoo -- it was required at
+                # one time, but does not seem to be now, and it breaks some of the
+                # code that still relies on inline assembly.
+                # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
+                enabled icc && ! enabled pic && add_cflags -fno-pic
+            ;;
+            *) log "Warning: Unknown os $tgt_os while setting up yasm flags"
+            ;;
+        esac
+    ;;
+    universal*|*-gcc|generic-gnu)
+        link_with_cc=gcc
+    setup_gnu_toolchain
+    ;;
+    esac
+
+    # Try to enable CPU specific tuning
+    if [ -n "${tune_cpu}" ]; then
+        if [ -n "${tune_cflags}" ]; then
+            check_add_cflags ${tune_cflags}${tune_cpu} || \
+                die "Requested CPU '${tune_cpu}' not supported by compiler"
+        fi
+    if [ -n "${tune_asflags}" ]; then
+            check_add_asflags ${tune_asflags}${tune_cpu} || \
+                die "Requested CPU '${tune_cpu}' not supported by assembler"
+        fi
+    if [ -z "${tune_cflags}${tune_asflags}" ]; then
+            log_echo "Warning: CPU tuning not supported by this toolchain"
+        fi
+    fi
+
+    enabled debug && check_add_cflags -g && check_add_ldflags -g
+    enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
+    enabled gcov &&
+        check_add_cflags -fprofile-arcs -ftest-coverage &&
+        check_add_ldflags -fprofile-arcs -ftest-coverage
+    enabled optimizations && check_add_cflags -O3
+    if enabled rvct; then
+        enabled optimizations && check_add_cflags -Otime
+    fi
+
+    # Position Independant Code (PIC) support, for building relocatable
+    # shared objects
+    enabled gcc && enabled pic && check_add_cflags -fPIC
+
+    # Check for strip utility variant
+    ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable gnu_strip
+
+    # Try to determine target endianness
+    check_cc <<EOF
+    unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
+EOF
+    [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
+        grep '4f *32 *42 *45' >/dev/null 2>&1 && enable big_endian
+
+    # Almost every platform uses pthreads.
+    if enabled multithread; then
+        case ${toolchain} in
+            *-win*);;
+            *) check_header pthread.h && add_extralibs -lpthread
+        esac
+    fi
+
+    # glibc needs these
+    if enabled linux; then
+	add_cflags -D_LARGEFILE_SOURCE
+	add_cflags -D_FILE_OFFSET_BITS=64
+    fi
+}
+
+process_toolchain() {
+    process_common_toolchain
+}
+
+print_config_mk() {
+    prefix=$1
+    makefile=$2
+    shift 2
+    for cfg; do
+        upname="`toupper $cfg`"
+        if enabled $cfg; then
+            echo "${prefix}_${upname}=yes" >> $makefile
+        fi
+    done
+}
+
+print_config_h() {
+    prefix=$1
+    header=$2
+    shift 2
+    for cfg; do
+        upname="`toupper $cfg`"
+        if enabled $cfg; then
+            echo "#define ${prefix}_${upname} 1" >> $header
+        else
+            echo "#define ${prefix}_${upname} 0" >> $header
+        fi
+    done
+}
+
+process_targets() {
+    true;
+}
+
+process_detect() {
+    true;
+}
+
+enable logging
+logfile="config.err"
+self=$0
+process() {
+    cmdline_args="$@"
+    process_cmdline "$@"
+    if enabled child; then
+        echo "# ${self} $@" >> ${logfile}
+    else
+        echo "# ${self} $@" > ${logfile}
+    fi
+    post_process_cmdline
+    process_toolchain
+    process_detect
+    process_targets
+
+    OOT_INSTALLS="${OOT_INSTALLS}"
+    if enabled source_path_used; then
+    # Prepare the PWD for building.
+    for f in ${OOT_INSTALLS}; do
+            install -D ${source_path}/$f $f
+    done
+    fi
+    cp ${source_path}/build/make/Makefile .
+
+    clean_temp_files
+    true
+}
diff --git a/build/make/gen_asm_deps.sh b/build/make/gen_asm_deps.sh
new file mode 100755
index 0000000..c1118e1
--- /dev/null
+++ b/build/make/gen_asm_deps.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+self=$0
+show_help() {
+    echo "usage: $self [options] <srcfile>"
+    echo
+    echo "Generate Makefile dependency information from assembly code source"
+    echo
+    exit 1
+}
+die_unknown(){
+    echo "Unknown option \"$1\"."
+    echo "See $0 --help for available options."
+    exit 1
+}
+for opt do
+    optval="${opt#*=}"
+    case "$opt" in
+    --build-pfx=*) pfx="${optval}"
+    ;;
+    --depfile=*) out="${optval}"
+    ;;
+    -I*) raw_inc_paths="${raw_inc_paths} ${opt}"
+         inc_path="${inc_path} ${opt#-I}"
+    ;;
+    -h|--help) show_help
+    ;;
+    *) [ -f "$opt" ] && srcfile="$opt"
+    ;;
+    esac
+done
+
+[ -n "$srcfile" ] || show_help
+sfx=${sfx:-asm}
+includes=$(egrep -i "include +\"?+[a-z0-9_/]+\.${sfx}" $srcfile |
+           perl -p -e "s;.*?([a-z0-9_/]+.${sfx}).*;\1;")
+#" restore editor state
+for inc in ${includes}; do
+    found_inc_path=
+    for idir in ${inc_path}; do
+        [ -f "${idir}/${inc}" ] && found_inc_path="${idir}" && break
+    done
+    if [ -f `dirname $srcfile`/$inc ]; then
+        # Handle include files in the same directory as the source
+        $self --build-pfx=$pfx --depfile=$out ${raw_inc_paths} `dirname $srcfile`/$inc
+    elif [ -n "${found_inc_path}" ]; then
+        # Handle include files on the include path
+        $self --build-pfx=$pfx --depfile=$out ${raw_inc_paths} "${found_inc_path}/$inc"
+    else
+        # Handle generated includes in the build root (which may not exist yet)
+        echo ${out} ${out%d}o: "${pfx}${inc}"
+    fi
+done
+echo ${out} ${out%d}o: $srcfile
diff --git a/build/make/gen_msvs_def.sh b/build/make/gen_msvs_def.sh
new file mode 100755
index 0000000..68b2406
--- /dev/null
+++ b/build/make/gen_msvs_def.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+self=$0
+self_basename=${self##*/}
+EOL=$'\n'
+
+show_help() {
+    cat <<EOF
+Usage: ${self_basename} [options] file1 [file2 ...]
+
+This script generates a MSVC module definition file containing a list of symbols
+to export from a DLL. Source files are technically bash scripts (and thus may
+use #comment syntax) but in general, take the form of a list of symbols:
+
+  <kind> symbol1 [symbol2, symbol3, ...]
+
+where <kind> is either 'text' or 'data'
+
+
+Options:
+    --help                      Print this message
+    --out=filename              Write output to a file [stdout]
+    --name=project_name         Name of the library (required)
+EOF
+    exit 1
+}
+
+die() {
+    echo "${self_basename}: $@"
+    exit 1
+}
+
+die_unknown(){
+    echo "Unknown option \"$1\"."
+    echo "See ${self_basename} --help for available options."
+    exit 1
+}
+
+text() {
+    for sym in "$@"; do
+        echo "  $sym" >> ${outfile}
+    done
+}
+
+data() {
+    for sym in "$@"; do
+        printf "  %-40s DATA\n" "$sym" >> ${outfile}
+    done
+}
+
+# Process command line
+for opt in "$@"; do
+    optval="${opt#*=}"
+    case "$opt" in
+    --help|-h) show_help
+    ;;
+    --out=*) outfile="$optval"
+    ;;
+    --name=*) name="${optval}"
+    ;;
+     -*) die_unknown $opt
+    ;;
+    *) file_list[${#file_list[@]}]="$opt"
+    esac
+done
+outfile=${outfile:-/dev/stdout}
+[ -n "$name" ] || die "Library name (--name) must be specified!"
+
+echo "LIBRARY ${name}" > ${outfile}
+echo "EXPORTS" >> ${outfile}
+for f in "${file_list[@]}"; do
+    . $f
+done
diff --git a/build/make/gen_msvs_proj.sh b/build/make/gen_msvs_proj.sh
new file mode 100755
index 0000000..eb482a4
--- /dev/null
+++ b/build/make/gen_msvs_proj.sh
@@ -0,0 +1,717 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+self=$0
+self_basename=${self##*/}
+EOL=$'\n'
+
+show_help() {
+    cat <<EOF
+Usage: ${self_basename} --name=projname [options] file1 [file2 ...]
+
+This script generates a Visual Studio project file from a list of source
+code files.
+
+Options:
+    --help                      Print this message
+    --exe                       Generate a project for building an Application
+    --lib                       Generate a project for creating a static library
+    --static-crt                Use the static C runtime (/MT)
+    --target=isa-os-cc          Target specifier (required)
+    --out=filename              Write output to a file [stdout]
+    --name=project_name         Name of the project (required)
+    --proj-guid=GUID            GUID to use for the project
+    --module-def=filename       File containing export definitions (for DLLs)
+    --ver=version               Version (7,8) of visual studio to generate for
+    -Ipath/to/include           Additional include directories
+    -DFLAG[=value]              Preprocessor macros to define
+    -Lpath/to/lib               Additional library search paths
+    -llibname                   Library to link against
+EOF
+    exit 1
+}
+
+die() {
+    echo "${self_basename}: $@" >&2
+    exit 1
+}
+
+die_unknown(){
+    echo "Unknown option \"$1\"." >&2
+    echo "See ${self_basename} --help for available options." >&2
+    exit 1
+}
+
+generate_uuid() {
+    local hex="0123456789ABCDEF"
+    local i
+    local uuid=""
+    local j
+    #93995380-89BD-4b04-88EB-625FBE52EBFB
+    for ((i=0; i<32; i++)); do
+        (( j = $RANDOM % 16 ))
+        uuid="${uuid}${hex:$j:1}"
+    done
+    echo "${uuid:0:8}-${uuid:8:4}-${uuid:12:4}-${uuid:16:4}-${uuid:20:12}"
+}
+
+indent1="    "
+indent=""
+indent_push() {
+    indent="${indent}${indent1}"
+}
+indent_pop() {
+    indent="${indent%${indent1}}"
+}
+
+tag_attributes() {
+    for opt in "$@"; do
+        optval="${opt#*=}"
+        [ -n "${optval}" ] ||
+            die "Missing attribute value in '$opt' while generating $tag tag"
+        echo "${indent}${opt%%=*}=\"${optval}\""
+    done
+}
+
+open_tag() {
+    local tag=$1
+    shift
+    if [ $# -ne 0 ]; then
+        echo "${indent}<${tag}"
+        indent_push
+        tag_attributes "$@"
+        echo "${indent}>"
+    else
+        echo "${indent}<${tag}>"
+        indent_push
+    fi
+}
+
+close_tag() {
+    local tag=$1
+    indent_pop
+    echo "${indent}</${tag}>"
+}
+
+tag() {
+    local tag=$1
+    shift
+    if [ $# -ne 0 ]; then
+        echo "${indent}<${tag}"
+        indent_push
+        tag_attributes "$@"
+        indent_pop
+        echo "${indent}/>"
+    else
+        echo "${indent}<${tag}/>"
+    fi
+}
+
+generate_filter() {
+    local var=$1
+    local name=$2
+    local pats=$3
+    local file_list_sz
+    local i
+    local f
+    local saveIFS="$IFS"
+    local pack
+    echo "generating filter '$name' from ${#file_list[@]} files" >&2
+    IFS=*
+
+    open_tag Filter \
+        Name=$name \
+        Filter=$pats \
+        UniqueIdentifier=`generate_uuid`
+
+    file_list_sz=${#file_list[@]}
+    for i in ${!file_list[@]}; do
+        f=${file_list[i]}
+        for pat in ${pats//;/$IFS}; do
+            if [ "${f##*.}" == "$pat" ]; then
+                unset file_list[i]
+
+                open_tag File RelativePath="./$f"
+                if [ "$pat" == "asm" ] && $asm_use_custom_step; then
+                    for plat in "${platforms[@]}"; do
+                        for cfg in Debug Release; do
+                            open_tag  FileConfiguration \
+                            Name="${cfg}|${plat}"
+                            tag Tool \
+                                Name="VCCustomBuildTool" \
+                                Description="Assembling \$(InputFileName)" \
+                                CommandLine="$(eval echo \$asm_${cfg}_cmdline)"\
+                                Outputs="\$(InputName).obj"
+                            close_tag FileConfiguration
+                        done
+                    done
+                fi
+
+                if [ "${f##*.}" == "cpp" ]; then
+                    for plat in "${platforms[@]}"; do
+                        for cfg in Debug Release; do
+                        open_tag FileConfiguration \
+                            Name="${cfg}|${plat}"
+                        tag Tool \
+                            Name="VCCLCompilerTool" \
+                            CompileAs="2"
+                        close_tag FileConfiguration
+                        done
+                    done
+                fi
+                close_tag  File
+
+                break
+            fi
+        done
+    done
+
+    close_tag Filter
+    IFS="$saveIFS"
+}
+
+# Process command line
+unset target
+for opt in "$@"; do
+    optval="${opt#*=}"
+    case "$opt" in
+    --help|-h) show_help
+    ;;
+    --target=*) target="${optval}"
+    ;;
+    --out=*) outfile="$optval"
+    ;;
+    --name=*) name="${optval}"
+    ;;
+    --proj-guid=*) guid="${optval}"
+    ;;
+    --module-def=*)
+        link_opts="${link_opts} ModuleDefinitionFile=${optval}"
+    ;;
+    --exe) proj_kind="exe"
+    ;;
+    --lib) proj_kind="lib"
+    ;;
+    --static-crt) use_static_runtime=true
+    ;;
+    --ver=*) vs_ver="$optval"
+             case $optval in
+             [78])
+             ;;
+             *) die Unrecognized Visual Studio Version in $opt
+             ;;
+             esac
+    ;;
+    -I*) opt="${opt%/}"
+         incs="${incs}${incs:+;}&quot;${opt##-I}&quot;"
+         yasmincs="${yasmincs} ${opt}"
+    ;;
+    -D*) defines="${defines}${defines:+;}${opt##-D}"
+    ;;
+    -L*) # fudge . to $(OutDir)
+         if [ "${opt##-L}" == "." ]; then
+             libdirs="${libdirs}${libdirs:+;}&quot;\$(OutDir)&quot;"
+         else
+             # Also try directories for this platform/configuration
+             libdirs="${libdirs}${libdirs:+;}&quot;${opt##-L}&quot;"
+             libdirs="${libdirs}${libdirs:+;}&quot;${opt##-L}/\$(PlatformName)/\$(ConfigurationName)&quot;"
+             libdirs="${libdirs}${libdirs:+;}&quot;${opt##-L}/\$(PlatformName)&quot;"
+         fi
+    ;;
+    -l*) libs="${libs}${libs:+ }${opt##-l}.lib"
+    ;;
+    -*) die_unknown $opt
+    ;;
+    *) file_list[${#file_list[@]}]="$opt"
+       case "$opt" in
+       *.asm) uses_asm=true;;
+       esac
+    esac
+done
+outfile=${outfile:-/dev/stdout}
+guid=${guid:-`generate_uuid`}
+asm_use_custom_step=false
+uses_asm=${uses_asm:-false}
+case "${vs_ver:-8}" in
+    7) vs_ver_id="7.10"
+       asm_use_custom_step=$uses_asm
+    ;;
+    8) vs_ver_id="8.00"
+    ;;
+esac
+
+[ -n "$name" ] || die "Project name (--name) must be specified!"
+[ -n "$target" ] || die "Target (--target) must be specified!"
+
+if ${use_static_runtime:-false}; then
+    release_runtime=0
+    debug_runtime=1
+    lib_sfx=mt
+else
+    release_runtime=2
+    debug_runtime=3
+    lib_sfx=md
+fi
+
+# Calculate debug lib names: If a lib ends in ${lib_sfx}.lib, then rename
+# it to ${lib_sfx}d.lib. This precludes linking to release libs from a
+# debug exe, so this may need to be refactored later.
+for lib in ${libs}; do
+    if [ "$lib" != "${lib%${lib_sfx}.lib}" ]; then
+        lib=${lib%.lib}d.lib
+    fi
+    debug_libs="${debug_libs}${debug_libs:+ }${lib}"
+done
+
+
+# List Keyword for this target
+case "$target" in
+    x86*)
+        keyword="ManagedCProj"
+    ;;
+    arm*|iwmmx*)
+        keyword="Win32Proj"
+    ;;
+    *) die "Unsupported target $target!"
+esac
+
+# List of all platforms supported for this target
+case "$target" in
+    x86_64*)
+        platforms[0]="x64"
+    ;;
+    x86*)
+        platforms[0]="Win32"
+        # these are only used by vs7
+        asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} \$(InputPath)"
+        asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} \$(InputPath)"
+    ;;
+    arm*|iwmmx*)
+        case "${name}" in
+        obj_int_extract) platforms[0]="Win32"
+        ;;
+        *) platforms[0]="Pocket PC 2003 (ARMV4)"
+        ;;
+        esac
+    ;;
+    *) die "Unsupported target $target!"
+esac
+
+# List Command-line Arguments for this target
+case "$target" in
+    arm*|iwmmx*)
+        if [ "$name" == "example" ];then
+            ARGU="--codec vp6 --flipuv --progress _bnd.vp6"
+        fi
+        if [ "$name" == "xma" ];then
+            ARGU="--codec vp6 -h 240 -w 320 -v"
+        fi
+    ;;
+esac
+
+generate_vcproj() {
+    case "$proj_kind" in
+    exe) vs_ConfigurationType=1
+    ;;
+    *)   vs_ConfigurationType=4
+    ;;
+    esac
+
+    echo "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
+    open_tag  VisualStudioProject \
+                  ProjectType="Visual C++" \
+                  Version="${vs_ver_id}" \
+                  Name="${name}" \
+                  ProjectGUID="{${guid}}" \
+                  RootNamespace="${name}" \
+                  Keyword="${keyword}"
+
+    open_tag  Platforms
+    for plat in "${platforms[@]}"; do
+        tag   Platform Name="$plat"
+    done
+    close_tag Platforms
+
+    open_tag  ToolFiles
+    case "$target" in
+        x86*) $uses_asm && tag DefaultToolFile FileName="yasm.rules"
+        ;;
+        arm*|iwmmx*)
+            if [ "$name" == "vpx_decoder" ];then
+            case "$target" in
+                armv5*)
+                    tag DefaultToolFile FileName="armasmv5.rules"
+                ;;
+                armv6*)
+                    tag DefaultToolFile FileName="armasmv6.rules"
+                ;;
+                iwmmxt*)
+                    tag DefaultToolFile FileName="armasmxscale.rules"
+                ;;
+            esac
+            fi
+        ;;
+    esac
+    close_tag ToolFiles
+
+    open_tag  Configurations
+    for plat in "${platforms[@]}"; do
+        plat_no_ws=`echo $plat | sed 's/[^A-Za-z0-9_]/_/g'`
+        open_tag  Configuration \
+                      Name="Debug|$plat" \
+                      OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
+                      IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
+                      ConfigurationType="$vs_ConfigurationType" \
+                      CharacterSet="1"
+
+        if [ "$target" == "armv6-wince-vs8" ] || [ "$target" == "armv5te-wince-vs8" ] || [ "$target" == "iwmmxt-wince-vs8" ] || [ "$target" == "iwmmxt2-wince-vs8" ];then
+            case "$name" in
+                vpx_decoder) tag Tool \
+                             Name="VCPreBuildEventTool" \
+                             CommandLine="call obj_int_extract.bat \$(ConfigurationName)"
+                             tag Tool \
+                             Name="VCMIDLTool" \
+                             TargetEnvironment="1"
+                             tag Tool \
+                             Name="VCCLCompilerTool" \
+                             ExecutionBucket="7" \
+                             Optimization="0" \
+                             AdditionalIncludeDirectories="$incs" \
+                             PreprocessorDefinitions="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;HAVE_CONFIG_H" \
+                             MinimalRebuild="true" \
+                             RuntimeLibrary="1" \
+                             BufferSecurityCheck="false" \
+                             UsePrecompiledHeader="0" \
+                             WarningLevel="3" \
+                             DebugInformationFormat="1" \
+                             CompileAs="1"
+                             tag Tool \
+                             Name="VCResourceCompilerTool" \
+                             PreprocessorDefinitions="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
+                             Culture="1033" \
+                             AdditionalIncludeDirectories="\$(IntDir)" \
+                ;;
+                example|xma) tag Tool \
+                             Name="VCCLCompilerTool" \
+                             ExecutionBucket="7" \
+                             Optimization="0" \
+                             AdditionalIncludeDirectories="$incs" \
+                             PreprocessorDefinitions="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;DEBUG;_CONSOLE;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;HAVE_CONFIG_H" \
+                             MinimalRebuild="true" \
+                             RuntimeLibrary="1" \
+                             BufferSecurityCheck="false" \
+                             UsePrecompiledHeader="0" \
+                             WarningLevel="3" \
+                             DebugInformationFormat="1" \
+                             CompileAs="1"
+                             tag Tool \
+                             Name="VCResourceCompilerTool" \
+                             PreprocessorDefinitions="_DEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
+                             Culture="1033" \
+                             AdditionalIncludeDirectories="\$(IntDir)" \
+                ;;
+                obj_int_extract) tag Tool \
+                             Name="VCCLCompilerTool" \
+                             Optimization="0" \
+                             AdditionalIncludeDirectories="$incs" \
+                             PreprocessorDefinitions="WIN32;DEBUG;_CONSOLE" \
+                             RuntimeLibrary="1" \
+                             WarningLevel="3" \
+                             DebugInformationFormat="1" \
+                ;;
+            esac
+        fi
+
+        case "$target" in
+            x86*) tag Tool \
+                Name="VCCLCompilerTool" \
+                Optimization="0" \
+                AdditionalIncludeDirectories="$incs" \
+                PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;$defines" \
+                RuntimeLibrary="$debug_runtime" \
+                UsePrecompiledHeader="0" \
+                WarningLevel="3" \
+                DebugInformationFormat="1" \
+                Detect64BitPortabilityProblems="true" \
+
+                $uses_asm && tag Tool Name="YASM"  IncludePaths="$incs" Debug="1"
+            ;;
+        esac
+
+        case "$proj_kind" in
+            exe)
+                case "$target" in
+                    x86*) tag Tool \
+                          Name="VCLinkerTool" \
+                          AdditionalDependencies="$debug_libs \$(NoInherit)" \
+                          AdditionalLibraryDirectories="$libdirs" \
+                          GenerateDebugInformation="true" \
+                          ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
+
+                    ;;
+                    arm*|iwmmx*)
+                        case "$name" in
+                            obj_int_extract) tag Tool \
+                                Name="VCLinkerTool" \
+                                OutputFile="${name}.exe" \
+                                GenerateDebugInformation="true"
+                            ;;
+                            *) tag Tool \
+                                Name="VCLinkerTool" \
+                                AdditionalDependencies="$debug_libs" \
+                                OutputFile="\$(OutDir)/${name}.exe" \
+                                LinkIncremental="2" \
+                                AdditionalLibraryDirectories="${libdirs};&quot;..\lib/$plat_no_ws&quot;" \
+                                DelayLoadDLLs="\$(NOINHERIT)" \
+                                GenerateDebugInformation="true" \
+                                ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
+                                SubSystem="9" \
+                                StackReserveSize="65536" \
+                                StackCommitSize="4096" \
+                                EntryPointSymbol="mainWCRTStartup" \
+                                TargetMachine="3"
+                            ;;
+                        esac
+                     ;;
+                 esac
+            ;;
+            lib)
+                case "$target" in
+                      arm*|iwmmx*) tag Tool \
+                                    Name="VCLibrarianTool" \
+                                    AdditionalOptions=" /subsystem:windowsce,4.20 /machine:ARM" \
+                                    OutputFile="\$(OutDir)/${name}.lib" \
+                                ;;
+                                *) tag Tool \
+                                    Name="VCLibrarianTool" \
+                                    OutputFile="\$(OutDir)/${name}${lib_sfx}d.lib" \
+                                ;;
+                esac
+            ;;
+            dll) tag Tool \
+                 Name="VCLinkerTool" \
+                AdditionalDependencies="\$(NoInherit)" \
+                LinkIncremental="2" \
+                GenerateDebugInformation="true" \
+                AssemblyDebug="1" \
+                TargetMachine="1" \
+                      $link_opts
+        esac
+
+        if [ "$target" == "armv6-wince-vs8" ] || [ "$target" == "armv5te-wince-vs8" ] || [ "$target" == "iwmmxt-wince-vs8" ] || [ "$target" == "iwmmxt2-wince-vs8" ];then
+            case "$name" in
+                vpx_decoder) tag DeploymentTool \
+                             ForceDirty="-1" \
+                             RegisterOutput="0"
+                                ;;
+                example|xma) tag DeploymentTool \
+                             ForceDirty="-1" \
+                             RegisterOutput="0"
+                             tag DebuggerTool \
+                             Arguments="${ARGU}"
+                                ;;
+            esac
+        fi
+        close_tag Configuration
+
+        open_tag  Configuration \
+                      Name="Release|$plat" \
+                      OutputDirectory="\$(SolutionDir)$plat_no_ws/\$(ConfigurationName)" \
+                      IntermediateDirectory="$plat_no_ws/\$(ConfigurationName)/${name}" \
+                      ConfigurationType="$vs_ConfigurationType" \
+                      CharacterSet="1" \
+                      WholeProgramOptimization="0"
+
+        if [ "$target" == "armv6-wince-vs8" ] || [ "$target" == "armv5te-wince-vs8" ] || [ "$target" == "iwmmxt-wince-vs8" ] || [ "$target" == "iwmmxt2-wince-vs8" ];then
+            case "$name" in
+                vpx_decoder) tag Tool \
+                                     Name="VCPreBuildEventTool" \
+                                     CommandLine="call obj_int_extract.bat \$(ConfigurationName)"
+                             tag Tool \
+                                     Name="VCMIDLTool" \
+                                     TargetEnvironment="1"
+                             tag Tool \
+                                             Name="VCCLCompilerTool" \
+                                             ExecutionBucket="7" \
+                                             Optimization="2" \
+                                             FavorSizeOrSpeed="1" \
+                                             AdditionalIncludeDirectories="$incs" \
+                                             PreprocessorDefinitions="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;_LIB;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;HAVE_CONFIG_H" \
+                                             RuntimeLibrary="0" \
+                                             BufferSecurityCheck="false" \
+                                             UsePrecompiledHeader="0" \
+                                             WarningLevel="3" \
+                                             DebugInformationFormat="0" \
+                                             CompileAs="1"
+                             tag Tool \
+                                             Name="VCResourceCompilerTool" \
+                                             PreprocessorDefinitions="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
+                                             Culture="1033" \
+                                             AdditionalIncludeDirectories="\$(IntDir)" \
+                ;;
+                example|xma) tag Tool \
+                             Name="VCCLCompilerTool" \
+                             ExecutionBucket="7" \
+                             Optimization="2" \
+                             FavorSizeOrSpeed="1" \
+                             AdditionalIncludeDirectories="$incs" \
+                             PreprocessorDefinitions="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES);WINCE;_CONSOLE;\$(ARCHFAM);\$(_ARCHFAM_);_UNICODE;UNICODE;HAVE_CONFIG_H" \
+                             RuntimeLibrary="0" \
+                             BufferSecurityCheck="false" \
+                             UsePrecompiledHeader="0" \
+                             WarningLevel="3" \
+                             DebugInformationFormat="0" \
+                             CompileAs="1"
+                             tag Tool \
+                             Name="VCResourceCompilerTool" \
+                             PreprocessorDefinitions="NDEBUG;_WIN32_WCE=\$(CEVER);UNDER_CE;\$(PLATFORMDEFINES)" \
+                             Culture="1033" \
+                             AdditionalIncludeDirectories="\$(IntDir)" \
+                ;;
+                obj_int_extract) tag Tool \
+                             Name="VCCLCompilerTool" \
+                             AdditionalIncludeDirectories="$incs" \
+                             PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" \
+                             RuntimeLibrary="0" \
+                             UsePrecompiledHeader="0" \
+                             WarningLevel="3" \
+                             Detect64BitPortabilityProblems="true" \
+                             DebugInformationFormat="0" \
+                ;;
+            esac
+        fi
+
+    case "$target" in
+        x86*) tag       Tool \
+                      Name="VCCLCompilerTool" \
+                      AdditionalIncludeDirectories="$incs" \
+                      PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;$defines" \
+                      RuntimeLibrary="$release_runtime" \
+                      UsePrecompiledHeader="0" \
+                      WarningLevel="3" \
+                      DebugInformationFormat="0" \
+                      Detect64BitPortabilityProblems="true"
+
+                $uses_asm && tag Tool Name="YASM"  IncludePaths="$incs"
+                ;;
+                esac
+
+        case "$proj_kind" in
+            exe)
+                case "$target" in
+                    x86*) tag Tool \
+                                  Name="VCLinkerTool" \
+                                  AdditionalDependencies="$libs \$(NoInherit)" \
+                                  AdditionalLibraryDirectories="$libdirs" \
+                    ;;
+                    arm*|iwmmx*)
+                        case "$name" in
+                            obj_int_extract) tag Tool \
+                                Name="VCLinkerTool" \
+                                OutputFile="${name}.exe" \
+                                LinkIncremental="1" \
+                                GenerateDebugInformation="false" \
+                                SubSystem="0" \
+                                OptimizeReferences="0" \
+                                EnableCOMDATFolding="0" \
+                                TargetMachine="0"
+                            ;;
+                            *) tag Tool \
+                                Name="VCLinkerTool" \
+                                AdditionalDependencies="$libs" \
+                                OutputFile="\$(OutDir)/${name}.exe" \
+                                LinkIncremental="1" \
+                                AdditionalLibraryDirectories="${libdirs};&quot;..\lib/$plat_no_ws&quot;" \
+                                DelayLoadDLLs="\$(NOINHERIT)" \
+                                GenerateDebugInformation="true" \
+                                ProgramDatabaseFile="\$(OutDir)/${name}.pdb" \
+                                SubSystem="9" \
+                                StackReserveSize="65536" \
+                                StackCommitSize="4096" \
+                                OptimizeReferences="2" \
+                                EnableCOMDATFolding="2" \
+                                EntryPointSymbol="mainWCRTStartup" \
+                                TargetMachine="3"
+                            ;;
+                        esac
+                     ;;
+                 esac
+            ;;
+        lib)
+                case "$target" in
+                      arm*|iwmmx*) tag Tool \
+                                    Name="VCLibrarianTool" \
+                                    AdditionalOptions=" /subsystem:windowsce,4.20 /machine:ARM" \
+                                    OutputFile="\$(OutDir)/${name}.lib" \
+                                ;;
+                                *) tag Tool \
+                                    Name="VCLibrarianTool" \
+                                    OutputFile="\$(OutDir)/${name}${lib_sfx}.lib" \
+                                ;;
+                esac
+        ;;
+        dll) # note differences to debug version: LinkIncremental, AssemblyDebug
+             tag Tool \
+                      Name="VCLinkerTool" \
+                      AdditionalDependencies="\$(NoInherit)" \
+                      LinkIncremental="1" \
+                      GenerateDebugInformation="true" \
+                      TargetMachine="1" \
+                      $link_opts
+        esac
+
+        if [ "$target" == "armv6-wince-vs8" ] || [ "$target" == "armv5te-wince-vs8" ] || [ "$target" == "iwmmxt-wince-vs8" ] || [ "$target" == "iwmmxt2-wince-vs8" ];then
+            case "$name" in
+                vpx_decoder) tag DeploymentTool \
+                             ForceDirty="-1" \
+                             RegisterOutput="0"
+                ;;
+                example|xma) tag DeploymentTool \
+                             ForceDirty="-1" \
+                             RegisterOutput="0"
+                             tag DebuggerTool \
+                             Arguments="${ARGU}"
+                                ;;
+            esac
+        fi
+
+        close_tag Configuration
+    done
+    close_tag Configurations
+
+    open_tag  Files
+    generate_filter srcs   "Source Files"   "cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+    generate_filter hdrs   "Header Files"   "h;hpp;hxx;hm;inl;inc;xsd"
+    generate_filter resrcs "Resource Files" "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+    generate_filter resrcs "Build Files"    "mk"
+    close_tag Files
+
+    tag       Globals
+    close_tag VisualStudioProject
+
+    # This must be done from within the {} subshell
+    echo "Ignored files list (${#file_list[@]} items) is:" >&2
+    for f in "${file_list[@]}"; do
+        echo "    $f" >&2
+    done
+}
+
+generate_vcproj |
+    sed  -e '/"/s;\([^ "]\)/;\1\\;g' > ${outfile}
+
+exit
+<!--
+TODO: Add any files not captured by filters.
+                <File
+                        RelativePath=".\ReadMe.txt"
+                        >
+                </File>
+-->
diff --git a/build/make/gen_msvs_sln.sh b/build/make/gen_msvs_sln.sh
new file mode 100755
index 0000000..b670ec5
--- /dev/null
+++ b/build/make/gen_msvs_sln.sh
@@ -0,0 +1,272 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+self=$0
+self_basename=${self##*/}
+EOL=$'\n'
+EOLDOS=$'\r'
+
+show_help() {
+    cat <<EOF
+Usage: ${self_basename} [options] file1 [file2 ...]
+
+This script generates a Visual Studio 2005 solution file from a list of project
+files.
+
+Options:
+    --help                      Print this message
+    --out=outfile               Redirect output to a file
+    --ver=version               Version (7,8) of visual studio to generate for
+    --target=isa-os-cc          Target specifier
+EOF
+    exit 1
+}
+
+die() {
+    echo "${self_basename}: $@" >&2
+    [ -f "${outfile}" ] && rm -f ${outfile}{,.mk}
+    exit 1
+}
+
+die_unknown(){
+    echo "Unknown option \"$1\"." >&2
+    echo "See ${self_basename} --help for available options." >&2
+    [ -f "${outfile}" ] && rm -f ${outfile}{,.mk}
+    exit 1
+}
+
+indent1=$'\t'
+indent=""
+indent_push() {
+    indent="${indent}${indent1}"
+}
+indent_pop() {
+    indent="${indent%${indent1}}"
+}
+
+parse_project() {
+    local file=$1
+    local name=`grep Name "$file" | awk 'BEGIN {FS="\""}{if (NR==1) print $2}'`
+    local guid=`grep ProjectGUID "$file" | awk 'BEGIN {FS="\""}{if (NR==1) print $2}'`
+
+    # save the project GUID to a varaible, normalizing to the basename of the
+    # vcproj file without the extension
+    local var
+    var=${file##*/}
+    var=${var%%.vcproj}
+    eval "${var}_file=\"$1\""
+    eval "${var}_name=$name"
+    eval "${var}_guid=$guid"
+
+    # assume that all projects have the same list of possible configurations,
+    # so overwriting old config_lists is not a problem
+    config_list=`grep -A1 '<Configuration' $file |
+        grep Name | cut -d\" -f2`
+    proj_list="${proj_list} ${var}"
+}
+
+process_project() {
+    eval "local file=\${$1_file}"
+    eval "local name=\${$1_name}"
+    eval "local guid=\${$1_guid}"
+
+    # save the project GUID to a varaible, normalizing to the basename of the
+    # vcproj file without the extension
+    local var
+    var=${file##*/}
+    var=${var%%.vcproj}
+    eval "${var}_guid=$guid"
+
+    echo "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"$name\", \"$file\", \"$guid\""
+    indent_push
+
+    eval "local deps=\"\${${var}_deps}\""
+    if [ -n "$deps" ]; then
+        echo "${indent}ProjectSection(ProjectDependencies) = postProject"
+        indent_push
+
+        for dep in $deps; do
+            eval "local dep_guid=\${${dep}_guid}"
+            [ -z "${dep_guid}" ] && die "Unknown GUID for $dep (dependency of $var)"
+            echo "${indent}$dep_guid = $dep_guid"
+        done
+
+        indent_pop
+        echo "${indent}EndProjectSection"
+
+    fi
+
+    indent_pop
+    echo "EndProject"
+}
+
+process_global() {
+    echo "Global"
+    indent_push
+
+    #
+    # Solution Configuration Platforms
+    #
+    echo "${indent}GlobalSection(SolutionConfigurationPlatforms) = preSolution"
+    indent_push
+    IFS_bak=${IFS}
+    IFS=$'\r'$'\n'
+    for config in ${config_list}; do
+        echo "${indent}$config = $config"
+    done
+    IFS=${IFS_bak}
+    indent_pop
+    echo "${indent}EndGlobalSection"
+
+    #
+    # Project Configuration Platforms
+    #
+    echo "${indent}GlobalSection(ProjectConfigurationPlatforms) = postSolution"
+    indent_push
+    for proj in ${proj_list}; do
+        eval "local proj_guid=\${${proj}_guid}"
+        IFS=$'\r'$'\n'
+        for config in ${config_list}; do
+            echo "${indent}${proj_guid}.${config}.ActiveCfg = ${config}"
+            echo "${indent}${proj_guid}.${config}.Build.0 = ${config}"
+
+            if [ "$target" == "armv6-wince-vs8" ] || [ "$target" == "armv5te-wince-vs8" ] || [ "$target" == "iwmmxt-wince-vs8" ] || [ "$target" == "iwmmxt2-wince-vs8" ];then
+                echo "${indent}${proj_guid}.${config}.Deploy.0 = ${config}"
+            fi
+        done
+        IFS=${IFS_bak}
+    done
+    indent_pop
+    echo "${indent}EndGlobalSection"
+
+    #
+    # Solution Properties
+    #
+    echo "${indent}GlobalSection(SolutionProperties) = preSolution"
+    indent_push
+    echo "${indent}HideSolutionNode = FALSE"
+    indent_pop
+    echo "${indent}EndGlobalSection"
+
+    indent_pop
+    echo "EndGlobal"
+}
+
+process_makefile() {
+    IFS_bak=${IFS}
+    IFS=$'\r'$'\n'
+    local TAB=$'\t'
+    cat <<EOF
+found_devenv := \$(shell which devenv.com >/dev/null 2>&1 && echo yes)
+.nodevenv.once:
+${TAB}@echo "  * devenv.com not found in path."
+${TAB}@echo "  * "
+${TAB}@echo "  * You will have to build all configurations manually using the"
+${TAB}@echo "  * Visual Studio IDE. To allow make to build them automatically,"
+${TAB}@echo "  * add the Common7/IDE directory of your Visual Studio"
+${TAB}@echo "  * installation to your path, eg:"
+${TAB}@echo "  *   C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"
+${TAB}@echo "  * "
+${TAB}@touch \$@
+CLEAN-OBJS += \$(if \$(found_devenv),,.nodevenv.once)
+
+EOF
+
+    for sln_config in ${config_list}; do
+        local config=${sln_config%%|*}
+        local platform=${sln_config##*|}
+        local nows_sln_config=`echo $sln_config | sed -e 's/[^a-zA-Z0-9]/_/g'`
+        cat <<EOF
+BUILD_TARGETS += \$(if \$(NO_LAUNCH_DEVENV),,$nows_sln_config)
+clean::
+${TAB}rm -rf "$platform"/"$config"
+.PHONY: $nows_sln_config
+ifneq (\$(found_devenv),)
+  ifeq (\$(CONFIG_VS_VERSION),7)
+$nows_sln_config: $outfile
+${TAB}devenv.com $outfile /build "$config"
+
+  else
+$nows_sln_config: $outfile
+${TAB}devenv.com $outfile /build "$sln_config"
+
+  endif
+else
+$nows_sln_config: $outfile .nodevenv.once
+${TAB}@echo "  * Skipping build of $sln_config (devenv.com not in path)."
+${TAB}@echo "  * "
+endif
+
+EOF
+    done
+    IFS=${IFS_bak}
+}
+
+# Process command line
+outfile=/dev/stdout
+for opt in "$@"; do
+    optval="${opt#*=}"
+    case "$opt" in
+    --help|-h) show_help
+    ;;
+    --out=*) outfile="${optval}"; mkoutfile="${optval}".mk
+    ;;
+    --dep=*) eval "${optval%%:*}_deps=\"\${${optval%%:*}_deps} ${optval##*:}\""
+    ;;
+    --ver=*) vs_ver="$optval"
+             case $optval in
+             [78])
+             ;;
+             *) die Unrecognized Visual Studio Version in $opt
+             ;;
+             esac
+    ;;
+    --ver=*) vs_ver="$optval"
+             case $optval in
+             7) sln_vers="8.00"
+                sln_vers_str="Visual Studio .NET 2003"
+             ;;
+             8)
+             ;;
+             *) die "Unrecognized Visual Studio Version '$optval' in $opt"
+             ;;
+             esac
+    ;;
+    --target=*) target="${optval}"
+    ;;
+    -*) die_unknown $opt
+    ;;
+    *) file_list[${#file_list[@]}]="$opt"
+    esac
+done
+outfile=${outfile:-/dev/stdout}
+mkoutfile=${mkoutfile:-/dev/stdout}
+case "${vs_ver:-8}" in
+    7) sln_vers="8.00"
+       sln_vers_str="Visual Studio .NET 2003"
+    ;;
+    8) sln_vers="9.00"
+       sln_vers_str="Visual Studio 2005"
+    ;;
+esac
+
+for f in "${file_list[@]}"; do
+    parse_project $f
+done
+cat  >${outfile} <<EOF
+Microsoft Visual Studio Solution File, Format Version $sln_vers${EOLDOS}
+# $sln_vers_str${EOLDOS}
+EOF
+for proj in ${proj_list}; do
+    process_project $proj >>${outfile}
+done
+process_global >>${outfile}
+process_makefile >${mkoutfile}
diff --git a/build/make/obj_int_extract.c b/build/make/obj_int_extract.c
new file mode 100644
index 0000000..cef14e7
--- /dev/null
+++ b/build/make/obj_int_extract.c
@@ -0,0 +1,755 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "vpx_config.h"
+
+#if defined(_MSC_VER)
+#include <io.h>
+#include <share.h>
+#include "vpx_ports/vpx_integer.h"
+#else
+#include <stdint.h>
+#include <unistd.h>
+#endif
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdarg.h>
+
+typedef enum
+{
+    OUTPUT_FMT_PLAIN,
+    OUTPUT_FMT_RVDS,
+    OUTPUT_FMT_GAS,
+} output_fmt_t;
+
+int log_msg(const char *fmt, ...)
+{
+    int res;
+    va_list ap;
+    va_start(ap, fmt);
+    res = vfprintf(stderr, fmt, ap);
+    va_end(ap);
+    return res;
+}
+
+#if defined(__GNUC__) && __GNUC__
+
+#if defined(__MACH__)
+
+#include <mach-o/loader.h>
+#include <mach-o/nlist.h>
+
+int parse_macho(uint8_t *base_buf, size_t sz)
+{
+    int i, j;
+    struct mach_header header;
+    uint8_t *buf = base_buf;
+    int base_data_section = 0;
+
+    memcpy(&header, buf, sizeof(struct mach_header));
+    buf += sizeof(struct mach_header);
+
+    if (header.magic != MH_MAGIC)
+    {
+        log_msg("Bad magic number for object file. 0x%x expected, 0x%x found.\n",
+                header.magic, MH_MAGIC);
+        goto bail;
+    }
+
+    if (header.cputype != CPU_TYPE_ARM)
+    {
+        log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_ARM.\n");
+        goto bail;
+    }
+
+    if (header.filetype != MH_OBJECT)
+    {
+        log_msg("Bad filetype for object file. Currently only tested for MH_OBJECT.\n");
+        goto bail;
+    }
+
+    for (i = 0; i < header.ncmds; i++)
+    {
+        struct load_command lc;
+        struct symtab_command sc;
+        struct segment_command seg_c;
+
+        memcpy(&lc, buf, sizeof(struct load_command));
+
+        if (lc.cmd == LC_SEGMENT)
+        {
+            uint8_t *seg_buf = buf;
+            struct section s;
+
+            memcpy(&seg_c, buf, sizeof(struct segment_command));
+
+            seg_buf += sizeof(struct segment_command);
+
+            for (j = 0; j < seg_c.nsects; j++)
+            {
+                memcpy(&s, seg_buf + (j * sizeof(struct section)), sizeof(struct section));
+
+                // Need to get this offset which is the start of the symbol table
+                // before matching the strings up with symbols.
+                base_data_section = s.offset;
+            }
+        }
+        else if (lc.cmd == LC_SYMTAB)
+        {
+            uint8_t *sym_buf = base_buf;
+            uint8_t *str_buf = base_buf;
+
+            if (base_data_section != 0)
+            {
+                memcpy(&sc, buf, sizeof(struct symtab_command));
+
+                if (sc.cmdsize != sizeof(struct symtab_command))
+                    log_msg("Can't find symbol table!\n");
+
+                sym_buf += sc.symoff;
+                str_buf += sc.stroff;
+
+                for (j = 0; j < sc.nsyms; j++)
+                {
+                    struct nlist nl;
+                    int val;
+
+                    memcpy(&nl, sym_buf + (j * sizeof(struct nlist)), sizeof(struct nlist));
+
+                    val = *((int *)(base_buf + base_data_section + nl.n_value));
+
+                    // Location of string is cacluated each time from the
+                    // start of the string buffer.  On darwin the symbols
+                    // are prefixed by "_".  On other platforms it is not
+                    // so it needs to be removed.  That is the reason for
+                    // the +1.
+                    printf("%-40s EQU %5d\n", str_buf + nl.n_un.n_strx + 1, val);
+                }
+            }
+        }
+
+        buf += lc.cmdsize;
+    }
+
+    return 0;
+bail:
+    return 1;
+
+}
+
+int main(int argc, char **argv)
+{
+    int fd;
+    char *f;
+    struct stat stat_buf;
+    uint8_t *file_buf;
+    int res;
+
+    if (argc < 2 || argc > 3)
+    {
+        fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
+        fprintf(stderr, "  <obj file>\tMachO format object file to parse\n");
+        fprintf(stderr, "Output Formats:\n");
+        fprintf(stderr, "  gas  - compatible with GNU assembler\n");
+        fprintf(stderr, "  rvds - compatible with armasm\n");
+        goto bail;
+    }
+
+    f = argv[2];
+
+    if (!((!strcmp(argv[1], "rvds")) || (!strcmp(argv[1], "gas"))))
+        f = argv[1];
+
+    fd = open(f, O_RDONLY);
+
+    if (fd < 0)
+    {
+        perror("Unable to open file");
+        goto bail;
+    }
+
+    if (fstat(fd, &stat_buf))
+    {
+        perror("stat");
+        goto bail;
+    }
+
+    file_buf = malloc(stat_buf.st_size);
+
+    if (!file_buf)
+    {
+        perror("malloc");
+        goto bail;
+    }
+
+    if (read(fd, file_buf, stat_buf.st_size) != stat_buf.st_size)
+    {
+        perror("read");
+        goto bail;
+    }
+
+    if (close(fd))
+    {
+        perror("close");
+        goto bail;
+    }
+
+    res = parse_macho(file_buf, stat_buf.st_size);
+    free(file_buf);
+
+    if (!res)
+        return EXIT_SUCCESS;
+
+bail:
+    return EXIT_FAILURE;
+}
+
+#else
+#include "elf.h"
+
+#define COPY_STRUCT(dst, buf, ofst, sz) do {\
+        if(ofst + sizeof((*(dst))) > sz) goto bail;\
+        memcpy(dst, buf+ofst, sizeof((*(dst))));\
+    } while(0)
+
+#define ENDIAN_ASSIGN(val, memb) do {\
+        if(!elf->le_data) {log_msg("Big Endian data not supported yet!\n");goto bail;}\
+        (val) = (memb);\
+    } while(0)
+
+#define ENDIAN_ASSIGN_IN_PLACE(memb) do {\
+        ENDIAN_ASSIGN(memb, memb);\
+    } while(0)
+
+typedef struct
+{
+    uint8_t     *buf; /* Buffer containing ELF data */
+    size_t       sz;  /* Buffer size */
+    int          le_data;   /* Data is little-endian */
+    Elf32_Ehdr   hdr;
+} elf_obj_t;
+
+int parse_elf32_header(elf_obj_t *elf)
+{
+    int res;
+    /* Verify ELF32 header */
+    COPY_STRUCT(&elf->hdr, elf->buf, 0, elf->sz);
+    res = elf->hdr.e_ident[EI_MAG0] == ELFMAG0;
+    res &= elf->hdr.e_ident[EI_MAG1] == ELFMAG1;
+    res &= elf->hdr.e_ident[EI_MAG2] == ELFMAG2;
+    res &= elf->hdr.e_ident[EI_MAG3] == ELFMAG3;
+    res &= elf->hdr.e_ident[EI_CLASS] == ELFCLASS32;
+    res &= elf->hdr.e_ident[EI_DATA] == ELFDATA2LSB
+           || elf->hdr.e_ident[EI_DATA] == ELFDATA2MSB;
+
+    if (!res) goto bail;
+
+    elf->le_data = elf->hdr.e_ident[EI_DATA] == ELFDATA2LSB;
+
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_type);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_machine);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_version);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_entry);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_phoff);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_shoff);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_flags);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_ehsize);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_phentsize);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_phnum);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_shentsize);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_shnum);
+    ENDIAN_ASSIGN_IN_PLACE(elf->hdr.e_shstrndx);
+    return 0;
+bail:
+    return 1;
+}
+
+int parse_elf32_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr)
+{
+    if (idx >= elf->hdr.e_shnum)
+        goto bail;
+
+    COPY_STRUCT(hdr, elf->buf, elf->hdr.e_shoff + idx * elf->hdr.e_shentsize,
+                elf->sz);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_name);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_type);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_flags);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_addr);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_offset);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_size);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_link);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_info);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_addralign);
+    ENDIAN_ASSIGN_IN_PLACE(hdr->sh_entsize);
+    return 0;
+bail:
+    return 1;
+}
+
+char *parse_elf32_string_table(elf_obj_t *elf, int s_idx, int idx)
+{
+    Elf32_Shdr shdr;
+
+    if (parse_elf32_section(elf, s_idx, &shdr))
+    {
+        log_msg("Failed to parse ELF string table: section %d, index %d\n",
+                s_idx, idx);
+        return "";
+    }
+
+    return (char *)(elf->buf + shdr.sh_offset + idx);
+}
+
+int parse_elf32_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym)
+{
+    COPY_STRUCT(sym, elf->buf, ofst, elf->sz);
+    ENDIAN_ASSIGN_IN_PLACE(sym->st_name);
+    ENDIAN_ASSIGN_IN_PLACE(sym->st_value);
+    ENDIAN_ASSIGN_IN_PLACE(sym->st_size);
+    ENDIAN_ASSIGN_IN_PLACE(sym->st_info);
+    ENDIAN_ASSIGN_IN_PLACE(sym->st_other);
+    ENDIAN_ASSIGN_IN_PLACE(sym->st_shndx);
+    return 0;
+bail:
+    return 1;
+}
+
+int parse_elf32(uint8_t *buf, size_t sz, output_fmt_t mode)
+{
+    elf_obj_t  elf;
+    Elf32_Shdr shdr;
+    unsigned int ofst;
+    int         i;
+    Elf32_Off strtab_off;   /* save String Table offset for later use */
+
+    memset(&elf, 0, sizeof(elf));
+    elf.buf = buf;
+    elf.sz = sz;
+
+    /* Parse Header */
+    if (parse_elf32_header(&elf))
+    {
+        log_msg("Parse error: File does not appear to be valid ELF32\n");
+        return 1;
+    }
+
+    for (i = 0; i < elf.hdr.e_shnum; i++)
+    {
+        parse_elf32_section(&elf, i, &shdr);
+
+        if (shdr.sh_type == SHT_STRTAB)
+        {
+            char strtsb_name[128];
+
+            strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
+
+            if (!(strcmp(strtsb_name, ".shstrtab")))
+            {
+                log_msg("found section: %s\n", strtsb_name);
+                strtab_off = shdr.sh_offset;
+                break;
+            }
+        }
+    }
+
+    /* Parse all Symbol Tables */
+    for (i = 0; i < elf.hdr.e_shnum; i++)
+    {
+
+        parse_elf32_section(&elf, i, &shdr);
+
+        if (shdr.sh_type == SHT_SYMTAB)
+        {
+            for (ofst = shdr.sh_offset;
+                 ofst < shdr.sh_offset + shdr.sh_size;
+                 ofst += shdr.sh_entsize)
+            {
+                Elf32_Sym sym;
+
+                parse_elf32_symbol(&elf, ofst, &sym);
+
+                /* For all OBJECTS (data objects), extract the value from the
+                 * proper data segment.
+                 */
+                if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
+                    log_msg("found data object %s\n",
+                            parse_elf32_string_table(&elf,
+                                                     shdr.sh_link,
+                                                     sym.st_name));
+
+                if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT
+                    && sym.st_size == 4)
+                {
+                    Elf32_Shdr dhdr;
+                    int32_t      val;
+                    char section_name[128];
+
+                    parse_elf32_section(&elf, sym.st_shndx, &dhdr);
+
+                    /* For explanition - refer to _MSC_VER version of code */
+                    strcpy(section_name, (char *)(elf.buf + strtab_off + dhdr.sh_name));
+                    log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type);
+
+                    if (!(strcmp(section_name, ".bss")))
+                    {
+                        val = 0;
+                    }
+                    else
+                    {
+                        memcpy(&val,
+                               elf.buf + dhdr.sh_offset + sym.st_value,
+                               sizeof(val));
+                    }
+
+                    if (!elf.le_data)
+                    {
+                        log_msg("Big Endian data not supported yet!\n");
+                        goto bail;
+                    }\
+
+                    switch (mode)
+                    {
+                    case OUTPUT_FMT_RVDS:
+                        printf("%-40s EQU %5d\n",
+                               parse_elf32_string_table(&elf,
+                                                        shdr.sh_link,
+                                                        sym.st_name),
+                               val);
+                        break;
+                    case OUTPUT_FMT_GAS:
+                        printf(".equ %-40s, %5d\n",
+                               parse_elf32_string_table(&elf,
+                                                        shdr.sh_link,
+                                                        sym.st_name),
+                               val);
+                        break;
+                    default:
+                        printf("%s = %d\n",
+                               parse_elf32_string_table(&elf,
+                                                        shdr.sh_link,
+                                                        sym.st_name),
+                               val);
+                    }
+                }
+            }
+        }
+    }
+
+    if (mode == OUTPUT_FMT_RVDS)
+        printf("    END\n");
+
+    return 0;
+bail:
+    log_msg("Parse error: File does not appear to be valid ELF32\n");
+    return 1;
+}
+
+int main(int argc, char **argv)
+{
+    int fd;
+    output_fmt_t mode;
+    char *f;
+    struct stat stat_buf;
+    uint8_t *file_buf;
+    int res;
+
+    if (argc < 2 || argc > 3)
+    {
+        fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
+        fprintf(stderr, "  <obj file>\tELF format object file to parse\n");
+        fprintf(stderr, "Output Formats:\n");
+        fprintf(stderr, "  gas  - compatible with GNU assembler\n");
+        fprintf(stderr, "  rvds - compatible with armasm\n");
+        goto bail;
+    }
+
+    f = argv[2];
+
+    if (!strcmp(argv[1], "rvds"))
+        mode = OUTPUT_FMT_RVDS;
+    else if (!strcmp(argv[1], "gas"))
+        mode = OUTPUT_FMT_GAS;
+    else
+        f = argv[1];
+
+
+    fd = open(f, O_RDONLY);
+
+    if (fd < 0)
+    {
+        perror("Unable to open file");
+        goto bail;
+    }
+
+    if (fstat(fd, &stat_buf))
+    {
+        perror("stat");
+        goto bail;
+    }
+
+    file_buf = malloc(stat_buf.st_size);
+
+    if (!file_buf)
+    {
+        perror("malloc");
+        goto bail;
+    }
+
+    if (read(fd, file_buf, stat_buf.st_size) != stat_buf.st_size)
+    {
+        perror("read");
+        goto bail;
+    }
+
+    if (close(fd))
+    {
+        perror("close");
+        goto bail;
+    }
+
+    res = parse_elf32(file_buf, stat_buf.st_size, mode);
+    //res = parse_coff(file_buf, stat_buf.st_size);
+    free(file_buf);
+
+    if (!res)
+        return EXIT_SUCCESS;
+
+bail:
+    return EXIT_FAILURE;
+}
+#endif
+#endif
+
+
+#if defined(_MSC_VER)
+/*  See "Microsoft Portable Executable and Common Object File Format Specification"
+    for reference.
+*/
+#define get_le32(x) ((*(x)) | (*(x+1)) << 8 |(*(x+2)) << 16 | (*(x+3)) << 24 )
+#define get_le16(x) ((*(x)) | (*(x+1)) << 8)
+
+int parse_coff(unsigned __int8 *buf, size_t sz)
+{
+    unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr;
+    unsigned int sectionrawdata_ptr;
+    unsigned int i;
+    unsigned __int8 *ptr;
+    unsigned __int32 symoffset;
+    FILE *fp;
+
+    char **sectionlist;  //this array holds all section names in their correct order.
+    //it is used to check if the symbol is in .bss or .data section.
+
+    nsections = get_le16(buf + 2);
+    symtab_ptr = get_le32(buf + 8);
+    symtab_sz = get_le32(buf + 12);
+    strtab_ptr = symtab_ptr + symtab_sz * 18;
+
+    if (nsections > 96)
+        goto bail;
+
+    sectionlist = malloc(nsections * sizeof * sectionlist);
+
+    //log_msg("COFF: Found %u symbols in %u sections.\n", symtab_sz, nsections);
+
+    /*
+    The size of optional header is always zero for an obj file. So, the section header
+    follows the file header immediately.
+    */
+
+    ptr = buf + 20;     //section header
+
+    for (i = 0; i < nsections; i++)
+    {
+        char sectionname[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+        strncpy(sectionname, ptr, 8);
+        //log_msg("COFF: Parsing section %s\n",sectionname);
+
+        sectionlist[i] = malloc(strlen(sectionname) + 1);
+        strcpy(sectionlist[i], sectionname);
+
+        if (!strcmp(sectionname, ".data")) sectionrawdata_ptr = get_le32(ptr + 20);
+
+        ptr += 40;
+    }
+
+    //log_msg("COFF: Symbol table at offset %u\n", symtab_ptr);
+    //log_msg("COFF: raw data pointer ofset for section .data is %u\n", sectionrawdata_ptr);
+
+    fp = fopen("vpx_asm_offsets.asm", "w");
+
+    if (fp == NULL)
+    {
+        perror("open file");
+        goto bail;
+    }
+
+    /*  The compiler puts the data with non-zero offset in .data section, but puts the data with
+        zero offset in .bss section. So, if the data in in .bss section, set offset=0.
+        Note from Wiki: In an object module compiled from C, the bss section contains
+        the local variables (but not functions) that were declared with the static keyword,
+        except for those with non-zero initial values. (In C, static variables are initialized
+        to zero by default.) It also contains the non-local (both extern and static) variables
+        that are also initialized to zero (either explicitly or by default).
+        */
+    //move to symbol table
+    /* COFF symbol table:
+        offset      field
+        0           Name(*)
+        8           Value
+        12          SectionNumber
+        14          Type
+        16          StorageClass
+        17          NumberOfAuxSymbols
+        */
+    ptr = buf + symtab_ptr;
+
+    for (i = 0; i < symtab_sz; i++)
+    {
+        __int16 section = get_le16(ptr + 12); //section number
+
+        if (section > 0 && ptr[16] == 2)
+        {
+            //if(section > 0 && ptr[16] == 3 && get_le32(ptr+8)) {
+
+            if (get_le32(ptr))
+            {
+                char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+                strncpy(name, ptr, 8);
+                //log_msg("COFF: Parsing symbol %s\n",name);
+                fprintf(fp, "%-40s EQU ", name);
+            }
+            else
+            {
+                //log_msg("COFF: Parsing symbol %s\n",
+                //        buf + strtab_ptr + get_le32(ptr+4));
+                fprintf(fp, "%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4));
+            }
+
+            if (!(strcmp(sectionlist[section-1], ".bss")))
+            {
+                symoffset = 0;
+            }
+            else
+            {
+                symoffset = get_le32(buf + sectionrawdata_ptr + get_le32(ptr + 8));
+            }
+
+            //log_msg("      Section: %d\n",section);
+            //log_msg("      Class:   %d\n",ptr[16]);
+            //log_msg("      Address: %u\n",get_le32(ptr+8));
+            //log_msg("      Offset: %u\n", symoffset);
+
+            fprintf(fp, "%5d\n", symoffset);
+        }
+
+        ptr += 18;
+    }
+
+    fprintf(fp, "    END\n");
+    fclose(fp);
+
+    for (i = 0; i < nsections; i++)
+    {
+        free(sectionlist[i]);
+    }
+
+    free(sectionlist);
+
+    return 0;
+bail:
+
+    for (i = 0; i < nsections; i++)
+    {
+        free(sectionlist[i]);
+    }
+
+    free(sectionlist);
+
+    return 1;
+}
+
+int main(int argc, char **argv)
+{
+    int fd;
+    output_fmt_t mode;
+    const char *f;
+    struct _stat stat_buf;
+    unsigned __int8 *file_buf;
+    int res;
+
+    if (argc < 2 || argc > 3)
+    {
+        fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
+        fprintf(stderr, "  <obj file>\tELF format object file to parse\n");
+        fprintf(stderr, "Output Formats:\n");
+        fprintf(stderr, "  gas  - compatible with GNU assembler\n");
+        fprintf(stderr, "  rvds - compatible with armasm\n");
+        goto bail;
+    }
+
+    f = argv[2];
+
+    if (!strcmp(argv[1], "rvds"))
+        mode = OUTPUT_FMT_RVDS;
+    else if (!strcmp(argv[1], "gas"))
+        mode = OUTPUT_FMT_GAS;
+    else
+        f = argv[1];
+
+    if (_sopen_s(&fd, f, _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE))
+    {
+        perror("Unable to open file");
+        goto bail;
+    }
+
+    if (_fstat(fd, &stat_buf))
+    {
+        perror("stat");
+        goto bail;
+    }
+
+    file_buf = malloc(stat_buf.st_size);
+
+    if (!file_buf)
+    {
+        perror("malloc");
+        goto bail;
+    }
+
+    if (_read(fd, file_buf, stat_buf.st_size) != stat_buf.st_size)
+    {
+        perror("read");
+        goto bail;
+    }
+
+    if (_close(fd))
+    {
+        perror("close");
+        goto bail;
+    }
+
+    res = parse_coff(file_buf, stat_buf.st_size);
+
+    free(file_buf);
+
+    if (!res)
+        return EXIT_SUCCESS;
+
+bail:
+    return EXIT_FAILURE;
+}
+#endif
diff --git a/build/make/version.sh b/build/make/version.sh
new file mode 100755
index 0000000..2bda701
--- /dev/null
+++ b/build/make/version.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+
+for opt in "$@"; do
+    optval="${opt#*=}"
+    case "$opt" in
+    --bare) bare=true ;;
+    *) break ;;
+    esac
+    shift
+done
+source_path=${1:-.}
+out_file=${2}
+id=${3:-VERSION_STRING}
+
+git_version_id=""
+if [ -d ${source_path}/.git ]; then
+    # Source Path is a git working copy. Check for local modifications.
+    export GIT_DIR=${source_path}/.git
+    git_version_id=`git describe --match=v[0-9]* 2>/dev/null`
+fi
+
+changelog_version=""
+for p in "${source_path}" "${source_path}/.."; do
+    if [ -z "$git_version_id" -a -f "${p}/CHANGELOG" ]; then
+        changelog_version=`head -n1 "${p}/CHANGELOG" | awk '{print $2}'`
+        changelog_version="${changelog_version}"
+        break
+    fi
+done
+version_str="${changelog_version}${git_version_id}"
+bare_version=${version_str#v}
+major_version=${bare_version%%.*}
+bare_version=${bare_version#*.}
+minor_version=${bare_version%%.*}
+bare_version=${bare_version#*.}
+patch_version=${bare_version%%-*}
+bare_version=${bare_version#${patch_version}}
+extra_version=${bare_version##-}
+
+#since they'll be used as integers below make sure they are or force to 0
+for v in major_version minor_version patch_version; do
+    if eval echo \$$v |grep -E -q '[^[:digit:]]'; then
+        eval $v=0
+    fi
+done
+
+if [ ${bare} ]; then
+    echo "${changelog_version}${git_version_id}" > $$.tmp
+else
+    cat<<EOF>$$.tmp
+#define VERSION_MAJOR  $major_version
+#define VERSION_MINOR  $minor_version
+#define VERSION_PATCH  $patch_version
+#define VERSION_EXTRA  "$extra_version"
+#define VERSION_PACKED ((VERSION_MAJOR<<16)|(VERSION_MINOR<<8)|(VERSION_PATCH))
+#define ${id}_NOSP "${version_str}"
+#define ${id}      " ${version_str}"
+EOF
+fi
+if [ -n "$out_file" ]; then
+diff $$.tmp ${out_file} >/dev/null 2>&1 || cat $$.tmp > ${out_file}
+else
+cat $$.tmp
+fi
+rm $$.tmp
diff --git a/configure b/configure
new file mode 100755
index 0000000..3083343
--- /dev/null
+++ b/configure
@@ -0,0 +1,515 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+#source_path="`dirname \"$0\"`"
+source_path=${0%/*}
+. "${source_path}/build/make/configure.sh"
+
+show_help(){
+    show_help_pre
+    cat << EOF
+Advanced options:
+  ${toggle_libs}                  don't build libraries
+  ${toggle_examples}              don't build examples
+  --libc=PATH                     path to alternate libc
+  ${toggle_fast_unaligned}        don't use unaligned accesses, even when
+                                  supported by hardware [auto]
+  ${toggle_codec_srcs}            in/exclude codec library source code
+  ${toggle_debug_libs}            in/exclude debug version of libraries
+  ${toggle_eval_limit}            enable limited evaluation build
+  ${toggle_md5}                   support for output of checksum data
+  ${toggle_static_msvcrt}         use static MSVCRT (VS builds only)
+  ${toggle_vp8}                   VP8 codec support
+  ${toggle_psnr}                  output of PSNR data, if supported (encoders)
+  ${toggle_mem_tracker}           track memory usage
+  ${toggle_eval_limit}            decoder limitted to 500 frames
+  ${toggle_postproc}              postprocessing
+  ${toggle_multithread}           multithreaded encoding and decoding.
+  ${toggle_spatial_resampling}    spatial sampling (scaling) support
+  ${toggle_realtime_only}         enable this option while building for real-time encoding
+  ${toggle_runtime_cpu_detect}    runtime cpu detection
+
+Codecs:
+  Codecs can be selectively enabled or disabled individually, or by family:
+      --disable-<codec>
+  is equivalent to:
+      --disable-<codec>-encoder
+      --disable-<codec>-decoder
+
+  Codecs available in this distribution:
+EOF
+#restore editor state '
+
+    local family;
+    local last_family;
+    local c;
+    local str;
+    for c in ${CODECS}; do
+        family=${c%_*}
+        if [ "${family}" != "${last_family}" ]; then
+            [ -z "${str}" ] || echo "${str}"
+            str="$(printf '    %10s:' ${family})"
+        fi
+        str="${str} $(printf '%10s' ${c#*_})"
+        last_family=${family}
+    done
+    echo "${str}"
+    show_help_post
+}
+
+##
+## BEGIN APPLICATION SPECIFIC CONFIGURATION
+##
+
+# all_platforms is a list of all supported target platforms. Maintain
+# alphabetically by architecture, generic-gnu last.
+all_platforms="${all_platforms} armv5te-linux-rvct"
+all_platforms="${all_platforms} armv5te-linux-gcc"
+all_platforms="${all_platforms} armv5te-symbian-gcc"
+all_platforms="${all_platforms} armv5te-wince-vs8"
+all_platforms="${all_platforms} armv6-darwin-gcc"
+all_platforms="${all_platforms} armv6-linux-rvct"
+all_platforms="${all_platforms} armv6-linux-gcc"
+all_platforms="${all_platforms} armv6-symbian-gcc"
+all_platforms="${all_platforms} armv6-wince-vs8"
+all_platforms="${all_platforms} iwmmxt-linux-rvct"
+all_platforms="${all_platforms} iwmmxt-linux-gcc"
+all_platforms="${all_platforms} iwmmxt-wince-vs8"
+all_platforms="${all_platforms} iwmmxt2-linux-rvct"
+all_platforms="${all_platforms} iwmmxt2-linux-gcc"
+all_platforms="${all_platforms} iwmmxt2-wince-vs8"
+all_platforms="${all_platforms} armv7-darwin-gcc"    #neon Cortex-A8
+all_platforms="${all_platforms} armv7-linux-rvct"    #neon Cortex-A8
+all_platforms="${all_platforms} armv7-linux-gcc"     #neon Cortex-A8
+all_platforms="${all_platforms} mips32-linux-gcc"
+all_platforms="${all_platforms} ppc32-darwin8-gcc"
+all_platforms="${all_platforms} ppc32-darwin9-gcc"
+all_platforms="${all_platforms} ppc64-darwin8-gcc"
+all_platforms="${all_platforms} ppc64-darwin9-gcc"
+all_platforms="${all_platforms} ppc64-linux-gcc"
+all_platforms="${all_platforms} x86-darwin8-gcc"
+all_platforms="${all_platforms} x86-darwin8-icc"
+all_platforms="${all_platforms} x86-darwin9-gcc"
+all_platforms="${all_platforms} x86-darwin9-icc"
+all_platforms="${all_platforms} x86-linux-gcc"
+all_platforms="${all_platforms} x86-linux-icc"
+all_platforms="${all_platforms} x86-solaris-gcc"
+all_platforms="${all_platforms} x86-win32-gcc"
+all_platforms="${all_platforms} x86-win32-vs7"
+all_platforms="${all_platforms} x86-win32-vs8"
+all_platforms="${all_platforms} x86_64-darwin9-gcc"
+all_platforms="${all_platforms} x86_64-linux-gcc"
+all_platforms="${all_platforms} x86_64-solaris-gcc"
+all_platforms="${all_platforms} x86_64-win64-vs8"
+all_platforms="${all_platforms} universal-darwin8-gcc"
+all_platforms="${all_platforms} universal-darwin9-gcc"
+all_platforms="${all_platforms} generic-gnu"
+
+# all_targets is a list of all targets that can be configured
+# note that these should be in dependency order for now.
+all_targets="libs examples docs"
+
+# all targets available are enabled, by default.
+for t in ${all_targets}; do
+    [ -f ${source_path}/${t}.mk ] && enable ${t}
+done
+
+# check installed doxygen version
+doxy_version=$(doxygen --version 2>/dev/null)
+doxy_major=${doxy_version%%.*}
+if [ ${doxy_major:-0} -ge 1 ]; then
+    doxy_version=${doxy_version#*.}
+    doxy_minor=${doxy_version%%.*}
+    doxy_patch=${doxy_version##*.}
+
+    [ $doxy_major -gt 1 ] && enable doxygen
+    [ $doxy_minor -gt 5 ] && enable doxygen
+    [ $doxy_minor -eq 5 ] && [ $doxy_patch -ge 3 ] && enable doxygen
+fi
+
+# install everything, by default
+enabled doxygen && php -v >/dev/null 2>&1 && enable install_docs
+enable install_bins
+enable install_libs
+enable install_srcs
+
+enable optimizations
+enable fast_unaligned #allow unaligned accesses, if supported by hw
+enable md5
+enable spatial_resampling
+enable multithread
+
+[ -d ${source_path}/../include ] && enable alt_tree_layout
+for d in vp8; do
+    [ -d ${source_path}/${d} ] && disable alt_tree_layout;
+done
+
+if ! enabled alt_tree_layout; then
+# development environment
+[ -d ${source_path}/vp8 ] && CODECS="${CODECS} vp8_encoder vp8_decoder"
+else
+# customer environment
+[ -f ${source_path}/../include/vp8cx.h ] && CODECS="${CODECS} vp8_encoder"
+[ -f ${source_path}/../include/vp8dx.h ] && CODECS="${CODECS} vp8_decoder"
+
+[ -f ${source_path}/../lib/*/*mt.lib ] && soft_enable static_msvcrt
+fi
+
+CODECS="$(echo ${CODECS} | tr ' ' '\n')"
+CODEC_FAMILIES="$(for c in ${CODECS}; do echo ${c%_*}; done | sort | uniq)"
+
+ARCH_LIST="
+    arm
+    mips
+    x86
+    x86_64
+    ppc32
+    ppc64
+"
+ARCH_EXT_LIST="
+    armv5te
+    armv6
+    armv7
+    iwmmxt
+    iwmmxt2
+
+    mips32
+
+    mmx
+    sse
+    sse2
+    sse3
+    ssse3
+
+    altivec
+"
+HAVE_LIST="
+    ${ARCH_EXT_LIST}
+    vpx_ports
+    stdint_h
+    alt_tree_layout
+    pthread_h
+    sys_mman_h
+"
+CONFIG_LIST="
+    external_build
+    install_docs
+    install_bins
+    install_libs
+    install_srcs
+    debug
+    gprof
+    gcov
+    rvct
+    gcc
+    msvs
+    pic
+    big_endian
+
+    codec_srcs
+    debug_libs
+    fast_unaligned
+    mem_manager
+    mem_tracker
+    mem_checks
+    md5
+
+    dequant_tokens
+    dc_recon
+    new_tokens
+    eval_limit
+    runtime_cpu_detect
+    postproc
+    postproc_generic
+    multithread
+    psnr
+    ${CODECS}
+    ${CODEC_FAMILIES}
+    encoders
+    decoders
+    static_msvcrt
+    spatial_resampling
+    realtime_only
+"
+CMDLINE_SELECT="
+    extra_warnings
+    werror
+    install_docs
+    install_bins
+    install_libs
+    install_srcs
+    debug
+    gprof
+    gcov
+    pic
+    optimizations
+    ccache
+    runtime_cpu_detect
+
+    libs
+    examples
+    libc
+    fast_unaligned
+    codec_srcs
+    debug_libs
+    md5
+
+    dequant_tokens
+    dc_recon
+    new_tokens
+    eval_limit
+    postproc
+    postproc_generic
+    multithread
+    psnr
+    ${CODECS}
+    ${CODEC_FAMILIES}
+    static_msvcrt
+    mem_tracker
+    spatial_resampling
+    realtime_only
+"
+
+process_cmdline() {
+    for opt do
+        optval="${opt#*=}"
+        case "$opt" in
+        --disable-codecs) for c in ${CODECS}; do disable $c; done ;;
+        *) process_common_cmdline $opt
+        ;;
+        esac
+    done
+}
+
+post_process_cmdline() {
+    local c
+
+    # If the codec family is disabled, disable all components of that family.
+    # If the codec family is enabled, enable all components of that family.
+    log_echo "Configuring selected codecs"
+    for c in ${CODECS}; do
+        disabled ${c%%_*} && disable ${c}
+        enabled ${c%%_*} && enable ${c}
+    done
+
+    # Enable all detected codecs, if they haven't been disabled
+    for c in ${CODECS}; do soft_enable $c; done
+
+    # Enable the codec family if any component of that family is enabled
+    for c in ${CODECS}; do
+        enabled $c && enable ${c%_*}
+    done
+
+    # Set the {en,de}coders variable if any algorithm in that class is enabled
+    for c in ${CODECS}; do
+        enabled ${c} && enable ${c##*_}s
+    done
+
+
+}
+
+
+process_targets() {
+    enabled child || write_common_config_banner
+    enabled universal || write_common_target_config_h  ${BUILD_PFX}vpx_config.h
+
+    # TODO: add host tools target (obj_int_extract, etc)
+
+    # For fat binaries, call configure recursively to configure for each
+    # binary architecture to be included.
+    if enabled universal; then
+        # Call configure (ourselves) for each subarchitecture
+        for arch in $fat_bin_archs; do
+            BUILD_PFX=${arch}/ toolchain=${arch} $self --child $cmdline_args || exit $?
+        done
+    fi
+
+    # The write_common_config (config.mk) logic is deferred until after the
+    # recursive calls to configure complete, becuase we want our universal
+    # targets to be executed last.
+    write_common_config_targets
+    enabled universal && echo "FAT_ARCHS=${fat_bin_archs}" >> config.mk
+
+    # Calculate the default distribution name, based on the enabled features
+    local cf
+    local DIST_DIR=vpx
+    for cf in $CODEC_FAMILIES; do
+        if enabled ${cf}_encoder && enabled ${cf}_decoder; then
+            DIST_DIR="${DIST_DIR}-${cf}"
+        elif enabled ${cf}_encoder; then
+            DIST_DIR="${DIST_DIR}-${cf}cx"
+        elif enabled ${cf}_decoder; then
+            DIST_DIR="${DIST_DIR}-${cf}dx"
+        fi
+    done
+    enabled debug_libs && DIST_DIR="${DIST_DIR}-debug"
+    enabled codec_srcs && DIST_DIR="${DIST_DIR}-src"
+    ! enabled postproc && DIST_DIR="${DIST_DIR}-nopost"
+    ! enabled multithread && DIST_DIR="${DIST_DIR}-nomt"
+    enabled eval_limit && DIST_DIR="${DIST_DIR}-eval"
+    ! enabled install_docs && DIST_DIR="${DIST_DIR}-nodocs"
+    DIST_DIR="${DIST_DIR}-${tgt_isa}-${tgt_os}"
+    case "${tgt_os}" in
+    win*) enabled static_msvcrt && DIST_DIR="${DIST_DIR}mt" || DIST_DIR="${DIST_DIR}md"
+          DIST_DIR="${DIST_DIR}-${tgt_cc}"
+          ;;
+    esac
+    if [ -f "${source_path}/build/make/version.sh" ]; then
+        local ver=`"$source_path/build/make/version.sh" --bare $source_path`
+        DIST_DIR="${DIST_DIR}-${ver}"
+    fi
+    enabled child || echo "DIST_DIR?=${DIST_DIR}" >> config.mk
+    enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
+
+    #
+    # Write makefiles for all enabled targets
+    #
+    for tgt in libs examples docs solution; do
+        local tgt_fn="$tgt-$toolchain.mk"
+
+        if enabled $tgt; then
+            echo "Creating makefiles for ${toolchain} ${tgt}"
+            write_common_target_config_mk $tgt_fn ${BUILD_PFX}vpx_config.h
+            #write_${tgt}_config
+        fi
+    done
+
+}
+
+process_detect() {
+    if [ -z "$CC" ]; then
+        echo "Bypassing toolchain for environment detection."
+        enable external_build
+        check_header() {
+            log fake_check_header "$@"
+            header=$1
+            shift
+            var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
+            disable $var
+            case $header in
+                stdio.h)
+                    true;
+                ;;
+                *)
+                    local result=false
+                    for d in "$@"; do
+                        [ -f "${d##-I}/$header" ] && result=true && break
+                    done
+                    ${result:-true}
+            esac && enable $var
+        }
+        check_ld() {
+            true
+        }
+    fi
+    check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
+    check_ld <<EOF || die "Toolchain is unable to link executables"
+int main(void) {return 0;}
+EOF
+    # check system headers
+    check_header stdint.h
+    check_header pthread.h
+    check_header sys/mman.h
+
+    check_header vpx_ports/vpx_integer.h -I${source_path} && enable vpx_ports
+}
+
+process_toolchain() {
+    process_common_toolchain
+
+    # Handle universal binaries for this architecture
+    case $toolchain in
+        universal-darwin*)
+            local darwin_ver=${tgt_os##darwin}
+            fat_bin_archs="$fat_bin_archs ppc32-${tgt_os}-gcc"
+
+            # Intel
+            fat_bin_archs="$fat_bin_archs x86-${tgt_os}-${tgt_cc}"
+            if [ $darwin_ver -gt 8 ]; then
+                fat_bin_archs="$fat_bin_archs x86_64-${tgt_os}-${tgt_cc}"
+            fi
+            ;;
+    esac
+
+
+    # Enable some useful compiler flags
+    if enabled gcc; then
+        enabled werror && check_add_cflags -Werror
+        check_add_cflags -Wall
+        check_add_cflags -Wdeclaration-after-statement
+        check_add_cflags -Wdisabled-optimization
+        check_add_cflags -Wpointer-arith
+        check_add_cflags -Wtype-limits
+        check_add_cflags -Wcast-qual
+        enabled extra_warnings || check_add_cflags -Wno-unused
+    fi
+
+    if enabled icc; then
+        enabled werror && check_add_cflags -Werror
+        check_add_cflags -Wall
+        check_add_cflags -Wpointer-arith
+
+        # ICC has a number of floating point optimizations that we disable
+        # in favor of deterministic output WRT to other compilers
+        add_cflags -fp-model precise
+    fi
+
+    # Enable extra, harmless warnings. These might provide additional insight
+    # to what the compiler is doing and why, but in general, but they shouldn't
+    # be treated as fatal, even if we're treating warnings as errors.
+    GCC_EXTRA_WARNINGS="
+        -Wdisabled-optimization
+        -Winline
+    "
+    enabled gcc && EXTRA_WARNINGS="${GCC_EXTRA_WARNINGS}"
+    RVCT_EXTRA_WARNINGS="
+        --remarks
+    "
+    enabled rvct && EXTRA_WARNINGS="${RVCT_EXTRA_WARNINGS}"
+    if enabled extra_warnings; then
+        for w in ${EXTRA_WARNINGS}; do
+            check_add_cflags ${w}
+            enabled gcc && enabled werror && check_add_cflags -Wno-error=${w}
+        done
+    fi
+
+    # ccache only really works on gcc toolchains
+    enabled gcc || soft_disable ccache
+    if enabled mips; then
+        enable dequant_tokens
+	enable dc_recon
+    fi
+
+    # Enable the postbuild target if building for visual studio.
+    case "$tgt_cc" in
+        vs*) enable msvs
+             enable solution
+             vs_version=${tgt_cc##vs}
+             all_targets="${all_targets} solution"
+             INLINE=__inline
+             FORCEINLINE=__forceinline
+        ;;
+    esac
+
+    # Other toolchain specific defaults
+    case $toolchain in x86*|ppc*|universal*) soft_enable postproc;; esac
+}
+
+
+##
+## END APPLICATION SPECIFIC CONFIGURATION
+##
+CONFIGURE_ARGS="$@"
+process "$@"
+cat <<EOF > ${BUILD_PFX}vpx_config.c
+static const char* const cfg = "$CONFIGURE_ARGS";
+const char *vpx_codec_build_config(void) {return cfg;}
+EOF
diff --git a/docs.mk b/docs.mk
new file mode 100644
index 0000000..3e7b5cd
--- /dev/null
+++ b/docs.mk
@@ -0,0 +1,54 @@
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+INSTALL_MAPS += docs/%    docs/%
+INSTALL_MAPS += src/%     %
+INSTALL_MAPS += %         %
+
+# Static documentation authored in doxygen
+CODEC_DOX :=    mainpage.dox \
+		keywords.dox \
+		usage.dox \
+		usage_cx.dox \
+		usage_dx.dox \
+
+# Other doxy files sourced in Markdown
+TXT_DOX-$(CONFIG_VP8)          += vp8_api1_migration.dox
+vp8_api1_migration.dox.DESC     = VP8 API 1.x Migration
+
+TXT_DOX = $(call enabled,TXT_DOX)
+
+%.dox: %.txt
+	@echo "    [DOXY] $@"
+	@$(SRC_PATH_BARE)/examples/gen_example_doxy.php \
+             $(@:.dox=)  "$($@.DESC)" > $@ < $<
+
+
+EXAMPLE_PATH += $(SRC_PATH_BARE) #for CHANGELOG, README, etc
+
+doxyfile: libs.doxy_template libs.doxy examples.doxy
+	@echo "    [CREATE] $@"
+	@cat $^ > $@
+	@echo "STRIP_FROM_PATH += $(SRC_PATH_BARE) $(BUILD_ROOT)" >> $@
+	@echo "INPUT += $(addprefix $(SRC_PATH_BARE)/,$(CODEC_DOX))" >> $@;
+	@echo "INPUT += $(TXT_DOX)" >> $@;
+	@echo "EXAMPLE_PATH += $(EXAMPLE_PATH)" >> $@
+
+CLEAN-OBJS += doxyfile $(wildcard docs/html/*)
+docs/html/index.html: doxyfile $(CODEC_DOX) $(TXT_DOX)
+	@echo "    [DOXYGEN] $<"
+	@doxygen $<
+DOCS-yes += docs/html/index.html
+
+INSTALL-DOCS-yes = $(wildcard docs/html/*)
+INSTALL-DOCS-$(CONFIG_CODEC_SRCS) += $(addprefix src/,$(CODEC_DOX))
+INSTALL-DOCS-$(CONFIG_CODEC_SRCS) += src/libs.doxy_template
+INSTALL-DOCS-yes                  += CHANGELOG
+INSTALL-DOCS-yes                  += README
diff --git a/example_xma.c b/example_xma.c
new file mode 100644
index 0000000..cc4e591
--- /dev/null
+++ b/example_xma.c
@@ -0,0 +1,213 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+/* This is a simple program showing how to initialize the decoder in XMA mode */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#define VPX_CODEC_DISABLE_COMPAT 1
+#include "vpx_config.h"
+#include "vpx_decoder.h"
+#include "vpx_integer.h"
+#if CONFIG_VP8_DECODER
+#include "vp8dx.h"
+#endif
+
+static char *exec_name;
+static int   verbose = 0;
+
+static const struct
+{
+    const char *name;
+    const vpx_codec_iface_t *iface;
+} ifaces[] =
+{
+#if CONFIG_VP8_DECODER
+    {"vp8",  &vpx_codec_vp8_dx_algo},
+#endif
+};
+
+static void usage_exit(void)
+{
+    int i;
+
+    printf("Usage: %s <options>\n\n"
+           "Options:\n"
+           "\t--codec <name>\tCodec to use (default=%s)\n"
+           "\t-h <height>\tHeight of the simulated video frame, in pixels\n"
+           "\t-w <width> \tWidth of the simulated video frame, in pixels\n"
+           "\t-v         \tVerbose mode (show individual segment sizes)\n"
+           "\t--help     \tShow this message\n"
+           "\n"
+           "Included decoders:\n"
+           "\n",
+           exec_name,
+           ifaces[0].name);
+
+    for (i = 0; i < sizeof(ifaces) / sizeof(ifaces[0]); i++)
+        printf("    %-6s - %s\n",
+               ifaces[i].name,
+               vpx_codec_iface_name(ifaces[i].iface));
+
+    exit(EXIT_FAILURE);
+}
+
+static void usage_error(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    vprintf(fmt, ap);
+    printf("\n");
+    usage_exit();
+}
+
+void my_mem_dtor(vpx_codec_mmap_t *mmap)
+{
+    if (verbose)
+        printf("freeing segment %d\n", mmap->id);
+
+    free(mmap->priv);
+}
+
+int main(int argc, char **argv)
+{
+    vpx_codec_ctx_t           decoder;
+    vpx_codec_iface_t        *iface = ifaces[0].iface;
+    vpx_codec_iter_t          iter;
+    vpx_codec_dec_cfg_t       cfg;
+    vpx_codec_err_t           res = VPX_CODEC_OK;
+    unsigned int            alloc_sz = 0;
+    unsigned int            w = 352;
+    unsigned int            h = 288;
+    int                     i;
+
+    exec_name = argv[0];
+
+    for (i = 1; i < argc; i++)
+    {
+        if (!strcmp(argv[i], "--codec"))
+        {
+            if (i + 1 < argc)
+            {
+                int j, k = -1;
+
+                i++;
+
+                for (j = 0; j < sizeof(ifaces) / sizeof(ifaces[0]); j++)
+                    if (!strcmp(ifaces[j].name, argv[i]))
+                        k = j;
+
+                if (k >= 0)
+                    iface = ifaces[k].iface;
+                else
+                    usage_error("Error: Unrecognized argument (%s) to --codec\n",
+                                argv[i]);
+            }
+            else
+                usage_error("Error: Option --codec requires argument.\n");
+        }
+        else if (!strcmp(argv[i], "-v"))
+            verbose = 1;
+        else if (!strcmp(argv[i], "-h"))
+            if (i + 1 < argc)
+            {
+                h = atoi(argv[++i]);
+            }
+            else
+                usage_error("Error: Option -h requires argument.\n");
+        else if (!strcmp(argv[i], "-w"))
+            if (i + 1 < argc)
+            {
+                w = atoi(argv[++i]);
+            }
+            else
+                usage_error("Error: Option -w requires argument.\n");
+        else if (!strcmp(argv[i], "--help"))
+            usage_exit();
+        else
+            usage_error("Error: Unrecognized option %s\n\n", argv[i]);
+    }
+
+    if (argc == 1)
+        printf("Using built-in defaults. For options, rerun with --help\n\n");
+
+    /* XMA mode is not supported on all decoders! */
+    if (!(vpx_codec_get_caps(iface) & VPX_CODEC_CAP_XMA))
+    {
+        printf("%s does not support XMA mode!\n", vpx_codec_iface_name(iface));
+        return EXIT_FAILURE;
+    }
+
+    /* The codec knows how much memory to allocate based on the size of the
+     * encoded frames. This data can be parsed from the bitstream with
+     * vpx_codec_peek_stream_info() if a bitstream is available. Otherwise,
+     * a fixed size can be used that will be the upper limit on the frame
+     * size the decoder can decode.
+     */
+    cfg.w = w;
+    cfg.h = h;
+
+    /* Initialize the decoder in XMA mode. */
+    if (vpx_codec_dec_init(&decoder, iface, &cfg, VPX_CODEC_USE_XMA))
+    {
+        printf("Failed to initialize decoder in XMA mode: %s\n", vpx_codec_error(&decoder));
+        return EXIT_FAILURE;
+    }
+
+    /* Iterate through the list of memory maps, allocating them with the
+     * requested alignment.
+     */
+    iter = NULL;
+
+    do
+    {
+        vpx_codec_mmap_t  mmap;
+        unsigned int    align;
+
+        res = vpx_codec_get_mem_map(&decoder, &mmap, &iter);
+        align = mmap.align ? mmap.align - 1 : 0;
+
+        if (!res)
+        {
+            if (verbose)
+                printf("Allocating segment %u, size %lu, align %u %s\n",
+                       mmap.id, mmap.sz, mmap.align,
+                       mmap.flags & VPX_CODEC_MEM_ZERO ? "(ZEROED)" : "");
+
+            if (mmap.flags & VPX_CODEC_MEM_ZERO)
+                mmap.priv = calloc(1, mmap.sz + align);
+            else
+                mmap.priv = malloc(mmap.sz + align);
+
+            mmap.base = (void *)((((uintptr_t)mmap.priv) + align) & ~(uintptr_t)align);
+            mmap.dtor = my_mem_dtor;
+            alloc_sz += mmap.sz + align;
+
+            if (vpx_codec_set_mem_map(&decoder, &mmap, 1))
+            {
+                printf("Failed to set mmap: %s\n", vpx_codec_error(&decoder));
+                return EXIT_FAILURE;
+            }
+        }
+        else if (res != VPX_CODEC_LIST_END)
+        {
+            printf("Failed to get mmap: %s\n", vpx_codec_error(&decoder));
+            return EXIT_FAILURE;
+        }
+    }
+    while (res != VPX_CODEC_LIST_END);
+
+    printf("%s\n    %d bytes external memory required for %dx%d.\n",
+           decoder.name, alloc_sz, cfg.w, cfg.h);
+    vpx_codec_destroy(&decoder);
+    return EXIT_SUCCESS;
+
+}
diff --git a/examples.mk b/examples.mk
new file mode 100644
index 0000000..036a423
--- /dev/null
+++ b/examples.mk
@@ -0,0 +1,231 @@
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+# List of examples to build. UTILS are files that are taken from the source
+# tree directly, and GEN_EXAMPLES are files that are created from the
+# examples folder.
+UTILS-$(CONFIG_DECODERS)    += ivfdec.c
+ivfdec.SRCS                 += md5_utils.c md5_utils.h
+ivfdec.SRCS                 += vpx_ports/vpx_timer.h
+ivfdec.SRCS                 += vpx_ports/vpx_integer.h
+ivfdec.SRCS                 += args.c args.h vpx_ports/config.h
+ivfdec.GUID                  = BA5FE66F-38DD-E034-F542-B1578C5FB950
+ivfdec.DESCRIPTION           = Full featured decoder
+UTILS-$(CONFIG_ENCODERS)    += ivfenc.c
+ivfenc.SRCS                 += args.c args.h vpx_ports/config.h
+ivfenc.SRCS                 += vpx_ports/mem_ops.h vpx_ports/mem_ops_aligned.h
+ivfenc.GUID                  = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
+ivfenc.DESCRIPTION           = Full featured encoder
+UTILS-$(CONFIG_DECODERS)    += example_xma.c
+example_xma.GUID             = A955FC4A-73F1-44F7-135E-30D84D32F022
+example_xma.DESCRIPTION      = External Memory Allocation mode usage
+
+GEN_EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
+simple_decoder.GUID              = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
+simple_decoder.DESCRIPTION       = Simplified decoder loop
+GEN_EXAMPLES-$(CONFIG_DECODERS) += postproc.c
+postproc.GUID                    = 65E33355-F35E-4088-884D-3FD4905881D7
+postproc.DESCRIPTION             = Decoder postprocessor control
+GEN_EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
+decode_to_md5.SRCS              += md5_utils.h md5_utils.c
+decode_to_md5.GUID               = 59120B9B-2735-4BFE-B022-146CA340FE42
+decode_to_md5.DESCRIPTION        = Frame by frame MD5 checksum
+
+GEN_EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
+simple_encoder.GUID              = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
+simple_encoder.DESCRIPTION       = Simplified encoder loop
+GEN_EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
+twopass_encoder.GUID             = 73494FA6-4AF9-4763-8FBB-265C92402FD8
+twopass_encoder.DESCRIPTION      = Two-pass encoder loop
+GEN_EXAMPLES-$(CONFIG_ENCODERS) += force_keyframe.c
+force_keyframe.GUID              = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
+force_keyframe.DESCRIPTION       = Force generation of keyframes
+ifeq ($(CONFIG_DECODERS),yes)
+GEN_EXAMPLES-$(CONFIG_ENCODERS) += decode_with_drops.c
+endif
+decode_with_drops.GUID           = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
+decode_with_drops.DESCRIPTION    = Drops frames while decoding
+GEN_EXAMPLES-$(CONFIG_ENCODERS) += error_resilient.c
+error_resilient.GUID             = DF5837B9-4145-4F92-A031-44E4F832E00C
+error_resilient.DESCRIPTION      = Error Resiliency Feature
+
+GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_scalable_patterns.c
+vp8_scalable_patterns.GUID          = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
+vp8_scalable_patterns.DESCRIPTION   = VP8 Scalable Bitstream Patterns
+GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_set_maps.c
+vp8_set_maps.GUID                   = ECB2D24D-98B8-4015-A465-A4AF3DCC145F
+vp8_set_maps.DESCRIPTION            = VP8 set active and ROI maps
+GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c
+vp8cx_set_ref.GUID                  = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
+vp8cx_set_ref.DESCRIPTION           = VP8 set encoder reference frame
+
+
+# Handle extra library flags depending on codec configuration
+CODEC_EXTRA_LIBS-$(CONFIG_VP8)         += m
+
+#
+# End of specified files. The rest of the build rules should happen
+# automagically from here.
+#
+
+
+# Examples need different flags based on whether we're building
+# from an installed tree or a version controlled tree. Determine
+# the proper paths.
+ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
+    LIB_PATH := $(SRC_PATH_BARE)/../lib
+    INC_PATH := $(SRC_PATH_BARE)/../include
+else
+    LIB_PATH-yes                     += $(if $(BUILD_PFX),$(BUILD_PFX),.)
+    INC_PATH-yes                     += $(SRC_PATH_BARE)/vpx_codec
+    INC_PATH-yes                     += $(SRC_PATH_BARE)/vpx_ports
+    INC_PATH-$(CONFIG_VP8_DECODER)   += $(SRC_PATH_BARE)/vp8
+    INC_PATH-$(CONFIG_VP8_ENCODER)   += $(SRC_PATH_BARE)/vp8
+    LIB_PATH := $(call enabled,LIB_PATH)
+    INC_PATH := $(call enabled,INC_PATH)
+endif
+CFLAGS += $(addprefix -I,$(INC_PATH))
+LDFLAGS += $(addprefix -L,$(LIB_PATH))
+
+
+# Expand list of selected examples to build (as specified above)
+UTILS           = $(call enabled,UTILS)
+GEN_EXAMPLES    = $(call enabled,GEN_EXAMPLES)
+ALL_EXAMPLES    = $(UTILS) $(GEN_EXAMPLES)
+ALL_SRCS        = $(foreach ex,$(ALL_EXAMPLES),$($(ex:.c=).SRCS))
+CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
+
+
+# Expand all example sources into a variable containing all sources
+# for that example (not just them main one specified in UTILS/GEN_EXAMPLES)
+# and add this file to the list (for MSVS workspace generation)
+$(foreach ex,$(ALL_EXAMPLES),$(eval $(ex:.c=).SRCS += $(ex) examples.mk))
+
+
+# If this is a universal (fat) binary, then all the subarchitectures have
+# already been built and our job is to stitch them together. The
+# BUILD_OBJS variable indicates whether we should be building
+# (compiling, linking) the library. The LIPO_OBJS variable indicates
+# that we're stitching.
+$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes)
+
+
+# Create build/install dependencies for all examples. The common case
+# is handled here. The MSVS case is handled below.
+NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
+INSTALL-BINS-$(NOT_MSVS)   += $(addprefix bin/,$(ALL_EXAMPLES:.c=))
+INSTALL-SRCS-yes           += $(ALL_SRCS)
+OBJS-$(NOT_MSVS)           += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS)))
+BINS-$(NOT_MSVS)           += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=))
+
+
+# Instantiate linker template for all examples.
+CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
+$(foreach bin,$(BINS-yes),\
+    $(if $(BUILD_OBJS),$(eval $(bin): $(LIB_PATH)/lib$(CODEC_LIB).a))\
+    $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\
+        $(call objs,$($(notdir $(bin)).SRCS)) \
+        -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
+        )))\
+    $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\
+    )
+
+
+# Rules to generate the GEN_EXAMPLES sources
+.PRECIOUS: %.c
+CLEAN-OBJS += $(GEN_EXAMPLES)
+%.c: examples/%.txt
+	@echo "    [EXAMPLE] $@"
+	@$(SRC_PATH_BARE)/examples/gen_example_code.sh $< > $@
+
+
+# The following pairs define a mapping of locations in the distribution
+# tree to locations in the source/build trees.
+INSTALL_MAPS += src/%.c   %.c
+INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
+INSTALL_MAPS += bin/%     %
+INSTALL_MAPS += %         %
+
+
+# Set up additional MSVS environment
+ifeq ($(CONFIG_MSVS),yes)
+CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
+# This variable uses deferred expansion intentionally, since the results of
+# $(wildcard) may change during the course of the Make.
+VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
+INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/%  $(p)/Release/%)
+endif
+
+# Build Visual Studio Projects. We use a template here to instantiate
+# explicit rules rather than using an implicit rule because we want to
+# leverage make's VPATH searching rather than specifying the paths on
+# each file in ALL_EXAMPLES. This has the unfortunate side effect that
+# touching the source files trigger a rebuild of the project files
+# even though there is no real dependency there (the dependency is on
+# the makefiles). We may want to revisit this.
+define vcproj_template
+$(1): $($(1:.vcproj=).SRCS)
+	@echo "    [vcproj] $$@"
+	$$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
+            --exe\
+            --target=$$(TOOLCHAIN)\
+            --name=$$(@:.vcproj=)\
+            --ver=$$(CONFIG_VS_VERSION)\
+            --proj-guid=$$($$(@:.vcproj=).GUID)\
+            $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
+            --out=$$@ $$(CFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) -lwinmm $$^
+endef
+PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES:.c=.vcproj)
+INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
+                               $(addprefix bin/$(p)/,$(ALL_EXAMPLES:.c=.exe)))
+$(foreach proj,$(call enabled,PROJECTS),\
+    $(eval $(call vcproj_template,$(proj))))
+
+
+
+#
+# Documentation Rules
+#
+%.dox: examples/%.txt
+	@echo "    [DOXY] $@"
+	@$(SRC_PATH_BARE)/examples/gen_example_text.sh $< | \
+         $(SRC_PATH_BARE)/examples/gen_example_doxy.php \
+             example_$(@:.dox=)  $(@:.dox=.c) > $@
+
+%.dox: %.c
+	@echo "    [DOXY] $@"
+	@echo "/*!\page example_$(@:.dox=) $(@:.dox=)" > $@
+	@echo "   \includelineno $(notdir $<)" >> $@
+	@echo "*/" >> $@
+
+samples.dox: examples.mk
+	@echo "    [DOXY] $@"
+	@echo "/*!\page samples Sample Code" > $@
+	@echo "    This SDK includes a number of sample applications."\
+	      "each sample documents a feature of the SDK in both prose"\
+	      "and the associated C code. In general, later samples"\
+	      "build upon prior samples, so it is best to work through the"\
+	      "list in order. The following samples are included: ">>$@
+	@$(foreach ex,$(GEN_EXAMPLES:.c=),\
+	   echo "     - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
+	@echo >> $@
+	@echo "    In addition, the SDK contains a number of utilities."\
+              "Since these utilities are built upon the concepts described"\
+              "in the sample code listed above, they are not documented in"\
+              "pieces like the samples are. Thir sourcre is included here"\
+              "for reference. The following utilities are included:" >> $@
+	@$(foreach ex,$(UTILS:.c=),\
+	   echo "     - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
+	@echo "*/" >> $@
+
+CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
+DOCS-yes += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
+examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox)
+	@echo "INPUT += $^" > $@
diff --git a/examples/decode_to_md5.txt b/examples/decode_to_md5.txt
new file mode 100644
index 0000000..0599b13
--- /dev/null
+++ b/examples/decode_to_md5.txt
@@ -0,0 +1,48 @@
+@TEMPLATE decoder_tmpl.c
+Frame-by-frame MD5 Checksum
+===========================
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+This example builds upon the simple decoder loop to show how checksums
+of the decoded output can be generated. These are used for validating
+decoder implementations against the reference implementation, for example.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+
+MD5 algorithm
+-------------
+The Message-Digest 5 (MD5) is a well known hash function. We have provided
+an implementation derived from the RSA Data Security, Inc. MD5 Message-Digest
+Algorithm for your use. Our implmentation only changes the interface of this
+reference code. You must include the `md5_utils.h` header for access to these
+functions.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_INCLUDES
+#include "md5_utils.h"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_INCLUDES
+
+
+Processing The Decoded Data
+---------------------------
+Each row of the image is passed to the MD5 accumulator. First the Y plane
+is processed, then U, then V. It is important to honor the image's `stride`
+values.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
+unsigned char  md5_sum[16];
+md5_ctx_t      md5;
+int            i;
+
+md5_init(&md5);
+
+for(plane=0; plane < 3; plane++) {
+    unsigned char *buf =img->planes[plane];
+
+    for(y=0; y<img->d_h >> (plane?1:0); y++) {
+        md5_update(&md5, buf, img->d_w >> (plane?1:0));
+        buf += img->stride[plane];
+    }
+}
+
+md5_finalize(&md5, md5_sum);
+for(i=0; i<16; i++)
+    fprintf(outfile, "%02x",md5_sum[i]);
+fprintf(outfile, "  img-%dx%d-%04d.i420\n", img->d_w, img->d_h,
+        frame_cnt);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
diff --git a/examples/decode_with_drops.txt b/examples/decode_with_drops.txt
new file mode 100644
index 0000000..fb77a7e
--- /dev/null
+++ b/examples/decode_with_drops.txt
@@ -0,0 +1,73 @@
+@TEMPLATE decoder_tmpl.c
+Decode With Drops Example
+=========================
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+This is an example utility which drops a series of frames, as specified
+on the command line. This is useful for observing the error recovery
+features of the codec.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+
+Usage
+-----
+This example adds a single argument to the `simple_decoder` example,
+which specifies the range or pattern of frames to drop. The parameter is
+parsed as follows:
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
+if(argc!=4)
+    die("Usage: %s <infile> <outfile> <N-M|N/M>\n", argv[0]);
+{
+    char *nptr;
+    n = strtol(argv[3], &nptr, 0);
+    m = strtol(nptr+1, NULL, 0);
+    is_range = *nptr == '-';
+    if(!n || !m || (*nptr != '-' && *nptr != '/'))
+        die("Couldn't parse pattern %s\n", argv[3]);
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
+
+
+Dropping A Range Of Frames
+--------------------------
+To drop a range of frames, specify the starting frame and the ending
+frame to drop, separated by a dash. The following command will drop
+frames 5 through 10 (base 1).
+
+  $ ./decode_with_drops in.ivf out.i420 5-10
+
+
+Dropping A Pattern Of Frames
+----------------------------
+To drop a pattern of frames, specify the number of frames to drop and
+the number of frames after which to repeat the pattern, separated by
+a forward-slash. The following command will drop 3 of 7 frames.
+Specifically, it will decode 4 frames, then drop 3 frames, and then
+repeat.
+
+  $ ./decode_with_drops in.ivf out.i420 3/7
+
+
+Extra Variables
+---------------
+This example maintains the pattern passed on the command line in the
+`n`, `m`, and `is_range` variables:
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS
+int              n, m, is_range;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_VARS
+
+
+Making The Drop Decision
+------------------------
+The example decides whether to drop the frame based on the current
+frame number, immediately before decoding the frame.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE
+if((is_range && frame_cnt >= n && frame_cnt <= m)
+   ||(!is_range && m - (frame_cnt-1)%m <= n)) {
+   putc('X', stdout);
+   continue;
+}
+putc('.', stdout);
+fflush(stdout);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRE_DECODE
diff --git a/examples/decoder_tmpl.c b/examples/decoder_tmpl.c
new file mode 100644
index 0000000..deea449
--- /dev/null
+++ b/examples/decoder_tmpl.c
@@ -0,0 +1,102 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+/*
+@*INTRODUCTION
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#define VPX_CODEC_DISABLE_COMPAT 1
+#include "vpx_decoder.h"
+#if CONFIG_VP8_DECODER && !defined(interface)
+#include "vp8dx.h"
+#define interface (&vpx_codec_vp8_dx_algo)
+#endif
+@EXTRA_INCLUDES
+
+
+#define IVF_FILE_HDR_SZ  (32)
+#define IVF_FRAME_HDR_SZ (12)
+
+static unsigned int mem_get_le32(const unsigned char *mem) {
+    return (mem[3] << 24)|(mem[2] << 16)|(mem[1] << 8)|(mem[0]);
+}
+
+static void die(const char *fmt, ...) {
+    va_list ap;
+
+    va_start(ap, fmt);
+    vprintf(fmt, ap);
+    if(fmt[strlen(fmt)-1] != '\n')
+        printf("\n");
+    exit(EXIT_FAILURE);
+}
+
+@DIE_CODEC
+
+int main(int argc, char **argv) {
+    FILE            *infile, *outfile;
+    vpx_codec_ctx_t  codec;
+    int              flags = 0, frame_cnt = 0;
+    unsigned char    file_hdr[IVF_FILE_HDR_SZ];
+    unsigned char    frame_hdr[IVF_FRAME_HDR_SZ];
+    unsigned char    frame[256*1024];
+    vpx_codec_err_t  res;
+@@@@EXTRA_VARS
+
+    (void)res;
+    /* Open files */
+@@@@USAGE
+    if(!(infile = fopen(argv[1], "rb")))
+        die("Failed to open %s for reading", argv[1]);
+    if(!(outfile = fopen(argv[2], "wb")))
+        die("Failed to open %s for writing", argv[2]);
+
+    /* Read file header */
+    fread(file_hdr, 1, IVF_FILE_HDR_SZ, infile);
+    if(!(file_hdr[0]=='D' && file_hdr[1]=='K' && file_hdr[2]=='I'
+         && file_hdr[3]=='F'))
+        die("%s is not an IVF file.", argv[1]);
+
+    printf("Using %s\n",vpx_codec_iface_name(interface));
+@@@@DEC_INIT
+
+    /* Read each frame */
+    while(fread(frame_hdr, 1, IVF_FRAME_HDR_SZ, infile) == IVF_FRAME_HDR_SZ) {
+        int               frame_sz = mem_get_le32(frame_hdr);
+        vpx_codec_iter_t  iter = NULL;
+        vpx_image_t      *img;
+
+
+        frame_cnt++;
+        if(frame_sz > sizeof(frame))
+            die("Frame %d data too big for example code buffer", frame_sz);
+        if(fread(frame, 1, frame_sz, infile) != frame_sz)
+            die("Frame %d failed to read complete frame", frame_cnt);
+
+@@@@@@@@PRE_DECODE
+@@@@@@@@DECODE
+
+        /* Write decoded data to disk */
+@@@@@@@@GET_FRAME
+            unsigned int plane, y;
+
+@@@@@@@@@@@@PROCESS_DX
+        }
+    }
+    printf("Processed %d frames.\n",frame_cnt);
+@@@@DESTROY
+
+    fclose(outfile);
+    fclose(infile);
+    return EXIT_SUCCESS;
+}
diff --git a/examples/decoder_tmpl.txt b/examples/decoder_tmpl.txt
new file mode 100644
index 0000000..3287d50
--- /dev/null
+++ b/examples/decoder_tmpl.txt
@@ -0,0 +1,61 @@
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
+#define VPX_CODEC_DISABLE_COMPAT 1
+#include "vpx_decoder.h"
+#include "vp8dx.h"
+#define interface (&vpx_codec_vp8_dx_algo)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INCLUDES
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC
+static void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
+    const char *detail = vpx_codec_error_detail(ctx);
+
+    printf("%s: %s\n", s, vpx_codec_error(ctx));
+    if(detail)
+        printf("    %s\n",detail);
+    exit(EXIT_FAILURE);
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
+if(argc!=3)
+    die("Usage: %s <infile> <outfile>\n", argv[0]);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INIT
+/* Initialize codec */
+if(vpx_codec_dec_init(&codec, interface, NULL, flags))
+    die_codec(&codec, "Failed to initialize decoder");
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEC_INIT
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DECODE
+/* Decode the frame */
+if(vpx_codec_decode(&codec, frame, frame_sz, NULL, 0))
+    die_codec(&codec, "Failed to decode frame");
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DECODE
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GET_FRAME
+while((img = vpx_codec_get_frame(&codec, &iter))) {
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GET_FRAME
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
+for(plane=0; plane < 3; plane++) {
+    unsigned char *buf =img->planes[plane];
+
+    for(y=0; y<img->d_h >> (plane?1:0); y++) {
+        fwrite(buf, 1, img->d_w >> (plane?1:0), outfile);
+        buf += img->stride[plane];
+    }
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
+if(vpx_codec_destroy(&codec))
+    die_codec(&codec, "Failed to destroy codec");
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
diff --git a/examples/encoder_tmpl.c b/examples/encoder_tmpl.c
new file mode 100644
index 0000000..2df893a
--- /dev/null
+++ b/examples/encoder_tmpl.c
@@ -0,0 +1,189 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+/*
+@*INTRODUCTION
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#define VPX_CODEC_DISABLE_COMPAT 1
+#include "vpx_encoder.h"
+#if CONFIG_VP8_ENCODER && !defined(interface)
+#include "vp8cx.h"
+#define interface (&vpx_codec_vp8_cx_algo)
+#define fourcc    0x30385056
+#endif
+@EXTRA_INCLUDES
+
+#define IVF_FILE_HDR_SZ  (32)
+#define IVF_FRAME_HDR_SZ (12)
+
+static void mem_put_le16(char *mem, unsigned int val) {
+    mem[0] = val;
+    mem[1] = val>>8;
+}
+
+static void mem_put_le32(char *mem, unsigned int val) {
+    mem[0] = val;
+    mem[1] = val>>8;
+    mem[2] = val>>16;
+    mem[3] = val>>24;
+}
+
+static void die(const char *fmt, ...) {
+    va_list ap;
+
+    va_start(ap, fmt);
+    vprintf(fmt, ap);
+    if(fmt[strlen(fmt)-1] != '\n')
+        printf("\n");
+    exit(EXIT_FAILURE);
+}
+
+@DIE_CODEC
+
+static int read_frame(FILE *f, vpx_image_t *img) {
+    size_t nbytes, to_read;
+    int    res = 1;
+
+    to_read = img->w*img->h*3/2;
+    nbytes = fread(img->planes[0], 1, to_read, f);
+    if(nbytes != to_read) {
+        res = 0;
+        if(nbytes > 0)
+            printf("Warning: Read partial frame. Check your width & height!\n");
+    }
+    return res;
+}
+
+static void write_ivf_file_header(FILE *outfile,
+                                  const vpx_codec_enc_cfg_t *cfg,
+                                  int frame_cnt) {
+    char header[32];
+
+    if(cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS)
+        return;
+    header[0] = 'D';
+    header[1] = 'K';
+    header[2] = 'I';
+    header[3] = 'F';
+    mem_put_le16(header+4,  0);                   /* version */
+    mem_put_le16(header+6,  32);                  /* headersize */
+    mem_put_le32(header+8,  fourcc);              /* headersize */
+    mem_put_le16(header+12, cfg->g_w);            /* width */
+    mem_put_le16(header+14, cfg->g_h);            /* height */
+    mem_put_le32(header+16, cfg->g_timebase.den); /* rate */
+    mem_put_le32(header+20, cfg->g_timebase.num); /* scale */
+    mem_put_le32(header+24, frame_cnt);           /* length */
+    mem_put_le32(header+28, 0);                   /* unused */
+
+    fwrite(header, 1, 32, outfile);
+}
+
+
+static void write_ivf_frame_header(FILE *outfile,
+                                   const vpx_codec_cx_pkt_t *pkt)
+{
+    char             header[12];
+    vpx_codec_pts_t  pts;
+
+    if(pkt->kind != VPX_CODEC_CX_FRAME_PKT)
+        return;
+
+    pts = pkt->data.frame.pts;
+    mem_put_le32(header, pkt->data.frame.sz);
+    mem_put_le32(header+4, pts&0xFFFFFFFF);
+    mem_put_le32(header+8, pts >> 32);
+
+    fwrite(header, 1, 12, outfile);
+}
+
+int main(int argc, char **argv) {
+    FILE                *infile, *outfile;
+    vpx_codec_ctx_t      codec;
+    vpx_codec_enc_cfg_t  cfg;
+    int                  frame_cnt = 0;
+    unsigned char        file_hdr[IVF_FILE_HDR_SZ];
+    unsigned char        frame_hdr[IVF_FRAME_HDR_SZ];
+    vpx_image_t          raw;
+    vpx_codec_err_t      res;
+    long                 width;
+    long                 height;
+    int                  frame_avail;
+    int                  got_data;
+    int                  flags = 0;
+@@@@TWOPASS_VARS
+
+    /* Open files */
+@@@@USAGE
+    width = strtol(argv[1], NULL, 0);
+    height = strtol(argv[2], NULL, 0);
+    if(width < 16 || width%2 || height <16 || height%2)
+        die("Invalid resolution: %ldx%ld", width, height);
+    if(!vpx_img_alloc(&raw, IMG_FMT_YV12, width, height, 1))
+        die("Faile to allocate image", width, height);
+    if(!(outfile = fopen(argv[4], "wb")))
+        die("Failed to open %s for writing", argv[4]);
+
+    printf("Using %s\n",vpx_codec_iface_name(interface));
+
+@@@@ENC_DEF_CFG
+
+@@@@ENC_SET_CFG
+@@@@ENC_SET_CFG2
+
+    write_ivf_file_header(outfile, &cfg, 0);
+
+@@@@TWOPASS_LOOP_BEGIN
+
+        /* Open input file for this encoding pass */
+        if(!(infile = fopen(argv[3], "rb")))
+            die("Failed to open %s for reading", argv[3]);
+
+@@@@@@@@ENC_INIT
+
+        frame_avail = 1;
+        got_data = 0;
+        while(frame_avail || got_data) {
+            vpx_codec_iter_t iter = NULL;
+            const vpx_codec_cx_pkt_t *pkt;
+
+@@@@@@@@@@@@PER_FRAME_CFG
+@@@@@@@@@@@@ENCODE_FRAME
+            got_data = 0;
+            while( (pkt = vpx_codec_get_cx_data(&codec, &iter)) ) {
+                got_data = 1;
+                switch(pkt->kind) {
+@@@@@@@@@@@@@@@@PROCESS_FRAME
+@@@@@@@@@@@@@@@@PROCESS_STATS
+                default:
+                    break;
+                }
+                printf(pkt->kind == VPX_CODEC_CX_FRAME_PKT
+                       && (pkt->data.frame.flags & VPX_FRAME_IS_KEY)? "K":".");
+                fflush(stdout);
+            }
+            frame_cnt++;
+        }
+        printf("\n");
+        fclose(infile);
+@@@@TWOPASS_LOOP_END
+
+    printf("Processed %d frames.\n",frame_cnt-1);
+@@@@DESTROY
+
+    /* Try to rewrite the file header with the actual frame count */
+    if(!fseek(outfile, 0, SEEK_SET))
+        write_ivf_file_header(outfile, &cfg, frame_cnt-1);
+    fclose(outfile);
+    return EXIT_SUCCESS;
+}
diff --git a/examples/encoder_tmpl.txt b/examples/encoder_tmpl.txt
new file mode 100644
index 0000000..db1ea77
--- /dev/null
+++ b/examples/encoder_tmpl.txt
@@ -0,0 +1,73 @@
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES
+#define VPX_CODEC_DISABLE_COMPAT 1
+#include "vpx_encoder.h"
+#include "vp8cx.h"
+#define interface (&vpx_codec_vp8_cx_algo)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC
+static void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
+    const char *detail = vpx_codec_error_detail(ctx);
+
+    printf("%s: %s\n", s, vpx_codec_error(ctx));
+    if(detail)
+        printf("    %s\n",detail);
+    exit(EXIT_FAILURE);
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
+if(argc!=5)
+    die("Usage: %s <width> <height> <infile> <outfile>\n", argv[0]);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_DEF_CFG
+/* Populate encoder configuration */
+res = vpx_codec_enc_config_default(interface, &cfg, 0);
+if(res) {
+    printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));
+    return EXIT_FAILURE;
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_DEF_CFG
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG
+/* Update the default configuration with our settings */
+cfg.rc_target_bitrate = width * height * cfg.rc_target_bitrate
+                        / cfg.g_w / cfg.g_h;
+cfg.g_w = width;
+cfg.g_h = height;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INIT
+/* Initialize codec */
+if(vpx_codec_enc_init(&codec, interface, &cfg, 0))
+    die_codec(&codec, "Failed to initialize encoder");
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INIT
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENCODE_FRAME
+frame_avail = read_frame(infile, &raw);
+if(vpx_codec_encode(&codec, frame_avail? &raw : NULL, frame_cnt,
+                    1, flags, VPX_DL_REALTIME))
+    die_codec(&codec, "Failed to encode frame");
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENCODE_FRAME
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_FRAME
+case VPX_CODEC_CX_FRAME_PKT:
+    write_ivf_frame_header(outfile, pkt);
+    fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz,
+           outfile);
+    break;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_FRAME
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
+if(vpx_codec_destroy(&codec))
+    die_codec(&codec, "Failed to destroy codec");
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
diff --git a/examples/error_resilient.txt b/examples/error_resilient.txt
new file mode 100644
index 0000000..e9d0949
--- /dev/null
+++ b/examples/error_resilient.txt
@@ -0,0 +1,25 @@
+@TEMPLATE encoder_tmpl.c
+Error Resiliency Features
+=========================
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+This is an example demonstrating how to enable the error resiliency
+features of the codec.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+
+
+Configuration
+-------------
+Error resiliency is controlled by the g_error_resilient member of the
+configuration structure.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ENC_SET_CFG2
+
+/* Enable error resilient mode */
+cfg.g_error_resilient = 1;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG2
+
+
+Observing The Effects
+---------------------
+Use the `decode_with_drops` example to decode with frames 5-10 dropped.
+Compare the output for a file encoded with this example versus one
+encoded with the `simple_encoder` example.
diff --git a/examples/force_keyframe.txt b/examples/force_keyframe.txt
new file mode 100644
index 0000000..a9c16be
--- /dev/null
+++ b/examples/force_keyframe.txt
@@ -0,0 +1,28 @@
+@TEMPLATE encoder_tmpl.c
+Forcing A Keyframe
+==================
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+This is an example demonstrating how to control placement of keyframes
+on a frame-by-frame basis.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
+
+
+Configuration
+-------------
+Keyframes can be forced by setting the VPX_EFLAG_FORCE_KF bit of the
+flags passed to `vpx_codec_control()`. In this example, we force a
+keyframe every 8 frames.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  PER_FRAME_CFG
+if(!(frame_cnt & 7))
+    flags |= VPX_EFLAG_FORCE_KF;
+else
+    flags &= ~VPX_EFLAG_FORCE_KF;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PER_FRAME_CFG
+
+
+Observing The Effects
+---------------------
+The output of the encoder examples shows a 'K' rather than a dot '.'
+when the encoder generates a keyframe. Note that every 8 frames a 'K'
+is output.
diff --git a/examples/gen_example_code.sh b/examples/gen_example_code.sh
new file mode 100755
index 0000000..f2e45c5
--- /dev/null
+++ b/examples/gen_example_code.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+# gen_example_code.sh
+
+self=$0
+
+die_usage() {
+    echo "Usage: $self <example.txt>"
+    exit 1
+}
+
+die() {
+    echo "$@"
+    exit 1
+}
+
+include_block() {
+    show_bar=$1
+    block_name=${line##*@}
+    indent=${line%%${block_name}}
+    indent=${#indent}
+    [ $indent -eq 1 ] && indent=0
+    local on_block
+    while IFS=$'\n' read -r t_line; do
+        case "$t_line" in
+            \~*\ ${block_name})
+                if [ "x$on_block" == "xyes" ]; then
+                    return 0;
+                else
+                    on_block=yes
+                fi
+                ;;
+            @DEFAULT)
+                if [ "x$on_block" == "xyes" ]; then
+                    include_block $show_bar < "${template%.c}.txt"
+                    return 0
+                fi
+                ;;
+            *)
+                if [ "x$on_block" == "xyes" ]; then
+                    local rem
+                    (( rem = 78 - indent ))
+                    case "$block_name" in
+                      \**) printf "%${indent}s * %s\n" "" "$t_line" ;;
+                        *)
+                            if [ "$show_bar" == "yes" ]; then
+                                printf "%${indent}s%-${rem}s//\n" "" "$t_line"
+                            else
+                                printf "%${indent}s%s\n" "" "$t_line"
+                            fi
+                            ;;
+                    esac
+                fi
+        esac
+    done
+    return 1
+}
+
+txt=$1
+[ -f "$txt" ] || die_usage
+read -r template < "$txt"
+case "$template" in
+    @TEMPLATE*) template=${txt%/*}/${template##@TEMPLATE } ;;
+    *) die "Failed to parse template name from '$template'" ;;
+esac
+
+while IFS=$'\n' read -r line; do
+    case "$line" in
+        @*) include_block yes < "$txt" \
+            || include_block < "${template%.c}.txt" \
+            #|| echo "WARNING: failed to find text for block $block_name" >&2
+            ;;
+        *)  echo "$line" ;;
+    esac
+done < "$template"
diff --git a/examples/gen_example_doxy.php b/examples/gen_example_doxy.php
new file mode 100755
index 0000000..08beade
--- /dev/null
+++ b/examples/gen_example_doxy.php
@@ -0,0 +1,223 @@
+#!/usr/bin/env php
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license and patent
+ *  grant that can be found in the LICENSE file in the root of the source
+ *  tree. All contributing project authors may be found in the AUTHORS
+ *  file in the root of the source tree.
+ */
+
+
+<?php
+
+/* This script converts markdown to doxygen htmlonly syntax, nesting the
+ * content inside a \page. It expects input on stdin and outputs on stdout.
+ *
+ * Usage: gen_example_doxy.php <page_identifier> "<page description>"
+ */
+
+
+$geshi_path = dirname($argv[0])."/includes/geshi/geshi/"; // Language files
+$tmp_token  = '<!-- I wanna rock you, Chaka Khan -->';
+
+// Include prerequisites or exit
+if(!include_once('includes/PHP-Markdown-Extra-1.2.3/markdown.php'))
+  die("Cannot load Markdown transformer.\n");
+if(!include_once('includes/PHP-SmartyPants-1.5.1e/smartypants.php'))
+  die("Cannot load SmartyPants transformer.\n");
+if(!include_once('includes/geshi/geshi.php'))
+  die("Cannot load GeSHi transformer.\n");
+// ASCIIMathPHP?
+// HTML::Toc?
+// Tidy?
+// Prince?
+
+/**
+ *  Generate XHTML body
+ *
+ */
+
+$page_body = file_get_contents('php://stdin');
+
+// Transform any MathML expressions in the body text
+$regexp = '/\[\[(.*?)\]\]/'; // Double square bracket delimiters
+$page_body = preg_replace_callback($regexp, 'ASCIIMathPHPCallback', $page_body);
+
+// Fix ASCIIMathPHP's output
+$page_body = fix_asciiMath($page_body);
+
+// Wrap block-style <math> elements in <p>, since Markdown doesn't.
+$page_body = preg_replace('/\n(<math.*<\/math>)\n/', '<p class="eq_para">$1</p>', $page_body);
+
+// Transform the body text to HTML
+$page_body = Markdown($page_body);
+
+// Preprocess code blocks
+// Decode XML entities. GeSHi doesn't anticipate that
+// Markdown has already done this.
+$regexp = '|<pre><code>(.*?)<\/code><\/pre>|si';
+while (preg_match($regexp, $page_body, $matches) > 0)
+{
+  // Replace 1st match with token
+  $page_body = preg_replace($regexp, $tmp_token, $page_body, 1);
+  $block_new = $matches[1];
+  // Un-encode ampersand entities
+  $block_new = decode_markdown($block_new);
+  // Replace token with revised string
+  $page_body = preg_replace("|$tmp_token|", '<div class="codeblock">'.$block_new.'</div>', $page_body);
+}
+
+// Run GeSHi over code blocks
+$regexp   = '|<div class="codeblock">(.*?)<\/div>|si';
+$language = 'c';
+
+while (preg_match($regexp, $page_body, $matches))
+{
+  $geshi = new GeSHi($matches[1], $language);
+  $geshi->set_language_path($geshi_path);
+  $block_new = $geshi->parse_code();
+  // Strip annoying final newline
+  $block_new = preg_replace('|\n&nbsp;<\/pre>|', '</pre>' , $block_new);
+  // Remove style attribute (TODO: Research this in GeSHi)
+  $block_new = preg_replace('| style="font-family:monospace;"|', '' , $block_new);
+  $page_body = preg_replace($regexp, $block_new, $page_body, 1);
+  unset($geshi);    // Clean up
+}
+unset($block_new);  // Clean up
+
+// Apply typographic flourishes
+$page_body = SmartyPants($page_body);
+
+
+/**
+ *  Generate Doxygen Body
+ *
+ */
+$page_id=(isset($argv[1]))?$argv[1]:"";
+$page_desc=(isset($argv[2]))?$argv[2]:"";
+print "/*!\\page ".$page_id." ".$page_desc."\n\\htmlonly\n";
+print $page_body;
+print "\\endhtmlonly\n*/\n";
+
+// ---------------------------------------------------------
+
+/**
+ * decode_markdown()
+ *
+ * Markdown encodes '&', '<' and '>' in detected code
+ * blocks, as a convenience. This will restore the
+ * encoded entities to ordinary characters, since a
+ * downstream transformer (like GeSHi) may not
+ * anticipate this.
+ *
+ **********************************************************/
+
+function decode_markdown($input)
+{
+  $out = FALSE;
+
+  $entities   = array ('|&amp;|'
+                      ,'|&lt;|'
+                      ,'|&gt;|'
+                      );
+  $characters = array ('&'
+                      ,'<'
+                      ,'>'
+                      );
+  $input = preg_replace($entities, $characters, $input);
+  $out = $input;
+
+  return $out;
+}
+
+
+/**
+ * ASCIIMathML parser
+ * http://tinyurl.com/ASCIIMathPHP
+ *
+ * @PARAM mtch_arr array - Array of ASCIIMath expressions
+ *   as returned by preg_replace_callback([pattern]). First
+ *   dimension is the full matched string (with delimiter);
+ *   2nd dimension is the undelimited contents (typically
+ *   a capture group).
+ *
+ **********************************************************/
+
+function ASCIIMathPHPCallback($mtch_arr)
+{
+  $txt = trim($mtch_arr[1]);
+
+  include('includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.cfg.php');
+  require_once('includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.class.php');
+
+  static $asciimath;
+
+  if (!isset($asciimath)) $asciimath = new ASCIIMathPHP($symbol_arr);
+
+  $math_attr_arr = array('displaystyle' => 'true');
+
+  $asciimath->setExpr($txt);
+  $asciimath->genMathML($math_attr_arr);
+
+  return($asciimath->getMathML());
+}
+
+/**
+ * fix_asciiMath()
+ *
+ * ASCIIMath pretty-prints its output, with linefeeds
+ * and tabs. Causes unexpected behavior in some renderers.
+ * This flattens <math> blocks.
+ *
+ * @PARAM page_body str - The <body> element of an
+ * XHTML page to transform.
+ *
+ **********************************************************/
+
+function fix_asciiMath($page_body)
+{
+  $out = FALSE;
+
+  // Remove linefeeds and whitespace in <math> elements
+  $tags_bad  = array('/(<math.*?>)\n*\s*/'
+                    , '/(<mstyle.*?>)\n*\s*/'
+                    , '/(<\/mstyle>)\n*\s*/'
+                    , '/(<mrow.*?>)\n*\s*/'
+                    , '/(<\/mrow>)\n*\s*/'
+                    , '/(<mo.*?>)\n*\s*/'
+                    , '/(<\/mo>)\n*\s*/'
+                    , '/(<mi.*?>)\n*\s*/'
+                    , '/(<\/mi>)\n*\s*/'
+                    , '/(<mn.*?>)\n*\s*/'
+                    , '/(<\/mn>)\n*\s*/'
+                    , '/(<mtext.*?>)\n*\s*/'
+                    , '/(<\/mtext>)\n*\s*/'
+                    , '/(<msqrt.*?>)\n*\s*/'
+                    , '/(<\/msqrt>)\n*\s*/'
+                    , '/(<mfrac.*?>)\n*\s*/'
+                    , '/(<\/mfrac>)\n*\s*/'
+                    );
+  $tags_good = array( '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    , '$1'
+                    );
+  $out = preg_replace($tags_bad, $tags_good, $page_body);
+
+  return $out;
+
+}
diff --git a/examples/gen_example_text.sh b/examples/gen_example_text.sh
new file mode 100755
index 0000000..0e1f796
--- /dev/null
+++ b/examples/gen_example_text.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+##
+##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+##
+##  Use of this source code is governed by a BSD-style license and patent
+##  grant that can be found in the LICENSE file in the root of the source
+##  tree. All contributing project authors may be found in the AUTHORS
+##  file in the root of the source tree.
+##
+
+
+# gen_example_text.sh
+
+self=$0
+
+die_usage() {
+    echo "Usage: $self <example.txt>"
+    exit 1
+}
+
+die() {
+    echo "$@"
+    exit 1
+}
+
+include_block() {
+    local on_block
+    while IFS=$'\n' read -r t_line; do
+        case "$t_line" in
+            \~*\ ${block_name})
+                if [ "x$on_block" == "xyes" ]; then
+                    return 0;
+                else
+                    on_block=yes
+                fi
+                ;;
+            *)
+                if [ "x$on_block" == "xyes" ]; then
+                    echo "$t_line"
+                fi
+                ;;
+        esac
+    done
+    echo "WARNING: failed to find text for block $block_name" >&2
+    return 1
+}
+
+txt=$1
+[ -f "$txt" ] || die_usage
+read -r template < "$txt"
+case "$template" in
+    @TEMPLATE*) template=${txt%/*}/${template##@TEMPLATE } ;;
+    *) die "Failed to parse template name from '$template'" ;;
+esac
+
+fence="~~~~~~~~~"
+fence="${fence}${fence}"
+fence="${fence}${fence}"
+fence="${fence}${fence}"
+while IFS=$'\n' read -r line; do
+    case "$line" in
+        @TEMPLATE*)
+            template=${template##@TEMPLATE }
+            template=${template%.c}.txt
+            ;;
+        @DEFAULT)
+            include_block < "$template"
+            ;;
+        ~~~*)
+            block_name=${line##~* }
+            [ "$block_name" == "INTRODUCTION" ] || echo "$fence"
+            ;;
+        *)  echo "$line"
+            ;;
+    esac
+done < "$txt"
+
+echo
+echo "Putting It All Together"
+echo "======================="
+echo "${fence}"
+${self%/*}/gen_example_code.sh "${txt}"
+echo "${fence}"
diff --git a/examples/includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.cfg.php b/examples/includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.cfg.php
new file mode 100644
index 0000000..06f7979
--- /dev/null
+++ b/examples/includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.cfg.php
@@ -0,0 +1,218 @@
+<?php
+
+$symbol_arr = array(
+
+// Greek symbols
+'alpha' => array( 'input'=>'alpha','tag'=>'mi', 'output'=>'&#' . hexdec('03B1') . ';'),
+'beta'  => array( 'input'=>'beta','tag'=>'mi', 'output'=>'&#' . hexdec('03B2') . ';'),
+'chi'   => array( 'input'=>'chi','tag'=>'mi', 'output'=>'&#' . hexdec('03C7') . ';'),
+'delta' => array( 'input'=>'delta','tag'=>'mi', 'output'=>'&#' . hexdec('03B4') . ';'),
+'Delta' => array( 'input'=>'Delta','tag'=>'mo', 'output'=>'&#' . hexdec('0394') . ';'),
+'epsi'  => array( 'input'=>'epsi','tag'=>'mi', 'output'=>'&#' . hexdec('03B5') . ';'),
+'varepsilon'    => array( 'input'=>'varepsilon','tag'=>'mi', 'output'=>'&#' . hexdec('025B') . ';'),
+'eta'   => array( 'input'=>'eta','tag'=>'mi', 'output'=>'&#' . hexdec('03B7') . ';'),
+'gamma' => array( 'input'=>'gamma','tag'=>'mi', 'output'=>'&#' . hexdec('03B3') . ';'),
+'Gamma' => array( 'input'=>'Gamma','tag'=>'mi', 'output'=>'&#' . hexdec('0393') . ';'),
+'iota'  => array( 'input'=>'iota','tag'=>'mi', 'output'=>'&#' . hexdec('03B9') . ';'),
+'kappa' => array( 'input'=>'kappa','tag'=>'mi', 'output'=>'&#' . hexdec('03BA') . ';'),
+'lambda'    => array( 'input'=>'lambda','tag'=>'mi', 'output'=>'&#' . hexdec('03BB') . ';'),
+'Lambda'    => array( 'input'=>'Lambda','tag'=>'mo', 'output'=>'&#' . hexdec('039B') . ';'),
+'mu'    => array( 'input'=>'mu','tag'=>'mi', 'output'=>'&#' . hexdec('03BC') . ';'),
+'nu'    => array( 'input'=>'nu','tag'=>'mi', 'output'=>'&#' . hexdec('03BD') . ';'),
+'omega' => array( 'input'=>'omega','tag'=>'mi', 'output'=>'&#' . hexdec('03C9') . ';'),
+'Omega' => array( 'input'=>'Omega','tag'=>'mo', 'output'=>'&#' . hexdec('03A9') . ';'),
+'phi'   => array( 'input'=>'phi','tag'=>'mi', 'output'=>'&#' . hexdec('03C6') . ';'),
+'varphi'    => array( 'input'=>'varphi','tag'=>'mi', 'output'=>'&#' . hexdec('03D5') . ';'),
+'Phi'   => array( 'input'=>'Phi','tag'=>'mo', 'output'=>'&#' . hexdec('03A6') . ';'),
+'pi'    => array( 'input'=>'pi','tag'=>'mi', 'output'=>'&#' . hexdec('03C0') . ';'),
+'Pi'    => array( 'input'=>'Pi','tag'=>'mo', 'output'=>'&#' . hexdec('03A0') . ';'),
+'psi'   => array( 'input'=>'psi','tag'=>'mi', 'output'=>'&#' . hexdec('03C8') . ';'),
+'rho'   => array( 'input'=>'rho','tag'=>'mi', 'output'=>'&#' . hexdec('03C1') . ';'),
+'sigma' => array( 'input'=>'sigma','tag'=>'mi', 'output'=>'&#' . hexdec('03C3') . ';'),
+'Sigma' => array( 'input'=>'Sigma','tag'=>'mo', 'output'=>'&#' . hexdec('03A3') . ';'),
+'tau'   => array( 'input'=>'tau','tag'=>'mi', 'output'=>'&#' . hexdec('03C4') . ';'),
+'theta' => array( 'input'=>'theta','tag'=>'mi', 'output'=>'&#' . hexdec('03B8') . ';'),
+'vartheta'  => array( 'input'=>'vartheta','tag'=>'mi', 'output'=>'&#' . hexdec('03D1') . ';'),
+'Theta' => array( 'input'=>'Theta','tag'=>'mo', 'output'=>'&#' . hexdec('0398') . ';'),
+'upsilon'   => array( 'input'=>'upsilon','tag'=>'mi', 'output'=>'&#' . hexdec('03C5') . ';'),
+'xi'    => array( 'input'=>'xi','tag'=>'mi', 'output'=>'&#' . hexdec('03BE') . ';'),
+'Xi'    => array( 'input'=>'alpha','tag'=>'mo', 'output'=>'&#' . hexdec('039E') . ';'),
+'zeta'  => array( 'input'=>'zeta','tag'=>'mi', 'output'=>'&#' . hexdec('03B6') . ';'),
+
+// Binary operation symbols
+'*'     => array( 'input'=>'*','tag'=>'mo', 'output'=>'&#' . hexdec('22C5') . ';'),
+'**'    => array( 'input'=>'**','tag'=>'mo', 'output'=>'&#' . hexdec('22C6') . ';'),
+'//'    => array( 'input'=>'//','tag'=>'mo', 'output'=>'/'),
+'\\\\'  => array( 'input'=>'\\\\','tag'=>'mo', 'output'=>'\\'),
+'xx'    => array( 'input'=>'xx','tag'=>'mo', 'output'=>'&#' . hexdec('00D7') . ';'),
+'-:'    => array( 'input'=>'-:','tag'=>'mo', 'output'=>'&#' . hexdec('00F7') . ';'),
+'@'     => array( 'input'=>'@','tag'=>'mo', 'output'=>'&#' . hexdec('2218') . ';'),
+'o+'    => array( 'input'=>'o+','tag'=>'mo', 'output'=>'&#' . hexdec('2295') . ';'),
+'ox'    => array( 'input'=>'ox','tag'=>'mo', 'output'=>'&#' . hexdec('2297') . ';'),
+'sum'   => array( 'input'=>'sum','tag'=>'mo', 'output'=>'&#' . hexdec('2211') . ';', 'underover'=>TRUE),
+'prod'  => array( 'input'=>'prod','tag'=>'mo', 'output'=>'&#' . hexdec('220F') . ';', 'underover'=>TRUE),
+'^^'    => array( 'input'=>'^^','tag'=>'mo', 'output'=>'&#' . hexdec('2227') . ';'),
+'^^^'   => array( 'input'=>'^^^','tag'=>'mo', 'output'=>'&#' . hexdec('22C0') . ';', 'underover'=>TRUE),
+'vv'    => array( 'input'=>'vv','tag'=>'mo', 'output'=>'&#' . hexdec('2228') . ';'),
+'vvv'   => array( 'input'=>'vvv','tag'=>'mo', 'output'=>'&#' . hexdec('22C1') . ';', 'underover'=>TRUE),
+'nn'    => array( 'input'=>'nn','tag'=>'mo', 'output'=>'&#' . hexdec('2229') . ';'),
+'nnn'   => array( 'input'=>'nnn','tag'=>'mo', 'output'=>'&#' . hexdec('22C5') . ';', 'underover'=>TRUE),
+'uu'    => array( 'input'=>'uu','tag'=>'mo', 'output'=>'&#' . hexdec('222A') . ';'),
+'uuu'   => array( 'input'=>'uuu','tag'=>'mo', 'output'=>'&#' . hexdec('22C3') . ';', 'underover'=>TRUE),
+
+// Binary relation symbols
+'!='    => array( 'input'=>'!=','tag'=>'mo', 'output'=>'&#' . hexdec('2260') . ';'),
+':='    => array( 'input'=>':=','tag'=>'mo', 'output'=>':=' ),              /* 2005-06-05 wes */
+'<'     => array( 'input'=>'<','tag'=>'mo', 'output'=>'&lt;'),
+'lt'    => array( 'input'=>'lt','tag'=>'mo', 'output'=>'&lt;'),             /* 2005-06-05 wes */
+'<='    => array( 'input'=>'<=','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'),
+'lt='   => array( 'input'=>'lt=','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'),
+'le'    => array( 'input'=>'le','tag'=>'mo', 'output'=>'&#' . hexdec('2264') . ';'),    /* 2005-06-05 wes */
+'>'     => array( 'input'=>'>','tag'=>'mo', 'output'=>'&gt;'),
+'>='    => array( 'input'=>'>=','tag'=>'mo', 'output'=>'&#' . hexdec('2265') . ';'),
+'qeq'   => array( 'input'=>'geq','tag'=>'mo', 'output'=>'&#' . hexdec('2265') . ';'),
+'-<'    => array( 'input'=>'-<','tag'=>'mo', 'output'=>'&#' . hexdec('227A') . ';'),
+'-lt'   => array( 'input'=>'-lt','tag'=>'mo', 'output'=>'&#' . hexdec('227A') . ';'),
+'>-'    => array( 'input'=>'>-','tag'=>'mo', 'output'=>'&#' . hexdec('227B') . ';'),
+'in'    => array( 'input'=>'in','tag'=>'mo', 'output'=>'&#' . hexdec('2208') . ';'),
+'!in'   => array( 'input'=>'!in','tag'=>'mo', 'output'=>'&#' . hexdec('2209') . ';'),
+'sub'   => array( 'input'=>'sub','tag'=>'mo', 'output'=>'&#' . hexdec('2282') . ';'),
+'sup'   => array( 'input'=>'sup','tag'=>'mo', 'output'=>'&#' . hexdec('2283') . ';'),
+'sube'  => array( 'input'=>'sube','tag'=>'mo', 'output'=>'&#' . hexdec('2286') . ';'),
+'supe'  => array( 'input'=>'supe','tag'=>'mo', 'output'=>'&#' . hexdec('2287') . ';'),
+'-='    => array( 'input'=>'-=','tag'=>'mo', 'output'=>'&#' . hexdec('2261') . ';'),
+'~='    => array( 'input'=>'~=','tag'=>'mo', 'output'=>'&#' . hexdec('2245') . ';'),
+'~~'    => array( 'input'=>'~~','tag'=>'mo', 'output'=>'&#' . hexdec('2248') . ';'),
+'prop'  => array( 'input'=>'prop','tag'=>'mo', 'output'=>'&#' . hexdec('221D') . ';'),
+
+// Logical symbols
+'and'   => array( 'input'=>'and','tag'=>'mtext', 'output'=>'and', 'space'=>'1ex'),
+'or'    => array( 'input'=>'or','tag'=>'mtext', 'output'=>'or', 'space'=>'1ex'),
+'not'   => array( 'input'=>'not','tag'=>'mo', 'output'=>'&#' . hexdec('00AC') . ';'),
+'=>'    => array( 'input'=>'=>','tag'=>'mo', 'output'=>'&#' . hexdec('21D2') . ';'),
+'if'    => array( 'input'=>'if','tag'=>'mo', 'output'=>'if', 'space'=>'1ex'),
+'iff'   => array( 'input'=>'iff','tag'=>'mo', 'output'=>'&#' . hexdec('21D4') . ';'),
+'<=>'   => array( 'input'=>'iff','tag'=>'mo', 'output'=>'&#' . hexdec('21D4') . ';'), /* 2005-06-07 wes */
+'AA'    => array( 'input'=>'AA','tag'=>'mo', 'output'=>'&#' . hexdec('2200') . ';'),
+'EE'    => array( 'input'=>'EE','tag'=>'mo', 'output'=>'&#' . hexdec('2203') . ';'),
+'_|_'   => array( 'input'=>'_|_','tag'=>'mo', 'output'=>'&#' . hexdec('22A5') . ';'),
+'TT'    => array( 'input'=>'TT','tag'=>'mo', 'output'=>'&#' . hexdec('22A4') . ';'),
+'|-'    => array( 'input'=>'|-','tag'=>'mo', 'output'=>'&#' . hexdec('22A2') . ';'),
+'|='    => array( 'input'=>'|=','tag'=>'mo', 'output'=>'&#' . hexdec('22A8') . ';'),
+
+// Miscellaneous symbols
+'ang'   => array('input'=>'ang','tag'=>'mo','output'=>'&#' . hexdec('2220') . ';'),
+'deg'   => array('input'=>'deg','tag'=>'mo','output'=>'&#' . hexdec('00B0') . ';'),
+'int'   => array( 'input'=>'int','tag'=>'mo', 'output'=>'&#' . hexdec('222B') . ';'),
+'dx'    => array( 'input'=>'dx','tag'=>'mi', 'output'=>'{:d x:}', 'definition'=>TRUE), /* 2005-06-11 wes */
+'dy'    => array( 'input'=>'dy','tag'=>'mi', 'output'=>'{:d y:}', 'definition'=>TRUE), /* 2005-06-11 wes */
+'dz'    => array( 'input'=>'dz','tag'=>'mi', 'output'=>'{:d z:}', 'definition'=>TRUE), /* 2005-06-11 wes */
+'dt'    => array( 'input'=>'dt','tag'=>'mi', 'output'=>'{:d t:}', 'definition'=>TRUE), /* 2005-06-11 wes */
+'oint'  => array( 'input'=>'oint','tag'=>'mo', 'output'=>'&#' . hexdec('222E') . ';'),
+'del'   => array( 'input'=>'del','tag'=>'mo', 'output'=>'&#' . hexdec('2202') . ';'),
+'grad'  => array( 'input'=>'grad','tag'=>'mo', 'output'=>'&#' . hexdec('2207') . ';'),
+'+-'    => array( 'input'=>'+-','tag'=>'mo', 'output'=>'&#' . hexdec('00B1') . ';'),
+'O/'    => array( 'input'=>'0/','tag'=>'mo', 'output'=>'&#' . hexdec('2205') . ';'),
+'oo'    => array( 'input'=>'oo','tag'=>'mo', 'output'=>'&#' . hexdec('221E') . ';'),
+'aleph' => array( 'input'=>'aleph','tag'=>'mo', 'output'=>'&#' . hexdec('2135') . ';'),
+'...'   => array( 'input'=>'int','tag'=>'mo', 'output'=>'...'),
+'~' => array( 'input'=>'!~','tag'=>'mo', 'output'=>'&#' . hexdec('0020') . ';'),
+'\\ '   => array( 'input'=>'~','tag'=>'mo', 'output'=>'&#' . hexdec('00A0') . ';'),
+'quad'  => array( 'input'=>'quad','tag'=>'mo', 'output'=>'&#' . hexdec('00A0') . ';&#' . hexdec('00A0') . ';'),
+'qquad' => array( 'input'=>'qquad','tag'=>'mo', 'output'=>  '&#' . hexdec('00A0') . ';&#' . hexdec('00A0') . ';&#' . hexdec('00A0') . ';'),
+'cdots' => array( 'input'=>'cdots','tag'=>'mo', 'output'=>'&#' . hexdec('22EF') . ';'),
+'vdots' => array( 'input'=>'vdots','tag'=>'mo', 'output'=>'&#' . hexdec('22EE') . ';'), /* 2005-06-11 wes */
+'ddots' => array( 'input'=>'ddots','tag'=>'mo', 'output'=>'&#' . hexdec('22F1') . ';'), /* 2005-06-11 wes */
+'diamond'   => array( 'input'=>'diamond','tag'=>'mo', 'output'=>'&#' . hexdec('22C4') . ';'),
+'square'    => array( 'input'=>'square','tag'=>'mo', 'output'=>'&#' . hexdec('25A1') . ';'),
+'|_'    => array( 'input'=>'|_','tag'=>'mo', 'output'=>'&#' . hexdec('230A') . ';'),
+'_|'    => array( 'input'=>'_|','tag'=>'mo', 'output'=>'&#' . hexdec('230B') . ';'),
+'|~'    => array( 'input'=>'|~','tag'=>'mo', 'output'=>'&#' . hexdec('2308') . ';'),
+'~|'    => array( 'input'=>'~|','tag'=>'mo', 'output'=>'&#' . hexdec('2309') . ';'),
+'CC'    => array( 'input'=>'CC','tag'=>'mo', 'output'=>'&#' . hexdec('2102') . ';'),
+'NN'    => array( 'input'=>'NN','tag'=>'mo', 'output'=>'&#' . hexdec('2115') . ';'),
+'QQ'    => array( 'input'=>'QQ','tag'=>'mo', 'output'=>'&#' . hexdec('211A') . ';'),
+'RR'    => array( 'input'=>'RR','tag'=>'mo', 'output'=>'&#' . hexdec('211D') . ';'),
+'ZZ'    => array( 'input'=>'ZZ','tag'=>'mo', 'output'=>'&#' . hexdec('2124') . ';'),
+
+// Standard functions
+'lim'   => array( 'input'=>'lim','tag'=>'mo', 'output'=>'lim', 'underover'=>TRUE),
+'Lim'   => array( 'input'=>'Lim','tag'=>'mo', 'output'=>'Lim', 'underover'=>TRUE), /* 2005-06-11 wes */
+'sin'   => array( 'input'=>'sin','tag'=>'mo', 'output'=>'sin', 'unary'=>TRUE, 'func'=>TRUE),
+'cos'   => array( 'input'=>'cos', 'tag'=>'mo', 'output'=>'cos', 'unary'=>TRUE, 'func'=>TRUE),
+'tan'   => array( 'input'=>'tan', 'tag'=>'mo', 'output'=>'tan', 'unary'=>TRUE, 'func'=>TRUE),
+'arcsin'    => array( 'input'=>'arcsin','tag'=>'mo', 'output'=>'arcsin', 'unary'=>TRUE, 'func'=>TRUE), //2006-9-7 DL
+'arccos'    => array( 'input'=>'arccos', 'tag'=>'mo', 'output'=>'arccos', 'unary'=>TRUE, 'func'=>TRUE), //2006-9-7 DL
+'arctan'    => array( 'input'=>'arctan', 'tag'=>'mo', 'output'=>'arctan', 'unary'=>TRUE, 'func'=>TRUE), //2006-9-7 DL
+'sinh'  => array( 'input'=>'sinh','tag'=>'mo', 'output'=>'sinh', 'unary'=>TRUE, 'func'=>TRUE),
+'cosh'  => array( 'input'=>'cosh', 'tag'=>'mo', 'output'=>'cosh', 'unary'=>TRUE, 'func'=>TRUE),
+'tanh'  => array( 'input'=>'tanh', 'tag'=>'mo', 'output'=>'tanh', 'unary'=>TRUE, 'func'=>TRUE),
+'cot'   => array( 'input'=>'cot','tag'=>'mo', 'output'=>'cot', 'unary'=>TRUE, 'func'=>TRUE),
+'sec'   => array( 'input'=>'sec', 'tag'=>'mo', 'output'=>'sec', 'unary'=>TRUE, 'func'=>TRUE),
+'csc'   => array( 'input'=>'csc', 'tag'=>'mo', 'output'=>'csc', 'unary'=>TRUE, 'func'=>TRUE),
+'coth'  => array( 'input'=>'coth','tag'=>'mo', 'output'=>'coth', 'unary'=>TRUE, 'func'=>TRUE),
+'sech'  => array( 'input'=>'sech', 'tag'=>'mo', 'output'=>'sech', 'unary'=>TRUE, 'func'=>TRUE),
+'csch'  => array( 'input'=>'csch', 'tag'=>'mo', 'output'=>'csch', 'unary'=>TRUE, 'func'=>TRUE),
+'log'   => array( 'input'=>'log', 'tag'=>'mo', 'output'=>'log', 'unary'=>TRUE, 'func'=>TRUE),
+'ln'    => array( 'input'=>'ln', 'tag'=>'mo', 'output'=>'ln', 'unary'=>TRUE, 'func'=>TRUE),
+'det'   => array( 'input'=>'det', 'tag'=>'mo', 'output'=>'det', 'unary'=>TRUE, 'func'=>TRUE),
+'dim'   => array( 'input'=>'dim', 'tag'=>'mo', 'output'=>'dim'),
+'mod'   => array( 'input'=>'mod', 'tag'=>'mo', 'output'=>'mod'),
+'gcd'   => array( 'input'=>'gcd', 'tag'=>'mo', 'output'=>'gcd', 'unary'=>TRUE, 'func'=>TRUE),
+'lcm'   => array( 'input'=>'lcm', 'tag'=>'mo', 'output'=>'lcm', 'unary'=>TRUE, 'func'=>TRUE),
+'lub'   => array( 'input'=>'lub', 'tag'=>'mo', 'output'=>'lub'), /* 2005-06-11 wes */
+'glb'   => array( 'input'=>'glb', 'tag'=>'mo', 'output'=>'glb'), /* 2005-06-11 wes */
+'min'   => array( 'input'=>'min', 'tag'=>'mo', 'output'=>'min', 'underover'=>TRUE), /* 2005-06-11 wes */
+'max'   => array( 'input'=>'max', 'tag'=>'mo', 'output'=>'max', 'underover'=>TRUE), /* 2005-06-11 wes */
+'f' => array( 'input'=>'f','tag'=>'mi', 'output'=>'f', 'unary'=>TRUE, 'func'=>TRUE), //2006-9-7 DL
+'g' => array( 'input'=>'g', 'tag'=>'mi', 'output'=>'g', 'unary'=>TRUE, 'func'=>TRUE), //2006-9-7 DL
+
+// Arrows
+'uarr'  => array( 'input'=>'uarr', 'tag'=>'mo', 'output'=>'&#' . hexdec('2191') . ';'),
+'darr'  => array( 'input'=>'darr', 'tag'=>'mo', 'output'=>'&#' . hexdec('2193') . ';'),
+'rarr'  => array( 'input'=>'rarr', 'tag'=>'mo', 'output'=>'&#' . hexdec('2192') . ';'),
+'->'    => array( 'input'=>'->', 'tag'=>'mo', 'output'=>'&#' . hexdec('2192') . ';'),
+'|->'   => array( 'input'=>'|->', 'tag'=>'mo', 'output'=>'&#' . hexdec('21A6') . ';'), /* 2005-06-11 wes */
+'larr'  => array( 'input'=>'larr', 'tag'=>'mo', 'output'=>'&#' . hexdec('2190') . ';'),
+'harr'  => array( 'input'=>'harr', 'tag'=>'mo', 'output'=>'&#' . hexdec('2194') . ';'),
+'rArr'  => array( 'input'=>'rArr', 'tag'=>'mo', 'output'=>'&#' . hexdec('21D2') . ';'),
+'lArr'  => array( 'input'=>'lArr', 'tag'=>'mo', 'output'=>'&#' . hexdec('21D0') . ';'),
+'hArr'  => array( 'input'=>'hArr', 'tag'=>'mo', 'output'=>'&#' . hexdec('21D4') . ';'),
+
+// Commands with argument
+'sqrt'  => array( 'input'=>'sqrt', 'tag'=>'msqrt', 'output'=>'sqrt', 'unary'=>TRUE ),
+'root'  => array( 'input'=>'root', 'tag'=>'mroot', 'output'=>'root', 'binary'=>TRUE ),
+'frac'  => array( 'input'=>'frac', 'tag'=>'mfrac', 'output'=>'/', 'binary'=>TRUE),
+'/'     => array( 'input'=>'/', 'tag'=>'mfrac', 'output'=>'/', 'infix'=>TRUE),
+'_'     => array( 'input'=>'_', 'tag'=>'msub', 'output'=>'_', 'infix'=>TRUE),
+'^'     => array( 'input'=>'^', 'tag'=>'msup', 'output'=>'^', 'infix'=>TRUE),
+'hat'   => array( 'input'=>'hat', 'tag'=>'mover', 'output'=>'&#' . hexdec('005E') . ';', 'unary'=>TRUE, 'acc'=>TRUE),
+'bar'   => array( 'input'=>'bar', 'tag'=>'mover', 'output'=>'&#' . hexdec('00AF') . ';', 'unary'=>TRUE, 'acc'=>TRUE),
+'vec'   => array( 'input'=>'vec', 'tag'=>'mover', 'output'=>'&#' . hexdec('2192') . ';', 'unary'=>TRUE, 'acc'=>TRUE),
+'dot'   => array( 'input'=>'dot', 'tag'=>'mover', 'output'=>'.', 'unary'=>TRUE, 'acc'=>TRUE),
+'ddot'  => array( 'input'=>'ddot', 'tag'=>'mover', 'output'=>'..', 'unary'=>TRUE, 'acc'=>TRUE),
+'ul'    => array( 'input'=>'ul', 'tag'=>'munder', 'output'=>'&#' . hexdec('0332') . ';', 'unary'=>TRUE, 'acc'=>TRUE),
+'avec'  => array( 'input'=>'avec', 'tag'=>'munder', 'output'=>'~', 'unary'=>TRUE, 'acc'=>TRUE),
+'text'  => array( 'input'=>'text', 'tag'=>'mtext', 'output'=>'text', 'unary'=>TRUE),
+'mbox'  => array( 'input'=>'mbox', 'tag'=>'mtext', 'output'=>'mbox', 'unary'=>TRUE),
+'"' => array( 'input'=>'"', 'tag'=>'mtext','output'=>'mbox', 'unary'=>TRUE),
+
+/* 2005-06-05 wes: added stackrel */
+'stackrel' => array( 'input'=>'stackrel', 'tag'=>'mover', 'output'=>'stackrel', 'binary'=>TRUE),
+
+// Grouping brackets
+'('     => array( 'input'=>'(', 'tag'=>'mo', 'output'=>'(', 'left_bracket'=>TRUE),
+')'     => array( 'input'=>')', 'tag'=>'mo', 'output'=>')', 'right_bracket'=>TRUE),
+'['     => array( 'input'=>'[', 'tag'=>'mo', 'output'=>'[', 'left_bracket'=>TRUE),
+']'     => array( 'input'=>']', 'tag'=>'mo', 'output'=>']', 'right_bracket'=>TRUE),
+'{'     => array( 'input'=>'{', 'tag'=>'mo', 'output'=>'{', 'left_bracket'=>TRUE),
+'}'     => array( 'input'=>'}', 'tag'=>'mo', 'output'=>'}', 'right_bracket'=>TRUE),
+'(:'    => array( 'input'=>'(:', 'tag'=>'mo', 'output'=>'&#' . hexdec('2329') . ';', 'left_bracket'=>TRUE),
+':)'    => array( 'input'=>':)', 'tag'=>'mo', 'output'=>'&#' . hexdec('232A') . ';', 'right_bracket'=>TRUE),
+'{:'    => array( 'input'=>'{:', 'tag'=>'mo', 'output'=>'{:', 'left_bracket'=>TRUE, 'invisible'=>TRUE),
+':}'    => array( 'input'=>':}', 'tag'=>'mo', 'output'=>':}', 'right_bracket'=>TRUE ,'invisible'=>TRUE),
+'<<'    => array( 'input'=>'<<', 'tag'=>'mo', 'output'=>'&#' . hexdec('2329') . ';', 'left_bracket'=>TRUE), // 2005-06-07 wes
+'>>'    => array( 'input'=>'>>', 'tag'=>'mo', 'output'=>'&#' . hexdec('232A') . ';', 'right_bracket'=>TRUE) // 2005-06-07 wes
+);
+
+?>
\ No newline at end of file
diff --git a/examples/includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.class.php b/examples/includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.class.php
new file mode 100644
index 0000000..5fb1060
--- /dev/null
+++ b/examples/includes/ASCIIMathPHP-2.0/ASCIIMathPHP-2.0.class.php
@@ -0,0 +1,1119 @@
+<?php
+
+/****
+ * ASCIIMathPHP and associated classes:
+ * -- XMLNode
+ * -- MathMLNode extends XMLNode
+ *
+ * These classes are a PHP port of ASCIIMath
+ * Version 1.3 Feb 19 2004, (c) Peter Jipsen http://www.chapman.edu/~jipsen
+ *
+ * ASCIIMathPHP Version 1.11, 26 April 2006, (c) Kee-Lin Steven Chan (kc56@cornell.edu)
+ *
+ * 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 of the License, 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 (at http://www.gnu.org/copyleft/gpl.html)
+ * for more details.
+ *
+ * ChangeLog
+ *
+ * Ver 2.0
+ * -- PHP5 only version of ASCIIMathPHP
+ *
+ * Ver 1.12.1
+ * -- Included the missing setCurrExpr() method
+ *
+ * Ver 1.12
+ * -- Added changes that David Lippman <DLippman@pierce.ctc.edu> made to bring ASCIIMathPHP up to
+ * ASCIIMath 1.4.7 functionality.
+ * -- Added parseIntExpr, for intermediate expression parsing rule, allowing x^2/x^3 to render as (x^2)/(x^3)
+ * -- Added quotes as another way of designating text; "hello" is equivalent to text(hello)
+ * -- Added FUNC designator to allow sin, cos, etc to act as functions, so sin(x)/x renders as {sin(x)}/x
+ *
+ * Ver 1.11
+ * -- Fixed bug that stopped script execution for incomplete expressions
+ * -- Changed the algorithm for parsing expressions so that it matches the longest string possible (greedy)
+ *
+ * Ver 1.10
+ * -- Added definition support
+ * -- Added stackrel support
+ * -- Added a bunch of different symbols etc. >>, << and definitions like dx, dy, dz etc.
+ *
+ * Ver 1.02
+ * -- Fixed bug with mbox and text
+ * -- Fixed spacing bug with mbox and text
+ *
+ * Ver 1.01
+ * -- Fixed Bug that did not parse symbols greater than a single character
+ * correctly when appearing at end of expression.
+ *
+ ***/
+
+class XMLNode
+{
+    // Private variables
+    var $_id;
+    var $_name;
+    var $_content;
+    var $_mt_elem_flg;
+    var $_attr_arr;
+    var $_child_arr;
+    var $_nmspc;
+    var $_nmspc_alias;
+    var $_parent_id;
+    var $_parent_node;
+
+    function XMLNode($id = NULL)
+    {
+        $this->_id = isset($id) ? $id : md5(uniqid(rand(),1));
+        $this->_name = '';
+        $this->_content = '';
+        $this->_mt_elem_flg = FALSE;
+        $this->_attr_arr = array();
+        $this->_child_arr = array();
+        $this->_nmspc = '';
+        $this->_nmspc_alias = '';
+        $this->_parent_id = FALSE;
+        $this->_parent_node = NULL;
+    }
+
+    function addChild(&$node)
+    {
+        $this->_child_arr[$node->getId()] = $node;
+        $node->setParentId($this->_id);
+        $node->setParentNode($this);
+    }
+
+    function addChildArr(&$node_arr)
+    {
+        $key_arr = array_keys($node_arr);
+        $num_key = count($key_arr);
+
+        for ($i = 0; $i < $num_key; $i++) {
+            $node = $node_arr[$key_arr[$i]];
+            $this->addChild($node);
+        }
+    }
+
+    function insertChildBefore($idx,&$node)
+    {
+        $key_arr = array_keys($this->_child_arr);
+        $num_key = count($key_arr);
+        $tmp_arr = arry();
+
+        for ($i = 0;$i < $num_key;$i++) {
+            if ($i == $idx) {
+                $tmp_arr[$node->getId()] = $node;
+            }
+            $tmp_arr[$key_arr[$i]] = $this->_child_arr[$key_arr[$i]];
+        }
+        $this->_child_arr = $tmp_arr;
+    }
+
+    function insertChildAfter($idx,&$node)
+    {
+        $key_arr = array_keys($this->_child_arr);
+        $num_key = count($key_arr);
+        $tmp_arr = arry();
+
+        for ($i = 0;$i < $num_key;$i++) {
+            $tmp_arr[$key_arr[$i]] = $this->_child_arr[$key_arr[$i]];
+            if ($i == $idx) {
+                $tmp_arr[$node->getId()] = $node;
+            }
+        }
+        $this->_child_arr = $tmp_arr;
+    }
+
+    function setId($id)
+    {
+        $this->_id = $id;
+    }
+
+    function setName($name)
+    {
+        $this->_name = $name;
+    }
+
+    function setNamepace($nmspc)
+    {
+        $this->_nmspc = $nmspc;
+    }
+
+    function setNamespaceAlias($nmspc_alias)
+    {
+        $this->_nmspc_alias = $nmspc_alias;
+    }
+
+    function setContent($content)
+    {
+        $this->_content = $content;
+    }
+
+    function setEmptyElem($mt_elem_flg)
+    {
+        $this->_mt_elem_flg = $mt_elem_flg;
+    }
+
+    function setAttr($attr_nm,$attr_val)
+    {
+        $this->_attr_arr[$attr_nm] = $attr_val;
+    }
+
+    function setAttrArr($attr_arr)
+    {
+        $this->_attr_arr = $attr_arr;
+    }
+
+    function setParentId($id)
+    {
+        $this->_parent_id = $id;
+    }
+
+    function setParentNode(&$node)
+    {
+        $this->_parent_node = $node;
+    }
+
+    function getId()
+    {
+        return($this->_id);
+    }
+
+    function getName()
+    {
+        return($this->_name);
+    }
+
+    function getNamespace()
+    {
+        return($this->_nmspc);
+    }
+
+    function getNamespaceAlias()
+    {
+        return($this->_nmspc_alias);
+    }
+
+    function getContent()
+    {
+        return($this->_content);
+    }
+
+    function getAttr($attr_nm)
+    {
+        if (isset($this->_attr_arr[$attr_nm])) {
+            return($this->_attr_arr[$attr_nm]);
+        } else {
+            return(NULL);
+        }
+    }
+
+    function getAttrArr()
+    {
+        return($this->_attr_arr);
+    }
+
+    function getParentId()
+    {
+        return($this->parent_id);
+    }
+
+    function getParentNode()
+    {
+        return($this->_parent_node);
+    }
+
+    function getChild($id)
+    {
+        if (isset($this->_child_arr[$id])) {
+            return($this->_child_arr[$id]);
+        } else {
+            return(FALSE);
+        }
+    }
+
+    function getFirstChild()
+    {
+        $id_arr = array_keys($this->_child_arr);
+        $num_child = count($id_arr);
+
+        if ($num_child > 0) {
+            return($this->_child_arr[$id_arr[0]]);
+        } else {
+            return(FALSE);
+        }
+    }
+
+    function getLastChild()
+    {
+        $id_arr = array_keys($this->_child_arr);
+        $num_child = count($id_arr);
+
+        if ($num_child > 0) {
+            return($this->_child_arr[$id_arr[$num_child - 1]]);
+        } else {
+            return(FALSE);
+        }
+    }
+
+    function getChildByIdx($idx)
+    {
+        $id_arr = array_keys($this->_child_arr);
+
+        if (isset($this->_child_arr[$id_arr[$idx]])) {
+            return($this->_child_arr[$id_arr[$idx]]);
+        } else {
+            return(FALSE);
+        }
+    }
+
+    function getNumChild()
+    {
+        return(count($this->_child_arr));
+    }
+
+    function removeChild($id)
+    {
+        unset($this->_child_arr[$id]);
+    }
+
+    function removeChildByIdx($idx)
+    {
+        $key_arr = array_keys($this->_child_arr);
+        unset($this->_child_arr[$key_arr[$idx]]);
+    }
+
+    function removeFirstChild()
+    {
+        $key_arr = array_keys($this->_child_arr);
+        unset($this->_child_arr[$key_arr[0]]);
+    }
+
+    function removeLastChild()
+    {
+        $key_arr = array_keys($this->_child_arr);
+        unset($this->_child_arr[$key_arr[count($key_arr)-1]]);
+    }
+
+    function dumpXML($indent_str = "\t")
+    {
+        $attr_txt = $this->_dumpAttr();
+        $name = $this->_dumpName();
+        $xmlns = $this->_dumpXmlns();
+        $lvl = $this->_getCurrentLevel();
+        $indent = str_pad('',$lvl,$indent_str);
+
+        if ($this->_mt_elem_flg) {
+            $tag = "$indent<$name$xmlns$attr_txt />";
+            return($tag);
+        } else {
+            $key_arr = array_keys($this->_child_arr);
+            $num_child = count($key_arr);
+
+            $tag = "$indent<$name$xmlns$attr_txt>$this->_content";
+
+            for ($i = 0;$i < $num_child;$i++) {
+                $node = $this->_child_arr[$key_arr[$i]];
+
+                $child_txt = $node->dumpXML($indent_str);
+                $tag .= "\n$child_txt";
+            }
+
+            $tag .= ($num_child > 0 ? "\n$indent</$name>" : "</$name>");
+            return($tag);
+        }
+    }
+
+    function _dumpAttr()
+    {
+        $id_arr = array_keys($this->_attr_arr);
+        $id_arr_cnt = count($id_arr);
+        $attr_txt = '';
+
+        for($i = 0;$i < $id_arr_cnt;$i++) {
+            $key = $id_arr[$i];
+            $attr_txt .= " $key=\"{$this->_attr_arr[$key]}\"";
+        }
+
+        return($attr_txt);
+    }
+
+    function _dumpName()
+    {
+        $alias = $this->getNamespaceAlias();
+        if ($alias == '') {
+            return($this->getName());
+        } else {
+            return("$alias:" . $this->getName());
+        }
+    }
+
+    function _dumpXmlns()
+    {
+        $nmspc = $this->getNamespace();
+        $alias = $this->getNamespaceAlias();
+
+        if ($nmspc != '') {
+            if ($alias == '') {
+                return(" xmlns=\"" . $nmspc . "\"");
+            } else {
+                return(" xmlns:$alias=\"" . $nmspc . "\"");
+            }
+        } else {
+            return('');
+        }
+    }
+
+    function _getCurrentLevel()
+    {
+        if ($this->_parent_id === FALSE) {
+            return(0);
+        } else {
+            $node = $this->getParentNode();
+            $lvl = $node->_getCurrentLevel();
+            $lvl++;
+            return($lvl);
+        }
+    }
+}
+
+class MathMLNode extends XMLNode
+{
+    function MathMLNode($id = NULL)
+    {
+        parent::XMLNode($id);
+    }
+
+    function removeBrackets()
+    {
+        if ($this->_name == 'mrow') {
+            if ($c_node_0 = $this->getFirstChild()) {
+                $c_node_0->isLeftBracket() ? $this->removeFirstChild() : 0;
+            }
+
+            if ($c_node_0 = $this->getLastChild()) {
+                $c_node_0->isRightBracket() ? $this->removeLastChild() : 0;
+            }
+        }
+    }
+
+    function isLeftBracket()
+    {
+        switch ($this->_content) {
+            case '{':
+            case '[':
+            case '(':
+                return(TRUE);
+                break;
+        }
+        return(FALSE);
+    }
+
+    function isRightBracket()
+    {
+        switch ($this->_content) {
+            case '}':
+            case ']':
+            case ')':
+                return(TRUE);
+                break;
+        }
+        return(FALSE);
+    }
+}
+
+class ASCIIMathPHP
+{
+    var $_expr;
+    var $_curr_expr;
+    var $_prev_expr;
+    var $_symbol_arr;
+    var $_node_arr;
+    var $_node_cntr;
+
+    function ASCIIMathPHP($symbol_arr,$expr = NULL)
+    {
+        $this->_symbol_arr = $symbol_arr;
+        if (isset($expr)) {
+            $this->setExpr($expr);
+        }
+    }
+
+    /**
+     * Returns an empty node (containing a non-breaking space) 26-Apr-2006
+     *
+     * Used when an expression is incomplete
+     *
+     * @return object
+     *
+     * @access private
+     */
+    function emptyNode()
+    {
+        $tmp_node = $this->createNode();
+        $tmp_node->setName('mn');
+        $tmp_node->setContent('&#' . hexdec('200B') . ';');
+        return $tmp_node;
+    }
+
+    function pushExpr($prefix) // 2005-06-11 wes
+    {
+        $this->_curr_expr = $prefix . $this->_curr_expr;
+    }
+
+    function setExpr($expr)
+    {
+        $this->_expr = $expr;
+        $this->_curr_expr = $expr;
+        $this->_prev_expr = $expr;
+
+        $this->_node_arr = array();
+        $this->_node_cntr = 0;
+    }
+
+    function genMathML($attr_arr = NULL)
+    {
+        // <math> node
+        $node_0 = $this->createNode();
+        $node_0->setName('math');
+        $node_0->setNamepace('http://www.w3.org/1998/Math/MathML');
+
+        // <mstyle> node
+        if (isset($attr_arr)) {
+            $node_1 = $this->createNode();
+            $node_1->setName('mstyle');
+            $node_1->setAttrArr($attr_arr);
+
+            $node_arr = $this->parseExpr();
+
+            $node_1->addChildArr($node_arr);
+            $node_0->addChild($node_1);
+        } else {
+            $node_arr = $this->parseExpr();
+            $node_0->addChildArr($node_arr);
+        }
+
+        return TRUE;
+    }
+
+    /*
+    function  mergeNodeArr(&$node_arr_0,&$node_arr_1)
+    {
+        $key_arr_0 = array_keys($node_arr_0);
+        $key_arr_1 = array_keys($node_arr_1);
+
+        $num_key_0 = count($key_arr_0);
+        $num_key_1 = count($key_arr_1);
+
+        $merge_arr = array();
+
+        for ($i = 0;$i < $num_key_0;$i++) {
+            $merge_arr[$key_arr_0[$i]] = $node_arr_0[$key_arr_0[$i]];
+        }
+
+        for ($j = 0;$j < $num_key_1;$i++) {
+            $merge_arr[$key_arr_1[$i]] = $node_arr_1[$key_arr_1[$i]];
+        }
+
+        return($merge_arr);
+    }
+    */
+
+    //Broken out of parseExpr Sept 7, 2006 David Lippman for
+    //ASCIIMathML 1.4.7 compatibility
+    function  parseIntExpr()
+    {
+        $sym_0 = $this->getSymbol();
+        $node_0 = $this->parseSmplExpr();
+        $sym = $this->getSymbol();
+
+        if (isset($sym['infix']) && $sym['input'] != '/') {
+            $this->chopExpr($sym['symlen']);
+            $node_1 = $this->parseSmplExpr();
+
+            if ($node_1 === FALSE) { //show box in place of missing argument
+                $node_1 = $this->emptyNode();//??
+            } else {
+                $node_1->removeBrackets();
+            }
+
+            // If 'sub' -- subscript
+            if ($sym['input'] == '_') {
+
+                $sym_1 = $this->getSymbol();
+
+                // If 'sup' -- superscript
+                if ($sym_1['input'] == '^') {
+                    $this->chopExpr($sym_1['symlen']);
+                    $node_2 = $this->parseSmplExpr();
+                    $node_2->removeBrackets();
+
+                    $node_3 = $this->createNode();
+                    $node_3->setName(isset($sym_0['underover']) ? 'munderover' : 'msubsup');
+                    $node_3->addChild($node_0);
+                    $node_3->addChild($node_1);
+                    $node_3->addChild($node_2);
+
+                    $node_4 = $this->createNode();
+                    $node_4->setName('mrow');
+                    $node_4->addChild($node_3);
+
+                    return $node_4;
+                } else {
+                    $node_2 = $this->createNode();
+                    $node_2->setName(isset($sym_0['underover']) ? 'munder' : 'msub');
+                    $node_2->addChild($node_0);
+                    $node_2->addChild($node_1);
+
+                    return $node_2;
+                }
+            } else {
+                $node_2 = $this->createNode();
+                $node_2->setName($sym['tag']);
+                $node_2->addChild($node_0);
+                $node_2->addChild($node_1);
+
+                return($node_2);
+            }
+        } elseif ($node_0 !== FALSE) {
+            return($node_0);
+        } else {
+            return $this->emptyNode();
+        }
+
+    }
+
+    function  parseExpr()
+    {
+        // Child/Fragment array
+        $node_arr = array();
+
+        // Deal whole expressions like 'ax + by + c = 0' etc.
+        do {
+            $sym_0 = $this->getSymbol();
+            $node_0 = $this->parseIntExpr();
+            $sym = $this->getSymbol();
+            // var_dump($sym);
+
+            if (isset($sym['infix']) && $sym['input'] == '/') {
+                $this->chopExpr($sym['symlen']);
+                $node_1 = $this->parseIntExpr();
+
+                if ($node_1 === FALSE) { //should show box in place of missing argument
+                    $node_1 = $this->emptyNode();
+                    continue;
+                }
+
+                $node_1->removeBrackets();
+
+                // If 'div' -- divide
+                $node_0->removeBrackets();
+                $node_2 = $this->createNode();
+                $node_2->setName($sym['tag']);
+                $node_2->addChild($node_0);
+                $node_2->addChild($node_1);
+                $node_arr[$node_2->getId()] = $node_2;
+
+            } elseif ($node_0 !== FALSE) {
+                $node_arr[$node_0->getId()] = $node_0;
+            }
+        } while (!isset($sym['right_bracket']) && $sym !== FALSE && $sym['output'] != '');
+
+        //var_dump($sym);
+        // Possibly to deal with matrices
+        if (isset($sym['right_bracket'])) {
+            $node_cnt = count($node_arr);
+            $key_node_arr = array_keys($node_arr);
+
+            if ($node_cnt > 1) {
+                $node_5 = $node_arr[$key_node_arr[$node_cnt-1]];
+                $node_6 = $node_arr[$key_node_arr[$node_cnt-2]];
+            } else {
+                $node_5 = FALSE;
+                $node_6 = FALSE;
+            }
+
+            // Dealing with matrices
+            if ($node_5 !== FALSE && $node_6 !== FALSE &&
+                $node_cnt > 1 &&
+                $node_5->getName() == 'mrow' &&
+                $node_6->getName() == 'mo' &&
+                $node_6->getContent() == ',') {
+
+                // Checking if Node 5 has a LastChild
+                if ($node_7 = $node_5->getLastChild()) {
+                    $node_7_cntnt = $node_7->getContent();
+                } else {
+                    $node_7_cntnt = FALSE;
+                }
+
+                // If there is a right bracket
+                if ($node_7 !== FALSE && ($node_7_cntnt == ']' || $node_7_cntnt == ')')) {
+
+                    // Checking if Node 5 has a firstChild
+                    if ($node_8 = $node_5->getFirstChild()) {
+                        $node_8_cntnt = $node_8->getContent();
+                    } else {
+                        $node_8_cntnt = FALSE;
+                    }
+
+                    // If there is a matching left bracket
+                    if ($node_8 !== FALSE &&
+                        (($node_8_cntnt == '(' && $node_7_cntnt == ')' && $sym['output'] != '}') ||
+                        ($node_8_cntnt == '[' && $node_7_cntnt == ']'))) {
+
+                        $is_mtrx_flg = TRUE;
+                        $comma_pos_arr = array();
+
+                        $i = 0;
+
+                        while ($i < $node_cnt && $is_mtrx_flg) {
+                            $tmp_node = $node_arr[$key_node_arr[$i]];
+
+                            if($tmp_node_first = $tmp_node->getFirstChild()) {
+                                $tnfc = $tmp_node_first->getContent();
+                            } else {
+                                $tnfc = FALSE;
+                            }
+
+                            if($tmp_node_last = $tmp_node->getLastChild()) {
+                                $tnlc = $tmp_node_last->getContent();
+                            } else {
+                                $tnlc = FALSE;
+                            }
+
+                            if (isset($key_node_arr[$i+1])) {
+                                $next_tmp_node = $node_arr[$key_node_arr[$i+1]];
+                                $ntnn = $next_tmp_node->getName();
+                                $ntnc = $next_tmp_node->getContent();
+                            } else {
+                                $ntnn = FALSE;
+                                $ntnc = FALSE;
+                            }
+
+                            // Checking each node in node array for matrix criteria
+                            if ($is_mtrx_flg) {
+                                $is_mtrx_flg = $tmp_node->getName() == 'mrow' &&
+                                    ($i == $node_cnt-1 || $ntnn == 'mo' && $ntnc == ',') &&
+                                    $tnfc == $node_8_cntnt && $tnlc == $node_7_cntnt;
+                            }
+
+                            if ($is_mtrx_flg) {
+                                for ($j = 0;$j < $tmp_node->getNumChild();$j++) {
+                                    $tmp_c_node = $tmp_node->getChildByIdx($j);
+
+                                    if ($tmp_c_node->getContent() == ',') {
+                                        $comma_pos_arr[$i][] = $j;
+                                    }
+                                }
+                            }
+
+                            if ($is_mtrx_flg && $i > 1) {
+
+                                $cnt_cpan = isset($comma_pos_arr[$i]) ? count($comma_pos_arr[$i]) : NULL;
+                                $cnt_cpap = isset($comma_pos_arr[$i-2]) ? count($comma_pos_arr[$i-2]) : NULL;
+                                $is_mtrx_flg = $cnt_cpan == $cnt_cpap;
+                            }
+
+                            $i += 2;
+                        }
+
+                        // If the node passes the matrix tests
+                        if ($is_mtrx_flg) {
+                            $tab_node_arr = array();
+
+                            for ($i = 0;$i < $node_cnt;$i += 2) {
+                                $tmp_key_node_arr = array_keys($node_arr);
+                                if (!($tmp_node = $node_arr[$tmp_key_node_arr[0]])) {
+                                    break;
+                                }
+                                $num_child = $tmp_node->getNumChild();
+                                $k = 0;
+
+                                $tmp_node->removeFirstChild();
+
+                                $row_node_arr = array();
+                                $row_frag_node_arr = array();
+
+                                for ($j = 1;$j < ($num_child-1);$j++) {
+                                    if (isset($comma_pos_arr[$i][$k]) &&
+                                        $j == $comma_pos_arr[$i][$k]) {
+
+                                        $tmp_node->removeFirstChild();
+
+                                        $tmp_c_node = $this->createNode();
+                                        $tmp_c_node->setName('mtd');
+                                        $tmp_c_node->addChildArr($row_frag_node_arr);
+                                        $row_frag_node_arr = array();
+
+                                        $row_node_arr[$tmp_c_node->getId()] = $tmp_c_node;
+
+                                        $k++;
+                                    } else {
+
+                                        if ($tmp_c_node = $tmp_node->getFirstChild()) {
+                                            $row_frag_node_arr[$tmp_c_node->getId()] = $tmp_c_node;
+                                            $tmp_node->removeFirstChild();
+                                        }
+                                    }
+                                }
+
+                                $tmp_c_node = $this->createNode();
+                                $tmp_c_node->setName('mtd');
+                                $tmp_c_node->addChildArr($row_frag_node_arr);
+
+                                $row_node_arr[$tmp_c_node->getId()] = $tmp_c_node;
+
+                                if (count($node_arr) > 2) {
+                                    $tmp_key_node_arr = array_keys($node_arr);
+                                    unset($node_arr[$tmp_key_node_arr[0]]);
+                                    unset($node_arr[$tmp_key_node_arr[1]]);
+                                }
+
+                                $tmp_c_node = $this->createNode();
+                                $tmp_c_node->setName('mtr');
+                                $tmp_c_node->addChildArr($row_node_arr);
+
+                                $tab_node_arr[$tmp_c_node->getId()] = $tmp_c_node;
+                            }
+
+                            $tmp_c_node = $this->createNode();
+                            $tmp_c_node->setName('mtable');
+                            $tmp_c_node->addChildArr($tab_node_arr);
+
+                            if (isset($sym['invisible'])) {
+                                $tmp_c_node->setAttr('columnalign','left');
+                            }
+
+                            $key_node_arr = array_keys($node_arr);
+                            $tmp_c_node->setId($key_node_arr[0]);
+
+                            $node_arr[$tmp_c_node->getId()] = $tmp_c_node;
+                        }
+                    }
+                }
+            }
+
+            $this->chopExpr($sym['symlen']);
+            if (!isset($sym['invisible'])) {
+                $node_7 = $this->createNode();
+                $node_7->setName('mo');
+                $node_7->setContent($sym['output']);
+                $node_arr[$node_7->getId()] = $node_7;
+            }
+        }
+
+        return($node_arr);
+    }
+
+    function  parseSmplExpr()
+    {
+        $sym = $this->getSymbol();
+
+        if (!$sym || isset($sym['right_bracket'])) //return FALSE;
+            return $this->emptyNode();
+
+        $this->chopExpr($sym['symlen']);
+
+        // 2005-06-11 wes: add definition type support
+        if(isset($sym['definition'])) {
+            $this->pushExpr($sym['output']);
+            $sym = $this->getSymbol();
+            $this->chopExpr($sym['symlen']);
+        }
+
+        if (isset($sym['left_bracket'])) {
+            $node_arr = $this->parseExpr();
+
+            if (isset($sym['invisible'])) {
+                $node_0 = $this->createNode();
+                $node_0->setName('mrow');
+                $node_0->addChildArr($node_arr);
+
+                return($node_0);
+            } else {
+                $node_0 = $this->createNode();
+                $node_0->setName('mo');
+                $node_0->setContent($sym['output']);
+
+                $node_1 = $this->createNode();
+                $node_1->setName('mrow');
+                $node_1->addChild($node_0);
+                $node_1->addChildArr($node_arr);
+
+                return($node_1);
+            }
+        } elseif (isset($sym['unary'])) {
+
+            if ($sym['input'] == 'sqrt') {
+                $node_0 = $this->parseSmplExpr();
+                $node_0->removeBrackets();
+
+                $node_1 = $this->createNode();
+                $node_1->setName($sym['tag']);
+                $node_1->addChild($node_0);
+
+                return($node_1);
+            } elseif (isset($sym['func'])) { //added 2006-9-7 David Lippman
+                $expr = ltrim($this->getCurrExpr());
+                $st = $expr{0};
+                $node_0 = $this->parseSmplExpr();
+                //$node_0->removeBrackets();
+                if ($st=='^' || $st == '_' || $st=='/' || $st=='|' || $st==',') {
+                    $node_1 = $this->createNode();
+                    $node_1->setName($sym['tag']);
+                    $node_1->setContent($sym['output']);
+                    $this->setCurrExpr($expr);
+                    return($node_1);
+                } else {
+                    $node_1 = $this->createNode();
+                    $node_1->setName('mrow');
+                    $node_2 = $this->createNode();
+                    $node_2->setName($sym['tag']);
+                    $node_2->setContent($sym['output']);
+                    $node_1->addChild($node_2);
+                    $node_1->addChild($node_0);
+                    return($node_1);
+                }
+            } elseif ($sym['input'] == 'text' || $sym['input'] == 'mbox' || $sym['input'] == '"') {
+                $expr = ltrim($this->getCurrExpr());
+                if ($sym['input']=='"') {
+                    $end_brckt = '"';
+                    $txt = substr($expr,0,strpos($expr,$end_brckt));
+                } else {
+                    switch($expr{0}) {
+                        case '(':
+                            $end_brckt = ')';
+                            break;
+                        case '[':
+                            $end_brckt = ']';
+                            break;
+                        case '{':
+                            $end_brckt = '}';
+                            break;
+                        default:
+                            $end_brckt = chr(11); // A character that will never be matched.
+                            break;
+                    }
+                    $txt = substr($expr,1,strpos($expr,$end_brckt)-1);
+                }
+
+                //$txt = substr($expr,1,strpos($expr,$end_brckt)-1);
+                $len = strlen($txt);
+
+                $node_0 = $this->createNode();
+                $node_0->setName('mrow');
+
+                if ($len > 0) {
+                    if ($txt{0} == " ") {
+                        $node_1 = $this->createNode();
+                        $node_1->setName('mspace');
+                        $node_1->setAttr('width','1ex');
+
+                        $node_0->addChild($node_1);
+                    }
+
+                    $node_3 = $this->createNode();
+                    $node_3->setName($sym['tag']);
+                    $node_3->setContent(trim($txt));
+
+                    $node_0->addChild($node_3);
+
+                    if ($len > 1 && $txt{$len-1} == " ") {
+                        $node_2 = $this->createNode();
+                        $node_2->setName('mspace');
+                        $node_2->setAttr('width','1ex');
+
+                        $node_0->addChild($node_2);
+                    }
+
+                    $this->chopExpr($len+2);
+                }
+                return($node_0);
+
+            } elseif (isset($sym['acc'])) {
+                $node_0 = $this->parseSmplExpr();
+                $node_0->removeBrackets();
+
+                $node_1 = $this->createNode();
+                $node_1->setName($sym['tag']);
+                $node_1->addChild($node_0);
+
+                $node_2 = $this->createNode();
+                $node_2->setName('mo');
+                $node_2->setContent($sym['output']);
+
+                $node_1->addChild($node_2);
+                return($node_1);
+            } else {
+                // Font change commands -- to complete
+            }
+        } elseif (isset($sym['binary'])) {
+            $node_arr = array();
+
+            $node_0 = $this->parseSmplExpr();
+            $node_0->removeBrackets();
+
+            $node_1 = $this->parseSmplExpr();
+            $node_1->removeBrackets();
+
+            /* 2005-06-05 wes: added stackrel */
+            if ($sym['input'] == 'root' || $sym['input'] == 'stackrel') {
+                $node_arr[$node_1->getId()] = $node_1;
+                $node_arr[$node_0->getId()] = $node_0;
+            } elseif ($sym['input'] == 'frac') {
+                $node_arr[$node_0->getId()] = $node_0;
+                $node_arr[$node_1->getId()] = $node_1;
+            }
+
+            $node_2 = $this->createNode();
+            $node_2->setName($sym['tag']);
+            $node_2->addChildArr($node_arr);
+
+            return($node_2);
+        } elseif (isset($sym['infix'])) {
+            $node_0 = $this->createNode();
+            $node_0->setName('mo');
+            $node_0->setContent($sym['output']);
+
+            return($node_0);
+        } elseif (isset($sym['space'])) {
+            $node_0 = $this->createNode();
+            $node_0->setName('mrow');
+
+            $node_1 = $this->createNode();
+            $node_1->setName('mspace');
+            $node_1->setAttr('width',$sym['space']);
+
+            $node_2 = $this->createNode();
+            $node_2->setName($sym['tag']);
+            $node_2->setContent($sym['output']);
+
+            $node_3 = $this->createNode();
+            $node_3->setName('mspace');
+            $node_3->setAttr('width',$sym['space']);
+
+            $node_0->addChild($node_1);
+            $node_0->addChild($node_2);
+            $node_0->addChild($node_3);
+
+            return($node_0);
+        } else {
+
+            // A constant
+            $node_0 = $this->createNode();
+            $node_0->setName($sym['tag']);
+            $node_0->setContent($sym['output']);
+            return($node_0);
+        }
+
+        // Return an empty node
+        return $this->emptyNode();
+    }
+
+    function getMathML()
+    {
+        $root = $this->_node_arr[0];
+        return($root->dumpXML());
+    }
+
+    function getCurrExpr()
+    {
+        return($this->_curr_expr);
+    }
+
+    function setCurrExpr($str)
+    {
+        $this->_curr_expr = $str;
+    }
+
+    function getExpr()
+    {
+        return($this->_expr);
+    }
+
+    function getPrevExpr()
+    {
+        return($this->_prev_expr);
+    }
+
+    function  createNode()
+    {
+        $node = new MathMLNode($this->_node_cntr);
+        // $node->setNamespaceAlias('m');
+        $this->_node_arr[$this->_node_cntr] = $node;
+        $this->_node_cntr++;
+        return($node);
+    }
+
+    /**
+     * Gets the largest symbol in the expression (greedy). Changed from non-greedy 26-Apr-2006
+     *
+     * @parameter boolean[optional] Chop original string?
+     *
+     * @return mixed
+     *
+     * @access private
+     */
+    function getSymbol($chop_flg = FALSE)
+    {
+        // Implemented a reverse symbol matcher.
+        // Instead of going front to back, it goes back to front. Steven 26-Apr-2006
+        $chr_cnt = strlen($this->_curr_expr);
+
+        if ($chr_cnt == 0) return FALSE;
+
+        for ($i = $chr_cnt; $i > 0; $i--) {
+            $sym_0 = substr($this->_curr_expr,0,$i);
+
+            // Reading string for numeric values
+            if (is_numeric($sym_0)) {
+
+                if ($chop_flg) $this->chopExpr($i);
+                return array('input'=>$sym_0, 'tag'=>'mn', 'output'=>$sym_0, 'symlen'=>$i);
+
+            } elseif (isset($this->_symbol_arr[$sym_0])) {
+
+                if ($chop_flg) $this->chopExpr($i);
+                $sym_arr = $this->_symbol_arr[$sym_0];
+                $sym_arr['symlen'] = $i;
+                return $sym_arr;
+            }
+        }
+
+        // Reading string for alphabetic constants and the minus sign
+        $char = $this->_curr_expr{0};
+        $len_left = $chop_flg ? $this->chopExpr(1) : strlen($this->_curr_expr)-1;
+
+        // Deals with expressions of length 1
+        if ($len_left == 0 && isset($this->_symbol_arr[$char])) {
+            $sym_arr = $this->_symbol_arr[$char];
+            $sym_arr['symlen'] = 1;
+            return $sym_arr;
+        } else {
+            $tag = preg_match('/[a-z]/i',$char) ? 'mi' : 'mo';
+            return array('input'=>$char, 'tag'=>$tag, 'output'=>$char, 'symlen'=>1);
+        }
+    }
+
+    function chopExpr($strlen)
+    {
+        $this->_prev_expr = $this->_curr_expr;
+
+        if ($strlen == strlen($this->_curr_expr)) {
+            $this->_curr_expr = '';
+            return(0);
+        } else {
+            $this->_curr_expr = ltrim(substr($this->_curr_expr,$strlen));
+            return(strlen($this->_curr_expr));
+        }
+    }
+}
+?>
\ No newline at end of file
diff --git a/examples/includes/ASCIIMathPHP-2.0/htmlMathML.js b/examples/includes/ASCIIMathPHP-2.0/htmlMathML.js
new file mode 100644
index 0000000..f81a1d2
--- /dev/null
+++ b/examples/includes/ASCIIMathPHP-2.0/htmlMathML.js
@@ -0,0 +1,86 @@
+/* March 19, 2004 MathHTML (c) Peter Jipsen http://www.chapman.edu/~jipsen
+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 of the License, 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 
+(at http://www.gnu.org/copyleft/gpl.html) for more details.*/
+
+function convertMath(node) {// for Gecko
+  if (node.nodeType==1) {
+    var newnode = 
+      document.createElementNS("http://www.w3.org/1998/Math/MathML",
+        node.nodeName.toLowerCase());
+    for(var i=0; i < node.attributes.length; i++) {
+	    if (node.attributes[i].nodeName == 'displaystyle') {
+	      newnode.setAttribute(node.attributes[i].nodeName,node.attributes[i].nodeValue);
+	    }
+    }
+    for (var i=0; i<node.childNodes.length; i++) {
+      var st = node.childNodes[i].nodeValue;
+      if (st==null || st.slice(0,1)!=" " && st.slice(0,1)!="\n") 
+        newnode.appendChild(convertMath(node.childNodes[i]));
+    }
+    return newnode;
+  }
+  else return node;
+}
+function convert() {
+	
+	if (document.createElementNS) {
+		var mmlnode = document.getElementsByTagName("span");
+		
+		for (var i=0; i<mmlnode.length; i++) {
+			var tmp_node = mmlnode[i];
+			if (tmp_node.className == 'asciimath') {
+				tmp_node.replaceChild(convertMath(tmp_node.firstChild),tmp_node.firstChild);
+				/*
+				for (var j=0;j<tmp_node.childNodes.length;j++) {
+					if (tmp_node.childNodes[j].nodeType != 3) {
+						
+					}
+				}
+				*/
+			}
+		}
+	} else {
+		var st,node,newnode;
+		var mmlnode = document.getElementsByTagName("math");
+		
+	  	for (var i=0; i<mmlnode.length; i++) {
+			var str = "";
+			node = mmlnode[i];
+			while (node.nodeName!="/MATH" && node.nextSibling) {
+				st = node.nodeName.toLowerCase();
+				if (st=="#text") { 
+					str += node.nodeValue;
+				} else {
+					str += (st.slice(0,1)=="/" ? "</m:"+st.slice(1) : "<m:"+st);
+					if (st.slice(0,1)!="/") {
+						for(var j=0; j < node.attributes.length; j++) {
+							if (node.attributes[j].nodeValue!="italic" &&
+							 node.attributes[j].nodeValue!="" &&
+							 node.attributes[j].nodeValue!="inherit" &&
+							 node.attributes[j].nodeValue!=undefined) {
+							 str += " "+node.attributes[j].nodeName+"="+
+							     "\""+node.attributes[j].nodeValue+"\"";
+							}
+						}
+					}
+					str += ">";
+				}
+				node = node.nextSibling;
+				node.parentNode.removeChild(node.previousSibling);
+			}
+			
+			if (str != '') {
+				str += "</m:math>";
+				newnode = document.createElement("span");
+				node.parentNode.replaceChild(newnode,node);
+				newnode.innerHTML = str;
+			}
+		}
+	}
+}
\ No newline at end of file
diff --git a/examples/includes/HTML-Toc-0.91/.gitattributes b/examples/includes/HTML-Toc-0.91/.gitattributes
new file mode 100644
index 0000000..aecf250
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/.gitattributes
@@ -0,0 +1 @@
+* -crlf
diff --git a/examples/includes/HTML-Toc-0.91/Changes b/examples/includes/HTML-Toc-0.91/Changes
new file mode 100644
index 0000000..81f8339
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/Changes
@@ -0,0 +1,26 @@
+Revision history for Perl extension HTML::Toc.

+

+2001-09-03   Freddy Vulto <fvu@fvu.myweb.nl>

+

+	Release 0.91

+

+	- Tested on Cygwin.

+	- Used Unix file type for source files.

+	- Updated documentation.

+	- Prohibited call with undefined parameter to HTML::Parser->parse() from

+	  HTML::_tokenTocEndParser->parse() which caused havoc with version 3.25

+	  of HTML::Parser.

+	- Specified 'HTML::Parser' as module that needs to be available in order

+	  to use HTML::Toc.

+	- Added protected method HTML::TocGenerator::_setActiveAnchorName().

+	  This method replaces the incongruous access of 

+	  'HTML::TocUpdator::_doDeleteTokens' by HTML::TocGenerator.

+	  HTML::TocUpdator now overrides '_setActiveAnchorName()' to allow

+	  the ancestor call to HTML::TocGenerator only when '_doDeleteTokens'

+	  equals false.

+

+2001-08-09   Freddy Vulto <fvu@fvu.myweb.nl>

+

+	Release 0.90

+

+	- First release.

diff --git a/examples/includes/HTML-Toc-0.91/MANIFEST b/examples/includes/HTML-Toc-0.91/MANIFEST
new file mode 100644
index 0000000..e90f3a8
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/MANIFEST
@@ -0,0 +1,26 @@
+Changes

+Toc.pod

+Toc.pm

+TocGenerator.pm

+TocInsertor.pm

+TocUpdator.pm

+Makefile.PL

+MANIFEST

+t/extend.t

+t/format.t

+t/generate.t

+t/insert.t

+t/manualTest.t

+t/options.t

+t/podExamples.t

+t/propagate.t

+t/siteMap.t

+t/update.t

+t/ManualTest/manualTest1.htm

+t/SiteMap/index.htm

+t/SiteMap/SubDir1/index.htm

+t/SiteMap/SubDir1/SubSubDir1/index.htm

+t/SiteMap/SubDir2/index.htm

+t/SiteMap/SubDir2/SubSubDir1/index.htm

+t/SiteMap/SubDir2/SubSubDir2/index.htm

+t/SiteMap/SubDir3/index.htm

diff --git a/examples/includes/HTML-Toc-0.91/Makefile.PL b/examples/includes/HTML-Toc-0.91/Makefile.PL
new file mode 100644
index 0000000..434d4fd
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/Makefile.PL
@@ -0,0 +1,8 @@
+use ExtUtils::MakeMaker;

+

+WriteMakefile(

+    'NAME'		      => 'HTML::Toc',

+    'VERSION_FROM'	=> 'Toc.pm',

+    'PREREQ_PM'		=> {'HTML::Parser' => 0},

+	 'MAN3PODS'       => {},

+);

diff --git a/examples/includes/HTML-Toc-0.91/Toc.pm b/examples/includes/HTML-Toc-0.91/Toc.pm
new file mode 100644
index 0000000..ae2e8d8
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/Toc.pm
@@ -0,0 +1,549 @@
+#=== HTML::Toc ================================================================
+# function: HTML Table of Contents
+
+
+package HTML::Toc;
+
+
+use strict;
+
+
+BEGIN {
+	use vars qw($VERSION);
+
+	$VERSION = '0.91';
+}
+
+
+use constant FILE_FILTER             => '.*';
+use constant GROUP_ID_H              => 'h';
+use constant LEVEL_1                 => 1;
+use constant NUMBERING_STYLE_DECIMAL => 'decimal';
+
+	# Templates
+
+	# Anchor templates
+use constant TEMPLATE_ANCHOR_NAME       => '$groupId."-".$node';
+use constant TEMPLATE_ANCHOR_HREF_BEGIN       => 
+					'"<a href=#$anchorName>"';
+use constant TEMPLATE_ANCHOR_HREF_BEGIN_FILE  => 
+					'"<a href=$file#$anchorName>"';
+use constant TEMPLATE_ANCHOR_HREF_END         => '"</a>"';
+use constant TEMPLATE_ANCHOR_NAME_BEGIN => 
+					'"<a name=$anchorName>"';
+use constant TEMPLATE_ANCHOR_NAME_END   => '"</a>"';
+use constant TOKEN_UPDATE_BEGIN_OF_ANCHOR_NAME_BEGIN => 
+					'<!-- #BeginTocAnchorNameBegin -->';
+use constant TOKEN_UPDATE_END_OF_ANCHOR_NAME_BEGIN   => 
+					'<!-- #EndTocAnchorNameBegin -->';
+use constant TOKEN_UPDATE_BEGIN_OF_ANCHOR_NAME_END => 
+					'<!-- #BeginTocAnchorNameEnd -->';
+use constant TOKEN_UPDATE_END_OF_ANCHOR_NAME_END   => 
+					'<!-- #EndTocAnchorNameEnd -->';
+use constant TOKEN_UPDATE_BEGIN_NUMBER      => 
+					'<!-- #BeginTocNumber -->';
+use constant TOKEN_UPDATE_END_NUMBER        => 
+					'<!-- #EndTocNumber -->';
+use constant TOKEN_UPDATE_BEGIN_TOC         => 
+					'<!-- #BeginToc -->';
+use constant TOKEN_UPDATE_END_TOC           => 
+					'<!-- #EndToc -->';
+
+use constant TEMPLATE_TOKEN_NUMBER      => '"$node &nbsp;"';
+
+	# Level templates
+use constant TEMPLATE_LEVEL             => '"<li>$text\n"';
+use constant TEMPLATE_LEVEL_BEGIN       => '"<ul>\n"';
+use constant TEMPLATE_LEVEL_END         => '"</ul>\n"';
+
+
+END {}
+
+
+#--- HTML::Toc::new() ---------------------------------------------------------
+# function: Constructor
+
+sub new {
+		# Get arguments
+	my ($aType) = @_;
+		# Local variables
+	my $self;
+
+	$self = bless({}, $aType);
+		# Default to empty 'options' array
+	$self->{options} = {};
+		# Empty toc
+	$self->{_toc} = "";
+		# Hash reference to array for each groupId, each array element
+		# referring to the group of the level indicated by the array index.
+		# For example, with the default 'tokenGroups', '_levelGroups' would
+		# look like: 
+		#
+		# {'h'} => [\$group1, \$group2, \$group3, \$group4, \$group5, \$group6];
+		#
+	$self->{_levelGroups} = undef;
+		# Set default options
+	$self->_setDefaults();
+	return $self;
+}  # new()
+
+
+#--- HTML::Toc::_compareLevels() ----------------------------------------------
+# function: Compare levels.
+# args:     - $aLevel: pointer to level
+#           - $aGroupLevel
+#           - $aPreviousLevel
+#           - $aPreviousGroupLevel
+# returns:  0 if new level equals previous level, 1 if new level exceeds
+#           previous level, -1 if new level is smaller then previous level.
+
+sub _compareLevels {
+		# Get arguments
+	my (
+		$self, $aLevel, $aPreviousLevel, $aGroupLevel, $aPreviousGroupLevel 
+	) = @_;
+		# Local variables
+	my ($result);
+		# Levels equals?
+	if (
+		($aLevel == $aPreviousLevel) &&
+		($aGroupLevel == $aPreviousGroupLevel)
+	) {
+		# Yes, levels are equals;
+			# Indicate so
+		$result = 0;
+	}
+	else {
+		# No, levels differ;
+			# Bias to new level being smaller than previous level;
+		$result = -1;
+			# Must groups not be nested and do group levels differ?
+		if (
+			($self->{options}{'doNestGroup'} == 0) &&
+			($aGroupLevel != $aPreviousGroupLevel)
+		) {
+			# Yes, groups must be kept apart and the group levels differ;
+				# Level is greater than previous level?
+			if (
+				($aLevel > $aPreviousLevel)
+			) {
+				# Yes, level is greater than previous level;
+					# Indicate so
+				$result = 1;
+			}
+		}
+		else {
+			# No, group must be nested;
+				# Level is greater than previous level?
+			if (
+				($aLevel > $aPreviousLevel) ||
+				($aGroupLevel > $aPreviousGroupLevel)
+			) {
+				# Yes, level is greater than previous level;
+					# Indicate so
+				$result = 1;
+			}
+		}
+	}
+		# Return value
+	return $result;
+}  # _compareLevels()
+
+
+#--- HTML::TocGenerator::_formatLevelIndent() ---------------------------------
+# function: Format indent.
+# args:     - $aText: text to indent
+#           - $aLevel: Level.
+#           - $aGroupLevel: Group level.
+#           - $aAdd
+#           - $aGlobalLevel
+
+sub _formatLevelIndent {
+		# Get arguments
+	my ($self, $aText, $aAdd, $aGlobalLevel) = @_;
+		# Local variables
+	my ($levelIndent, $indent, $nrOfIndents);
+		# Alias indentation option
+	$levelIndent = $self->{options}{'levelIndent'}; #=~ s/[0-9]+/&/;
+		# Calculate number of indents
+	$nrOfIndents = ($aGlobalLevel + $aAdd) * $levelIndent;
+		# Assemble indents
+	$indent = pack("A$nrOfIndents");
+		# Return value
+	return $indent . $aText;
+}  # _formatLevelIndent()
+
+
+#--- HTML::Toc::_formatToc() --------------------------------------------------
+# function: Format ToC.
+# args:     - aPreviousLevel
+#           - aPreviousGroupLevel
+#           - aToc: ToC to format.
+#           - aHeaderLines
+# note:     Recursive function this is.
+
+sub _formatToc {
+		# Get arguments
+	my (
+		$self, $aPreviousLevel, $aPreviousGroupLevel, $aToc, $aHeaderLines, 
+		$aGlobalLevel
+	) = @_;
+		# Local variables
+	my ($level, $groupLevel, $line, $groupId, $text, $compareStatus);
+	my ($anchorName, $globalLevel, $node, $sequenceNr);
+
+	LOOP: {
+			# Lines need processing?
+		while (scalar(@$aHeaderLines) > 0) {
+			# Yes, lines need processing;
+				# Get line
+			$line = shift @$aHeaderLines;
+				
+				# Determine levels
+			($level, $groupLevel, $groupId, $node, $sequenceNr, 
+			$anchorName, $text) = split(
+				/ /, $line, 7
+			);
+				# Must level and group be processed?
+			if (
+				($level =~ m/$self->{options}{'levelToToc'}/) &&
+				($groupId =~ m/$self->{options}{'groupToToc'}/)
+			) {
+				# Yes, level must be processed;
+					# Compare levels
+				$compareStatus = $self->_compareLevels(
+					$level, $aPreviousLevel, $groupLevel, $aPreviousGroupLevel
+				);
+
+				COMPARE_LEVELS: {
+
+						# Equals?
+					if ($compareStatus == 0) {
+						# Yes, levels are equal;
+							# Format level
+						$$aToc .= $self->_formatLevelIndent(
+							ref($self->{_templateLevel}) eq "CODE" ?
+								&{$self->{_templateLevel}}(
+									$level, $groupId, $node, $sequenceNr, $text
+								) :
+								eval($self->{_templateLevel}),
+							0, $aGlobalLevel
+						);
+					}
+
+						# Greater?
+					if ($compareStatus > 0) {
+						# Yes, new level is greater than previous level;
+							# Must level be single-stepped?
+						if (
+							$self->{options}{'doSingleStepLevel'} && 
+							($aPreviousLevel) && 
+							($level > $aPreviousLevel)
+						) {
+							# Yes, level must be single-stepped;
+								# Make sure, new level is increased one step only
+							$level = $aPreviousLevel + 1;
+						}
+							# Increase global level
+						$aGlobalLevel++;
+							# Format begin of level
+						$$aToc .= $self->_formatLevelIndent(
+							eval($self->{_templateLevelBegin}), -1, $aGlobalLevel
+						);
+							# Process line again
+						unshift @$aHeaderLines, $line;
+							# Assemble TOC (recursive) for next level
+						$self->_formatToc(
+							$level, $groupLevel, $aToc, $aHeaderLines, $aGlobalLevel
+						);
+							# Format end of level
+						$$aToc .= $self->_formatLevelIndent(
+							eval($self->{_templateLevelEnd}), -1, $aGlobalLevel
+						);
+							# Decrease global level
+						$aGlobalLevel--;
+							# Exit loop
+						last COMPARE_LEVELS;
+					}
+
+						# Smaller?
+					if ($compareStatus < 0) {
+						# Yes, new level is smaller than previous level;
+							# Process line again
+						unshift @$aHeaderLines, $line;
+							# End loop
+						last LOOP;
+					}
+				}
+			}
+		}
+	}
+}	# _formatToc()
+
+
+#--- HTML::Toc::_parseTokenGroups() -------------------------------------------
+# function: Parse token groups
+
+sub _parseTokenGroups {
+		# Get arguments
+	my ($self) = @_;
+		# Local variables
+	my ($group, $levelGroups, $numberingStyle);
+
+		# Clear any previous 'levelGroups'
+	$self->{_levelGroups} = undef;
+		# Determine default 'numberingStyle'
+	$numberingStyle = defined($self->{options}{'numberingStyle'}) ?
+		$self->{options}{'numberingStyle'} : NUMBERING_STYLE_DECIMAL;
+
+		# Loop through groups
+	foreach $group (@{$self->{options}{'tokenToToc'}}) {
+			# 'groupId' is specified?
+		if (! defined($group->{'groupId'})) {
+			# No, 'groupId' isn't specified;
+				# Set default groupId
+			$group->{'groupId'} = GROUP_ID_H;
+		}
+			# 'level' is specified?
+		if (! defined($group->{'level'})) {
+			# No, 'level' isn't specified;
+				# Set default level
+			$group->{'level'} = LEVEL_1;
+		}
+			# 'numberingStyle' is specified?
+		if (! defined($group->{'numberingStyle'})) {
+			# No, 'numberingStyle' isn't specified;
+				# Set default numberingStyle
+			$group->{'numberingStyle'} = $numberingStyle;
+		}
+			# Add group to '_levelGroups' variabele
+		$self->{_levelGroups}{$group->{'groupId'}}[$group->{'level'} - 1] = 
+			$group;
+	}
+}  # _parseTokenGroups()
+
+
+#--- HTML::Toc::_setDefaults() ------------------------------------------------
+# function: Set default options.
+
+sub _setDefaults {
+		# Get arguments
+	my ($self) = @_;
+		# Set default options
+	$self->setOptions(
+		{
+			'attributeToExcludeToken' => '-',
+			'attributeToTocToken'     => '@',
+			'insertionPoint'          => 'after <body>',
+			'levelToToc'              => '.*',
+			'groupToToc'              => '.*',
+			'doNumberToken'           => 0,
+			'doLinkToFile'            => 0,
+			'doLinkToToken'           => 1,
+			'doLinkToId'              => 0,
+			'doSingleStepLevel'       => 1,
+			'linkUri'                 => '',
+			'levelIndent'             => 3,
+			'doNestGroup'             => 0,
+			'doUseExistingAnchors'    => 1,
+			'doUseExistingIds'        => 1,
+			'tokenToToc'              => [
+				{
+					'level'  => 1,
+					'tokenBegin' => '<h1>'
+				}, {
+					'level'  => 2,
+					'tokenBegin' => '<h2>'
+				}, {
+					'level'  => 3,
+					'tokenBegin' => '<h3>'
+				}, {
+					'level'  => 4,
+					'tokenBegin' => '<h4>'
+				}, {
+					'level'  => 5,
+					'tokenBegin' => '<h5>'
+				}, {
+					'level'  => 6,
+					'tokenBegin' => '<h6>'
+				}
+			],
+			'header'            =>
+				"\n<!-- Table of Contents generated by Perl - HTML::Toc -->\n",
+			'footer'            =>
+				"\n<!-- End of generated Table of Contents -->\n",
+		}
+	);
+}  # _setDefaults()
+
+
+#--- HTML::Toc::clear() -------------------------------------------------------
+# function: Clear ToC.
+
+sub clear {
+		# Get arguments
+	my ($self) = @_;
+		# Clear ToC
+	$self->{_toc}          = "";
+	$self->{toc}           = "";
+	$self->{groupIdLevels} = undef;
+	$self->{levels}        = undef;
+}   # clear()
+
+
+#--- HTML::Toc::format() ------------------------------------------------------
+# function: Format ToC.
+# returns:  Formatted ToC.
+
+sub format {
+		# Get arguments
+	my ($self) = @_;
+		# Local variables;
+	my $toc = "";
+	my @tocLines = split(/\r\n|\n/, $self->{_toc});
+		# Format table of contents
+	$self->_formatToc("0", "0", \$toc, \@tocLines, 0);
+		# Remove last newline
+	$toc =~ s/\n$//m;
+		# Add header & footer
+	$toc = $self->{options}{'header'} . $toc . $self->{options}{'footer'};
+		# Return value
+	return $toc;
+}	# format()
+
+
+#--- HTML::Toc::parseOptions() ------------------------------------------------
+# function: Parse options.
+
+sub parseOptions {
+		# Get arguments
+	my ($self) = @_;
+		# Alias options
+	my $options = $self->{options};
+
+		# Parse token groups
+	$self->_parseTokenGroups();
+
+		# Link ToC to tokens?
+	if ($self->{options}{'doLinkToToken'}) {
+		# Yes, link ToC to tokens;
+			# Determine anchor href template begin
+		$self->{_templateAnchorHrefBegin} =
+			defined($options->{'templateAnchorHrefBegin'}) ?
+				$options->{'templateAnchorHrefBegin'} :
+				$options->{'doLinkToFile'} ? 
+					TEMPLATE_ANCHOR_HREF_BEGIN_FILE : TEMPLATE_ANCHOR_HREF_BEGIN;
+
+			# Determine anchor href template end
+		$self->{_templateAnchorHrefEnd} =
+			defined($options->{'templateAnchorHrefEnd'}) ?
+				$options->{'templateAnchorHrefEnd'} :
+				TEMPLATE_ANCHOR_HREF_END;
+
+			# Determine anchor name template
+		$self->{_templateAnchorName} =
+			defined($options->{'templateAnchorName'}) ?
+				$options->{'templateAnchorName'} :
+				TEMPLATE_ANCHOR_NAME;
+
+			# Determine anchor name template begin
+		$self->{_templateAnchorNameBegin} =
+			defined($options->{'templateAnchorNameBegin'}) ?
+				$options->{'templateAnchorNameBegin'} :
+				TEMPLATE_ANCHOR_NAME_BEGIN;
+
+			# Determine anchor name template end
+		$self->{_templateAnchorNameEnd} =
+			defined($options->{'templateAnchorNameEnd'}) ?
+				$options->{'templateAnchorNameEnd'} :
+				TEMPLATE_ANCHOR_NAME_END;
+	}
+
+		# Determine token number template
+	$self->{_templateTokenNumber} = 
+		defined($options->{'templateTokenNumber'}) ?
+			$options->{'templateTokenNumber'} :
+			TEMPLATE_TOKEN_NUMBER;
+
+		# Determine level template
+	$self->{_templateLevel} =
+		defined($options->{'templateLevel'}) ?
+			$options->{'templateLevel'} :
+			TEMPLATE_LEVEL;
+
+		# Determine level begin template
+	$self->{_templateLevelBegin} =
+		defined($options->{'templateLevelBegin'}) ?
+			$options->{'templateLevelBegin'} :
+			TEMPLATE_LEVEL_BEGIN;
+
+		# Determine level end template
+	$self->{_templateLevelEnd} =
+		defined($options->{'templateLevelEnd'}) ?
+			$options->{'templateLevelEnd'} :
+			TEMPLATE_LEVEL_END;
+
+		# Determine 'anchor name begin' begin update token
+	$self->{_tokenUpdateBeginOfAnchorNameBegin} =
+		defined($options->{'tokenUpdateBeginOfAnchorNameBegin'}) ?
+			$options->{'tokenUpdateBeginOfAnchorNameBegin'} :
+			TOKEN_UPDATE_BEGIN_OF_ANCHOR_NAME_BEGIN;
+
+		# Determine 'anchor name begin' end update token
+	$self->{_tokenUpdateEndOfAnchorNameBegin} =
+		defined($options->{'tokenUpdateEndOfAnchorNameBegin'}) ?
+			$options->{'tokenUpdateEndOfAnchorNameBegin'} :
+			TOKEN_UPDATE_END_OF_ANCHOR_NAME_BEGIN;
+
+		# Determine 'anchor name end' begin update token
+	$self->{_tokenUpdateBeginOfAnchorNameEnd} =
+		defined($options->{'tokenUpdateBeginOfAnchorNameEnd'}) ?
+			$options->{'tokenUpdateBeginOfAnchorNameEnd'} :
+			TOKEN_UPDATE_BEGIN_OF_ANCHOR_NAME_END;
+
+		# Determine 'anchor name end' end update token
+	$self->{_tokenUpdateEndOfAnchorNameEnd} =
+		defined($options->{'tokenUpdateEndOfAnchorNameEnd'}) ?
+			$options->{'tokenUpdateEndOfAnchorNameEnd'} :
+			TOKEN_UPDATE_END_OF_ANCHOR_NAME_END;
+
+		# Determine number begin update token
+	$self->{_tokenUpdateBeginNumber} =
+		defined($options->{'tokenUpdateBeginNumber'}) ?
+			$options->{'tokenUpdateBeginNumber'} :
+			TOKEN_UPDATE_BEGIN_NUMBER;
+
+		# Determine number end update token
+	$self->{_tokenUpdateEndNumber} =
+		defined($options->{'tokenUpdateEndNumber'}) ?
+			$options->{'tokenUpdateEndNumber'} :
+			TOKEN_UPDATE_END_NUMBER;
+
+		# Determine toc begin update token
+	$self->{_tokenUpdateBeginToc} =
+		defined($options->{'tokenUpdateBeginToc'}) ?
+			$options->{'tokenUpdateBeginToc'} :
+			TOKEN_UPDATE_BEGIN_TOC;
+
+		# Determine toc end update token
+	$self->{_tokenUpdateEndToc} =
+		defined($options->{'tokenUpdateEndToc'}) ?
+			$options->{'tokenUpdateEndToc'} :
+			TOKEN_UPDATE_END_TOC;
+
+}  # parseOptions()
+
+
+#--- HTML::Toc::setOptions() --------------------------------------------------
+# function: Set options.
+# args:     - aOptions: Reference to hash containing options.
+
+sub setOptions {
+		# Get arguments
+	my ($self, $aOptions) = @_;
+		# Add options
+	%{$self->{options}} = (%{$self->{options}}, %$aOptions);
+}  # setOptions()
+
+
+1;
diff --git a/examples/includes/HTML-Toc-0.91/Toc.pod b/examples/includes/HTML-Toc-0.91/Toc.pod
new file mode 100644
index 0000000..6348503
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/Toc.pod
@@ -0,0 +1,1710 @@
+=head1 NAME
+
+HTML::Toc - Generate, insert and update HTML Table of Contents.
+
+=head1 DESCRIPTION
+
+Generate, insert and update HTML Table of Contents.
+
+=head1 Introduction
+
+The HTML::Toc consists out of the following packages:
+
+    HTML::Toc
+    HTML::TocGenerator
+    HTML::TocInsertor
+    HTML::TocUpdator
+
+HTML::Toc is the object which will eventually hold the Table of Contents.  HTML::TocGenerator does the actual generation of the ToC.  HTML::TocInsertor handles the insertion of the ToC in the source.  HTML::TocUpdator takes care of updating previously inserted ToCs.
+
+HTML::Parser is the base object of HTML::TocGenerator, HTML::TocInsertor and HTML::TocUpdator.  Each of these objects uses its predecessor as its ancestor, as shown in the UML diagram underneath:
+    
+    +---------------------+
+    |    HTML::Parser     |
+    +---------------------+
+    +---------------------+
+    |    +parse()         |
+    |    +parse_file()    |
+    +----------+----------+
+              /_\
+               |
+    +----------+----------+  <<uses>>  +-----------+
+    | HTML::TocGenerator  + - - - - - -+ HTML::Toc |
+    +---------------------+            +-----------+
+    +---------------------+            +-----------+
+    | +extend()           |            | +clear()  |
+    | +extendFromFile()   |            | +format() |
+    | +generate()         |            +-----+-----+
+    | +generateFromFile() |                  :
+    +----------+----------+                  :
+              /_\                            :
+               |                             :
+    +----------+----------+     <<uses>>     :
+    |  HTML::TocInsertor  + - - - - - - - - -+
+    +---------------------+                  :
+    +---------------------+                  :
+    |  +insert()          |                  :
+    |  +insertIntoFile()  |                  :
+    +----------+----------+                  :
+              /_\                            :
+               |                             :
+    +----------+----------+     <<uses>>     :
+    |  HTML::TocUpdator   + - - - - - - - - -+
+    +---------------------+
+    +---------------------+
+    |  +insert()          |
+    |  +insertIntoFile()  |
+    |  +update()          |
+    |  +updateFile()      |
+    +---------------------+
+
+When generating a ToC you'll have to decide which object you want to use:
+
+    TocGenerator:
+        for generating a ToC without inserting the ToC into the source
+    TocInsertor:
+        for generating a ToC and inserting the ToC into the source
+    TocUpdator:
+        for generating and inserting a ToC, removing any previously
+        inserted ToC elements
+
+Thus in tabular view, each object is capable of:
+
+                   generating   inserting   updating
+                   ---------------------------------
+    TocGenerator        X
+    TocInsertor         X           X
+    TocUpdator          X           X           X
+
+=head2 Generating
+
+The code underneath will generate a ToC of the HTML headings C<<h1>>..C<<h6>> from a file C<index.htm>:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+
+    my $toc          = HTML::Toc->new();
+    my $tocGenerator = HTML::TocGenerator->new();
+
+    $tocGenerator->generateFromFile($toc, 'index.htm');
+    print $toc->format();
+
+For example, with C<index.htm> containing:
+
+    <html>
+    <body>
+       <h1>Chapter</h1>
+    </body>
+    </html>
+
+the output will be:
+
+    
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1>Chapter</a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+=head2 Inserting
+
+This code will generate a ToC of HTML headings C<<h1>>..C<<h6>> of file C<index.htm>, and insert the ToC after the C<<body>> tag at the same time:
+
+    use HTML::Toc;
+    use HTML::TocInsertor;
+
+    my $toc         = HTML::Toc->new();
+    my $tocInsertor = HTML::TocInsertor->new();
+
+    $tocInsertor->insertIntoFile($toc, 'index.htm');
+
+For example, with C<index.htm> containing:
+
+    <html>
+    <body>
+       <h1>Chapter</h1>
+    </body>
+    </html>
+
+the output will be:
+
+    <html>
+    <body>
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1>Chapter</a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+       <a name=h-1><h1>Chapter</h1></a>
+    </body>
+    </html>
+
+If you're planning to update the inserted ToC, you'd better use C<TocUpdator> to insert the ToC.  C<TocUpdator> marks the inserted ToC elements with update tokens.  These update tokens allow C<TocUpdator> to identify and remove the ToC elements during a future update session.  This code uses C<TocUpdator> instead of C<TocInsertor>:
+
+    use HTML::Toc;
+    use HTML::TocUpdator;
+
+    my $toc        = HTML::Toc->new();
+    my $tocUpdator = HTML::TocUpdator->new();
+
+    $tocUpdator->insertIntoFile($toc, 'index.htm');
+
+When applying the code above on 'index.htm':
+
+    <html>
+    <body>
+       <h1>
+       Chapter
+       </h1>
+    </body>
+    </html>
+
+the output will contain additional update tokens:
+
+    <!-- #BeginToc -->
+    <!-- #EndToc -->
+    <!-- #BeginTocAnchorNameBegin -->
+    <!-- #EndTocAnchorNameBegin -->
+    <!-- #BeginTocAnchorNameEnd -->
+    <!-- #EndTocAnchorNameEnd -->
+
+around the inserted ToC elements:
+
+    <html>
+    <body><!-- #BeginToc-->
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1> Chapter </a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+    <!-- #EndToc -->
+       <!-- #BeginTocAnchorNameBegin --><a name=h-1><!-- #EndTocAnchorNameBegin --><h1>
+       Chapter
+       </h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+    </body>
+    </html>
+
+Instead of C<HTML::TocUpdator::insertIntoFile> you can also use C<HTML::TocUpdator::updateFile()>.  C<HTML::TocUpdator::updateFile()> will also insert the ToC, whether there is a ToC already inserted or not.
+
+=head2 Updating
+
+This code will generate a ToC of HTML headings C<<h1>>..C<<h6>> of file C<indexToc.htm>, and insert or update the ToC after the C<<body>> tag at the same time:
+
+    use HTML::Toc;
+    use HTML::TocUpdator;
+
+    my $toc        = HTML::Toc->new();
+    my $tocUpdator = HTML::TocUpdator->new();
+
+    $tocUpdator->updateFile($toc, 'indexToc.htm');
+
+For example, with C<indexToc.htm> containing:
+
+    <html>
+    <body><!-- #BeginToc -->
+    foo
+    <!-- #EndToc -->
+       <!-- #BeginTocAnchorNameBegin -->bar<!-- #EndTocAnchorNameBegin --><h1>
+       Chapter
+       </h1><!-- #BeginTocAnchorNameEnd -->foo<!-- #EndTocAnchorNameEnd -->
+    </body>h
+    </html>
+
+the output will be:
+
+    <html>
+    <body><!-- #BeginToc -->
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1> Chapter </a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+    <!-- #EndToc -->
+       <!-- #BeginTocAnchorNameBegin --><a name=h-1><!-- #EndTocAnchorNameBegin --><h1>
+       Chapter
+       </h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+    </body>
+    </html>
+
+All text between the update tokens will be replaced.  So be warned: all manual changes made to text between update tokens will be removed unrecoverable after calling C<HTML::TocUpdator::update()> or C<HTML::TocUpdator::updateFile()>.
+
+=head2 Formatting
+
+The ToC isn't generated all at once.  There are two stages involved: generating and formatting.  Generating the ToC actually means storing a preliminary ToC in C<HTML::Toc-E<gt>{_toc}>.  This preliminary, tokenized ToC has to be turned into something useful by calling C<HTML::Toc-E<gt>format()>.  For an example, see paragraph 'L<Generating|"generating">'.
+
+=head1 Advanced
+
+The ToC generation can be modified in a variety of ways.  The following paragraphs each explain a single modification.  An example of most of the modifications can be found in the C<manualTest.t> test file.  Within this test, a manual containing:
+
+    preface
+    introduction
+    table of contents
+    table of figures
+    table of tables
+    parts
+    chapters
+    appendixes
+    bibliography
+
+is formatted.
+
+=head2 Using attribute value as ToC text
+
+Normally, the ToC will be made of text between specified ToC tokens.  It's also possible to use the attribute value of a token as a ToC text.  This can be done by specifying the attribute marked with an L<attributeToTocToken|"attributeToTocToken"> within the L<tokenBegin|"tokenBegin"> token.  For example, suppose you want to generate a ToC of the C<alt> attributes of the following image tokens:
+
+    <body>
+       <img src=test1.gif alt="First picture">
+       <img src=test2.gif alt="Second picture">
+    </body>
+
+This would be the code:
+
+    use HTML::Toc;
+    use HTML::TocInsertor;
+
+    my $toc         = HTML::Toc->new();
+    my $tocInsertor = HTML::TocInsertor->new();
+
+    $toc->setOptions({
+       'tokenToToc'   => [{
+          'groupId'    => 'image',
+          'tokenBegin' => '<img alt=@>'
+       }],
+    });
+    $tocInsertor->insertIntoFile($toc, $filename);
+
+and the output will be:
+
+    <body>
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#image-1>First picture</a>
+       <li><a href=#image-2>Second picture</a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+       <a name=image-1><img src=test1.gif alt="First picture"></a>
+       <a name=image-2><img src=test2.gif alt="Second picture"></a>
+    </body>
+
+=head2 Generate single ToC of multiple files
+
+Besides generating a ToC of a single file, it's also possible to generate a single ToC of multiple files.  This can be done by specifying either an array of files as the file argument and/or by extending an existing ToC.
+
+=head3 Specify an array of files
+
+For example, suppose you want to generate a ToC of both C<doc1.htm>:
+
+    <body>
+       <h1>Chapter of document 1</h1>
+    </body>
+
+and C<doc2.htm>:
+
+    <body>
+       <h1>Chapter of document 2</h1>
+    </body>
+
+Here's the code to do so by specifying an array of files:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+
+    my $toc          = HTML::Toc->new();
+    my $tocGenerator = HTML::TocGenerator->new();
+
+    $toc->setOptions({'doLinkToFile' => 1});
+    $tocGenerator->generateFromFile($toc, ['doc1.htm', 'doc2.htm']);
+    print $toc->format();
+
+And the output will be:
+
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=doc1.htm#h-1>Chapter of document 1</a>
+       <li><a href=doc2.htm#h-2>Chapter of document 2</a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+=head3 Extend an existing ToC
+
+It's also possible to extend an existing ToC.  For example, suppose we want the generate a ToC of file C<doc1.htm>:
+
+    <body>
+       <h1>Chapter of document 1</h1>
+    </body>
+
+and extend this ToC with text from C<doc2.htm>:
+
+    <body>
+       <h1>Chapter of document 2</h1>
+    </body>
+
+Here's the code to do so:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+
+    my $toc          = HTML::Toc->new();
+    my $tocGenerator = HTML::TocGenerator->new();
+
+    $toc->setOptions({'doLinkToFile' => 1});
+    $tocGenerator->generateFromFile($toc, 'doc1.htm');
+    $tocGenerator->extendFromFile($toc, 'doc2.htm');
+    print $toc->format();
+
+And the output will be:
+
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=doc1.htm#h-1>Chapter of document 1</a>
+       <li><a href=doc2.htm#h-2>Chapter of document 2</a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+=head2 Generate multiple ToCs
+
+It's possible to generate multiple ToCs at once by specifying a C<HTML::Toc> object array as the ToC argument.  For example, suppose you want to generate a default ToC of HTML headings <h1>..<h6> as well as a ToC of the C<alt> image attributes of the following text:
+
+    <body>
+       <h1>Header One</h1>
+       <img src=test1.gif alt="First picture" id=image_001>
+       <h2>Paragraph One</h2>
+       <img src=test2.gif alt="Second picture" id=image_002>
+    </body>
+
+Here's how you would do so:
+
+    use HTML::Toc;
+    use HTML::TocInsertor;
+
+    my $toc1        = HTML::Toc->new();
+    my $toc2        = HTML::Toc->new();
+    my $tocInsertor = HTML::TocInsertor->new();
+
+    $toc2->setOptions({
+       'tokenToToc'   => [{
+          'groupId'    => 'image',
+          'tokenBegin' => '<img alt=@>'
+       }],
+    });
+    $tocInsertor->insertIntoFile([$toc1, $toc2], $filename);
+
+And the output will be:
+
+    <body>
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1>Header One</a>
+       <ul>
+          <li><a href=#h-1.1>Paragraph One</a>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#image-1>First picture</a>
+       <li><a href=#image-2>Second picture</a>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+       <a name=h-1><h1>Header One</h1></a>
+       <a name=image-1><img src=test1.gif alt="First picture"></a>
+       <a name=h-1.1><h2>Paragraph One</h2></a>
+       <a name=image-2><img src=test2.gif alt="Second picture"></a>
+    </body>
+
+=head2 Generate multiple groups in one ToC
+
+You may want to generate a ToC consisting of multiple ToC groups.
+
+=head3 Specify an additional 'Appendix' group
+
+Suppose you want to generate a ToC with one group for the normal headings, and one group for the appendix headings, using this source file:
+
+    <body>
+       <h1>Chapter</h1>
+       <h2>Paragraph</h2>
+       <h3>Subparagraph</h3>
+       <h1>Chapter</h1>
+       <h1 class=appendix>Appendix Chapter</h1>
+       <h2 class=appendix>Appendix Paragraph</h2>
+    </body>
+
+With the code underneath:
+
+    use HTML::Toc;
+    use HTML::TocInsertor;
+
+    my $toc         = HTML::Toc->new();
+    my $tocInsertor = HTML::TocInsertor->new();
+
+    $toc->setOptions({
+       'tokenToToc' => [{
+             'tokenBegin' => '<h1 class=-appendix>'
+          }, {
+             'tokenBegin' => '<h2 class=-appendix>',
+             'level'      => 2
+          }, {
+             'groupId'    => 'appendix',
+             'tokenBegin' => '<h1 class=appendix>',
+          }, {
+             'groupId'    => 'appendix',
+             'tokenBegin' => '<h2 class=appendix>',
+             'level'      => 2
+          }]
+    });
+    $tocInsertor->insertIntoFile($toc, $filename);
+
+the output will be:
+
+    <body>
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1>Chapter</a>
+       <ul>
+          <li><a href=#h-1.1>Paragraph</a>
+       </ul>
+       <li><a href=#h-2>Chapter</a>
+    </ul>
+    <ul>
+       <li><a href=#appendix-1>Appendix Chapter</a>
+       <ul>
+          <li><a href=#appendix-1.1>Appendix Paragraph</a>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+       <a name=h-1><h1>Chapter</h1></a>
+       <a name=h-1.1><h2>Paragraph</h2></a>
+       <h3>Subparagraph</h3>
+       <a name=h-2><h1>Chapter</h1></a>
+       <a name=appendix-1><h1 class=appendix>Appendix Chapter</h1></a>
+       <a name=appendix-1.1><h2 class=appendix>Appendix Paragraph</h2></a>
+    </body>
+
+=head3 Specify an additional 'Part' group
+
+Suppose you want to generate a ToC of a document which is divided in multiple parts like this file underneath:
+
+    <body>
+       <h1 class=part>First Part</h1>
+       <h1>Chapter</h1>
+       <h2>Paragraph</h2>
+       <h1 class=part>Second Part</h1>
+       <h1>Chapter</h1>
+       <h2>Paragraph</h2>
+    </body>
+
+With the code underneath:
+
+    use HTML::Toc;
+    use HTML::TocInsertor;
+
+    my $toc         = HTML::Toc->new();
+    my $tocInsertor = HTML::TocInsertor->new();
+
+    $toc->setOptions({
+       'doNumberToken'    => 1,
+       'tokenToToc' => [{
+             'tokenBegin' => '<h1 class=-part>'
+          }, {
+             'tokenBegin' => '<h2 class=-part>',
+             'level'      => 2,
+          }, {
+             'groupId'        => 'part',
+             'tokenBegin'     => '<h1 class=part>',
+             'level'          => 1,
+             'numberingStyle' => 'upper-alpha'
+          }]
+    });
+    $tocInsertor->insertIntoFile($toc, $filename);
+
+the output will be:
+
+    <body>
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#part-A>First Part</a>
+    </ul>
+    <ul>
+       <li><a href=#h-1>Chapter</a>
+       <ul>
+          <li><a href=#h-1.1>Paragraph</a>
+       </ul>
+    </ul>
+    <ul>
+       <li><a href=#part-B>Second Part</a>
+    </ul>
+    <ul>
+       <li><a href=#h-2>Chapter</a>
+       <ul>
+          <li><a href=#h-2.1>Paragraph</a>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+       <a name=part-A><h1 class=part>A &nbsp;First Part</h1></a>
+       <a name=h-1><h1>1 &nbsp;Chapter</h1></a>
+       <a name=h-1.1><h2>1.1 &nbsp;Paragraph</h2></a>
+       <a name=part-B><h1 class=part>B &nbsp;Second Part</h1></a>
+       <a name=h-2><h1>2 &nbsp;Chapter</h1></a>
+       <a name=h-2.1><h2>2.1 &nbsp;Paragraph</h2></a>
+    </body>
+
+=head2 Number ToC entries
+
+By default, the generated ToC will list its entries unnumbered.  If you want to number the ToC entries, two options are available.  Either you can specify a numbered list by modifying L<templateLevelBegin|"templateLevelBegin"> and L<templateLevelEnd|"templateLevelEnd">.  Or when the ToC isn't a simple numbered list, you can use the numbers generated by HTML::TocGenerator.
+
+=head3 Specify numbered list
+
+By modifying L<templateLevelBegin|"templateLevelBegin"> and L<templateLevelEnd|"templateLevelEnd"> you can specify a numbered ToC:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+
+    my $toc          = HTML::Toc->new();
+    my $tocGenerator = HTML::TocGenerator->new();
+
+    $toc->setOptions({
+        'templateLevelBegin' => '"<ol>\n"',
+        'templateLevelEnd'   => '"</ol>\n"',
+    });
+    $tocGenerator->generateFromFile($toc, 'index.htm');
+    print $toc->format();
+
+For instance with the original file containing:
+
+    <body>
+        <h1>Chapter</h1>
+        <h2>Paragraph</h2>
+    </body>
+
+The formatted ToC now will contain C<ol> instead of C<ul> tags:
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ol>
+       <li><a href=#h-1>Chapter</a>
+       <ol>
+          <li><a href=#h-1.1>Paragraph</a>
+       </ol>
+    </ol>
+    <!-- End of generated Table of Contents -->
+
+See also: L<Using CSS for ToC formatting|"Using CSS for ToC formatting">.
+
+=head3 Use generated numbers
+
+Instead of using the HTML ordered list (OL), it's also possible to use the generated numbers to number to ToC nodes.  This can be done by modifying L<templateLevel|"templateLevel">:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+
+    my $toc          = HTML::Toc->new();
+    my $tocGenerator = HTML::TocGenerator->new();
+
+    $toc->setOptions({
+		'templateLevel' => '"<li>$node &nbsp;$text\n"',
+    });
+    $tocGenerator->generateFromFile($toc, 'index.htm');
+    print $toc->format();
+
+For instance with the original file containing:
+
+    <body>
+        <h1>Chapter</h1>
+        <h2>Paragraph</h2>
+    </body>
+
+The formatted ToC now will have the node numbers hard-coded:
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li>1 &nbsp;<a href=#h-1>Chapter</a>
+       <ul>
+          <li>1.1 &nbsp;<a href=#h-1.1>Paragraph</a>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+See also: L<Using CSS for ToC formatting|"Using CSS for ToC formatting">.
+
+=head2 Using CSS for ToC formatting
+
+Suppose you want to display a ToC with upper-alpha numbered appendix headings.  To accomplish this, you can specify a CSS style within the source document:
+
+    <html>
+    <head>
+       <style type="text/css">
+          ol.toc_appendix1 { list-style-type: upper-alpha }
+       </style>
+    </head>
+    <body>
+       <h1 class=appendix>Appendix</h1>
+       <h2 class=appendix>Appendix Paragraph</h2>
+       <h1 class=appendix>Appendix</h1>
+       <h2 class=appendix>Appendix Paragraph</h2>
+    </body>
+    </html>
+
+Here's the code:
+
+    my $toc          = new HTML::Toc;
+    my $tocInsertor  = new HTML::TocInsertor;
+
+    $toc->setOptions({
+       'templateLevelBegin'   => '"<ol class=toc_$groupId$level>\n"',
+       'templateLevelEnd'     => '"</ol>\n"',
+       'doNumberToken'        => 1,
+       'tokenToToc' => [{
+             'groupId'        => 'appendix',
+             'tokenBegin'     => '<h1>',
+             'numberingStyle' => 'upper-alpha'
+          }, {
+             'groupId'        => 'appendix',
+             'tokenBegin'     => '<h2>',
+             'level'          => 2,
+         }]
+    });
+    $tocInsertor->insertIntoFile($toc, $filename);
+
+Which whill result in the following output:
+
+    <html>
+    <head>
+       <style type="text/css">
+          ol.toc_appendix1 { list-style-type: upper-alpha }
+       </style>
+    </head>
+    <body>
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ol class=toc_appendix1>
+       <li><a href=#appendix-A>Appendix</a>
+       <ol class=toc_appendix2>
+          <li><a href=#appendix-A.1>Appendix Paragraph</a>
+       </ol>
+       <li><a href=#appendix-B>Appendix</a>
+       <ol class=toc_appendix2>
+          <li><a href=#appendix-B.1>Appendix Paragraph</a>
+       </ol>
+    </ol>
+    <!-- End of generated Table of Contents -->
+
+       <a name=appendix-A><h1>A &nbsp;Appendix</h1></a>
+       <a name=appendix-A.1><h2>A.1 &nbsp;Appendix Paragraph</h2></a>
+       <a name=appendix-B><h1>B &nbsp;Appendix</h1></a>
+       <a name=appendix-B.1><h2>B.1 &nbsp;Appendix Paragraph</h2></a>
+    </body>
+    </html>
+
+=head2 Creating site map
+
+Suppose you want to generate a table of contents of the E<lt>titleE<gt> tags of the files in the following directory structure:
+
+    path               file
+
+    .                  index.htm, <title>Main</title>
+    |- SubDir1         index.htm, <title>Sub1</title>
+    |  |- SubSubDir1   index.htm, <title>SubSub1</title>
+    |
+    |- SubDir2         index.htm, <title>Sub2</title>
+    |  |- SubSubDir1   index.htm, <title>SubSub1</title>
+    |  |- SubSubDir2   index.htm, <title>SubSub2</title>
+    |
+    |- SubDir3         index.htm, <title>Sub3</title>
+
+By specifying 'fileSpec' which determine how many slashes (/) each file may contain for a specific level:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+    use File::Find;
+
+    my $toc          = HTML::Toc->new;
+    my $tocGenerator = HTML::TocGenerator->new;
+    my @fileList;
+
+    sub wanted {
+          # Add file to 'fileList' if extension matches '.htm'
+       push (@fileList, $File::Find::name) if (m/\.htm$/);
+    }
+
+    $toc->setOptions({
+       'doLinkToFile'       => 1,
+       'templateAnchorName' => '""',
+       'templateAnchorHref' => '"<a href=$file"."#".$groupId.$level.">"',
+       'doLinkTocToToken'   => 1,
+       'tokenToToc'         => [{
+          'groupId'         => 'dir',
+          'level'           => 1,
+          'tokenBegin'      => '<title>',
+          'tokenEnd'        => '</title>',
+          'fileSpec'        => '\./[^/]+$'
+       }, {
+          'groupId'         => 'dir',
+          'level'           => 2,
+          'tokenBegin'      => '<title>',
+          'tokenEnd'        => '</title>',
+          'fileSpec'        => '\./[^/]+?/[^/]+$'
+       }, {
+          'groupId'         => 'dir',
+          'level'           => 3,
+          'tokenBegin'      => '<title>',
+          'tokenEnd'        => '</title>',
+          'fileSpec'        => '\./[^/]+?/[^/]+?/[^/]+$'
+       }]
+    });
+
+       # Traverse directory structure
+    find({wanted => \&wanted, no_chdir => 1}, '.');
+       # Generate ToC of case-insensitively sorted file list
+    $tocGenerator->extendFromFile(
+       $toc, [sort {uc($a) cmp uc($b)} @fileList]
+    );
+    print $toc->format();
+
+the following ToC will be generated:
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=./index.htm#>Main</a>
+       <ul>
+          <li><a href=./SubDir1/index.htm#>Sub1</a>
+          <ul>
+             <li><a href=./SubDir1/SubSubDir1/index.htm#>SubSub1</a>
+          </ul>
+          <li><a href=./SubDir2/index.htm#>Sub2</a>
+          <ul>
+             <li><a href=./SubDir2/SubSubDir1/index.htm#>SubSub1</a>
+             <li><a href=./SubDir2/SubSubDir2/index.htm#>SubSub2</a>
+          </ul>
+          <li><a href=./SubDir3/index.htm#>Sub3</a>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+=head1 Methods
+
+=head2 HTML::Toc::clear()
+
+    syntax:  $toc->clear()
+    returns: --
+
+Clear the ToC.
+
+=head2 HTML::Toc::format()
+
+    syntax:  $scalar = $toc->format()
+    returns: Formatted ToC.
+
+Format tokenized ToC.
+
+=head2 HTML::TocGenerator::extend()
+
+    syntax:  $tocGenerator->extend($toc, $string [, $options])
+    args:    - $toc:     (reference to array of) HTML::Toc object(s) to extend
+             - $string:  string to retrieve ToC from
+             - $options: hash reference containing generator options.
+
+Extend ToC from specified string.  For generator options, see L<HTML::TocGenerator Options|"HTML::TocGenerator Options">
+
+=head2 HTML::TocGenerator::extendFromFile()
+
+    syntax:  $tocGenerator->extendFromFile($toc, $filename [, $options])
+    args:    - $toc:      (reference to array of) HTML::Toc object(s) to extend
+             - $filename: (reference to array of) file(s) to extend ToC from
+             - $options:  hash reference containing generator options.
+
+Extend ToC from specified file.  For generator options, see L<HTML::TocGenerator Options|"HTML::TocGenerator Options">.  For an example, see L<Extend an existing ToC>.
+
+=head2 HTML::TocGenerator::generate()
+
+    syntax:  $tocGenerator->generate($toc, $string [, $options])
+    args:    - $toc:     (reference to array of) HTML::Toc object(s) to generate
+             - $string:  string to retrieve ToC from
+             - $options: hash reference containing generator options.
+
+Generate ToC from specified string.  Before generating, the ToC will be cleared.  For extending an existing ToC, use the L<HTML::TocGenerator::extend()|"HTML::TocGenerator::extend()"> method.  For generator options, see L<HTML::TocGenerator Options|"HTML::TocGenerator Options">.
+
+=head2 HTML::TocGenerator::generateFromFile()
+
+    syntax:  $tocGenerator->generateFromFile($toc, $filename [, $options])
+    args:    - $toc:      (reference to array of) HTML::Toc object(s) to 
+                          generate
+             - $filename: (reference to array of) file(s) to generate ToC from
+             - $options:  hash reference containing generator options.
+
+Generate ToC from specified file.  Before generating, the ToC will be cleared.  For extending an extisting ToC, use the L<HTML::TocGenerator::extendFromFile()|"HTML::TocGenerator::extendFromFile()"> method.  For generator options, see L<HTML::TocGenerator Options|"HTML::TocGenerator Options">.
+
+=head2 HTML::TocInsertor::insert()
+
+    syntax:  $tocInsertor->insert($toc, $string [, $options])
+    args:    - $toc:     (reference to array of) HTML::Toc object(s) to insert
+             - $string:  string to insert ToC in
+             - $options: hash reference containing insertor options.
+
+Insert ToC into specified string.  For insertor options, see L<HTML::TocInsertor Options|"HTML::TocInsertor Options">.
+
+=head2 HTML::TocInsertor::insertIntoFile()
+
+    syntax:  $tocInsertor->insertIntoFile($toc, $filename [, $options])
+    args:    - $toc:      (reference to array of) HTML::Toc object(s) to insert
+             - $filename: (reference to array of) file(s) to insert ToC in
+             - $options:  hash reference containing insertor options.
+
+Insert ToC into specified file.  For insertor options, see L<HTML::TocInsertor Options|"HTML::TocInsertor Options">.
+
+=head2 HTML::TocUpdator::insert()
+
+    syntax:  $tocUpdator->insert($toc, $string [, $options])
+    args:    - $toc:     (reference to array of) HTML::Toc object(s) to insert
+             - $string:  string to insert ToC in
+             - $options: hash reference containing updator options.
+
+Insert ToC into specified string.  Differs from L<HTML::TocInsertor::insert()|"HTML::TocInsertor::insert()"> in that inserted text will be surrounded with update tokens in order for C<HTML::TocUpdator> to be able to update this text the next time an update is issued.  For updator options, see L<HTML::TocUpdator Options|"HTML::TocUpdator Options">.
+
+=head2 HTML::TocUpdator::insertIntoFile()
+
+    syntax:  $tocUpdator->insertIntoFile($toc, $filename [, $options])
+    args:    - $toc:      (reference to array of) HTML::Toc object(s) to insert
+             - $filename: (reference to array of) file(s) to insert ToC in
+             - $options:  hash reference containing updator options.
+
+Insert ToC into specified file.  Differs from L<HTML::TocInsertor::insert()|"HTML::TocInsertor::insert()"> in that inserted text will be surrounded with update tokens in order for C<HTML::TocUpdator> to be able to update this text the next time an update is issued.  For updator options, see L<HTML::TocUpdator Options|"HTML::TocUpdator Options">.
+
+=head2 HTML::TocUpdator::update()
+
+    syntax:  $tocUpdator->update($toc, $string [, $options])
+    args:    - $toc:     (reference to array of) HTML::Toc object(s) to insert
+             - $string:  string to update ToC in
+             - $options: hash reference containing updator options.
+
+Update ToC within specified string.  For updator options, see L<HTML::TocUpdator Options|"HTML::TocUpdator Options">.
+
+=head2 HTML::TocUpdator::updateFile()
+
+    syntax:  $tocUpdator->updateFile($toc, $filename [, $options])
+    args:    - $toc:      (reference to array of) HTML::Toc object(s) to insert
+             - $filename: (reference to array of) file(s) to update ToC in
+             - $options:  hash reference containing updator options.
+
+Update ToC of specified file.  For updator options, see L<HTML::TocUpdator Options|"HTML::TocUpdator Options">.
+
+=head1 Parser Options
+
+When generating a ToC, additional options may be specified which influence the way the ToCs are generated using either C<TocGenerator>, C<TocInsertor> or C<TocUpdator>.  The options must be specified as a hash reference.  For example:
+
+    $tocGenerator->generateFromFile($toc, $filename, {doUseGroupsGlobal => 1});
+
+Available options are:
+
+=over 4
+
+=item L<doGenerateToc|"doGenerateToc">
+
+=item L<doUseGroupsGlobal|"doUseGroupsGlobal">
+
+=item L<output|"output">
+
+=item L<outputFile|"outputFile">
+
+=back
+
+=head2 doGenerateToc
+
+    syntax:         [0|1]
+    default:        1
+    applicable to:  TocInsertor, TocUpdator
+
+True (1) if ToC must be generated.  False (0) if ToC must be inserted only.
+
+=head2 doUseGroupsGlobal
+
+    syntax:         [0|1]
+    default:        0
+    applicable to:  TocGenerator, TocInsertor, TocUpdator
+
+True (1) if group levels must be used globally accross ToCs.  False (0) if not.  This option only makes sense when an array of ToCs is specified.  For example, suppose you want to generate two ToCs, one ToC for '<h1>' tokens and one ToC for '<h2>' tokens, of the file 'index.htm':
+
+    <h1>Chapter</h1>
+    <h2>Paragraph</h2>
+
+Using the default setting of 'doUseGroupsGlobal' => 0:
+
+    use HTML::Toc;
+    use HTML::TocGenerator;
+
+    my $toc1         = HTML::Toc->new();
+    my $toc2         = HTML::Toc->new();
+    my $tocGenerator = HTML::TocGenerator->new();
+
+    $toc1->setOptions({
+       'header'     => '',
+       'footer'     => '',
+       'tokenToToc' => [{'tokenBegin' => '<h1>'}]
+    });
+    $toc2->setOptions({
+       'header'     => '',
+       'footer'     => '',
+       'tokenToToc' => [{'tokenBegin' => '<h2>'}]
+    });
+    $tocGenerator->generateFromFile([$toc1, $toc2], 'index.htm');
+    print $toc1->format() . "\n\n" . $toc2->format();
+
+the output will be:
+
+    <ul>
+       <li><a href=#h-1>Chapter</a>
+    </ul>
+
+    <ul>
+       <li><a href=#h-1>Paragraph</a>
+    </ul>
+
+Each ToC will use its own numbering scheme.  Now if 'C<doUseGroupsGlobal = 1>' is specified:
+
+    $tocGenerator->generateFromFile(
+    	[$toc1, $toc2], 'index.htm', {'doUseGroupsGlobal' => 1}
+    );
+
+the output will be:
+
+    <ul>
+       <li><a href=#h-1>Chapter</a>
+    </ul>
+
+    <ul>
+       <li><a href=#h-2>Paragraph</a>
+    </ul>
+
+using a global numbering scheme for all ToCs.
+
+=head2 output
+
+    syntax:         reference to scalar
+    default:        none
+    applicable to:  TocInsertor, TocUpdator
+
+Reference to scalar where the output must be stored in.
+
+=head2 outputFile
+
+    syntax:         scalar
+    default:        none
+    applicable to:  TocInsertor, TocUpdator
+
+Filename to write output to.  If no filename is specified, output will be written to standard output.
+
+=head1 HTML::Toc Options
+
+The C<HTML::Toc> options can be grouped in the following categories:
+
+=over 4
+
+=item L<Generate options|"Generate options">
+
+=item L<Insert options|"Insert options">
+
+=item L<Update options|"Update options">
+
+=item L<Format options|"Format options">
+
+=back
+
+The ToC options must be specified using the 'setOptions' method.  For example:
+
+    my $toc = new HTML::Toc;
+
+    $toc->setOptions({
+       'doNumberToken' => 1,
+       'footer'        => '<!-- End Of ToC -->'
+       'tokenToToc'    => [{
+          'level'          => 1,
+          'tokenBegin'     => '<h1>',
+          'numberingStyle' => 'lower-alpha'
+       }]
+    });
+
+=head2 Generate options
+
+=over 4
+
+=item Token groups
+
+=over 4
+
+=item L<tokenToToc|"tokenToToc">
+
+=over 4
+
+=item L<doNumberToken|"doNumberToken">
+
+=item L<fileSpec|"fileSpec">
+
+=item L<groupId|"groupId">
+
+=item L<level|"level">
+
+=item L<tokenBegin|"tokenBegin">
+
+=item L<tokenEnd|"tokenEnd">
+
+=item L<numberingStyle|"numberingStyle">
+
+=back
+
+=item L<groupToToc|"groupToToc">
+
+=item L<levelToToc|"levelToToc">
+
+=back
+
+=item Numbering tokens
+
+=over 4
+
+=item L<doNumberToken|"doNumberToken">
+
+=item L<numberingStyle|"numberingStyle">
+
+=item L<templateTokenNumber|"templateTokenNumber">
+
+=back
+
+=item Miscellaneous
+
+=over 4
+
+=item L<attributeToExcludeToken|"attributeToExcludeToken">
+
+=item L<attributeToTocToken|"attributeToTocToken">
+
+=item L<groupToToc|"groupToToc">
+
+=item L<levelToToc|"levelToToc">
+
+=back
+
+=item Linking ToC to tokens
+
+=over 4
+
+=item L<doLinkToToken|"doLinkToToken">
+
+=item L<doLinkToFile|"doLinkToFile">
+
+=item L<doLinkToId|"doLinkToId">
+
+=item L<templateAnchorName|"templateAnchorName">
+
+=item L<templateAnchorHrefBegin|"templateAnchorHrefBegin">
+
+=item L<templateAnchorHrefEnd|"templateAnchorHrefEnd">
+
+=item L<templateAnchorNameBegin|"templateAnchorNameBegin">
+
+=item L<templateAnchorNameEnd|"templateAnchorNameEnd">
+
+=back
+
+=back
+
+=head2 Insert options
+
+=over 4
+
+=item L<insertionPoint|"insertionPoint">
+
+=back
+
+=head2 Update options
+
+=over 4
+
+=item L<tokenUpdateBeginAnchorName|"tokenUpdateBeginAnchorName">
+
+=item L<tokenUpdateEndAnchorName|"tokenUpdateEndAnchorName">
+
+=item L<tokenUpdateBeginToc|"tokenUpdateBeginToc">
+
+=item L<tokenUpdateEndToc|"tokenUpdateEndToc">
+
+=item L<tokenUpdateBeginNumber|"tokenUpdateBeginNumber">
+
+=item L<tokenUpdateEndNumber|"tokenUpdateEndNumber">
+
+=back
+
+=head2 Format options
+
+=over 4
+
+=item L<doSingleStepLevel|"doSingleStepLevel">
+
+=item L<doNestGroup|"doNestGroup">
+
+=item L<footer|"footer">
+
+=item L<groupToToc|"groupToToc">
+
+=item L<header|"header">
+
+=item L<levelIndent|"levelIndent">
+
+=item L<levelToToc|"levelToToc">
+
+=item L<templateLevelBegin|"templateLevelBegin">
+
+=item L<templateLevelEnd|"templateLevelEnd">
+
+=back
+
+=head1 HTML::Toc Options Reference
+
+=head2 attributeToExcludeToken
+
+    syntax:  $scalar
+    default: '-'
+
+Token which marks an attribute value in a L<tokenBegin|"tokenBegin"> or L<insertionPoint|"insertionPoint"> token as an attribute value a token should not have to be marked as a ToC token.  See also: L<Using attribute value as ToC entry|"Using attribute value as ToC text">.
+
+=head2 attributeToTocToken
+
+    syntax:  $scalar
+    default: '@'
+
+Token which marks an attribute in a L<tokenBegin|"tokenBegin"> token as an attribute which must be used as ToC text.  See also: L<Using attribute value as ToC entry|"Using attribute value as ToC text">.
+
+=head2 doLinkToToken
+
+    syntax:  [0|1]
+    default: 1
+
+True (1) if ToC must be linked to tokens, False (0) if not.  Note that 'HTML::TocInsertor' must be used to do the actual insertion of the anchor name within the source data.
+
+=head2 doLinkToFile
+
+    syntax:  [0|1]
+    default: 0
+
+True (1) if ToC must be linked to file, False (0) if not.  In effect only when L<doLinkToToken|"doLinkToToken"> equals True (1) and L<templateAnchorHrefBegin|"templateAnchorHrefBegin"> isn't specified.
+
+=head2 doLinkToId
+
+    syntax:  [0|1]
+    default: 0
+
+True (1) if ToC must be linked to tokens by using token ids.  False (0) if ToC must be linked to tokens by using anchor names.
+
+=head2 doNestGroup
+
+    syntax:  [0|1]
+    default: 0
+
+True (1) if groups must be nested in the formatted ToC, False (0) if not.  In effect only when multiple groups are specified within the L<tokenToToc|"tokenToToc"> setting.  For an example, see L<Generate multiple groups in one ToC|"Generate multiple groups in one ToC">.
+
+=head2 doNumberToken
+
+    syntax:  [0|1]
+    default: 0
+
+True (1) if tokens which are used for the ToC generation must be numbered.  This option may be specified both as a global ToC option or within a L<tokenToToc|"tokenToToc"> group.  When specified within a C<tokenToToc> option, the C<doNumberToken> applies to that group only.  For an example, see L<Specify an additional 'Part' group|"Specify an additional 'Part' group">.
+
+=head2 doSingleStepLevel
+
+    syntax:  [0|1]
+    default: 1
+
+True (1) if levels of a formatted ToC must advance one level at a time.  For example, when generating a ToC of a file with a missing '<h2>':
+
+    <h1>Chapter</h1>
+    <h3>Paragraph</h3>
+
+By default, an empty indentation level will be inserted in the ToC:
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1>Header 1</a>
+       <ul>
+          <ul>
+             <li><a href=#h-1.0.1>Header 3</a>
+          </ul>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+After specifying:
+
+    $toc->setOptions({'doSingleStepLevel' => 0});
+
+the ToC will not have an indentation level inserted for level 2:
+
+    <!-- Table of Contents generated by Perl - HTML::Toc -->
+    <ul>
+       <li><a href=#h-1>Header 1</a>
+       <ul>
+             <li><a href=#h-1.0.1>Header 3</a>
+       </ul>
+    </ul>
+    <!-- End of generated Table of Contents -->
+
+=head2 fileSpec
+
+    syntax:  <regexp>
+    default: undef
+
+Specifies which files should match the current level.  Valid only if L<doLinkToFile|"doLinkToFile"> equals 1.  For an example, see L<Site map|"Site map">.
+
+=head2 footer
+
+    syntax:  $scalar
+    default: "\n<!-- End of generated Table of Contents -->\n"
+
+String to output at end of ToC.
+
+=head2 groupId
+
+    syntax:  $scalar
+    default: 'h'
+
+Sets the group id attribute of a tokenGroup.  With this attribute it's possible to divide the ToC into multiple groups.  Each group has its own numbering scheme.  For example, to generate a ToC of both normal headings and 'appendix' headings, specify the following ToC settings:
+
+    $toc->setOptions({
+       'tokenToToc' => [{
+              'tokenBegin' => '<h1 class=-appendix>'
+           }, {
+              'groupId' => 'appendix',
+              'tokenBegin' => '<h1 class=appendix>'
+       }]
+    });
+
+=head2 groupToToc
+
+    syntax:  <regexp>
+    default: '.*'
+
+Determines which groups to use for generating the ToC.  For example, to create a ToC for groups [a-b] only, specify:
+
+    'groupToToc => '[a-b]'
+
+This option is evaluated during both ToC generation and ToC formatting.  This enables you to generate a ToC of all groups, but - after generating - format only specified groups:
+
+    $toc->setOptions({'groupToToc' => '.*'});
+    $tocGenerator->generateToc($toc, ...);
+        # Get ToC of all groups
+    $fullToc = $toc->format();
+        # Get ToC of 'appendix' group only
+    $toc->setOptions({'groupToToc' => 'appendix'});
+    $appendixToc = $toc->format();
+
+=head2 header
+
+    syntax:  $scalar
+    default: "\n<!-- Table of Contents generated by Perl - HTML::Toc -->\n"
+
+String to output at begin of ToC.
+
+
+=head2 insertionPoint
+
+    syntax:  [<before|after|replace>] <token>
+    default: 'after <body>'
+    token:   <[/]tag{ attribute=[-|@]<regexp>}> |
+             <text regexp> |
+             <declaration regexp> |
+             <comment regexp>
+
+Determines the point within the source, where the ToC should be inserted.  When specifying a start tag as the insertion point token, attributes to be included may be specified as well.  Note that the attribute value must be specified as a regular expression.  For example, to specify the C<<h1 class=header>> tag as insertion point:
+
+    '<h1 class=^header$>'
+
+Examples of valid 'insertionPoint' tokens are:
+
+    '<h1>'
+    '</h1>'
+    '<!-- ToC -->'
+    '<!ToC>'
+    'ToC will be placed here'
+
+It is also possible to specify attributes to exclude, by prefixing the value with an L<attributeToExcludeToken|"attributeToExcludeToken">, default a minus sign (-).  For example, to specify the C<<h1>> tag as insertion point, excluding all C<<h1 class=header>> tags:
+
+    '<h1 class=-^header$>'
+
+See also L<tokenBegin|"tokenBegin">.
+
+=head2 level
+
+    syntax:  number
+    default: 1
+
+Number which identifies at which level the tokengroup should be incorporated into the ToC.  See also: L<tokenToToc|"tokenToToc">.
+
+=head2 levelIndent
+
+    syntax:  number
+    default: 3
+
+Sets the number of spaces each level will be indented, when formatting the ToC.
+
+=head2 levelToToc
+
+    syntax:  <regexp>
+    default: '.*'
+
+Determines which group levels to use for generating the ToC.  For example, to create a ToC for levels 1-2 only, specify:
+
+    'levelToToc => '[1-2]'
+
+This option is evaluated during both ToC generation and ToC formatting.  This enables you to generate a ToC of all levels, but - after generating - retrieve only specified levels:
+
+    $toc->setOptions({'levelToToc' => '.*'});
+    $tocGenerator->generateToc($toc, ...);
+        # Get ToC of all levels
+    $fullToc = $toc->getToc();
+        # Get ToC of level 1 only
+    $toc->setOptions({'levelToToc' => '1'});
+    $level1Toc = $toc->getToc();
+
+=head2 numberingStyle
+
+    syntax:  [decimal|lower-alpha|upper-alpha|lower-roman|upper-roman]}
+    default: decimal
+
+Determines which numbering style to use for a token group when L<doLinkToToken|"doLinkToToken"> is set to True (1).  When specified as a main ToC option, the setting will be the default for all groups.  When specified within a tokengroup, this setting will override any default for that particular tokengroup, e.g.:
+
+    $toc->setOptions({
+       'doNumberToken' => 1,
+       'tokenToToc' => [{
+          'level'          => 1,
+          'tokenBegin'     => '<h1>',
+          'numberingStyle' => 'lower-alpha'
+       }]
+    });
+
+If C<roman> style is specified, be sure to have the Roman module installed, available from L<http://www.perl.com/CPAN/modules/by-module/Roman>.
+
+=head2 templateAnchorName
+
+    syntax:  <expression|function reference>
+    default: '$groupId."-".$node'
+
+Anchor name to use when L<doLinkToToken|"doLinkToToken"> is set to True (1).  The anchor name is passed to both L<templateAnchorHrefBegin|"templateAnchorHrefBegin"> and L<templateAnchorNameBegin|"templateAnchorNameBegin">.  The template may be specified as either an expression or a function reference.  The expression may contain the following variables:
+
+    $file
+    $groupId
+    $level
+    $node
+
+If C<templateAnchorHrefBegin> is a function reference to a function returning the anchor, like in:
+
+    $toc->setOptions({'templateAnchorName' => \&assembleAnchorName});
+
+the function will be called with the following arguments:
+
+    $anchorName = assembleAnchorName($file, $groupId, $level, $node);
+
+=head2 templateAnchorHrefBegin
+
+    syntax:  <expression|function reference>
+    default: '"<a href=#$anchorName>"' or
+             '"<a href=$file#$anchorName>"',
+             depending on 'doLinkToFile' being 0 or 1 respectively.
+
+Anchor reference begin token to use when L<doLinkToToken|"doLinkToToken"> is set to True (1).  The template may be specified as either an expression or a function reference.  The expression may contain the following variables:
+
+    $file
+    $groupId
+    $level
+    $node
+    $anchorName
+
+If C<templateAnchorHrefBegin> is a function reference to a function returning the anchor, like in:
+
+    $toc->setOptions({'templateAnchorHrefBegin' => \&assembleAnchorHrefBegin});
+
+the function will be called with the following arguments:
+
+    $anchorHrefBegin = &assembleAnchorHrefBegin(
+       $file, $groupId, $level, $node, $anchorName
+    );
+
+See also: L<templateAnchorName|"templateAnchorName">, L<templateAnchorHrefEnd|"templateAnchorHrefEnd">.
+
+=head2 templateAnchorHrefEnd
+
+    syntax:  <expression|function reference>
+    default: '"</a>"'
+
+Anchor reference end token to use when L<doLinkToToken|"doLinkToToken"> is set to True (1).  The template may be specified as either an expression or a function reference.  If L<templateAnchorHrefEnd|"templateAnchorHrefEnd"> is a function reference to a function returning the anchor end, like in:
+
+    $toc->setOptions({'templateAnchorHrefEnd' => \&assembleAnchorHrefEnd});
+
+the function will be called without arguments:
+
+    $anchorHrefEnd = &assembleAnchorHrefEnd;
+
+See also: L<templateAnchorHrefBegin|"templateAnchorHrefBegin">.
+
+=head2 templateAnchorNameBegin
+
+    syntax:  <expression|function reference>
+    default: '"<a name=$anchorName>"'
+
+Anchor name begin token to use when L<doLinkToToken|"doLinkToToken"> is set to True (1).  The template may be specified as either an expression or a function reference.  The expression may contain the following variables:
+
+    $file
+    $groupId
+    $level
+    $node
+    $anchorName
+
+If C<templateAnchorNameBegin> is a function reference to a function returning the anchor name, like in:
+
+    $toc->setOptions({'templateAnchorNameBegin' => \&assembleAnchorNameBegin});
+
+the function will be called with the following arguments:
+
+    $anchorNameBegin = assembleAnchorNameBegin(
+        $file, $groupId, $level, $node, $anchorName
+    );
+
+See also: L<templateAnchorName|"templateAnchorName">, L<templateAnchorNameEnd|"templateAnchorNameEnd">.
+
+=head2 templateAnchorNameEnd
+
+    syntax:  <expression|function reference>
+    default: '"</a>"'
+
+Anchor name end token to use when L<doLinkToToken|"doLinkToToken"> is set to True (1).  The template may be specified as either an expression or a function reference.  If L<templateAnchorNameEnd|"templateAnchorNameEnd"> is a function reference to a function returning the anchor end, like in:
+
+    $toc->setOptions({'templateAnchorNameEnd' => \&assembleAnchorNameEnd});
+
+the function will be called without arguments:
+
+    $anchorNameEnd = &assembleAnchorNameEnd;
+
+See also: L<templateAnchorNameBegin|"templateAnchorNameBegin">.
+
+=head2 templateLevel
+
+    syntax:  <expression|function reference>
+    default: '"<li>$text\n"'
+
+Expression to use when formatting a ToC node.  The template may be specified as either an expression or a function reference.  The expression may contain the following variables:
+
+    $level
+    $groupId
+    $node
+    $sequenceNr
+    $text
+
+If C<templateLevel> is a function reference to a function returning the ToC node, like in:
+
+    $toc->setOptions({'templateLevel' => \&AssembleTocNode});
+
+the function will be called with the following arguments:
+
+    $tocNode = &AssembleTocNode(
+        $level, $groupId, $node, $sequenceNr, $text
+    );
+
+=head2 templateLevelBegin
+
+    syntax:  <expression>
+    default: '"<ul>\n"'
+
+Expression to use when formatting begin of ToC level.  See L<templateLevel|"templateLevel"> for list of available variables to use within the expression.  For example, to give each ToC level a class name to use with Cascading Style Sheets (CSS), use the expression:
+
+    '"<ul class=toc_$groupId$level>\n"'
+
+which will result in each ToC group being given a class name:
+
+    <ul class=toc_h1>
+       <li>Header
+    </ul>
+
+For an example, see L<Using CSS for ToC formatting|"Using CSS for ToC formatting">.
+
+=head2 templateLevelEnd
+
+    syntax:  <expression>
+    default: '"<ul>\n"'
+
+Expression to use when formatting end of ToC level.  See L<templateLevel|"templateLevel"> for a list of available variables to use within the expression.  The default expression is:
+
+    '"</ul>\n"'
+
+For an example, see L<Using CSS for ToC formatting|"Using CSS for ToC formatting">.
+
+=head2 templateTokenNumber
+
+    syntax:  <expression|function reference>
+    default: '"$node &nbsp;"'
+
+Token number to use when L<doNumberToken|"doNumberToken"> equals True (1).  The template may be specified as either an expression or a function reference.  The expression has access to the following variables:
+
+    $file
+    $groupId
+    $groupLevel
+    $level
+    $node
+    $toc
+
+If C<templateTokenNumber> is a function reference to a function returning the token number, like in:
+
+    $toc->setOptions({'templateTokenNumber' => \&assembleTokenNumber});
+
+the function will be called with the following arguments:
+
+    $number = &assembleTokenNumber(
+        $node, $groupId, $file, $groupLevel, $level, $toc
+    );
+
+=head2 tokenBegin
+
+    syntax:  <token>
+    default: '<h1>'
+    token:   <[/]tag{ attribute=[-|@]<regexp>}> |
+             <text regexp> |
+             <declaration regexp> |
+             <comment regexp>
+
+This scalar defines the token that will trigger text to be put into the ToC.  Any start tag, end tag, comment, declaration or text string can be specified.  Examples of valid 'tokenBegin' tokens are:
+
+    '<h1>'
+    '</end>'
+    '<!-- Start ToC entry -->'
+    '<!Start ToC entry>'
+    'ToC entry'
+
+When specifying a start tag, attributes to be included may be specified as well.  Note that the attribute value is used as a regular expression.  For example, to specify the C<<h1 class=header>> tag as tokenBegin:
+
+    '<h1 class=^header$>'
+
+It is also possible to specify attributes to exclude, by prefixing the value with an L<attributeToExcludeToken|"attributeToExcludeToken">, default a minus sign (-).  For example, to specify the C<<h1>> tag as tokenBegin, excluding all C<<h1 class=header>> tags:
+
+    '<h1 class=-^header$>'
+
+Also, you can specify here an attribute value which has to be used as ToC text, by prefixing the value with an L<attributeToTocToken|"">, default an at sign (@).  For example, to use the class value as ToC text:
+
+    '<h1 class=@>'
+
+See L<Generate multiple ToCs|"Generate multiple ToCs"> for an elaborated example using the C<attributeToTocToken> to generate a ToC of image C<alt> attribute values.
+
+See also: L<tokenEnd|"tokenEnd">, L<tokenToToc|"tokenToToc">.
+
+=head2 tokenEnd
+
+    syntax:  $scalar
+    default: empty string ('') or end tag counterpart of 'tokenBegin' if 
+             'tokenBegin' is a start tag
+
+The 'tokenEnd' definition applies to the same rules as L<tokenBegin|"tokenBegin">.
+
+See also: L<tokenBegin|"tokenBegin">, L<tokenToToc|"tokenToToc">.
+
+=head2 tokenToToc
+
+    syntax:  [{array of hashrefs}]
+    default: [{
+                'level'      => 1,
+                'tokenBegin' => '<h1>'
+             }, {
+                'level'      => 2,
+                'tokenBegin' => '<h2>'
+             }, {
+                'level'      => 3,
+                'tokenBegin' => '<h3>'
+             }, {
+                'level'      => 4,
+                'tokenBegin' => '<h4>'
+             }, {
+                'level'      => 5,
+                'tokenBegin' => '<h5>'
+             }, {
+                'level'      => 6,
+                'tokenBegin' => '<h6>'
+             }]
+
+This hash define the tokens that must act as ToC entries.  Each tokengroup may contain a L<groupId|"groupId">, L<level|"level">, L<numberingStyle|"numberingStyle">, L<tokenBegin|"tokenBegin"> and L<tokenEnd|"tokenEnd"> identifier.
+
+=head2 tokenUpdateBeginAnchorName
+
+    syntax:  <string>
+    default: '<!-- #BeginTocAnchorNameBegin -->';
+
+This token marks the begin of an anchor name, inserted by C<HTML::TocInsertor>.  This option is used by C<HTML::TocUpdator>.
+
+=head2 tokenUpdateEndAnchorName
+
+    syntax:  <string>
+    default: '<!-- #EndTocAnchorName -->';
+
+This option is used by C<HTML::TocUpdator>, to mark the end of an inserted anchor name.
+
+=head2 tokenUpdateBeginNumber
+
+    syntax:  <string>
+    default: '<!-- #BeginTocNumber -->';
+
+This option is used by C<HTML::TocUpdator>, to mark the begin of an inserted number.
+
+=head2 tokenUpdateEndNumber
+
+    syntax:  <string>
+    default: '<!-- #EndTocAnchorName -->';
+
+This option is used by C<HTML::TocUpdator>, to mark the end of an inserted number.
+
+=head2 tokenUpdateBeginToc
+
+    syntax:  <string>
+    default: '<!-- #BeginToc -->';
+
+This option is used by C<HTML::TocUpdator>, to mark the begin of an inserted ToC.
+
+=head2 tokenUpdateEndToc
+
+    syntax:  <string>
+    default: '<!-- #EndToc -->';
+
+This option is used by C<HTML::TocUpdator>, to mark the end of an inserted ToC.
+
+=head1 Known issues
+
+=head2 Cygwin
+
+In order for the test files to run on Cygwin without errors, the 'UNIX' default text file type has to be selected during the Cygwin setup.
+When extracting the tar.gz file with WinZip the 'TAR file smart CR/LF conversion' has to be turned off via {Options|Configuration...|Miscellaneous} in order for the files 'toc.pod' and './manualTest/manualTest1.htm' to be left in UNIX format.
+
+=head2 Nested anchors
+
+HTML::Toc can only link to existing anchors if these anchors are placed outside of the ToC tokens.  Otherwise a warning will be given.  For example, generating a L<linked|"doLinkToToken"> ToC of C<E<lt>h1E<gt>> tokens of the following text:
+
+    <a name=foo><h1>Header</h1></a>
+
+will go all right, whereas:
+
+    <h1><a name=foo>Header</a></h1>
+
+will yield the warning:
+
+    warning (1): Nested anchor '<a name=foo>' within anchor '<a name=h-1>'.
+
+since anchor names aren't allowed to be nested according to the HTML 4.01 specification.
+
+=head1 AUTHOR
+
+Freddy Vulto E<lt>L<"fvu@fvu.myweb.nl">E<gt>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001 Freddy Vulto.  All rights reserved.
+
+This library is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
diff --git a/examples/includes/HTML-Toc-0.91/TocGenerator.pm b/examples/includes/HTML-Toc-0.91/TocGenerator.pm
new file mode 100644
index 0000000..8c49194
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/TocGenerator.pm
@@ -0,0 +1,1793 @@
+#=== HTML::TocGenerator =======================================================
+# function: Generate 'HTML::Toc' table of contents.
+# note:     - 'TT' is an abbrevation of 'TocToken'.
+
+
+package HTML::TocGenerator;
+
+
+use strict;
+use HTML::Parser;
+
+
+BEGIN {
+	use vars qw(@ISA $VERSION);
+
+	$VERSION = '0.91';
+
+	@ISA = qw(HTML::Parser);
+}
+
+
+	# Warnings
+use constant WARNING_NESTED_ANCHOR_PS_WITHIN_PS               => 1;
+use constant WARNING_TOC_ATTRIBUTE_PS_NOT_AVAILABLE_WITHIN_PS => 2;
+
+
+use constant TOC_TOKEN_ID       => 0;
+use constant TOC_TOKEN_INCLUDE  => 1;
+use constant TOC_TOKEN_EXCLUDE  => 2;
+use constant TOC_TOKEN_TOKENS   => 3;
+use constant TOC_TOKEN_GROUP    => 4;
+use constant TOC_TOKEN_TOC      => 5;
+
+	# Token types
+use constant TT_TAG_BEGIN                => 0;
+use constant TT_TAG_END                  => 1;
+use constant TT_TAG_TYPE_END             => 2;
+use constant TT_INCLUDE_ATTRIBUTES_BEGIN => 3;
+use constant TT_EXCLUDE_ATTRIBUTES_BEGIN => 4;
+use constant TT_INCLUDE_ATTRIBUTES_END   => 5;
+use constant TT_EXCLUDE_ATTRIBUTES_END   => 6;
+use constant TT_GROUP                    => 7;
+use constant TT_TOC                      => 8;
+use constant TT_ATTRIBUTES_TOC           => 9;
+
+
+use constant CONTAINMENT_INCLUDE => 0;
+use constant CONTAINMENT_EXCLUDE => 1;
+
+use constant TEMPLATE_ANCHOR            => '$groupId."-".$node';
+use constant TEMPLATE_ANCHOR_HREF       => 
+					'"<a href=#".' . TEMPLATE_ANCHOR . '.">"';
+use constant TEMPLATE_ANCHOR_HREF_FILE  => 
+					'"<a href=".$file."#".' . TEMPLATE_ANCHOR . '.">"';
+use constant TEMPLATE_ANCHOR_NAME       => 
+					'"<a name=".' . TEMPLATE_ANCHOR . '.">"';
+
+use constant TEMPLATE_TOKEN_NUMBER      => '"$node &nbsp"';
+
+
+use constant TT_TOKENTYPE_START        => 0;
+use constant TT_TOKENTYPE_END          => 1;
+use constant TT_TOKENTYPE_TEXT         => 2;
+use constant TT_TOKENTYPE_COMMENT      => 3;
+use constant TT_TOKENTYPE_DECLARATION  => 4;
+
+
+END {}
+
+
+#--- HTML::TocGenerator::new() ------------------------------------------------
+# function: Constructor
+
+sub new {
+		# Get arguments
+	my ($aType) = @_;
+	my $self = $aType->SUPER::new;
+		# Bias to not generate ToC
+	$self->{_doGenerateToc} = 0;
+		# Bias to not use global groups
+	$self->{_doUseGroupsGlobal} = 0;
+		# Output
+	$self->{output} = "";
+		# Reset internal variables
+	$self->_resetBatchVariables();
+
+	$self->{options} = {};
+
+	return $self;
+}  # new()
+
+
+#--- HTML::TocGenerator::_deinitializeBatch() ---------------------------------
+
+sub _deinitializeBatch() {
+		# Get arguments
+	my ($self) = @_;
+}  # _deinitializeBatch()
+
+
+#--- HTML::TocGenerator::_deinitializeExtenderBatch() -------------------------
+
+sub _deinitializeExtenderBatch() {
+		# Get arguments
+	my ($self) = @_;
+		# Do general batch deinitialization
+	$self->_deinitializeBatch();
+		# Indicate end of ToC generation
+	$self->{_doGenerateToc} = 0;
+		# Reset batch variables
+	$self->_resetBatchVariables();
+}  # _deinitializeExtenderBatch()
+
+
+#--- HTML::TocGenerator::_deinitializeGeneratorBatch() ------------------------
+
+sub _deinitializeGeneratorBatch() {
+		# Get arguments
+	my ($self) = @_;
+		# Do 'extender' batch deinitialization
+	$self->_deinitializeExtenderBatch();
+}  # _deinitializeBatchGenerator()
+
+
+#--- HTML::TocGenerator::_doesHashContainHash() -------------------------------
+# function: Determines whether hash1 matches regular expressions of hash2.
+# args:     - $aHash1
+#           - $aHash2
+#           - $aContainmentType: 0 (include) or 1 (exclude)
+# returns:  True (1) if hash1 satisfies hash2, 0 if not.  For example, with the
+#           following hashes:
+#
+#              %hash1 = {							%hash2 = {
+#                 'class' => 'header'				'class' => '^h'
+#                 'id'    => 'intro'         }
+#              }
+#
+#           the routine will return 1 if 'aContainmentType' equals 0, cause
+#           'hash1' satisfies the conditions of 'hash2'.  The routine will
+#           return 0 if 'aContainmentType' equals 1, cause 'hash1' doesn't
+#           exclude the conditions of 'hash2'.
+# note:     Class function.
+
+sub _doesHashContainHash {
+		# Get arguments
+	my ($aHash1, $aHash2, $aContainmentType) = @_;
+		# Local variables
+	my ($key1, $value1, $key2, $value2, $result);
+		# Bias to success
+	$result = 1;
+		# Loop through hash2
+	HASH2: while (($key2, $value2) = each %$aHash2) {
+		# Yes, values are available;
+			# Get value1
+		$value1 = $aHash1->{$key2};
+			# Does value1 match criteria of value2?
+		if (defined($value1) && $value1 =~ m/$value2/) {
+			# Yes, value1 matches criteria of value2;
+				# Containment type was exclude?
+			if ($aContainmentType == CONTAINMENT_EXCLUDE) {
+				# Yes, containment type was exclude;
+					# Indicate condition fails
+				$result = 0;
+					# Reset 'each' iterator which we're going to break
+				keys %$aHash2;
+					# Break loop
+				last HASH2;
+			}
+		}
+		else {
+			# No, value1 didn't match criteria of value2;
+				# Containment type was include?
+			if ($aContainmentType == CONTAINMENT_INCLUDE) {
+				# Yes, containment type was include;
+					# Indicate condition fails
+				$result = 0;
+					# Reset 'each' iterator which we're going to break
+				keys %$aHash2;
+					# Break loop
+				last HASH2;
+			}
+		}
+	}
+		# Return value
+	return $result;
+}  # _doesHashContainHash()
+
+
+#--- HTML::TocGenerator::_extend() --------------------------------------------
+# function: Extend ToC.
+#           - $aString: String to parse.
+
+sub _extend {
+		# Get arguments
+	my ($self, $aFile) = @_;
+		# Local variables
+	my ($file);
+		# Parse string
+	$self->parse($aFile);
+		# Flush remaining buffered text
+	$self->eof();
+}  # _extend()
+
+
+#--- HTML::TocGenerator::_extendFromFile() ------------------------------------
+# function: Extend ToC.
+#           - $aFile: (reference to array of) file to parse.
+
+sub _extendFromFile {
+		# Get arguments
+	my ($self, $aFile) = @_;
+		# Local variables
+	my ($file, @files);
+		# Dereference array reference or make array of file specification
+	@files = (ref($aFile) =~ m/ARRAY/) ? @$aFile : ($aFile);
+		# Loop through files
+	foreach $file (@files) {
+			# Store filename
+		$self->{_currentFile} = $file;
+			# Parse file
+		$self->parse_file($file);
+			# Flush remaining buffered text
+		$self->eof();
+	}
+}  # _extendFromFile()
+
+
+#--- HTML::TocGenerator::_formatHeadingLevel() --------------------------------
+# function: Format heading level.
+# args:     - $aLevel: Level of current heading
+#           - $aClass: Class of current heading
+#           - $aGroup: Group of current heading
+#           - $aToc: Toc of current heading
+
+sub _formatHeadingLevel {
+		# Get arguments
+	my ($self, $aLevel, $aClass, $aGroup, $aToc) = @_;
+		# Local variables
+	my ($result, $headingNumber, $numberingStyle);
+
+	$headingNumber = $self->_getGroupIdManager($aToc)->
+		{levels}{$aClass}[$aLevel - 1] || 0;
+
+		# Alias numbering style of current group
+	$numberingStyle = $aGroup->{numberingStyle};
+
+	SWITCH: {
+		if ($numberingStyle eq "decimal") {
+			$result = $headingNumber;
+			last SWITCH;
+		}
+		if ($numberingStyle eq "lower-alpha") {
+			$result = chr($headingNumber + ord('a') - 1);
+			last SWITCH;
+		}
+		if ($numberingStyle eq "upper-alpha") {
+			$result = chr($headingNumber + ord('A') - 1);
+			last SWITCH;
+		}
+		if ($numberingStyle eq "lower-roman") {
+			require Roman;
+			$result = Roman::roman($headingNumber);
+			last SWITCH;
+		}
+		if ($numberingStyle eq "upper-roman") {
+			require Roman;
+			$result = Roman::Roman($headingNumber);
+			last SWITCH;
+		}
+		die "Unknown case: $numberingStyle";
+	}
+		# Return value
+	return $result;
+}	# _formatHeadingLevel()
+
+
+#--- HTML::TocGenerator::_formatTocNode() -------------------------------------
+# function: Format heading node.
+# args:     - $aLevel: Level of current heading
+#           - $aClass: Class of current heading
+#           - $aGroup: Group of current heading
+#           - $aToc: Toc of current heading
+
+sub _formatTocNode {
+		# Get arguments
+	my ($self, $aLevel, $aClass, $aGroup, $aToc) = @_;
+		# Local variables
+	my ($result, $level, $levelGroups);
+
+		# Alias 'levelGroups' of right 'groupId'
+	$levelGroups = $aToc->{_levelGroups}{$aGroup->{'groupId'}};
+		# Loop through levels
+	for ($level = 1; $level <= $aLevel; $level++) {
+			# If not first level, add dot
+		$result = ($result ? $result . "." : $result);
+			# Format heading level using argument group
+		$result .= $self->_formatHeadingLevel(
+			$level, $aClass, @{$levelGroups}[$level - 1], $aToc
+		);
+	}
+		# Return value
+	return $result;
+}  # _formatTocNode()
+     	
+     	
+#--- HTML::TocGenerator::_generate() ------------------------------------------
+# function: Generate ToC.
+# args:     - $aString: Reference to string to parse
+
+sub _generate {
+		# Get arguments
+	my ($self, $aString) = @_;
+		# Local variables
+	my ($toc);
+		# Loop through ToCs
+	foreach $toc (@{$self->{_tocs}}) {
+			# Clear ToC
+		$toc->clear();
+	}
+		# Extend ToCs
+	$self->_extend($aString);
+}  # _generate()
+
+
+#--- HTML::TocGenerator::_generateFromFile() ----------------------------------
+# function: Generate ToC.
+# args:     - $aFile: (reference to array of) file to parse.
+
+sub _generateFromFile {
+		# Get arguments
+	my ($self, $aFile) = @_;
+		# Local variables
+	my ($toc);
+		# Loop through ToCs
+	foreach $toc (@{$self->{_tocs}}) {
+			# Clear ToC
+		$toc->clear();
+	}
+		# Extend ToCs
+	$self->_extendFromFile($aFile);
+}  # _generateFromFile()
+
+
+#--- HTML::TocGenerator::_getGroupIdManager() ---------------------------------
+# function: Get group id manager.
+# args:     - $aToc: Active ToC.
+# returns:  Group id levels.
+
+sub _getGroupIdManager {
+		# Get arguments
+	my ($self, $aToc) = @_;
+		# Local variables
+	my ($result);
+		# Global groups?
+	if ($self->{options}{'doUseGroupsGlobal'}) {
+		# Yes, global groups;
+		$result = $self;
+	}
+	else {
+		# No, local groups;
+		$result = $aToc;
+	}
+		# Return value
+	return $result;
+}  # _getGroupIdManager()
+
+
+#--- HTML::TocGenerator::_initializeBatch() -----------------------------------
+# function: Initialize batch.  This function is called once when a parse batch
+#           is started.
+# args:     - $aTocs: Reference to array of tocs.
+
+sub _initializeBatch {
+		# Get arguments
+	my ($self, $aTocs) = @_;
+		# Local variables
+	my ($toc);
+
+		# Store reference to tocs
+		
+		# Is ToC specification reference to array?
+	if (ref($aTocs) =~ m/ARRAY/) {
+		# Yes, ToC specification is reference to array;
+			# Store array reference
+		$self->{_tocs} = $aTocs;
+	}
+	else {
+		# No, ToC specification is reference to ToC object;
+			# Wrap reference in array reference, containing only one element
+		$self->{_tocs} = [$aTocs];
+	}
+		# Loop through ToCs
+	foreach $toc (@{$self->{_tocs}}) {
+			# Parse ToC options
+		$toc->parseOptions();
+	}
+}  # _initializeBatch()
+
+
+#--- HTML::TocGenerator::_initializeExtenderBatch() --------------------------
+# function: Initialize 'extender' batch.  This function is called once when a 
+#           parse batch is started.
+# args:     - $aTocs: Reference to array of tocs.
+
+sub _initializeExtenderBatch {
+		# Get arguments
+	my ($self, $aTocs) = @_;
+		# Do general batch initialization
+	$self->_initializeBatch($aTocs);
+		# Parse ToC options
+	$self->_parseTocOptions();
+		# Indicate start of batch
+	$self->{_doGenerateToc} = 1;
+}  # _initializeExtenderBatch()
+
+
+#--- HTML::TocGenerator::_initializeGeneratorBatch() --------------------------
+# function: Initialize generator batch.  This function is called once when a 
+#           parse batch is started.
+# args:     - $aTocs: Reference to array of tocs.
+#           - $aOptions: optional options
+
+sub _initializeGeneratorBatch {
+		# Get arguments
+	my ($self, $aTocs, $aOptions) = @_;
+		# Add invocation options
+	$self->setOptions($aOptions);
+		# Option 'doUseGroupsGlobal' specified?
+	if (!defined($self->{options}{'doUseGroupsGlobal'})) {
+		# No, options 'doUseGroupsGlobal' not specified;
+			# Default to no 'doUseGroupsGlobal'
+		$self->{options}{'doUseGroupsGlobal'} = 0;
+	}
+		# Global groups?
+	if ($self->{options}{'doUseGroupsGlobal'}) {
+		# Yes, global groups;
+			# Reset groups and levels
+		$self->_resetStackVariables();
+	}
+		# Do 'extender' batch initialization
+	$self->_initializeExtenderBatch($aTocs);
+}  # _initializeGeneratorBatch()
+
+
+#--- HTML::TocGenerator::_linkTocToToken() ------------------------------------
+# function: Link ToC to token.
+# args:     - $aToc: ToC to add token to.
+#           - $aFile
+#           - $aGroupId
+#           - $aLevel
+#           - $aNode
+#           - $aGroupLevel
+#           - $aLinkType
+#           - $aTokenAttributes: reference to hash containing attributes of 
+#                currently parsed token
+
+sub _linkTocToToken {
+		# Get arguments
+	my (
+		$self, $aToc, $aFile, $aGroupId, $aLevel, $aNode, $aGroupLevel, 
+		$aDoLinkToId, $aTokenAttributes
+	) = @_;
+		# Local variables
+	my ($file, $groupId, $level, $node, $anchorName);
+	my ($doInsertAnchor, $doInsertId);
+
+		# Fill local arguments to be used by templates
+	$file    = $aFile;
+	$groupId = $aGroupId;
+	$level   = $aLevel;
+	$node    = $aNode;
+	
+		# Assemble anchor name
+	$anchorName = 
+		ref($aToc->{_templateAnchorName}) eq "CODE" ?
+			&{$aToc->{_templateAnchorName}}(
+				$aFile, $aGroupId, $aLevel, $aNode
+			) : 
+			eval($aToc->{_templateAnchorName});
+
+		# Bias to insert anchor name
+	$doInsertAnchor = 1;
+	$doInsertId     = 0;
+		# Link to 'id'?
+	if ($aDoLinkToId) {
+		# Yes, link to 'id';
+			# Indicate to insert anchor id
+		$doInsertAnchor = 0;
+		$doInsertId     = 1;
+			# Id attribute is available?
+		if (defined($aTokenAttributes->{id})) {
+			# Yes, id attribute is available;
+				# Use existing ids?
+			if ($aToc->{options}{'doUseExistingIds'}) {
+				# Yes, use existing ids;
+					# Use existing id
+				$anchorName = $aTokenAttributes->{id};
+					# Indicate to not insert id
+				$doInsertId = 0;
+			}
+		}
+
+	}
+	else {
+		# No, link to 'name';
+			# Anchor name is currently active?
+		if (defined($self->{_activeAnchorName})) {
+			# Yes, anchor name is currently active;
+				# Use existing anchors?
+			if ($aToc->{options}{'doUseExistingAnchors'}) {
+				# Yes, use existing anchors;
+					# Use existing anchor name
+				$anchorName = $self->{_activeAnchorName};
+					# Indicate to not insert anchor name
+				$doInsertAnchor = 0;
+			}
+			else {
+				# No, don't use existing anchors; insert new anchor;
+					# 
+			}
+		}
+	}
+
+		# Add reference to ToC
+	$aToc->{_toc} .= 
+		ref($aToc->{_templateAnchorHrefBegin}) eq "CODE" ?
+			&{$aToc->{_templateAnchorHrefBegin}}(
+				$aFile, $aGroupId, $aLevel, $aNode, $anchorName
+			) : 
+			eval($aToc->{_templateAnchorHrefBegin});
+
+		# Bias to not output anchor name end
+	$self->{_doOutputAnchorNameEnd} = 0;
+		# Must anchor be inserted?
+	if ($doInsertAnchor) {
+		# Yes, anchor must be inserted;
+			# Allow adding of anchor name begin token to text by calling 
+			# 'anchorNameBegin' method
+		$self->anchorNameBegin(
+			ref($aToc->{_templateAnchorNameBegin}) eq "CODE" ?
+				&{$aToc->{_templateAnchorNameBegin}}(
+					$aFile, $aGroupId, $aLevel, $aNode, $anchorName
+				) :
+				eval($aToc->{_templateAnchorNameBegin}),
+			$aToc
+		);
+	}
+
+		# Must anchorId attribute be inserted?
+	if ($doInsertId) {
+		# Yes, anchorId attribute must be inserted;
+			# Allow adding of anchorId attribute to text by calling 'anchorId'
+			# method
+		$self->anchorId($anchorName);
+	}
+}  # _linkTocToToken()
+
+
+#--- HTML::TocGenerator::_outputAnchorNameEndConditionally() ------------------
+# function: Output 'anchor name end' if necessary
+# args:     - $aToc: ToC of which 'anchor name end' must be output.
+
+sub _outputAnchorNameEndConditionally {
+		# Get arguments
+	my ($self, $aToc) = @_;
+		# Must anchor name end be output?
+	if ($self->{_doOutputAnchorNameEnd}) {
+		# Yes, output anchor name end;
+			# Allow adding of anchor to text by calling 'anchorNameEnd' 
+			# method
+		$self->anchorNameEnd(
+			ref($aToc->{_templateAnchorNameEnd}) eq "CODE" ?
+				&{$aToc->{_templateAnchorNameEnd}} :
+				eval($aToc->{_templateAnchorNameEnd}),
+			$aToc
+		);
+	}
+}  # _outputAnchorNameEndConditionally()
+
+
+#--- HTML::TocGenerator::_parseTocOptions() -----------------------------------
+# function: Parse ToC options.
+
+sub _parseTocOptions {
+		# Get arguments
+	my ($self) = @_;
+		# Local variables
+	my ($toc, $group, $tokens, $tokenType, $i);
+		# Create parsers for ToC tokens
+	$self->{_tokensTocBegin} = [];
+	my $tokenTocBeginParser = HTML::_TokenTocBeginParser->new(
+		$self->{_tokensTocBegin}
+	);
+	my $tokenTocEndParser = HTML::_TokenTocEndParser->new();
+		# Loop through ToCs
+	foreach $toc (@{$self->{_tocs}}) {
+			# Reference parser ToC to current ToC
+		$tokenTocBeginParser->setToc($toc);
+			# Loop through 'tokenToToc' groups
+		foreach $group (@{$toc->{options}{'tokenToToc'}}) {
+				# Reference parser group to current group
+			$tokenTocBeginParser->setGroup($group);
+				# Parse 'tokenToToc' group
+			$tokenTocBeginParser->parse($group->{'tokenBegin'});
+				# Flush remaining buffered text
+			$tokenTocBeginParser->eof();
+			$tokenTocEndParser->parse(
+				$group->{'tokenEnd'}, 
+				$tokenTocBeginParser->{_lastAddedToken},
+				$tokenTocBeginParser->{_lastAddedTokenType}
+			);
+				# Flush remaining buffered text
+			$tokenTocEndParser->eof();
+		}
+	}
+}  # _parseTocOptions()
+
+
+#--- HTML::TocGenerator::_processTocEndingToken() -----------------------------
+# function: Process ToC-ending-token.
+# args:     - $aTocToken: token which acts as ToC-ending-token.
+
+sub _processTocEndingToken {
+		# Get arguments
+	my ($self, $aTocToken) = @_;
+		# Local variables
+	my ($toc);
+		# Aliases
+	$toc = $aTocToken->[TT_TOC];
+		# Link ToC to tokens?
+	if ($toc->{options}{'doLinkToToken'}) {
+		# Yes, link ToC to tokens;
+			# Add anchor href end
+		$toc->{_toc} .= 
+			(ref($toc->{_templateAnchorHrefEnd}) eq "CODE") ?
+				&{$toc->{_templateAnchorHrefEnd}} : 
+				eval($toc->{_templateAnchorHrefEnd});
+
+			# Output anchor name end only if necessary
+		$self->_outputAnchorNameEndConditionally($toc);
+	}
+}  # _processTocEndingToken()
+
+
+#--- HTML::TocGenerator::_processTocStartingToken() ---------------------------
+# function: Process ToC-starting-token.
+# args:     - $aTocToken: token which acts as ToC-starting-token.
+#           - $aTokenType: type of token.  Can be either TT_TOKENTYPE_START,
+#                _END, _TEXT, _COMMENT or _DECLARATION.
+#           - $aTokenAttributes: reference to hash containing attributes of 
+#                currently parsed token
+#           - $aTokenOrigText: reference to original token text
+
+sub _processTocStartingToken {
+		# Get arguments
+	my ($self, $aTocToken, $aTokenType, $aTokenAttributes, $aTokenOrigText) = @_;
+		# Local variables
+	my ($i, $level, $doLinkToId, $node, $groupLevel);
+	my ($file, $tocTokenId, $groupId, $toc, $attribute);
+		# Aliases
+	$file        = $self->{_currentFile};
+	$toc		    = $aTocToken->[TT_TOC];
+	$level	    = $aTocToken->[TT_GROUP]{'level'};
+	$groupId	    = $aTocToken->[TT_GROUP]{'groupId'};
+
+		# Retrieve 'doLinkToId' setting from either group options or toc options
+	$doLinkToId = (defined($aTocToken->[TT_GROUP]{'doLinkToId'})) ?
+		$aTocToken->[TT_GROUP]{'doLinkToId'} : $toc->{options}{'doLinkToId'}; 
+	
+		# Link to 'id' and tokenType isn't 'start'?
+	if (($doLinkToId) && ($aTokenType != TT_TOKENTYPE_START)) {
+		# Yes, link to 'id' and tokenType isn't 'start';
+			# Indicate to *not* link to 'id'
+		$doLinkToId = 0;
+	}
+
+	if (ref($level) eq "CODE") {
+		$level = &$level($self->{_currentFile}, $node);
+	}
+	if (ref($groupId) eq "CODE") {
+		$groupId = &$groupId($self->{_currentFile}, $node);
+	}
+
+		# Determine class level
+
+	my $groupIdManager = $self->_getGroupIdManager($toc);
+		# Known group?
+	if (!exists($groupIdManager->{groupIdLevels}{$groupId})) {
+		# No, unknown group;
+			# Add group
+		$groupIdManager->{groupIdLevels}{$groupId} = keys(
+			%{$groupIdManager->{groupIdLevels}}
+		) + 1;
+	}
+	$groupLevel = $groupIdManager->{groupIdLevels}{$groupId};
+
+		# Temporarily allow symbolic references
+	#no strict qw(refs);
+		# Increase level
+	$groupIdManager->{levels}{$groupId}[$level - 1] += 1;
+		# Reset remaining levels of same group
+	for ($i = $level; $i < @{$groupIdManager->{levels}{$groupId}}; $i++) {
+		$groupIdManager->{levels}{$groupId}[$i] = 0;
+	}
+
+		# Assemble numeric string indicating current level
+	$node = $self->_formatTocNode(
+		$level, $groupId, $aTocToken->[TT_GROUP], $toc
+	);
+
+		# Add newline if _toc not empty
+	if ($toc->{_toc}) { 
+		$toc->{_toc} .= "\n";
+	}
+
+		# Add toc item info
+	$toc->{_toc} .= "$level $groupLevel $groupId $node " .
+		$groupIdManager->{levels}{$groupId}[$level - 1] . " ";
+
+		# Add value of 'id' attribute if available
+	if (defined($aTokenAttributes->{id})) {
+		$toc->{_toc} .= $aTokenAttributes->{id};
+	}
+	$toc->{_toc} .= " ";
+		# Link ToC to tokens?
+	if ($toc->{options}{'doLinkToToken'}) {
+		# Yes, link ToC to tokens;
+			# Link ToC to token
+		$self->_linkTocToToken(
+			$toc, $file, $groupId, $level, $node, $groupLevel, $doLinkToId,
+			$aTokenAttributes
+		);
+	}
+
+		# Number tokens?
+	if (
+		$aTocToken->[TT_GROUP]{'doNumberToken'} || 
+		(
+			! defined($aTocToken->[TT_GROUP]{'doNumberToken'}) && 
+			$toc->{options}{'doNumberToken'}
+		)
+	) {
+		# Yes, number tokens;
+			# Add number by calling 'number' method
+		$self->number(
+			ref($toc->{_templateTokenNumber}) eq "CODE" ?
+				&{$toc->{_templateTokenNumber}}(
+					$node, $groupId, $file, $groupLevel, $level, $toc
+				) : 
+				eval($toc->{_templateTokenNumber}),
+			$toc
+		);
+	}
+
+		# Must attribute be used as ToC text?
+	if (defined($aTocToken->[TT_ATTRIBUTES_TOC])) {
+		# Yes, attribute must be used as ToC text;
+			# Loop through attributes
+		foreach $attribute (@{$aTocToken->[TT_ATTRIBUTES_TOC]}) {
+				# Attribute is available?
+			if (defined($$aTokenAttributes{$attribute})) {
+				# Yes, attribute is available;
+					# Add attribute value to ToC
+				$self->_processTocText($$aTokenAttributes{$attribute}, $toc);
+			}
+			else {
+				# No, attribute isn't available;
+					# Show warning
+				$self->_showWarning(
+					WARNING_TOC_ATTRIBUTE_PS_NOT_AVAILABLE_WITHIN_PS,
+					[$attribute, $$aTokenOrigText]
+				);
+			}
+				# Output anchor name end only if necessary
+			#$self->_outputAnchorNameEndConditionally($toc);
+				# End attribute
+			$self->_processTocEndingToken($aTocToken);
+		}
+	}
+	else {
+		# No, attribute mustn't be used as ToC text;
+			# Add end token to 'end token array'
+		push(
+			@{$self->{_tokensTocEnd}[$aTocToken->[TT_TAG_TYPE_END]]}, $aTocToken
+		);
+	}
+}  # _processTocStartingToken()
+
+
+#--- HTML::TocGenerator::_processTocText() ------------------------------------
+# function: This function processes text which must be added to the preliminary
+#           ToC.
+# args:     - $aText: Text to add to ToC.
+#           - $aToc: ToC to add text to.
+
+sub _processTocText {
+		# Get arguments
+	my ($self, $aText, $aToc) = @_;
+		# Add text to ToC
+	$aToc->{_toc} .= $aText;
+}  # _processTocText()
+
+
+#--- HTML::TocGenerator::_processTokenAsTocEndingToken() ----------------------
+# function: Check for token being a token to use for triggering the end of
+#           a ToC line and process it accordingly.
+# args:     - $aTokenType: type of token: 'start', 'end', 'comment' or 'text'.
+#           - $aTokenId: token id of currently parsed token
+
+sub _processTokenAsTocEndingToken {
+		# Get arguments
+	my ($self, $aTokenType, $aTokenId) = @_;
+		# Local variables
+	my ($i, $tokenId, $toc, $tokens);
+		# Loop through dirty start tokens
+	$i = 0;
+
+		# Alias token array of right type
+	$tokens = $self->{_tokensTocEnd}[$aTokenType];
+		# Loop through token array
+	while ($i < scalar @$tokens) {
+			# Aliases
+		$tokenId = $tokens->[$i][TT_TAG_END];
+			# Does current end tag equals dirty tag?
+		if ($aTokenId eq $tokenId) {
+			# Yes, current end tag equals dirty tag;
+				# Process ToC-ending-token
+			$self->_processTocEndingToken($tokens->[$i]);
+				# Remove dirty tag from array, automatically advancing to
+				# next token
+			splice(@$tokens, $i, 1);
+		}
+		else {
+			# No, current end tag doesn't equal dirty tag;
+				# Advance to next token
+			$i++;
+		}
+	}
+}  # _processTokenAsTocEndingToken()
+
+
+#--- HTML::TocGenerator::_processTokenAsTocStartingToken() --------------------
+# function: Check for token being a ToC-starting-token and process it 
+#           accordingly.
+# args:     - $aTokenType: type of token.  Can be either TT_TOKENTYPE_START,
+#                _END, _TEXT, _COMMENT or _DECLARATION.
+#           - $aTokenId: token id of currently parsed token
+#           - $aTokenAttributes: reference to hash containing attributes of 
+#                currently parsed token
+#           - $aTokenOrigText: reference to original text of token
+# returns:  1 if successful, i.e. token is processed as ToC-starting-token, 0
+#           if not.
+
+sub _processTokenAsTocStartingToken {
+		# Get arguments
+	my ($self, $aTokenType, $aTokenId, $aTokenAttributes, $aTokenOrigText) = @_;
+		# Local variables
+	my ($level, $levelToToc, $groupId, $groupToToc);
+	my ($result, $tocToken, $tagBegin, @tokensTocBegin, $fileSpec);
+		# Bias to token not functioning as ToC-starting-token
+	$result = 0;
+		# Loop through start tokens of right type
+	foreach $tocToken (@{$self->{_tokensTocBegin}[$aTokenType]}) {
+			# Alias file filter
+		$fileSpec = $tocToken->[TT_GROUP]{'fileSpec'};
+			# File matches?
+		if (!defined($fileSpec) || (
+			defined($fileSpec) &&
+			($self->{_currentFile} =~ m/$fileSpec/)
+		)) {
+			# Yes, file matches;
+				# Alias tag begin
+			$tagBegin = $tocToken->[TT_TAG_BEGIN];
+				# Tag and attributes match?
+			if (
+				defined($tagBegin) && 
+				($aTokenId =~ m/$tagBegin/) && 
+				HTML::TocGenerator::_doesHashContainHash(
+					$aTokenAttributes, $tocToken->[TT_INCLUDE_ATTRIBUTES_BEGIN], 0
+				) &&
+				HTML::TocGenerator::_doesHashContainHash(
+					$aTokenAttributes, $tocToken->[TT_EXCLUDE_ATTRIBUTES_BEGIN], 1
+				)
+			) {
+				# Yes, tag and attributes match;
+					# Aliases
+				$level	    = $tocToken->[TT_GROUP]{'level'};
+				$levelToToc = $tocToken->[TT_TOC]{options}{'levelToToc'};
+				$groupId     = $tocToken->[TT_GROUP]{'groupId'}; 
+				$groupToToc = $tocToken->[TT_TOC]{options}{'groupToToc'};
+					# Must level and group be processed?
+				if (
+					($level =~ m/$levelToToc/) &&
+					($groupId =~ m/$groupToToc/)
+				) {
+					# Yes, level and group must be processed;
+						# Indicate token acts as ToC-starting-token
+					$result = 1;
+						# Process ToC-starting-token
+					$self->_processTocStartingToken(
+						$tocToken, $aTokenType, $aTokenAttributes, $aTokenOrigText
+					);
+				}
+			}
+		}
+	}
+		# Return value
+	return $result;
+}  # _processTokenAsTocStartingToken()
+
+
+#--- HTML::TocGenerator::_resetBatchVariables() -------------------------------
+# function: Reset variables which are set because of batch invocation.
+
+sub _resetBatchVariables {
+		# Get arguments
+	my ($self) = @_;
+
+		# Filename of current file being parsed, empty string if not available
+	$self->{_currentFile} = "";
+		# Arrays containing start, end, comment, text & declaration tokens which 
+		# must trigger the ToC assembling.  Each array element may contain a 
+		# reference to an array containing the following elements:
+		#
+      #    TT_TAG_BEGIN                => 0;
+      #    TT_TAG_END                  => 1;
+      #    TT_TAG_TYPE_END             => 2;
+      #    TT_INCLUDE_ATTRIBUTES_BEGIN => 3;
+      #    TT_EXCLUDE_ATTRIBUTES_BEGIN => 4;
+      #    TT_INCLUDE_ATTRIBUTES_END   => 5;
+      #    TT_EXCLUDE_ATTRIBUTES_END   => 6;
+      #    TT_GROUP                    => 7;
+      #    TT_TOC                      => 8;
+		#    TT_ATTRIBUTES_TOC           => 9;
+		#
+	$self->{_tokensTocBegin} = [
+		[],  # TT_TOKENTYPE_START      
+		[],  # TT_TOKENTYPE_END        
+		[],  # TT_TOKENTYPE_COMMENT    
+		[],  # TT_TOKENTYPE_TEXT       
+		[]   # TT_TOKENTYPE_DECLARATION
+	];
+	$self->{_tokensTocEnd} = [
+		[],  # TT_TOKENTYPE_START      
+		[],  # TT_TOKENTYPE_END        
+		[],  # TT_TOKENTYPE_COMMENT    
+		[],  # TT_TOKENTYPE_TEXT       
+		[]   # TT_TOKENTYPE_DECLARATION
+	];
+		# TRUE if ToCs have been initialized, FALSE if not.
+	$self->{_doneInitializeTocs} = 0;
+		# Array of ToCs to process
+	$self->{_tocs} = [];
+		# Active anchor name
+	$self->{_activeAnchorName} = undef;
+}  # _resetBatchVariables()
+
+
+#--- HTML::TocGenerator::_resetStackVariables() -------------------------------
+# function: Reset variables which cumulate during ToC generation.
+
+sub _resetStackVariables {
+		# Get arguments
+	my ($self) = @_;
+		# Reset variables
+	$self->{levels}        = undef;
+	$self->{groupIdLevels} = undef;
+}  # _resetStackVariables()
+
+
+#--- HTML::TocGenerator::_setActiveAnchorName() -------------------------------
+# function: Set active anchor name.
+# args:     - aAnchorName: Name of anchor name to set active.
+
+sub _setActiveAnchorName {
+		# Get arguments
+	my ($self, $aAnchorName) = @_;
+		# Set active anchor name
+	$self->{_activeAnchorName} = $aAnchorName;
+}  # _setActiveAnchorName()
+
+
+#--- HTML::TocGenerator::_showWarning() ---------------------------------------
+# function: Show warning.
+# args:     - aWarningNr: Number of warning to show.
+#           - aWarningArgs: Arguments to display within the warning.
+
+sub _showWarning {
+		# Get arguments
+	my ($self, $aWarningNr, $aWarningArgs) = @_;
+		# Local variables
+	my (%warnings);
+		# Set warnings
+	%warnings = (
+		WARNING_NESTED_ANCHOR_PS_WITHIN_PS()               => 
+			"Nested anchor '%s' within anchor '%s'.", 
+		WARNING_TOC_ATTRIBUTE_PS_NOT_AVAILABLE_WITHIN_PS() =>
+			"ToC attribute '%s' not available within token '%s'.",
+	);
+		# Show warning
+	print STDERR "warning ($aWarningNr): " . sprintf($warnings{"$aWarningNr"}, @$aWarningArgs) . "\n";
+}  # _showWarning()
+
+
+#--- HTML::TocGenerator::anchorId() -------------------------------------------
+# function: Anchor id processing method.  Leave it up to the descendant to do 
+#           something useful with it.
+# args:     - $aAnchorId
+#           - $aToc: Reference to ToC to which anchorId belongs.
+
+sub anchorId {
+}  # anchorId()
+
+
+#--- HTML::TocGenerator::anchorNameBegin() ------------------------------------
+# function: Anchor name begin processing method.  Leave it up to the descendant
+#           to do something useful with it.
+# args:     - $aAnchorName
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub anchorNameBegin {
+}  # anchorNameBegin()
+
+
+#--- HTML::TocGenerator::anchorNameEnd() --------------------------------------
+# function: Anchor name end processing method.  Leave it up to the descendant
+#           to do something useful with it.
+# args:     - $aAnchorName
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub anchorNameEnd {
+}  # anchorNameEnd()
+
+
+#--- HTML::TocGenerator::comment() --------------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Must a ToC be generated?
+	if ($self->{_doGenerateToc}) {
+		# Yes, a ToC must be generated
+			# Process end tag as ToC-starting-token
+		$self->_processTokenAsTocStartingToken(
+			TT_TOKENTYPE_COMMENT, $aComment, undef, \$aComment
+		);
+			# Process end tag as token which ends ToC registration
+		$self->_processTokenAsTocEndingToken(
+			TT_TOKENTYPE_COMMENT, $aComment
+		);
+	}
+}  # comment()
+
+
+#--- HTML::TocGenerator::end() ------------------------------------------------
+# function: This function is called every time a closing tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aOrigText: tag name including brackets.
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Local variables
+	my ($tag, $toc, $i);
+		# Must a ToC be generated?
+	if ($self->{_doGenerateToc}) {
+		# Yes, a ToC must be generated
+			# Process end tag as ToC-starting-token
+		$self->_processTokenAsTocStartingToken(
+			TT_TOKENTYPE_END, $aTag, undef, \$aOrigText
+		);
+			# Process end tag as ToC-ending-token
+		$self->_processTokenAsTocEndingToken(
+			TT_TOKENTYPE_END, $aTag
+		);
+			# Tag is of type 'anchor'?
+		if (defined($self->{_activeAnchorName}) && ($aTag eq "a")) {
+			# Yes, tag is of type 'anchor';
+				# Reset dirty anchor
+			$self->{_activeAnchorName} = undef;
+		}
+	}
+}  # end()
+
+
+#--- HTML::TocGenerator::extend() ---------------------------------------------
+# function: Extend ToCs.
+# args:     - $aTocs: Reference to array of ToC objects
+#           - $aString: String to parse.
+
+sub extend {
+		# Get arguments
+	my ($self, $aTocs, $aString) = @_;
+		# Initialize TocGenerator batch
+	$self->_initializeExtenderBatch($aTocs);
+		# Extend ToCs
+	$self->_extend($aString);
+		# Deinitialize TocGenerator batch
+	$self->_deinitializeExtenderBatch();
+}  # extend()
+
+
+#--- HTML::TocGenerator::extendFromFile() -------------------------------------
+# function: Extend ToCs.
+# args:     - @aTocs: Reference to array of ToC objects
+#           - @aFiles: Reference to array of files to parse.
+
+sub extendFromFile {
+		# Get arguments
+	my ($self, $aTocs, $aFiles) = @_;
+		# Initialize TocGenerator batch
+	$self->_initializeExtenderBatch($aTocs);
+		# Extend ToCs
+	$self->_extendFromFile($aFiles);
+		# Deinitialize TocGenerator batch
+	$self->_deinitializeExtenderBatch();
+}  # extendFromFile()
+
+
+#--- HTML::TocGenerator::generate() -------------------------------------------
+# function: Generate ToC.
+# args:     - $aToc: Reference to (array of) ToC object(s)
+#           - $aString: Reference to string to parse
+#           - $aOptions: optional options
+
+sub generate {
+		# Get arguments
+	my ($self, $aToc, $aString, $aOptions) = @_;
+		# Initialize TocGenerator batch
+	$self->_initializeGeneratorBatch($aToc, $aOptions);
+		# Do generate ToC
+	$self->_generate($aString);
+		# Deinitialize TocGenerator batch
+	$self->_deinitializeGeneratorBatch();
+}  # generate()
+
+
+#--- HTML::TocGenerator::generateFromFile() -----------------------------------
+# function: Generate ToC.
+# args:     - $aToc: Reference to (array of) ToC object(s)
+#           - $aFile: (reference to array of) file to parse.
+#           - $aOptions: optional options
+
+sub generateFromFile {
+		# Get arguments
+	my ($self, $aToc, $aFile, $aOptions) = @_;
+		# Initialize TocGenerator batch
+	$self->_initializeGeneratorBatch($aToc, $aOptions);
+		# Do generate ToC
+	$self->_generateFromFile($aFile);
+		# Deinitialize TocGenerator batch
+	$self->_deinitializeGeneratorBatch();
+}  # generateFromFile()
+
+
+#--- HTML::TocGenerator::number() ---------------------------------------------
+# function: Heading number processing method.  Leave it up to the descendant
+#           to do something useful with it.
+# args:     - $aNumber
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub number {
+		# Get arguments
+	my ($self, $aNumber, $aToc) = @_;
+}  # number()
+
+
+#--- HTML::TocGenerator::parse() ----------------------------------------------
+# function: Parse scalar.
+# args:     - $aString: string to parse
+
+sub parse {
+		# Get arguments
+	my ($self, $aString) = @_;
+		# Call ancestor
+	$self->SUPER::parse($aString);
+}  # parse()
+
+
+#--- HTML::TocGenerator::parse_file() -----------------------------------------
+# function: Parse file.
+
+sub parse_file {
+		# Get arguments
+	my ($self, $aFile) = @_;
+		# Call ancestor
+	$self->SUPER::parse_file($aFile);
+}  # parse_file()
+
+
+#--- HTML::TocGenerator::setOptions() -----------------------------------------
+# function: Set options.
+# args:     - aOptions: Reference to hash containing options.
+
+sub setOptions {
+		# Get arguments
+	my ($self, $aOptions) = @_;
+		# Options are defined?
+	if (defined($aOptions)) {
+		# Yes, options are defined; add to options
+		%{$self->{options}} = (%{$self->{options}}, %$aOptions);
+	}
+}  # setOptions()
+
+
+#--- HTML::TocGenerator::start() ----------------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all tag attributes (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+	$self->{isTocToken} = 0;
+		# Start tag is of type 'anchor name'?
+	if ($aTag eq "a" && defined($aAttr->{name})) {
+		# Yes, start tag is of type 'anchor name';
+			# Is another anchor already active?
+		if (defined($self->{_activeAnchorName})) {
+			# Yes, another anchor is already active;
+				# Is the first anchor inserted by 'TocGenerator'?
+			if ($self->{_doOutputAnchorNameEnd}) {
+				# Yes, the first anchor is inserted by 'TocGenerator';
+					# Show warning
+				$self->_showWarning(
+					WARNING_NESTED_ANCHOR_PS_WITHIN_PS,
+					[$aOrigText, $self->{_activeAnchorName}]
+				);
+			}
+		}
+			# Set active anchor name
+		$self->_setActiveAnchorName($aAttr->{name});
+	}
+		# Must a ToC be generated?
+	if ($self->{_doGenerateToc}) {
+		# Yes, a ToC must be generated
+			# Process start tag as ToC token
+		$self->{isTocToken} = $self->_processTokenAsTocStartingToken(
+			TT_TOKENTYPE_START, $aTag, $aAttr, \$aOrigText
+		);
+			# Process end tag as ToC-ending-token
+		$self->_processTokenAsTocEndingToken(
+			TT_TOKENTYPE_START, $aTag
+		);
+	}
+}  # start()
+
+
+#--- HTML::TocGenerator::text() -----------------------------------------------
+# function: This function is called every time plain text is encountered.
+# args:     - @_: array containing data.
+
+sub text {
+		# Get arguments
+	my ($self, $aText) = @_;
+		# Local variables
+	my ($text, $toc, $i, $token, $tokens);
+		# Must a ToC be generated?
+	if ($self->{_doGenerateToc}) {
+		# Yes, a ToC must be generated
+			# Are there dirty start tags?
+
+			# Loop through token types
+		foreach $tokens (@{$self->{_tokensTocEnd}}) {
+				# Loop though tokens
+			foreach $token (@$tokens) {
+					# Add text to toc
+
+					# Alias
+				$toc = $token->[TT_TOC];
+					# Remove possible newlines from text
+				($text = $aText) =~ s/\s*\n\s*/ /g;
+					# Add text to toc
+				$self->_processTocText($text, $toc);
+			}
+		}
+	}
+}  # text()
+
+
+
+
+#=== HTML::_TokenTocParser ====================================================
+# function: Parse 'toc tokens'.  'Toc tokens' mark HTML code which is to be
+#           inserted into the ToC.
+# note:     Used internally.
+
+package HTML::_TokenTocParser;
+
+
+BEGIN {
+	use vars qw(@ISA);
+
+	@ISA = qw(HTML::Parser);
+}
+
+
+END {}
+
+
+#--- HTML::_TokenTocParser::new() ---------------------------------------------
+# function: Constructor
+
+sub new {
+		# Get arguments
+	my ($aType) = @_;
+		# Create instance
+	my $self = $aType->SUPER::new;
+
+		# Return instance
+	return $self;
+}  # new()
+
+
+#--- HTML::_TokenTocParser::_parseAttributes() --------------------------------
+# function: Parse attributes.
+# args:     - $aAttr: Reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aIncludeAttributes: Reference to hash to which 'include
+#                attributes' must be added.
+#           - $aExcludeAttributes: Reference to hash to which 'exclude
+#                attributes' must be added.
+#           - $aTocAttributes: Reference to hash to which 'ToC attributes' 
+#                must be added.
+
+sub _parseAttributes {
+		# Get arguments
+	my (
+		$self, $aAttr, $aIncludeAttributes, $aExcludeAttributes,
+		$aTocAttributes
+	) = @_;
+		# Local variables
+	my ($key, $value);
+	my ($attributeToExcludeToken, $attributeToTocToken);
+		# Get token which marks attributes which must be excluded
+	$attributeToExcludeToken = $self->{_toc}{options}{'attributeToExcludeToken'};
+	$attributeToTocToken     = $self->{_toc}{options}{'attributeToTocToken'};
+		# Loop through attributes
+	while (($key, $value) = each %$aAttr) {
+			# Attribute value equals 'ToC token'?
+		if ($value =~ m/$attributeToTocToken/) {
+			# Yes, attribute value equals 'ToC token';
+				# Add attribute to 'ToC attributes'
+			push @$aTocAttributes, $key;
+		}
+		else {
+			# No, attribute isn't 'ToC' token;
+				# Attribute value starts with 'exclude token'?
+			if ($value =~ m/^$attributeToExcludeToken(.*)/) {
+				# Yes, attribute value starts with 'exclude token';
+					# Add attribute to 'exclude attributes'
+				$$aExcludeAttributes{$key} = "$1";
+			}
+			else {
+				# No, attribute key doesn't start with '-';
+					# Add attribute to 'include attributes'
+				$$aIncludeAttributes{$key} = $value;
+			}
+		}
+	}
+}  # _parseAttributes()
+
+
+
+
+#=== HTML::_TokenTocBeginParser ===============================================
+# function: Parse 'toc tokens'.  'Toc tokens' mark HTML code which is to be
+#           inserted into the ToC.
+# note:     Used internally.
+
+package HTML::_TokenTocBeginParser;
+
+
+BEGIN {
+	use vars qw(@ISA);
+
+	@ISA = qw(HTML::_TokenTocParser);
+}
+
+END {}
+
+
+#--- HTML::_TokenTocBeginParser::new() ----------------------------------------
+# function: Constructor
+
+sub new {
+		# Get arguments
+	my ($aType, $aTokenArray) = @_;
+		# Create instance
+	my $self = $aType->SUPER::new;
+		# Reference token array
+	$self->{tokens} = $aTokenArray;
+		# Reference to last added token
+	$self->{_lastAddedToken}     = undef;
+	$self->{_lastAddedTokenType} = undef;
+		# Return instance
+	return $self;
+}  # new()
+
+
+#--- HTML::_TokenTocBeginParser::_processAttributes() -------------------------
+# function: Process attributes.
+# args:     - $aAttributes: Attributes to parse.
+
+sub _processAttributes {
+		# Get arguments
+	my ($self, $aAttributes) = @_;
+		# Local variables
+	my (%includeAttributes, %excludeAttributes, @tocAttributes);
+
+		# Parse attributes
+	$self->_parseAttributes(
+		$aAttributes, \%includeAttributes, \%excludeAttributes, \@tocAttributes
+	);
+		# Include attributes are specified?
+	if (keys(%includeAttributes) > 0) {
+		# Yes, include attributes are specified;
+			# Store include attributes
+		@${$self->{_lastAddedToken}}[
+			HTML::TocGenerator::TT_INCLUDE_ATTRIBUTES_BEGIN
+		] = \%includeAttributes;
+	}
+		# Exclude attributes are specified?
+	if (keys(%excludeAttributes) > 0) {
+		# Yes, exclude attributes are specified;
+			# Store exclude attributes
+		@${$self->{_lastAddedToken}}[
+			HTML::TocGenerator::TT_EXCLUDE_ATTRIBUTES_BEGIN
+		] = \%excludeAttributes;
+	}
+		# Toc attributes are specified?
+	if (@tocAttributes > 0) {
+		# Yes, toc attributes are specified;
+			# Store toc attributes
+		@${$self->{_lastAddedToken}}[
+			HTML::TocGenerator::TT_ATTRIBUTES_TOC
+		] = \@tocAttributes;
+	}
+}  # _processAttributes()
+
+
+#--- HTML::_TokenTocBeginParser::_processToken() ------------------------------
+# function: Process token.
+# args:     - $aTokenType: Type of token to process.
+#           - $aTag: Tag of token.
+
+sub _processToken {
+		# Get arguments
+	my ($self, $aTokenType, $aTag) = @_;
+		# Local variables
+	my ($tokenArray, $index);
+		# Push element on array of update tokens
+	$index = push(@{$self->{tokens}[$aTokenType]}, []) - 1;
+		# Alias token array to add element to
+	$tokenArray = $self->{tokens}[$aTokenType];
+		# Indicate last updated token array element
+	$self->{_lastAddedTokenType} = $aTokenType;
+	$self->{_lastAddedToken}     = \$$tokenArray[$index];
+		# Add fields
+	$$tokenArray[$index][HTML::TocGenerator::TT_TAG_BEGIN] = $aTag;
+	$$tokenArray[$index][HTML::TocGenerator::TT_GROUP]     = $self->{_group};
+	$$tokenArray[$index][HTML::TocGenerator::TT_TOC]       = $self->{_toc};
+}  # _processToken()
+
+
+#--- HTML::_TokenTocBeginParser::comment() ------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_COMMENT, $aComment);
+}  # comment()
+
+
+#--- HTML::_TokenTocBeginParser::declaration() --------------------------------
+# function: This function is called every time a markup declaration is
+#           encountered by HTML::Parser.
+# args:     - $aDeclaration: Markup declaration.
+
+sub declaration {
+		# Get arguments
+	my ($self, $aDeclaration) = @_;
+		# Process token
+	$self->_processToken(
+		HTML::TocGenerator::TT_TOKENTYPE_DECLARATION, $aDeclaration
+	);
+}  # declaration()
+
+	
+#--- HTML::_TokenTocBeginParser::end() ----------------------------------------
+# function: This function is called every time a closing tag is encountered
+#           by HTML::Parser.
+# args:     - $aTag: tag name (in lower case).
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_END, $aTag);
+}  # end()
+
+
+#--- HTML::_TokenTocBeginParser::parse() --------------------------------------
+# function: Parse begin token.
+# args:     - $aToken: 'toc token' to parse
+
+sub parse {
+		# Get arguments
+	my ($self, $aString) = @_;
+		# Call ancestor
+	$self->SUPER::parse($aString);
+}  # parse()
+
+
+#--- HTML::_TokenTocBeginParser->setGroup() -----------------------------------
+# function: Set current 'tokenToToc' group.
+
+sub setGroup {
+		# Get arguments
+	my ($self, $aGroup) = @_;
+		# Set current 'tokenToToc' group
+	$self->{_group} = $aGroup;
+}  # setGroup()
+
+
+#--- HTML::_TokenTocBeginParser->setToc() -------------------------------------
+# function: Set current ToC.
+
+sub setToc {
+		# Get arguments
+	my ($self, $aToc) = @_;
+		# Set current ToC
+	$self->{_toc} = $aToc;
+}  # setToc()
+
+
+#--- HTML::_TokenTocBeginParser::start() --------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all attribute keys (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_START, $aTag);
+		# Process attributes
+	$self->_processAttributes($aAttr);
+}  # start()
+
+
+#--- HTML::_TokenTocBeginParser::text() ---------------------------------------
+# function: This function is called every time plain text is encountered.
+# args:     - @_: array containing data.
+
+sub text {
+		# Get arguments
+	my ($self, $aText) = @_;
+		# Was token already created and is last added token of type 'text'?
+	if (
+		defined($self->{_lastAddedToken}) && 
+		$self->{_lastAddedTokenType} == HTML::TocGenerator::TT_TOKENTYPE_TEXT
+	) {
+		# Yes, token is already created;
+			# Add tag to existing token
+		@${$self->{_lastAddedToken}}[HTML::TocGenerator::TT_TAG_BEGIN] .= $aText;
+	}
+	else {
+		# No, token isn't created;
+			# Process token
+		$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_TEXT, $aText);
+	}
+}  # text()
+
+
+
+
+#=== HTML::_TokenTocEndParser =================================================
+# function: Parse 'toc tokens'.  'Toc tokens' mark HTML code which is to be
+#           inserted into the ToC.
+# note:     Used internally.
+
+package HTML::_TokenTocEndParser;
+
+
+BEGIN {
+	use vars qw(@ISA);
+
+	@ISA = qw(HTML::_TokenTocParser);
+}
+
+
+END {}
+
+
+#--- HTML::_TokenTocEndParser::new() ------------------------------------------
+# function: Constructor
+# args:     - $aType: Class type.
+
+sub new {
+		# Get arguments
+	my ($aType) = @_;
+		# Create instance
+	my $self = $aType->SUPER::new;
+		# Reference to last added token
+	$self->{_lastAddedToken} = undef;
+		# Return instance
+	return $self;
+}  # new()
+
+
+#--- HTML::_TokenTocEndParser::_processAttributes() ---------------------------
+# function: Process attributes.
+# args:     - $aAttributes: Attributes to parse.
+
+sub _processAttributes {
+		# Get arguments
+	my ($self, $aAttributes) = @_;
+		# Local variables
+	my (%includeAttributes, %excludeAttributes);
+
+		# Parse attributes
+	$self->_parseAttributes(
+		$aAttributes, \%includeAttributes, \%excludeAttributes
+	);
+		# Include attributes are specified?
+	if (keys(%includeAttributes) > 0) {
+		# Yes, include attributes are specified;
+			# Store include attributes
+		@${$self->{_Token}}[
+			HTML::TocGenerator::TT_INCLUDE_ATTRIBUTES_END
+		] = \%includeAttributes;
+	}
+		# Exclude attributes are specified?
+	if (keys(%excludeAttributes) > 0) {
+		# Yes, exclude attributes are specified;
+			# Store exclude attributes
+		@${$self->{_Token}}[
+			HTML::TocGenerator::TT_EXCLUDE_ATTRIBUTES_END
+		] = \%excludeAttributes;
+	}
+}  # _processAttributes()
+
+
+#--- HTML::_TokenTocEndParser::_processToken() --------------------------------
+# function: Process token.
+# args:     - $aTokenType: Type of token to process.
+#           - $aTag: Tag of token.
+
+sub _processToken {
+		# Get arguments
+	my ($self, $aTokenType, $aTag) = @_;
+		# Update token
+	@${$self->{_token}}[HTML::TocGenerator::TT_TAG_TYPE_END] = $aTokenType;
+	@${$self->{_token}}[HTML::TocGenerator::TT_TAG_END]      = $aTag;
+		# Indicate token type which has been processed
+	$self->{_lastAddedTokenType} = $aTokenType;
+}  # _processToken()
+
+
+#--- HTML::_TokenTocEndParser::comment() --------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_COMMENT, $aComment);
+}  # comment()
+
+
+#--- HTML::_TokenTocDeclarationParser::declaration() --------------------------
+# function: This function is called every time a markup declaration is
+#           encountered by HTML::Parser.
+# args:     - $aDeclaration: Markup declaration.
+
+sub declaration {
+		# Get arguments
+	my ($self, $aDeclaration) = @_;
+		# Process token
+	$self->_processToken(
+		HTML::TocGenerator::TT_TOKENTYPE_DECLARATION, $aDeclaration
+	);
+}  # declaration()
+
+	
+#--- HTML::_TokenTocEndParser::end() ------------------------------------------
+# function: This function is called every time a closing tag is encountered
+#           by HTML::Parser.
+# args:     - $aTag: tag name (in lower case).
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_END, $aTag);
+}  # end()
+
+
+#--- HTML::_TokenTocEndParser::parse() ----------------------------------------
+# function: Parse token.
+# args:     - $aString: 'toc token' to parse
+#           - $aToken: Reference to token
+#           - $aTokenTypeBegin: Type of begin token
+
+sub parse {
+		# Get arguments
+	my ($self, $aString, $aToken, $aTokenTypeBegin) = @_;
+		# Token argument specified?
+	if (defined($aToken)) {
+		# Yes, token argument is specified;
+			# Store token reference
+		$self->{_token} = $aToken;
+	}
+		# End tag defined?
+	if (! defined($aString)) {
+		# No, end tag isn't defined;
+			# Last added tokentype was of type 'start'?
+		if (
+			(defined($aTokenTypeBegin)) &&
+			($aTokenTypeBegin == HTML::TocGenerator::TT_TOKENTYPE_START) 
+		) {
+			# Yes, last added tokentype was of type 'start';
+				# Assume end tag
+			$self->_processToken(
+				HTML::TocGenerator::TT_TAG_END,
+				@${$self->{_token}}[HTML::TocGenerator::TT_TAG_BEGIN]
+			);
+		}
+	}
+	else {
+			# Call ancestor
+		$self->SUPER::parse($aString);
+	}
+}  # parse()
+
+
+#--- HTML::_TokenTocEndParser::start() ----------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all attribute keys (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_START, $aTag);
+		# Process attributes
+	$self->_processAttributes($aAttr);
+}  # start()
+
+
+#--- HTML::_TokenTocEndParser::text() -----------------------------------------
+# function: This function is called every time plain text is encountered.
+# args:     - @_: array containing data.
+
+sub text {
+		# Get arguments
+	my ($self, $aText) = @_;
+
+		# Is token already created?
+	if (defined($self->{_lastAddedTokenType})) {
+		# Yes, token is already created;
+			# Add tag to existing token
+		@${$self->{_token}}[HTML::TocGenerator::TT_TAG_END] .= $aText;
+	}
+	else {
+		# No, token isn't created;
+			# Process token
+		$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_TEXT, $aText);
+	}
+}  # text()
+
+
+1;
diff --git a/examples/includes/HTML-Toc-0.91/TocInsertor.pm b/examples/includes/HTML-Toc-0.91/TocInsertor.pm
new file mode 100644
index 0000000..b554870
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/TocInsertor.pm
@@ -0,0 +1,1066 @@
+#--- TocInsertor.pm -----------------------------------------------------------
+# function: Insert Table of Contents HTML::Toc, generated by 
+#           HTML::TocGenerator.
+# note:     - The term 'propagate' is used as a shortcut for the process of 
+#             both generating and inserting a ToC at the same time.
+#           - 'TIP' is an abbreviation of 'Toc Insertion Point'.
+
+
+package HTML::TocInsertor;
+
+
+use strict;
+use FileHandle;
+use HTML::TocGenerator;
+
+
+BEGIN {
+	use vars qw(@ISA $VERSION);
+
+	$VERSION = '0.91';
+
+	@ISA = qw(HTML::TocGenerator);
+}
+
+	# TocInsertionPoint (TIP) constants
+	
+use constant TIP_PREPOSITION_REPLACE => 'replace';
+use constant TIP_PREPOSITION_BEFORE  => 'before';
+use constant TIP_PREPOSITION_AFTER   => 'after';
+
+use constant TIP_TOKEN_ID           => 0;
+use constant TIP_PREPOSITION        => 1;
+use constant TIP_INCLUDE_ATTRIBUTES => 2;
+use constant TIP_EXCLUDE_ATTRIBUTES => 3;
+use constant TIP_TOC                => 4;
+
+use constant MODE_DO_NOTHING   => 0;	# 0b00
+use constant MODE_DO_INSERT    => 1;	# 0b01
+use constant MODE_DO_PROPAGATE => 3;	# 0b11
+
+END {}
+
+
+#--- HTML::TocInsertor::new() -------------------------------------------------
+# function: Constructor.
+
+sub new {
+		# Get arguments
+	my ($aType) = @_;
+	my $self = $aType->SUPER::new;
+		# TRUE if insertion point token must be output, FALSE if not
+	$self->{_doOutputInsertionPointToken} = 1;
+		# Reset batch variables
+	$self->_resetBatchVariables;
+		# Bias to not insert ToC
+	$self->{hti__Mode} = MODE_DO_NOTHING;
+
+		# TODO: Initialize output
+
+	return $self;
+}  # new()
+
+
+#--- HTML::TocInsertor::_deinitializeOutput() ---------------------------------
+# function: Deinitialize output.
+
+sub _deinitializeOutput {
+		# Get arguments
+	my ($self) = @_;
+		# Filehandle is defined?
+	if (defined($self->{_outputFileHandle})) {
+		# Yes, filehandle is defined;
+			# Restore selected filehandle
+		select($self->{_oldFileHandle});
+			# Undefine filehandle, closing it automatically
+		undef $self->{_outputFileHandle};
+	}
+}  # _deinitializeOutput()
+
+
+#--- HTML::TocInsertor::_initializeOutput() -----------------------------------
+# function: Initialize output.
+
+sub _initializeOutput {
+		# Get arguments
+	my ($self) = @_;
+		# Bias to write to outputfile
+	my $doOutputToFile = 1;
+
+		# Is output specified?
+	if (defined($self->{options}{'output'})) {
+		# Yes, output is specified;
+			# Indicate to not output to outputfile
+		$doOutputToFile = 0;
+			# Alias output reference
+		$self->{_output} = $self->{options}{'output'};
+			# Clear output
+		${$self->{_output}} = "";
+	}
+
+		# Is output file specified?
+	if (defined($self->{options}{'outputFile'})) {
+		# Yes, output file is specified;
+			# Indicate to output to outputfile
+		$doOutputToFile = 1;
+			# Open file
+		$self->{_outputFileHandle} = 
+			new FileHandle ">" . $self->{options}{'outputFile'};
+
+			# Backup currently selected filehandle
+		$self->{_oldFileHandle} = select;
+			# Set new default filehandle
+		select($self->{_outputFileHandle});
+	}
+
+		# Alias output-to-file indicator
+	$self->{_doOutputToFile} = $doOutputToFile;
+}  # _initializeOutput()
+
+
+#--- HTML::TocInsertor::_deinitializeInsertorBatch() --------------------------
+# function: Deinitialize insertor batch.
+
+sub _deinitializeInsertorBatch {
+		# Get arguments
+	my ($self) = @_;
+		# Indicate ToC insertion has finished
+	$self->{_isTocInsertionPointPassed} = 0;
+		# Write buffered output
+	$self->_writeBufferedOutput();
+		# Propagate?
+	if ($self->{hti__Mode} == MODE_DO_PROPAGATE) {
+		# Yes, propagate;
+			# Deinitialize generator batch
+		$self->_deinitializeGeneratorBatch();
+	}
+	else {
+		# No, insert only;
+			# Do general batch deinitialization
+		$self->_deinitializeBatch();
+	}
+		# Deinitialize output
+	$self->_deinitializeOutput();
+		# Indicate end of batch
+	$self->{hti__Mode} = MODE_DO_NOTHING;
+		# Reset batch variables
+	$self->_resetBatchVariables();
+}  # _deinitializeInsertorBatch()
+
+
+#--- HTML::TocInsertor::_initializeInsertorBatch() ----------------------------
+# function: Initialize insertor batch.
+# args:     - $aTocs: Reference to array of tocs.
+#           - $aOptions: optional options
+
+sub _initializeInsertorBatch {
+		# Get arguments
+	my ($self, $aTocs, $aOptions) = @_;
+		# Add invocation options
+	$self->setOptions($aOptions);
+		# Option 'doGenerateToc' specified?
+	if (!defined($self->{options}{'doGenerateToc'})) {
+		# No, options 'doGenerateToc' not specified;
+			# Default to 'doGenerateToc'
+		$self->{options}{'doGenerateToc'} = 1;
+	}
+		# Propagate?
+	if ($self->{options}{'doGenerateToc'}) {
+		# Yes, propagate;
+			# Indicate mode
+		$self->{hti__Mode} = MODE_DO_PROPAGATE;
+			# Initialize generator batch
+			# NOTE: This method takes care of calling '_initializeBatch()'
+		$self->_initializeGeneratorBatch($aTocs);
+	}
+	else {
+		# No, insert;
+			# Indicate mode
+		$self->{hti__Mode} = MODE_DO_INSERT;
+			# Do general batch initialization
+		$self->_initializeBatch($aTocs);
+	}
+		# Initialize output
+	$self->_initializeOutput();
+		# Parse ToC insertion points
+	$self->_parseTocInsertionPoints();
+}  # _initializeInsertorBatch()
+
+
+#--- HTML::TocInsertor::_insert() ---------------------------------------------
+# function: Insert ToC in string.
+# args:     - $aString: Reference to string to parse.
+# note:     Used internally.
+
+sub _insert {
+		# Get arguments
+	my ($self, $aString) = @_;
+		# Propagate?
+	if ($self->{options}{'doGenerateToc'}) {
+		# Yes, propagate;
+			# Generate & insert ToC
+		$self->_generate($aString);
+	}
+	else {
+		# No, just insert ToC
+			# Insert by parsing file
+		$self->parse($aString);
+			# Flush remaining buffered text
+		$self->eof();
+	}
+}  # _insert()
+
+
+#--- HTML::TocInsertor::_insertIntoFile() -------------------------------------
+# function: Do insert generated ToCs in file.
+# args:     - $aToc: (reference to array of) ToC object(s) to insert.
+#           - $aFile: (reference to array of) file(s) to parse for insertion
+#                points.
+#           - $aOptions: optional insertor options
+# note:     Used internally.
+
+sub _insertIntoFile {
+		# Get arguments
+	my ($self, $aFile) = @_;
+		# Local variables;
+	my ($file, @files);
+		# Dereference array reference or make array of file specification
+	@files = (ref($aFile) =~ m/ARRAY/) ? @$aFile : ($aFile);
+		# Loop through files
+	foreach $file (@files) {
+			# Propagate?
+		if ($self->{options}{'doGenerateToc'}) {
+			# Yes, propagate;
+				# Generate and insert ToC
+			$self->_generateFromFile($file);
+		}
+		else {
+			# No, just insert ToC
+				# Insert by parsing file
+			$self->parse_file($file);
+		}
+	}
+}  # _insertIntoFile()
+
+
+#--- HTML::TocInsertor::_parseTocInsertionPoints() ----------------------------
+# function: Parse ToC insertion point specifier.
+
+sub _parseTocInsertionPoints {
+		# Get arguments
+	my ($self) = @_;
+		# Local variables
+	my ($tipPreposition, $tipToken, $toc, $tokenTipParser);
+		# Create parser for TIP tokens
+	$tokenTipParser = HTML::_TokenTipParser->new(
+		$self->{_tokensTip}
+	);
+		# Loop through ToCs
+	foreach $toc (@{$self->{_tocs}}) {
+			# Split TIP in preposition and token
+		($tipPreposition, $tipToken) = split(
+			'\s+', $toc->{options}{'insertionPoint'}, 2
+		);
+			# Known preposition?
+		if (
+			($tipPreposition ne TIP_PREPOSITION_REPLACE) &&
+			($tipPreposition ne TIP_PREPOSITION_BEFORE) &&
+			($tipPreposition ne TIP_PREPOSITION_AFTER)
+		) {
+			# No, unknown preposition;
+				# Use default preposition
+			$tipPreposition = TIP_PREPOSITION_AFTER;
+				# Use entire 'insertionPoint' as token
+			$tipToken = $toc->{options}{'insertionPoint'};
+		}
+			# Indicate current ToC to parser
+		$tokenTipParser->setToc($toc);
+			# Indicate current preposition to parser
+		$tokenTipParser->setPreposition($tipPreposition);
+			# Parse ToC Insertion Point
+		$tokenTipParser->parse($tipToken);
+			# Flush remaining buffered text
+		$tokenTipParser->eof();
+	}
+}  # _parseTocInsertionPoints()
+
+
+#--- HTML::TocInsertor::_processTokenAsInsertionPoint() -----------------------
+# function: Check for token being a ToC insertion point (Tip) token and
+#           process it accordingly.
+# args:     - $aTokenType: type of token: start, end, comment or text.
+#           - $aTokenId: token id of currently parsed token
+#           - $aTokenAttributes: attributes of currently parsed token
+#           - $aOrigText: complete token
+# returns:  1 if successful -- token is processed as insertion point, 0
+#           if not.
+
+sub _processTokenAsInsertionPoint {
+		# Get arguments
+	my ($self, $aTokenType, $aTokenId, $aTokenAttributes, $aOrigText) = @_;
+		# Local variables
+	my ($i, $result, $tipToken, $tipTokenId, $tipTokens);
+		# Bias to token not functioning as a ToC insertion point (Tip) token
+	$result = 0;
+		# Alias ToC insertion point (Tip) array of right type
+	$tipTokens = $self->{_tokensTip}[$aTokenType];
+		# Loop through tipTokens
+	$i = 0;
+	while ($i < scalar @{$tipTokens}) {
+			# Aliases
+		$tipToken			         = $tipTokens->[$i];
+		$tipTokenId			         = $tipToken->[TIP_TOKEN_ID];
+			# Id & attributes match?
+		if (
+			($aTokenId =~ m/$tipTokenId/) && (
+				HTML::TocGenerator::_doesHashContainHash(
+					$aTokenAttributes, $tipToken->[TIP_INCLUDE_ATTRIBUTES], 0
+				) &&
+				HTML::TocGenerator::_doesHashContainHash(
+					$aTokenAttributes, $tipToken->[TIP_EXCLUDE_ATTRIBUTES], 1
+				)
+			)
+		) {
+			# Yes, id and attributes match;
+				# Process ToC insertion point
+			$self->_processTocInsertionPoint($tipToken);
+				# Indicate token functions as ToC insertion point
+			$result = 1;
+				# Remove Tip token, automatically advancing to next token
+			splice(@$tipTokens, $i, 1);
+		}
+		else {
+			# No, tag doesn't match ToC insertion point
+				# Advance to next start token
+			$i++;
+		}
+	}
+		# Token functions as ToC insertion point?
+	if ($result) {
+		# Yes, token functions as ToC insertion point;
+			# Process insertion point(s)
+		$self->_processTocInsertionPoints($aOrigText);
+	}
+		# Return value
+	return $result;
+}  # _processTokenAsInsertionPoint()
+
+
+#--- HTML::TocInsertor::toc() -------------------------------------------------
+# function: Toc processing method.  Add toc reference to scenario.
+# args:     - $aScenario: Scenario to add ToC reference to.
+#           - $aToc: Reference to ToC to insert.
+# note:     The ToC hasn't been build yet; only a reference to the ToC to be
+#           build is inserted.
+
+sub toc {
+		# Get arguments
+	my ($self, $aScenario, $aToc) = @_;
+		# Add toc to scenario
+	push(@$aScenario, $aToc);
+}  # toc()
+
+
+#--- HTML::TocInsertor::_processTocInsertionPoint() ----------------------------
+# function: Process ToC insertion point.
+# args:     - $aTipToken: Reference to token array item which matches the ToC 
+#                insertion point.
+
+sub _processTocInsertionPoint {
+		# Get arguments
+	my ($self, $aTipToken) = @_;
+		# Local variables
+	my ($tipToc, $tipPreposition); 
+	
+		# Aliases
+	$tipToc         = $aTipToken->[TIP_TOC];
+	$tipPreposition = $aTipToken->[TIP_PREPOSITION];
+
+	SWITCH: {
+			# Replace token with ToC?
+		if ($tipPreposition eq TIP_PREPOSITION_REPLACE) {
+			# Yes, replace token;
+				# Indicate ToC insertion point has been passed
+			$self->{_isTocInsertionPointPassed} = 1;
+				# Add ToC reference to scenario reference by calling 'toc' method
+			$self->toc($self->{_scenarioAfterToken}, $tipToc);
+			#push(@{$self->{_scenarioAfterToken}}, $tipTokenToc);
+				# Indicate token itself must not be output
+			$self->{_doOutputInsertionPointToken} = 0;
+			last SWITCH;
+		}
+			# Output ToC before token?
+		if ($tipPreposition eq TIP_PREPOSITION_BEFORE) {
+			# Yes, output ToC before token;
+				# Indicate ToC insertion point has been passed
+			$self->{_isTocInsertionPointPassed} = 1;
+				# Add ToC reference to scenario reference by calling 'toc' method
+			$self->toc($self->{_scenarioBeforeToken}, $tipToc);
+			#push(@{$self->{_scenarioBeforeToken}}, $tipTokenToc);
+			last SWITCH;
+		}
+			# Output ToC after token?
+		if ($tipPreposition eq TIP_PREPOSITION_AFTER) {
+			# Yes, output ToC after token;
+				# Indicate ToC insertion point has been passed
+			$self->{_isTocInsertionPointPassed} = 1;
+				# Add ToC reference to scenario reference by calling 'toc' method
+			$self->toc($self->{_scenarioAfterToken}, $tipToc);
+			#push(@{$self->{_scenarioAfterToken}}, $tipTokenToc);
+			last SWITCH;
+		}
+	}
+}  # _processTocInsertionPoint()
+
+
+#--- HTML::TocInsertor::_processTocInsertionPoints() --------------------------
+# function: Process ToC insertion points
+# args:     - $aTokenText: Text of token which acts as insertion point for one
+#                or multiple ToCs.
+
+sub _processTocInsertionPoints {
+		# Get arguments
+	my ($self, $aTokenText) = @_;
+		# Local variables
+	my ($outputPrefix, $outputSuffix);
+		# Extend scenario
+	push(@{$self->{_scenario}}, @{$self->{_scenarioBeforeToken}});
+
+	if ($outputPrefix = $self->{_outputPrefix}) {
+		push(@{$self->{_scenario}}, \$outputPrefix);
+		$self->{_outputPrefix} = "";
+	}
+
+		# Must insertion point token be output?
+	if ($self->{_doOutputInsertionPointToken}) {
+		# Yes, output insertion point token;
+		push(@{$self->{_scenario}}, \$aTokenText);
+	}
+
+	if ($outputSuffix = $self->{_outputSuffix}) {
+		push(@{$self->{_scenario}}, \$outputSuffix);
+		$self->{_outputSuffix} = "";
+	}
+
+	push(@{$self->{_scenario}}, @{$self->{_scenarioAfterToken}});
+		# Add new act to scenario for output to come
+	my $output = "";
+	push(@{$self->{_scenario}}, \$output);
+		# Write output, processing possible '_outputSuffix'
+	#$self->_writeOrBufferOutput("");
+		# Reset helper scenario's
+	$self->{_scenarioBeforeToken} = [];
+	$self->{_scenarioAfterToken}  = [];
+		# Reset bias value to output insertion point token
+	$self->{_doOutputInsertionPointToken} = 1;
+
+}  # _processTocInsertionPoints()
+
+
+#--- HTML::Toc::_resetBatchVariables() ----------------------------------------
+# function: Reset batch variables.
+
+sub _resetBatchVariables {
+	my ($self) = @_;
+		# Call ancestor
+	$self->SUPER::_resetBatchVariables();
+		# Array containing references to scalars.  This array depicts the order
+		# in which output must be performed after the first ToC Insertion Point
+		# has been passed.
+	$self->{_scenario}            = [];
+		# Helper scenario
+	$self->{_scenarioBeforeToken} = [];
+		# Helper scenario
+	$self->{_scenarioAfterToken}  = [];
+		# Arrays containing start, end, comment, text & declaration tokens which 
+		# must trigger the ToC insertion.  Each array element may contain a 
+		# reference to an array containing the following elements:
+	$self->{_tokensTip} = [
+		[],	# TT_TOKENTYPE_START
+		[],	# TT_TOKENTYPE_END
+		[],	# TT_TOKENTYPE_COMMENT
+		[],	# TT_TOKENTYPE_TEXT
+		[]		# TT_TOKENTYPE_DECLARATION
+	];
+		# 1 if ToC insertion point has been passed, 0 if not
+	$self->{_isTocInsertionPointPassed} = 0;
+		# Tokens after ToC
+	$self->{outputBuffer} = "";
+		# Trailing text after parsed token
+	$self->{_outputSuffix} = "";
+		# Preceding text before parsed token
+	$self->{_outputPrefix} = "";
+}  # _resetBatchVariables()
+
+
+#--- HTML::TocInsertor::_writeBufferedOutput() --------------------------------
+# function: Write buffered output to output device(s).
+
+sub _writeBufferedOutput {
+		# Get arguments
+	my ($self) = @_;
+		# Local variables
+	my ($scene);
+		# Must ToC be parsed?
+	if ($self->{options}{'parseToc'}) {
+		# Yes, ToC must be parsed;
+			# Parse ToC
+		#$self->parse($self->{toc});
+			# Output tokens after ToC
+		#$self->_writeOrBufferOutput($self->{outputBuffer});
+	}
+	else {
+		# No, ToC needn't be parsed;
+			# Output scenario
+		foreach $scene (@{$self->{_scenario}}) {
+				# Is scene a reference to a scalar?
+			if (ref($scene) eq "SCALAR") {
+				# Yes, scene is a reference to a scalar;
+					# Output scene
+				$self->_writeOutput($$scene);
+			}
+			else {
+				# No, scene must be reference to HTML::Toc;
+					# Output toc
+				$self->_writeOutput($scene->format());
+			}
+		}
+	}
+}  # _writeBufferedOutput()
+
+
+#--- HTML::TocInsertor::_writeOrBufferOutput() --------------------------------
+# function: Write processed HTML to output device(s).
+# args:     - aOutput: scalar to write
+# note:     If '_isTocInsertionPointPassed' text is buffered before being 
+#           output because the ToC has to be generated before it can be output.
+#           Only after the entire data has been parsed, the ToC and the 
+#           following text will be output.
+
+sub _writeOrBufferOutput {
+		# Get arguments
+	my ($self, $aOutput) = @_;
+
+		# Add possible output prefix and suffix
+	$aOutput = $self->{_outputPrefix} . $aOutput . $self->{_outputSuffix};
+		# Clear output prefix and suffix
+	$self->{_outputPrefix} = "";
+	$self->{_outputSuffix} = "";
+
+		# Has ToC insertion point been passed?
+	if ($self->{_isTocInsertionPointPassed}) {
+		# Yes, ToC insertion point has been passed;
+			# Buffer output; add output to last '_scenario' item
+		my $index = scalar(@{$self->{_scenario}}) - 1;
+		${$self->{_scenario}[$index]} .= $aOutput;
+	}
+	else {
+		# No, ToC insertion point hasn't been passed;
+			# Write output
+		$self->_writeOutput($aOutput);
+	}
+}  # _writeOrBufferOutput()
+
+
+#--- HTML::TocInsertor::_writeOutput() ----------------------------------------
+# function: Write processed HTML to output device(s).
+# args:     - aOutput: scalar to write
+
+sub _writeOutput {
+		# Get arguments
+	my ($self, $aOutput) = @_;
+		# Write output to scalar;
+	${$self->{_output}} .= $aOutput if (defined($self->{_output}));
+		# Write output to output file
+	print $aOutput if ($self->{_doOutputToFile})
+}  # _writeOutput()
+
+
+#--- HTML::TocGenerator::anchorId() -------------------------------------------
+# function: Anchor id processing method.
+# args:     - $aAnchorId
+
+sub anchorId {
+		# Get arguments
+	my ($self, $aAnchorId) = @_;
+		# Indicate id must be added to start tag
+	$self->{_doAddAnchorIdToStartTag} = 1;
+	$self->{_anchorId} = $aAnchorId;
+}  # anchorId()
+
+
+#--- HTML::TocInsertor::anchorNameBegin() -------------------------------------
+# function: Process anchor name begin, generated by HTML::TocGenerator.
+# args:     - $aAnchorNameBegin: Anchor name begin tag to output.
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub anchorNameBegin {
+		# Get arguments
+	my ($self, $aAnchorNameBegin, $aToc) = @_;
+		# Is another anchorName active?
+	if (defined($self->{_activeAnchorName})) {
+		# Yes, another anchorName is active;
+			# Show warning
+		print "Warn\n";
+		$self->_showWarning(
+			HTML::TocGenerator::WARNING_NESTED_ANCHOR_PS_WITHIN_PS,
+			[$aAnchorNameBegin, $self->{_activeAnchorName}]
+		);
+	}
+		# Store anchor name as output prefix
+	$self->{_outputPrefix} = $aAnchorNameBegin;
+		# Indicate active anchor name
+	$self->{_activeAnchorName} = $aAnchorNameBegin;
+		# Indicate anchor name end must be output
+	$self->{_doOutputAnchorNameEnd} = 1;
+}	# anchorNameBegin()
+
+
+#--- HTML::TocInsertor::anchorNameEnd() ---------------------------------------
+# function: Process anchor name end, generated by HTML::TocGenerator.
+# args:     - $aAnchorNameEnd: Anchor name end tag to output.
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub anchorNameEnd {
+		# Get arguments
+	my ($self, $aAnchorNameEnd) = @_;
+		# Store anchor name as output prefix
+	$self->{_outputSuffix} .= $aAnchorNameEnd;
+		# Indicate deactive anchor name
+	$self->{_activeAnchorName} = undef;
+}	# anchorNameEnd()
+
+
+#--- HTML::TocInsertor::comment() ---------------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Local variables
+	my ($tocInsertionPointToken, $doOutput, $origText);
+		# Allow ancestor to process the comment tag
+	$self->SUPER::comment($aComment);
+		# Assemble original comment
+	$origText = "<!--$aComment-->";
+		# Must ToCs be inserted?
+	if ($self->{hti__Mode} & MODE_DO_INSERT) {
+		# Yes, ToCs must be inserted;
+			# Processing comment as ToC insertion point is successful?
+		if (! $self->_processTokenAsInsertionPoint(
+			HTML::TocGenerator::TT_TOKENTYPE_COMMENT, $aComment, undef, $origText
+		)) {
+			# No, comment isn't a ToC insertion point;
+				# Output comment normally
+			$self->_writeOrBufferOutput($origText);
+		}
+	}
+}  # comment()
+
+
+#--- HTML::TocInsertor::declaration() -----------------------------------------
+# function: This function is called every time a declaration is encountered
+#           by HTML::Parser.
+
+sub declaration {
+		# Get arguments
+	my ($self, $aDeclaration) = @_;
+		# Allow ancestor to process the declaration tag
+	$self->SUPER::declaration($aDeclaration);
+		# Must ToCs be inserted?
+	if ($self->{hti__Mode} & MODE_DO_INSERT) {
+		# Yes, ToCs must be inserted;
+			# Processing declaration as ToC insertion point is successful?
+		if (! $self->_processTokenAsInsertionPoint(
+			HTML::TocGenerator::TT_TOKENTYPE_DECLARATION, $aDeclaration, undef, 
+			"<!$aDeclaration>"
+		)) {
+			# No, declaration isn't a ToC insertion point;
+				# Output declaration normally
+			$self->_writeOrBufferOutput("<!$aDeclaration>");
+		}
+	}
+}  # declaration()
+
+
+#--- HTML::TocInsertor::end() -------------------------------------------------
+# function: This function is called every time a closing tag is encountered
+#           by HTML::Parser.
+# args:     - $aTag: tag name (in lower case).
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Allow ancestor to process the end tag
+	$self->SUPER::end($aTag, $aOrigText);
+		# Must ToCs be inserted?
+	if ($self->{hti__Mode} & MODE_DO_INSERT) {
+		# Yes, ToCs must be inserted;
+			# Processing end tag as ToC insertion point is successful?
+		if (! $self->_processTokenAsInsertionPoint(
+			HTML::TocGenerator::TT_TOKENTYPE_END, $aTag, undef, $aOrigText
+		)) {
+			# No, end tag isn't a ToC insertion point;
+				# Output end tag normally
+			$self->_writeOrBufferOutput($aOrigText);
+		}
+	}
+}  # end()
+
+
+#--- HTML::TocInsertor::insert() ----------------------------------------------
+# function: Insert ToC in string.
+# args:     - $aToc: (reference to array of) ToC object to insert
+#           - $aString: string to insert ToC in
+#           - $aOptions: hash reference with optional insertor options
+
+sub insert {
+		# Get arguments
+	my ($self, $aToc, $aString, $aOptions) = @_;
+		# Initialize TocInsertor batch
+	$self->_initializeInsertorBatch($aToc, $aOptions);
+		# Do insert Toc
+	$self->_insert($aString);
+		# Deinitialize TocInsertor batch
+	$self->_deinitializeInsertorBatch();
+}  # insert()
+
+
+#--- HTML::TocInsertor::insertIntoFile() --------------------------------------
+# function: Insert ToCs in file.
+# args:     - $aToc: (reference to array of) ToC object(s) to insert.
+#           - $aFile: (reference to array of) file(s) to parse for insertion
+#                points.
+#           - $aOptions: optional insertor options
+
+sub insertIntoFile {
+		# Get arguments
+	my ($self, $aToc, $aFile, $aOptions) = @_;
+		# Initialize TocInsertor batch
+	$self->_initializeInsertorBatch($aToc, $aOptions);
+		# Do insert ToCs into file
+	$self->_insertIntoFile($aFile);
+		# Deinitialize TocInsertor batch
+	$self->_deinitializeInsertorBatch();
+}  # insertIntoFile()
+
+
+#--- HTML::TocInsertor::number() ----------------------------------------------
+# function: Process heading number generated by HTML::Toc.
+# args:     - $aNumber
+
+sub number {
+		# Get arguments
+	my ($self, $aNumber) = @_;
+		# Store heading number as output suffix
+	$self->{_outputSuffix} .= $aNumber;
+}	# number()
+
+
+#--- HTML::TocInsertor::propagateFile() ---------------------------------------
+# function: Propagate ToC; generate & insert ToC, using file as input.
+# args:     - $aToc: (reference to array of) ToC object to insert
+#           - $aFile: (reference to array of) file to parse for insertion
+#                points.
+#           - $aOptions: optional insertor options
+
+sub propagateFile {
+		# Get arguments
+	my ($self, $aToc, $aFile, $aOptions) = @_;
+		# Local variables;
+	my ($file, @files);
+		# Initialize TocInsertor batch
+	$self->_initializeInsertorBatch($aToc, $aOptions);
+		# Dereference array reference or make array of file specification
+	@files = (ref($aFile) =~ m/ARRAY/) ? @$aFile : ($aFile);
+		# Loop through files
+	foreach $file (@files) {
+			# Generate and insert ToC
+		$self->_generateFromFile($file);
+	}
+		# Deinitialize TocInsertor batch
+	$self->_deinitializeInsertorBatch();
+}  # propagateFile()
+
+
+#--- HTML::TocInsertor::start() -----------------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all tag attributes (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+		# Local variables
+	my ($doOutput, $i, $tocToken, $tag, $anchorId);
+		# Let ancestor process the start tag
+	$self->SUPER::start($aTag, $aAttr, $aAttrSeq, $aOrigText);
+		# Must ToC be inserted?
+	if ($self->{hti__Mode} & MODE_DO_INSERT) {
+		# Yes, ToC must be inserted;
+			# Processing start tag as ToC insertion point is successful?
+		if (! $self->_processTokenAsInsertionPoint(
+			HTML::TocGenerator::TT_TOKENTYPE_START, $aTag, $aAttr, $aOrigText
+		)) {
+			# No, start tag isn't a ToC insertion point;
+				# Add anchor id?
+			if ($self->{_doAddAnchorIdToStartTag}) {
+				# Yes, anchor id must be added;
+					# Reset indicator;
+				$self->{_doAddAnchorIdToStartTag} = 0;
+					# Alias anchor id
+				$anchorId = $self->{_anchorId};
+					# Attribute 'id' already exists?
+				if (defined($aAttr->{id})) {
+					# Yes, attribute 'id' already exists;
+						# Show warning
+					print STDERR "WARNING: Overwriting existing id attribute '" .
+						$aAttr->{id} . "' of tag $aOrigText\n";
+					
+						# Add anchor id to start tag
+					$aOrigText =~ s/(id)=\S*([\s>])/$1=$anchorId$2/i;
+				}
+				else {
+					# No, attribute 'id' doesn't exist;
+						# Add anchor id to start tag
+					$aOrigText =~ s/>/ id=$anchorId>/;
+				}
+			}
+				# Output start tag normally
+			$self->_writeOrBufferOutput($aOrigText);
+		}
+	}
+}  # start()
+
+
+#--- HTML::TocInsertor::text() ------------------------------------------------
+# function: This function is called every time plain text is encountered.
+# args:     - @_: array containing data.
+
+sub text {
+		# Get arguments
+	my ($self, $aText) = @_;
+		# Let ancestor process the text
+	$self->SUPER::text($aText);
+		# Must ToC be inserted?
+	if ($self->{hti__Mode} & MODE_DO_INSERT) {
+		# Yes, ToC must be inserted;
+			# Processing text as ToC insertion point is successful?
+		if (! $self->_processTokenAsInsertionPoint(
+			HTML::TocGenerator::TT_TOKENTYPE_TEXT, $aText, undef, $aText
+		)) {
+			# No, text isn't a ToC insertion point;
+				# Output text normally
+			$self->_writeOrBufferOutput($aText);
+		}
+	}
+}  # text()
+
+
+
+
+#=== HTML::_TokenTipParser ====================================================
+# function: Parse 'TIP tokens'.  'TIP tokens' mark HTML code which is to be
+#           used as the ToC Insertion Point.
+# note:     Used internally.
+
+package HTML::_TokenTipParser;
+
+
+BEGIN {
+	use vars qw(@ISA);
+
+	@ISA = qw(HTML::_TokenTocParser);
+}
+
+
+END {}
+
+
+#--- HTML::_TokenTipParser::new() ---------------------------------------------
+# function: Constructor
+
+sub new {
+		# Get arguments
+	my ($aType, $aTokenArray) = @_;
+		# Create instance
+	my $self = $aType->SUPER::new;
+		# Reference token array
+	$self->{tokens} = $aTokenArray;
+		# Reference to last added token
+	$self->{_lastAddedToken}     = undef;
+	$self->{_lastAddedTokenType} = undef;
+		# Return instance
+	return $self;
+}  # new()
+
+
+#--- HTML::_TokenTipParser::_processAttributes() ------------------------------
+# function: Process attributes.
+# args:     - $aAttributes: Attributes to parse.
+
+sub _processAttributes {
+		# Get arguments
+	my ($self, $aAttributes) = @_;
+		# Local variables
+	my (%includeAttributes, %excludeAttributes);
+
+		# Parse attributes
+	$self->_parseAttributes(
+		$aAttributes, \%includeAttributes, \%excludeAttributes
+	);
+		# Include attributes are specified?
+	if (keys(%includeAttributes) > 0) {
+		# Yes, include attributes are specified;
+			# Store include attributes
+		@${$self->{_lastAddedToken}}[
+			HTML::TocInsertor::TIP_INCLUDE_ATTRIBUTES
+		] = \%includeAttributes;
+	}
+		# Exclude attributes are specified?
+	if (keys(%excludeAttributes) > 0) {
+		# Yes, exclude attributes are specified;
+			# Store exclude attributes
+		@${$self->{_lastAddedToken}}[
+			HTML::TocInsertor::TIP_EXCLUDE_ATTRIBUTES
+		] = \%excludeAttributes;
+	}
+}  # _processAttributes()
+
+
+#--- HTML::_TokenTipParser::_processToken() -----------------------------------
+# function: Process token.
+# args:     - $aTokenType: Type of token to process.
+#           - $aTag: Tag of token.
+
+sub _processToken {
+		# Get arguments
+	my ($self, $aTokenType, $aTag) = @_;
+		# Local variables
+	my ($tokenArray, $index);
+		# Push element on array of update tokens
+	$index = push(@{$self->{tokens}[$aTokenType]}, []) - 1;
+		# Alias token array to add element to
+	$tokenArray = $self->{tokens}[$aTokenType];
+		# Indicate last updated token array element
+	$self->{_lastAddedTokenType} = $aTokenType;
+	$self->{_lastAddedToken}     = \$$tokenArray[$index];
+		# Add fields
+	$$tokenArray[$index][HTML::TocInsertor::TIP_TOC]         = $self->{_toc};
+	$$tokenArray[$index][HTML::TocInsertor::TIP_TOKEN_ID] 	= $aTag;
+	$$tokenArray[$index][HTML::TocInsertor::TIP_PREPOSITION] =
+		$self->{_preposition};
+}  # _processToken()
+
+
+#--- HTML::_TokenTipParser::comment() -----------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_COMMENT, $aComment);
+}  # comment()
+
+
+#--- HTML::_TokenTipParser::declaration() --------------------------------
+# function: This function is called every time a markup declaration is
+#           encountered by HTML::Parser.
+# args:     - $aDeclaration: Markup declaration.
+
+sub declaration {
+		# Get arguments
+	my ($self, $aDeclaration) = @_;
+		# Process token
+	$self->_processToken(
+		HTML::TocGenerator::TT_TOKENTYPE_DECLARATION, $aDeclaration
+	);
+}  # declaration()
+
+	
+#--- HTML::_TokenTipParser::end() ----------------------------------------
+# function: This function is called every time a closing tag is encountered
+#           by HTML::Parser.
+# args:     - $aTag: tag name (in lower case).
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_END, $aTag);
+}  # end()
+
+
+#--- HTML::_TokenTipParser->setPreposition() ----------------------------------
+# function: Set current preposition.
+
+sub setPreposition {
+		# Get arguments
+	my ($self, $aPreposition) = @_;
+		# Set current ToC
+	$self->{_preposition} = $aPreposition;
+}  # setPreposition()
+
+
+#--- HTML::_TokenTipParser->setToc() ------------------------------------------
+# function: Set current ToC.
+
+sub setToc {
+		# Get arguments
+	my ($self, $aToc) = @_;
+		# Set current ToC
+	$self->{_toc} = $aToc;
+}  # setToc()
+
+
+#--- HTML::_TokenTipParser::start() --------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all attribute keys (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+		# Process token
+	$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_START, $aTag);
+		# Process attributes
+	$self->_processAttributes($aAttr);
+}  # start()
+
+
+#--- HTML::_TokenTipParser::text() ---------------------------------------
+# function: This function is called every time plain text is encountered.
+# args:     - @_: array containing data.
+
+sub text {
+		# Get arguments
+	my ($self, $aText) = @_;
+		# Was token already created and is last added token of type 'text'?
+	if (
+		defined($self->{_lastAddedToken}) && 
+		$self->{_lastAddedTokenType} == HTML::TocGenerator::TT_TOKENTYPE_TEXT
+	) {
+		# Yes, token is already created;
+			# Add tag to existing token
+		@${$self->{_lastAddedToken}}[HTML::TocGenerator::TT_TAG_BEGIN] .= $aText;
+	}
+	else {
+		# No, token isn't created;
+			# Process token
+		$self->_processToken(HTML::TocGenerator::TT_TOKENTYPE_TEXT, $aText);
+	}
+}  # text()
+
+
+1;
diff --git a/examples/includes/HTML-Toc-0.91/TocUpdator.pm b/examples/includes/HTML-Toc-0.91/TocUpdator.pm
new file mode 100644
index 0000000..affca9d
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/TocUpdator.pm
@@ -0,0 +1,693 @@
+#==== HTML::TocUpdator ========================================================
+# function: Update 'HTML::Toc' table of contents.
+# note:     - 'TUT' is an abbreviation of 'Toc Update Token'.
+
+
+package HTML::TocUpdator;
+
+
+use strict;
+use HTML::TocInsertor;
+
+
+BEGIN {
+	use vars qw(@ISA $VERSION);
+
+	$VERSION = '0.91';
+
+	@ISA = qw(HTML::TocInsertor);
+}
+
+
+use constant TUT_TOKENTYPE_START    => 0;
+use constant TUT_TOKENTYPE_END      => 1;
+use constant TUT_TOKENTYPE_TEXT     => 2;
+use constant TUT_TOKENTYPE_COMMENT  => 3;
+
+use constant MODE_DO_NOTHING   => 0;	# 0b00
+use constant MODE_DO_INSERT    => 1;	# 0b01
+use constant MODE_DO_UPDATE    => 3;	# 0b11
+
+
+END {}
+
+
+#--- HTML::TocUpdator::new() --------------------------------------------------
+# function: Constructor.
+
+sub new {
+		# Get arguments
+	my ($aType) = @_;
+	my $self = $aType->SUPER::new;
+		# Bias to not update ToC
+	$self->{htu__Mode} = MODE_DO_NOTHING;
+		# Bias to not delete tokens
+	$self->{_doDeleteTokens} = 0;
+		# Reset batch variables
+	#$self->_resetBatchVariables;
+
+	$self->{options} = {};
+		
+		# TODO: Initialize output
+
+	return $self;
+}  # new()
+
+
+#--- HTML::TocUpdator::_deinitializeUpdatorBatch() --------------------------
+# function: Deinitialize updator batch.
+# args:     - $aTocs: Reference to array of tocs.
+
+sub _deinitializeUpdatorBatch {
+		# Get arguments
+	my ($self, $aTocs) = @_;
+		# Indicate end of ToC updating
+	$self->{htu__Mode} = MODE_DO_NOTHING;
+		# Deinitialize insertor batch
+	$self->_deinitializeInsertorBatch();
+}  # _deinitializeUpdatorBatch()
+
+
+#--- HTML::TokenUpdator::_doesHashEqualHash() ---------------------------------
+# function: Determines whether hash1 equals hash2.
+# args:     - $aHash1
+#           - $aHash2
+# returns:  True (1) if hash1 equals hash2, 0 if not.  For example, with the
+#           following hashes:
+#
+#              %hash1 = {                     %hash2 = {
+#                 'class' => 'header',          'class' => 'header',
+#                 'id'    => 'intro1'           'id'    => 'intro2'
+#              }                             }
+#
+#           the routine will return 0, cause the hash fields 'id' differ.
+# note:     Class function.
+
+sub _doesHashEqualHash {
+		# Get arguments
+	my ($aHash1, $aHash2) = @_;
+		# Local variables
+	my ($key1, $value1, $key2, $value2, $result);
+		# Bias to success
+	$result = 1;
+		# Loop through hash1 while values available
+	HASH1: while (($key1, $value1) = each %$aHash1) {
+		# Yes, values are available;
+			# Value1 differs from value2?
+		if ($value1 ne $aHash2->{$key1}) {
+			# Yes, hashes differ;
+				# Indicate condition fails
+			$result = 0;
+				# Reset 'each' iterator which we're going to break
+			keys %$aHash2;
+				# Break loop
+			last HASH1;
+		}
+	}
+		# Return value
+	return $result;
+}  # _doesHashEqualHash()
+
+
+#--- HTML::TokenUpdator::_doesTagExistInArray() -------------------------------
+# function: Check whether tag & attributes matches any of the tags & attributes
+#           in the specified array.  The array must consist of elements with 
+#           format:
+#
+#              [$tag, \%attributes]
+#
+# args:     - $aTag: tag to search for
+#           - $aAttributes: tag attributes to search for
+#           - $aArray: Array to search in.
+# returns:  1 if tag does exist in array, 0 if not.
+# note:     Class function.
+
+sub _doesTagExistInArray {
+		# Get arguments
+	my ($aTag, $aAttributes, $aArray) = @_;
+		# Local variables
+	my ($tag, $result);
+		# Bias to non-existing tag
+	$result = 0;
+		# Loop through existing tags
+	TAG: foreach $tag (@{$aArray}) {
+		if (defined(@{$tag}[0])) {
+				# Does tag equals any existing tag?
+			if ($aTag eq @{$tag}[0]) {
+				# Yes, tag equals existing tag;
+					# Do hashes equal?
+				if (HTML::TocUpdator::_doesHashEqualHash(
+					$aAttributes, @{$tag}[1]
+				)) {
+					# Yes, hashes are the same;
+						# Indicate tag exists in array
+					$result = 1;
+						# Break loop
+					last TAG;
+				}
+			}
+		}
+	}
+		# Return value
+	return $result;
+}  # _doesTagExistInArray()
+
+
+#--- HTML::TocUpdator::_initializeUpdatorBatch() ----------------------------
+# function: Initialize insertor batch.
+# args:     - $aMode: Mode.  Can be either MODE_DO_INSERT or MODE_DO_UPDATE
+#           - $aTocs: Reference to array of tocs.
+#           - $aOptions: optional options
+# note:     Updating actually means: deleting the old ToC and inserting a new
+#           ToC.  That's why we're calling 'insertor' methods here.
+
+sub _initializeUpdatorBatch {
+		# Get arguments
+	my ($self, $aMode, $aTocs, $aOptions) = @_;
+		# Initialize insertor batch
+	$self->_initializeInsertorBatch($aTocs, $aOptions);
+		# Parse ToC update templates
+	$self->_parseTocUpdateTokens();
+		# Indicate start of ToC updating
+	$self->{htu__Mode} = $aMode;
+}  # _initializeUpdatorBatch()
+
+
+#--- HTML::TocUpdator::_parseTocUpdateTokens() --------------------------------
+# function: Parse ToC insertion point specifier.
+
+sub _parseTocUpdateTokens {
+		# Get arguments
+	my ($self) = @_;
+		# Local variables
+	my ($toc, $tokenType, $tokenPreposition, $token);
+	my ($tocInsertionPoint, $tocInsertionPointTokenAttributes);
+		# Create parser for update begin tokens
+	my $tokenUpdateBeginParser = HTML::_TokenUpdateParser->new(
+		$self->{_tokensUpdateBegin}
+	);
+		# Create parser for update end tokens
+	my $tokenUpdateEndParser = HTML::_TokenUpdateParser->new(
+		$self->{_tokensUpdateEnd}
+	);
+
+		# Loop through ToCs
+	foreach $toc (@{$self->{_tocs}}) {
+			# Parse update tokens
+		$tokenUpdateBeginParser->parse(
+			$toc->{_tokenUpdateBeginOfAnchorNameBegin}
+		);
+		$tokenUpdateBeginParser->parse($toc->{_tokenUpdateBeginOfAnchorNameEnd});
+		$tokenUpdateBeginParser->parse($toc->{_tokenUpdateBeginNumber});
+		$tokenUpdateBeginParser->parse($toc->{_tokenUpdateBeginToc});
+
+		$tokenUpdateEndParser->parse($toc->{_tokenUpdateEndOfAnchorNameBegin});
+		$tokenUpdateEndParser->parse($toc->{_tokenUpdateEndOfAnchorNameEnd});
+		$tokenUpdateEndParser->parse($toc->{_tokenUpdateEndNumber});
+		$tokenUpdateEndParser->parse($toc->{_tokenUpdateEndToc});
+	}
+}  # _parseTocUpdateTokens()
+
+
+#--- HTML::TocUpdator::_resetBatchVariables() ---------------------------------
+# function: Reset batch variables
+
+sub _resetBatchVariables {
+		# Get arguments
+	my ($self) = @_;
+		# Call ancestor
+	$self->SUPER::_resetBatchVariables();
+		# Arrays containing start, end, comment & text tokens which indicate
+		# the begin of ToC tokens.  The tokens are stored in keys of hashes to 
+		# avoid storing duplicates as an array would.
+	$self->{_tokensUpdateBegin} = [
+		[],	# ['<start tag>', <attributes>]
+		{},	# {'<end tag>' => ''}
+		{},	# {'<text>'    => ''}
+		{}		# {'<comment>' => ''}
+	];
+		# Arrays containing start, end, comment & text tokens which indicate
+		# the end of ToC tokens.  The tokens are stored in keys of hashes to 
+		# avoid storing duplicates as an array would.
+	$self->{_tokensUpdateEnd} = [
+		[],	# ['<start tag>', <attributes>]
+		{},	# {'<end tag>' => ''}
+		{},	# {'<text>'    => ''}
+		{}		# {'<comment>' => ''}
+	];
+}  # _resetBatchVariables()
+
+
+#--- HTML::TocUpdator::_setActiveAnchorName() ---------------------------------
+# function: Set active anchor name.
+# args:     - aAnchorName: Name of anchor name to set active.
+
+sub _setActiveAnchorName {
+		# Get arguments
+	my ($self, $aAnchorName) = @_;
+		# Are tokens being deleted?
+	if (! $self->{_doDeleteTokens}) {
+		# No, tokens aren't being deleted;
+			# Call ancestor to set anchor name
+		$self->SUPER::_setActiveAnchorName($aAnchorName);
+	}
+}  # _setActiveAnchorName()
+
+
+#--- HTML::TocUpdator::_update() ----------------------------------------------
+# function: Update ToC in string.
+# args:     - $aMode: Mode.  Can be either MODE_DO_UPDATE or MODE_DO_INSERT.
+#           - $aToc: (reference to array of) ToC object to update
+#           - $aString: string to update ToC of
+#           - $aOptions: optional updator options
+# note:     Used internally.
+
+sub _update {
+		# Get arguments
+	my ($self, $aMode, $aToc, $aString, $aOptions) = @_;
+		# Initialize TocUpdator batch
+	$self->_initializeUpdatorBatch($aMode, $aToc, $aOptions);
+		# Start updating ToC by starting ToC insertion
+	$self->_insert($aString);
+		# Deinitialize TocUpdator batch
+	$self->_deinitializeUpdatorBatch();
+}  # update()
+
+
+#--- HTML::TocUpdator::_updateFile() ------------------------------------------
+# function: Update ToCs in file.
+# args:     - $aMode: Mode.  Can be either MODE_DO_UPDATE or MODE_DO_INSERT.
+#           - $aToc: (reference to array of) ToC object to update
+#           - $aFile: (reference to array of) file to parse for updating.
+#           - $aOptions: optional updator options
+# note:     Used internally.
+
+sub _updateFile {
+		# Get arguments
+	my ($self, $aMode, $aToc, $aFile, $aOptions) = @_;
+		# Initialize TocUpdator batch
+	$self->_initializeUpdatorBatch($aMode, $aToc, $aOptions);
+		# Start updating ToC by starting ToC insertion
+	$self->_insertIntoFile($aFile);
+		# Deinitialize TocUpdator batch
+	$self->_deinitializeUpdatorBatch();
+}  # _updateFile()
+
+
+#--- HTML::TocUpdator::_writeOrBufferOutput() ---------------------------------
+# function: Write processed HTML to output device(s).
+# args:     - aOutput: scalar to write
+
+sub _writeOrBufferOutput {
+		# Get arguments
+	my ($self, $aOutput) = @_;
+		# Delete output?
+	if (! $self->{_doDeleteTokens}) {
+		# No, don't delete output;
+			# Call ancestor
+		$self->SUPER::_writeOrBufferOutput($aOutput);
+	}
+}  # _writeOrBufferOutput()
+
+
+#--- HTML::TocUpdator::anchorNameBegin() --------------------------------------
+# function: Process 'anchor name begin' generated by HTML::Toc.
+# args:     - $aAnchorName: Anchor name begin tag to output.
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub anchorNameBegin {
+		# Get arguments
+	my ($self, $aAnchorNameBegin, $aToc) = @_;
+		# Call ancestor
+	$self->SUPER::anchorNameBegin($aAnchorNameBegin);
+		# Must ToC be inserted or updated?
+	if ($self->{htu__Mode} != MODE_DO_NOTHING) {
+		# Yes, ToC must be inserted or updated;
+			# Surround anchor name with update tags
+		$self->{_outputPrefix} = 
+			$aToc->{_tokenUpdateBeginOfAnchorNameBegin} .
+			$self->{_outputPrefix} . 
+			$aToc->{_tokenUpdateEndOfAnchorNameBegin};
+	}
+}	# anchorNameBegin()
+
+
+#--- HTML::TocUpdator::anchorNameEnd() ----------------------------------------
+# function: Process 'anchor name end' generated by HTML::Toc.
+# args:     - $aAnchorNameEnd: Anchor name end tag to output.
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub anchorNameEnd {
+		# Get arguments
+	my ($self, $aAnchorNameEnd, $aToc) = @_;
+		# Call ancestor
+	$self->SUPER::anchorNameEnd($aAnchorNameEnd);
+		# Must ToC be inserted or updated?
+	if ($self->{htu__Mode} != MODE_DO_NOTHING) {
+		# Yes, ToC must be inserted or updated;
+			# Surround anchor name with update tags
+		$self->{_outputSuffix} = 
+			$aToc->{_tokenUpdateBeginOfAnchorNameEnd} .
+			$self->{_outputSuffix} . 
+			$aToc->{_tokenUpdateEndOfAnchorNameEnd};
+	}
+}	# anchorNameEnd()
+
+
+#--- HTML::TocUpdator::comment() ----------------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Must ToC be updated?
+	if ($self->{htu__Mode} == MODE_DO_UPDATE) {
+		# Yes, ToC must be updated;
+			# Updator is currently deleting tokens?
+		if ($self->{_doDeleteTokens}) {
+			# Yes, tokens must be deleted;
+				# Call ancestor
+			$self->SUPER::comment($aComment);
+
+				# Look for update end token
+
+				# Does comment matches update end token?
+			if (defined(
+				$self->{_tokensUpdateEnd}[TUT_TOKENTYPE_COMMENT]{$aComment}
+			)) {
+				# Yes, comment matches update end token;
+					# Indicate to stop deleting tokens
+				$self->{_doDeleteTokens} = 0;
+			}
+		}
+		else {
+			# No, tokens mustn't be deleted;
+
+				# Look for update begin token
+
+				# Does comment matches update begin token?
+			if (defined(
+				$self->{_tokensUpdateBegin}[TUT_TOKENTYPE_COMMENT]{$aComment}
+			)) {
+				# Yes, comment matches update begin token;
+					# Indicate to start deleting tokens
+				$self->{_doDeleteTokens} = 1;
+			}
+				# Call ancestor
+			$self->SUPER::comment($aComment);
+		}
+	}
+	else {
+		# No, ToC mustn't be updated;
+			# Call ancestor
+		$self->SUPER::comment($aComment);
+	}
+}  # comment()
+
+
+#--- HTML::TocUpdator::end() --------------------------------------------------
+# function: This function is called every time a closing tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aOrigText: tag name including brackets.
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Call ancestor
+	$self->SUPER::end($aTag, $aOrigText);
+		# Must ToC be updated?
+	if ($self->{htu__Mode} == MODE_DO_UPDATE) {
+		# Yes, ToC must be updated;
+			# Updator is currently deleting tokens?
+		if ($self->{_doDeleteTokens}) {
+			# Yes, tokens must be deleted;
+				# Does end tag matches update end token?
+			if (defined(
+				$self->{_tokensUpdateEnd}[TUT_TOKENTYPE_END]{$aTag}
+			)) {
+				# Yes, end tag matches update end token;
+					# Indicate to stop deleting tokens
+				$self->{_doDeleteTokens} = 0;
+			}
+		}
+	}
+}  # end()
+
+
+#--- HTML::TocUpdator::insert() -----------------------------------------------
+# function: Insert ToC in string.
+# args:     - $aToc: (reference to array of) ToC object to update
+#           - $aString: string to insert ToC in.
+#           - $aOptions: optional updator options
+
+sub insert {
+		# Get arguments
+	my ($self, $aToc, $aString, $aOptions) = @_;
+		# Do start insert
+	$self->_update(MODE_DO_INSERT, $aToc, $aString, $aOptions);
+}  # insert()
+
+
+#--- HTML::TocUpdator::insertIntoFile() --------------------------------------
+# function: Insert ToC in file.
+# args:     - $aToc: (reference to array of) ToC object to update
+#           - $aFile: File to insert ToC in.
+#           - $aOptions: optional updator options
+
+sub insertIntoFile {
+		# Get arguments
+	my ($self, $aToc, $aFile, $aOptions) = @_;
+		# Do start insert
+	$self->_updateFile(MODE_DO_INSERT, $aToc, $aFile, $aOptions);
+}  # insertIntoFile()
+
+
+#--- HTML::TocUpdator::number() -----------------------------------------------
+# function: Process heading number generated by HTML::Toc.
+# args:     - $aNumber
+#           - $aToc: Reference to ToC to which anchorname belongs.
+
+sub number {
+		# Get arguments
+	my ($self, $aNumber, $aToc) = @_;
+		# Call ancestor
+	$self->SUPER::number($aNumber);
+		# Must ToC be inserted or updated?
+	if ($self->{htu__Mode} != MODE_DO_NOTHING) {
+		# Yes, ToC must be inserted or updated;
+			# Surround number with update tags
+		$self->{_outputSuffix} = 
+			$aToc->{_tokenUpdateBeginNumber} .
+			$self->{_outputSuffix} . 
+			$aToc->{_tokenUpdateEndNumber};
+	}
+}	# number()
+
+
+#--- HTML::TocUpdator::start() ------------------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all tag attributes (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+		# Must ToC be updated?
+	if ($self->{htu__Mode} == MODE_DO_UPDATE) {
+		# Yes, ToC must be updated;
+			# Does start tag matches token update begin tag?
+		if (HTML::TocUpdator::_doesTagExistInArray(
+			$aTag, $aAttr, $self->{_tokensUpdateBegin}[TUT_TOKENTYPE_START]
+		)) {
+			# Yes, start tag matches token update tag;
+				# Indicate to delete tokens
+			$self->{_doDeleteTokens} = 1;
+		}
+	}
+		# Let ancestor process the start tag
+	$self->SUPER::start($aTag, $aAttr, $aAttrSeq, $aOrigText);
+}  # start()
+
+
+#--- HTML::TocUpdator::toc() --------------------------------------------------
+# function: Toc processing method.  Add toc reference to scenario.
+# args:     - $aScenario: Scenario to add ToC reference to.
+#           - $aToc: Reference to ToC to insert.
+# note:     The ToC hasn't been build yet; only a reference to the ToC to be
+#           build is inserted.
+
+sub toc {
+		# Get arguments
+	my ($self, $aScenario, $aToc) = @_;
+
+		# Surround toc with update tokens
+
+		# Add update begin token
+	push(@$aScenario, \$aToc->{_tokenUpdateBeginToc});
+		# Call ancestor
+	$self->SUPER::toc($aScenario, $aToc);
+		# Add update end token
+	push(@$aScenario, \$aToc->{_tokenUpdateEndToc});
+}  # toc()
+
+
+#--- HTML::TocUpdator::_processTocText() --------------------------------------
+# function: Toc text processing function.
+# args:     - $aText: Text to add to ToC.
+#           - $aToc: ToC to add text to.
+
+sub _processTocText {
+		# Get arguments
+	my ($self, $aText, $aToc) = @_;
+		# Delete output?
+	if (! $self->{_doDeleteTokens}) {
+		# No, don't delete output;
+			# Call ancestor
+		$self->SUPER::_processTocText($aText, $aToc);
+	}
+}  # _processTocText()
+
+
+#--- HTML::TocUpdator::update() -----------------------------------------------
+# function: Update ToC in string.
+# args:     - $aToc: (reference to array of) ToC object to update
+#           - $aString: string to update ToC of
+#           - $aOptions: optional updator options
+
+sub update {
+		# Get arguments
+	my ($self, $aToc, $aString, $aOptions) = @_;
+		# Do start update
+	$self->_update(MODE_DO_UPDATE, $aToc, $aString, $aOptions);
+}  # update()
+
+
+#--- HTML::TocUpdator::updateFile() -------------------------------------------
+# function: Update ToC of file.
+# args:     - $aToc: (reference to array of) ToC object to update
+#           - $aFile: (reference to array of) file to parse for updating.
+#           - $aOptions: optional updator options
+
+sub updateFile {
+		# Get arguments
+	my ($self, $aToc, $aFile, $aOptions) = @_;
+		# Do start update
+	$self->_updateFile(MODE_DO_UPDATE, $aToc, $aFile, $aOptions);
+}  # update()
+
+
+
+
+#=== HTML::_TokenUpdateParser =================================================
+# function: Parse 'update tokens'.  'Update tokens' mark HTML code which is
+#           inserted by 'HTML::TocInsertor'.
+# note:     Used internally.
+
+package HTML::_TokenUpdateParser;
+
+
+BEGIN {
+	use vars qw(@ISA);
+
+	@ISA = qw(HTML::Parser);
+}
+
+END {}
+
+
+#--- HTML::_TokenUpdateParser::new() ------------------------------------------
+# function: Constructor
+
+sub new {
+		# Get arguments
+	my ($aType, $aTokenArray) = @_;
+		# Create instance
+	my $self = $aType->SUPER::new;
+		# Reference token array
+	$self->{tokens} = $aTokenArray;
+		# Return instance
+	return $self;
+}  # new()
+
+
+#--- HTML::_TokenUpdateParser::comment() --------------------------------------
+# function: Process comment.
+# args:     - $aComment: comment text with '<!--' and '-->' tags stripped off.
+
+sub comment {
+		# Get arguments
+	my ($self, $aComment) = @_;
+		# Add token to array of update tokens
+	$self->{tokens}[HTML::TocUpdator::TUT_TOKENTYPE_COMMENT]{$aComment} = '';
+}  # comment()
+
+
+#--- HTML::_TokenUpdateParser::end() ------------------------------------------
+# function: This function is called every time a closing tag is encountered
+#           by HTML::Parser.
+# args:     - $aTag: tag name (in lower case).
+
+sub end {
+		# Get arguments
+	my ($self, $aTag, $aOrigText) = @_;
+		# Add token to array of update tokens
+	$self->{tokens}[HTML::TocUpdator::TUT_TOKENTYPE_END]{$aTag} = '';
+}  # end()
+
+
+#--- HTML::_TokenUpdateParser::parse() ----------------------------------------
+# function: Parse token.
+# args:     - $aToken: 'update token' to parse
+
+sub parse {
+		# Get arguments
+	my ($self, $aString) = @_;
+		# Call ancestor
+	$self->SUPER::parse($aString);
+}  # parse()
+
+
+#--- HTML::_TokenUpdateParser::start() ----------------------------------------
+# function: This function is called every time an opening tag is encountered.
+# args:     - $aTag: tag name (in lower case).
+#           - $aAttr: reference to hash containing all tag attributes (in lower
+#                case).
+#           - $aAttrSeq: reference to array containing all tag attributes (in 
+#                lower case) in the original order
+#           - $aOrigText: the original HTML text
+
+sub start {
+		# Get arguments
+	my ($self, $aTag, $aAttr, $aAttrSeq, $aOrigText) = @_;
+		# Does token exist in array?
+	if (! HTML::TocUpdator::_doesTagExistInArray(
+		$aTag, $aAttr, $self->{tokens}[HTML::TocUpdator::TUT_TOKENTYPE_START]
+	)) {
+		# No, token doesn't exist in array;
+			# Add token to array of update tokens
+		push(
+			@{$self->{tokens}[HTML::TocUpdator::TUT_TOKENTYPE_START]},
+			[$aTag, $aAttr]
+		);
+	}
+}  # start()
+
+
+#--- HTML::_TokenUpdateParser::text() -----------------------------------------
+# function: This function is called every time plain text is encountered.
+# args:     - @_: array containing data.
+
+sub text {
+		# Get arguments
+	my ($self, $aText) = @_;
+		# Add token to array of update tokens
+	$self->{tokens}[HTML::TocUpdator::TUT_TOKENTYPE_TEXT]{$aText} = '';
+}  # text()
+
+
+1;
diff --git a/examples/includes/HTML-Toc-0.91/t/ManualTest/manualTest1.htm b/examples/includes/HTML-Toc-0.91/t/ManualTest/manualTest1.htm
new file mode 100644
index 0000000..1bd250f
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/ManualTest/manualTest1.htm
@@ -0,0 +1,92 @@
+<html>
+<head>
+   <title>Manual</title>
+    <style type="text/css">
+       ul.toc_appendix1 { 
+         list-style-type: none;
+         margin-left: 0;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_h1 {
+         list-style-type: none;
+         margin-left: 1;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_h2 {
+         list-style-type: none;
+       }
+       ul.toc_h3 {
+         list-style-type: none;
+       }
+       ul.toc_part1 {
+         list-style-type: none;
+         margin-left: 1;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_prelude1 {
+         list-style: none;
+       }
+       p.captionFigure {
+         font-style: italic;
+         font-weight: bold;
+       }
+       p.captionTable {
+         font-style: italic;
+         font-weight: bold;
+       }
+    </style>
+</head>
+<body>
+
+<h1 class=prelude>Preface</h1>
+Better C than never.
+
+<h1 class=hidden>Table of Contents</h1>
+<!-- Table of Contents -->
+
+<h1 class=prelude>Table of Figures</h1>
+<!-- Table of Figures -->
+
+<h1 class=prelude>Table of Tables</h1>
+<!-- Table of Tables -->
+
+<h1 class=prelude>Introduction</h1>
+Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.
+<p class=captionTable>Compile Steps</p>
+<ul><pre>
+   Parser
+   Compiler
+   Linker
+</pre></ul>
+
+<h1 class=part>Disks</h1>
+<h1>Compiler Disk v1</h1>
+<img src=img.gif alt="Contents Compiler Disk v1">
+<p class=captionFigure>Contents Compiler Disk v1</p>
+
+<h2>System</h2>
+<h2>Standard Library</h2>
+
+<h1>Compiler Disk v2</h1>
+<img src=img.gif alt="Contents Compiler Disk v2">
+<p class=captionFigure>Contents Compiler Disk v2</p>
+
+<h2>System</h2>
+<h3>parser.com</h3>
+<h3>compiler.com</h3>
+<h3>linker.com</h3>
+<h2>Standard Library</h2>
+
+<h1>Library System Disk</h1>
+<h1 class=part>Personal</h1>
+<h1>Tips & Tricks</h1>
+<h1 class=part>Appendixes</h1>
+<h1 class=appendix>Functions Standard Library v1</h1>
+<h1 class=appendix>Functions Standard Library v2</h1>
+<h1 class=appendix>Functions Graphic Library</h1>
+<h1 class=prelude>Bibliography</h1>
+</body>
+</html>
diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir1/SubSubDir1/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir1/SubSubDir1/index.htm
new file mode 100644
index 0000000..5288cde
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir1/SubSubDir1/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>SubSub1</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir1/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir1/index.htm
new file mode 100644
index 0000000..c938212
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir1/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>Sub1</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/SubSubDir1/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/SubSubDir1/index.htm
new file mode 100644
index 0000000..5288cde
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/SubSubDir1/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>SubSub1</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/SubSubDir2/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/SubSubDir2/index.htm
new file mode 100644
index 0000000..eaadf8c
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/SubSubDir2/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>SubSub2</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/index.htm
new file mode 100644
index 0000000..8445eb1
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir2/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>Sub2</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir3/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir3/index.htm
new file mode 100644
index 0000000..cf9aa99
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/SubDir3/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>Sub3</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/SiteMap/index.htm b/examples/includes/HTML-Toc-0.91/t/SiteMap/index.htm
new file mode 100644
index 0000000..864b0b5
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/SiteMap/index.htm
@@ -0,0 +1,5 @@
+<html>

+<head>

+<title>Main</title>

+</head>

+</html>

diff --git a/examples/includes/HTML-Toc-0.91/t/extend.t b/examples/includes/HTML-Toc-0.91/t/extend.t
new file mode 100644
index 0000000..fe9daee
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/extend.t
@@ -0,0 +1,87 @@
+#--- generate.t ---------------------------------------------------------------
+# function: Test ToC generation.
+
+use strict;
+use Test;
+
+BEGIN { plan tests => 4; }
+
+use HTML::Toc;
+use HTML::TocGenerator;
+
+my ($filename);
+my $toc          = HTML::Toc->new;
+my $tocGenerator = HTML::TocGenerator->new;
+
+$toc->setOptions({
+	'doLinkToToken' => 0,
+	'levelIndent'       => 0,
+	'header'            => '',
+	'footer'            => '',
+});
+
+
+BEGIN {
+		# Create test file
+	$filename = "file$$.htm";
+	die "$filename is already there" if -e $filename;
+	open(FILE, ">$filename") || die "Can't create $filename: $!";
+	print FILE <<'EOT';
+<h1>Header</h1>
+EOT
+	close(FILE);
+}
+
+
+END {
+		# Remove test file
+	unlink($filename) or warn "Can't unlink $filename: $!";
+}
+
+
+#--- 1. extend ----------------------------------------------------------------
+
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+	# Extend ToC
+$tocGenerator->extend($toc, "<h1>Header</h1>");
+	# Test ToC
+ok($toc->format(), "<ul>\n<li>Header\n<li>Header\n</ul>");
+
+
+#--- 2. extendFromFile --------------------------------------------------------
+
+	# Generate ToC
+$tocGenerator->generateFromFile($toc, $filename);
+	# Extend ToC
+$tocGenerator->extendFromFile($toc, $filename);
+	# Test ToC
+ok($toc->format(), "<ul>\n<li>Header\n<li>Header\n</ul>");
+
+
+#--- 3. extendFromFiles -------------------------------------------------------
+
+	# Generate ToC
+$tocGenerator->generateFromFile($toc, $filename);
+	# Extend ToC
+$tocGenerator->extendFromFile($toc, [$filename, $filename]);
+	# Test ToC
+ok($toc->format(), "<ul>\n<li>Header\n<li>Header\n<li>Header\n</ul>");
+
+
+#--- 4. linkTocToToken --------------------------------------------------------
+
+$toc->setOptions({
+	'doLinkToToken' => 1,
+});
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+	# Extend ToC
+$tocGenerator->extend($toc, "<h1>Header</h1>");
+	# Test ToC
+ok($toc->format() . "\n", <<'EOT');
+<ul>
+<li><a href=#h-1>Header</a>
+<li><a href=#h-2>Header</a>
+</ul>
+EOT
diff --git a/examples/includes/HTML-Toc-0.91/t/format.t b/examples/includes/HTML-Toc-0.91/t/format.t
new file mode 100644
index 0000000..62d2b6c
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/format.t
@@ -0,0 +1,157 @@
+#--- format.t -----------------------------------------------------------------
+# function: Test ToC formatting.
+
+use strict;
+use Test;
+
+BEGIN { plan tests => 6; }
+
+use HTML::Toc;
+use HTML::TocGenerator;
+use HTML::TocInsertor;
+
+my ($output, $content, $filename);
+my $toc          = HTML::Toc->new;
+my $tocGenerator = HTML::TocGenerator->new;
+my $tocInsertor  = HTML::TocInsertor->new;
+
+$toc->setOptions({
+	'doLinkToToken'  => 0,
+	'levelIndent'       => 0,
+	'insertionPoint'    => 'before <h1>',
+	'header'            => '',
+	'footer'            => '',
+});
+
+
+BEGIN {
+		# Create test file
+	$filename = "file$$.htm";
+	die "$filename is already there" if -e $filename;
+	open(FILE, ">$filename") || die "Can't create $filename: $!";
+	print FILE <<'EOT'; close(FILE);
+<h1>Header</h1>
+EOT
+}
+
+
+END {
+		# Remove test file
+	unlink($filename) or warn "Can't unlink $filename: $!";
+}
+
+
+#--- 1. templateLevelBegin ----------------------------------------------------
+
+$toc->setOptions({
+	'templateLevelBegin' => '"<ul class=toc_$groupId$level>\n"'
+});
+$tocInsertor->insert($toc, "<h1>Header</h1>", {'output' => \$output});
+ok($output, "<ul class=toc_h1>\n<li>Header\n</ul><h1>Header</h1>");
+$toc->setOptions({'templateLevelBegin' => undef});
+
+
+#--- 2. levelToToc -----------------------------------------------------------
+
+$tocGenerator->generate($toc, "<h1>Header1</h1>\n<h2>Header2</h2>");
+$toc->setOptions({'levelToToc' => '1'});
+ok($toc->format(), "<ul>\n<li>Header1\n</ul>");
+$toc->setOptions({'levelToToc' => '.*'});
+
+
+#--- 3. groupToToc -----------------------------------------------------------
+
+$toc->setOptions({
+	'tokenToToc' => [{
+		'level' => 1,
+		'tokenBegin' => '<h1 class=-foo>'
+	}, {
+		'groupId' => 'foo',
+		'level' => 1,
+		'tokenBegin' => '<h1 class=foo>'
+	}]
+});
+$tocGenerator->generate($toc, "<h1>Header1</h1>\n<h1 class=foo>Foo</h1>");
+$toc->setOptions({'groupToToc' => 'foo'});
+ok($toc->format(), "<ul>\n<li>Foo\n</ul>");
+$toc->setOptions({'groupToToc' => '.*'});
+
+
+#--- 4. header & footer -------------------------------------------------------
+
+$toc->setOptions({
+	'tokenToToc' => [{
+		'level'      => 1,
+		'tokenBegin' => '<h1>'
+	}],
+	'header' => '<!-- TocHeader -->',
+	'footer' => '<!-- TocFooter -->',
+});
+$tocInsertor->insert($toc, "<h1>Header1</h1>", {'output' => \$output});
+ok("$output\n", <<EOT);
+<!-- TocHeader --><ul>
+<li>Header1
+</ul><!-- TocFooter --><h1>Header1</h1>
+EOT
+
+
+	# Test 'doSingleStepLevel' => 1
+TestSingleStepLevel1();
+	# Test 'doSingleStepLevel' => 0
+TestSingleStepLevel0();
+
+
+#--- 5. TestSingleStepLevel1 --------------------------------------------------
+
+sub TestSingleStepLevel1 {
+	my $toc          = new HTML::Toc;
+	my $tocGenerator = new HTML::TocGenerator;
+	
+		# Generate ToC
+	$tocGenerator->generate($toc, <<EOT);
+<h1>Header 1</h1>
+<h3>Header 3</h3>
+EOT
+		# Compare output
+	ok($toc->format(), <<EOT);
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul>
+   <li><a href=#h-1>Header 1</a>
+   <ul>
+      <ul>
+         <li><a href=#h-1.0.1>Header 3</a>
+      </ul>
+   </ul>
+</ul>
+<!-- End of generated Table of Contents -->
+EOT
+}  # TestSingleStepLevel1()
+
+
+#--- 6. TestSingleStepLevel0 --------------------------------------------------
+
+sub TestSingleStepLevel0 {
+	my $toc          = new HTML::Toc;
+	my $tocGenerator = new HTML::TocGenerator;
+	
+		# Set ToC options
+	$toc->setOptions({'doSingleStepLevel' => 0});
+		# Generate ToC
+	$tocGenerator->generate($toc, <<EOT);
+<h1>Header 1</h1>
+<h3>Header 3</h3>
+EOT
+	 	# Compare output
+	ok($toc->format(), <<EOT);
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul>
+   <li><a href=#h-1>Header 1</a>
+   <ul>
+      <li><a href=#h-1.0.1>Header 3</a>
+   </ul>
+</ul>
+<!-- End of generated Table of Contents -->
+EOT
+}  # TestSingleStepLevel0()
diff --git a/examples/includes/HTML-Toc-0.91/t/generate.t b/examples/includes/HTML-Toc-0.91/t/generate.t
new file mode 100644
index 0000000..869bdf4
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/generate.t
@@ -0,0 +1,200 @@
+#--- generate.t ---------------------------------------------------------------
+# function: Test ToC generation.
+
+use strict;
+use Test;
+
+BEGIN { plan tests => 13; }
+
+use HTML::Toc;
+use HTML::TocGenerator;
+
+my ($filename);
+my $toc          = HTML::Toc->new;
+my $tocGenerator = HTML::TocGenerator->new;
+
+$toc->setOptions({
+	'doLinkToToken' => 0,
+	'levelIndent'   => 0,
+	'header'        => '',
+	'footer'        => '',
+});
+
+
+BEGIN {
+		# Create test file
+	$filename = "file$$.htm";
+	die "$filename is already there" if -e $filename;
+	open(FILE, ">$filename") || die "Can't create $filename: $!";
+	print FILE <<'EOT';
+<h1>Header</h1>
+EOT
+	close(FILE);
+}
+
+
+END {
+		# Remove test file
+	unlink($filename) or warn "Can't unlink $filename: $!";
+}
+
+
+#--- 1. generate --------------------------------------------------------------
+
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+ok($toc->format(), "<ul>\n<li>Header\n</ul>");
+
+
+#--- 2. generateFromFile ------------------------------------------------------
+
+$tocGenerator->generateFromFile($toc, $filename);
+ok($toc->format(), "<ul>\n<li>Header\n</ul>");
+
+
+#--- 3. generateFromFiles -----------------------------------------------------
+
+$tocGenerator->generateFromFile($toc, [$filename, $filename]);
+ok($toc->format(), "<ul>\n<li>Header\n<li>Header\n</ul>");
+	
+
+#--- 4. doLinkToToken -----------------------------------------------------
+
+$toc->setOptions({'doLinkToToken' => 1});
+$tocGenerator->generateFromFile($toc, $filename, {'globalGroups' => 1});
+ok($toc->format(), "<ul>\n<li><a href=#h-1>Header</a>\n</ul>");
+
+
+#--- 5. doLinkToFile -------------------------------------------------------
+
+$toc->setOptions({'doLinkToFile' => 1});
+$tocGenerator->generateFromFile($toc, $filename);
+ok($toc->format(), "<ul>\n<li><a href=$filename#h-1>Header</a>\n</ul>");
+
+
+#--- 6. templateAnchorHrefBegin -----------------------------------------------
+
+	# Set options
+$toc->setOptions({'templateAnchorHrefBegin' => '"test-$file"'});
+	# Generate ToC
+$tocGenerator->generateFromFile($toc, $filename);
+	# Test ToC
+ok($toc->format(), "<ul>\n<li>test-".$filename."Header</a>\n</ul>");
+	# Reset options
+$toc->setOptions({'templateAnchorHrefBegin' => undef});
+
+
+#--- 7. templateAnchorHrefBegin function --------------------------------------
+
+sub AssembleAnchorHrefBegin {
+		# Get arguments
+	my ($aFile, $aGroupId, $aLevel, $aNode) = @_;
+		# Return value
+	return $aFile . $aGroupId . $aLevel . $aNode;
+}  # AssembleAnchorHrefBegin()
+
+
+	# Set options
+$toc->setOptions({'templateAnchorHrefBegin' => \&AssembleAnchorHrefBegin});
+	# Generate ToC
+$tocGenerator->generateFromFile($toc, $filename);
+	# Test ToC
+ok($toc->format(), "<ul>\n<li>".$filename."h11Header</a>\n</ul>");
+	# Reset options
+$toc->setOptions({'templateAnchorHrefBegin' => undef});
+
+
+#--- 8. levelToToc no levels available ---------------------------------------
+
+$toc->setOptions({'levelToToc' => '2'});
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+ok($toc->format(), "");
+
+
+#--- 9. levelToToc level 1 ---------------------------------------------------
+
+	# Set options
+$toc->setOptions({
+	'levelToToc' => '1',
+	'doLinkToToken' => 0,
+});
+$tocGenerator->generate($toc, "<h1>Header1</h1>\n<h2>Header2</h2>");
+ok($toc->format(), "<ul>\n<li>Header1\n</ul>");
+
+
+#--- 10. levelToToc level 2 --------------------------------------------------
+
+	# Set options
+$toc->setOptions({
+	'levelToToc' => '2',
+	'doLinkToToken' => 0,
+});
+$tocGenerator->generate($toc, "<h1>Header1</h1>\n<h2>Header2</h2>");
+ok($toc->format(), "<ul>\n<li>Header2\n</ul>");
+	# Restore options
+$toc->setOptions({
+	'levelToToc' => '.*',
+});
+
+
+#--- 11. tokenToToc empty array ----------------------------------------------
+
+	# Set options
+$toc->setOptions({'tokenToToc' => []});
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+ok($toc->format(), "");
+
+
+#--- 12. groups nested --------------------------------------------------------
+
+$toc->setOptions({
+	'doNestGroup' => 1,
+	'tokenToToc' => [
+		{
+			'level' => 1,
+			'tokenBegin' => '<h1 class=-appendix>'
+		}, {
+			'groupId' => 'appendix',
+			'level' => 1,
+			'tokenBegin' => '<h1 class=appendix>'
+		}
+	]
+});
+$tocGenerator->generate(
+	$toc, "<h1>Header1</h1>\n<h1 class=appendix>Appendix</h1>"
+);
+ok($toc->format() . "\n", <<'EOT');
+<ul>
+<li>Header1
+<ul>
+<li>Appendix
+</ul>
+</ul>
+EOT
+
+
+#--- 13. groups not nested ----------------------------------------------------
+
+$toc->setOptions({
+	'doNestGroup' => 0,
+	'tokenToToc' => [
+		{
+			'level' => 1,
+			'tokenBegin' => '<h1 class=-appendix>'
+		}, {
+			'groupId' => 'appendix',
+			'level' => 1,
+			'tokenBegin' => '<h1 class=appendix>'
+		}
+	]
+});
+$tocGenerator->generate(
+	$toc, "<h1>Header1</h1>\n<h1 class=appendix>Appendix</h1>"
+);
+ok($toc->format() . "\n", <<'EOT');
+<ul>
+<li>Header1
+</ul>
+<ul>
+<li>Appendix
+</ul>
+EOT
diff --git a/examples/includes/HTML-Toc-0.91/t/insert.t b/examples/includes/HTML-Toc-0.91/t/insert.t
new file mode 100644
index 0000000..3f1adba
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/insert.t
@@ -0,0 +1,336 @@
+#--- insert.t -----------------------------------------------------------------
+# function: Test ToC insertion.
+
+use strict;
+use Test;
+
+BEGIN { plan tests => 10; }
+
+use HTML::Toc;
+use HTML::TocGenerator;
+use HTML::TocInsertor;
+
+my ($output, $content, $filename);
+my $toc          = HTML::Toc->new;
+my $tocGenerator = HTML::TocGenerator->new;
+my $tocInsertor  = HTML::TocInsertor->new;
+
+$toc->setOptions({
+	'doLinkToToken'  => 0,
+	'levelIndent'       => 0,
+	'header'            => "",
+	'footer'            => "",
+});
+
+
+BEGIN {
+		# Create test file
+	$filename = "file$$.htm";
+	die "$filename is already there" if -e $filename;
+	open(FILE, ">$filename") || die "Can't create $filename: $!";
+	print FILE <<'EOT'; close(FILE);
+<h1>Header</h1>
+EOT
+}
+
+
+END {
+		# Remove test file
+	unlink($filename) or warn "Can't unlink $filename: $!";
+}
+
+
+#--- 1. insert before start ---------------------------------------------------
+
+$toc->setOptions({'insertionPoint' => 'before <h1>'});
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+$tocInsertor->insert($toc, "<h1>Header</h1>", {
+	'output'        => \$output,
+	'doGenerateToc' => 0
+});
+	# Test ToC
+ok($output, "<ul>\n<li>Header\n</ul><h1>Header</h1>");
+
+
+#--- 2. insert after start ----------------------------------------------------
+
+$toc->setOptions({'insertionPoint' => 'after <h1>'});
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+$tocInsertor->insert($toc, "<h1>Header</h1>", {
+	'output' => \$output,
+	'doGenerateToc' => 0
+});
+	# Test ToC
+ok($output, "<h1><ul>\n<li>Header\n</ul>Header</h1>");
+
+
+#--- 3. insert before end -----------------------------------------------------
+
+$toc->setOptions({'insertionPoint' => 'before </h1>'});
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+$tocInsertor->insert($toc, "<h1>Header</h1>", {
+	'output' => \$output,
+	'doGenerateToc' => 0
+});
+	# Test ToC
+ok($output, "<h1>Header<ul>\n<li>Header\n</ul></h1>");
+
+
+#--- 4. insert after end ------------------------------------------------------
+
+$toc->setOptions({'insertionPoint' => 'after </h1>'});
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+$tocInsertor->insert($toc, "<h1>Header</h1>", {
+	'output' => \$output,
+	'doGenerateToc' => 0
+});
+	# Test ToC
+ok($output, "<h1>Header</h1><ul>\n<li>Header\n</ul>");
+
+
+#--- 5. outputFile ------------------------------------------------------------
+
+$toc->setOptions({'insertionPoint' => 'before <h1>'});
+	# Generate ToC
+$tocGenerator->generate($toc, "<h1>Header</h1>");
+	# Insert ToC, output to file
+$tocInsertor->insert($toc, "<h1>Header</h1>", {
+	'outputFile' => $filename,
+	'doGenerateToc' => 0
+});
+	# Read outputfile
+open(FILE, "<$filename") || die "Can't open $filename: $!";
+$content = join('', <FILE>);
+close(FILE);
+	# Test ToC
+ok($output, "<ul>\n<li>Header\n</ul><h1>Header</h1>");
+
+
+#--- 6. empty toc -------------------------------------------------------------
+
+$tocGenerator->generate($toc, "");
+$tocInsertor->insert($toc, "", {
+	'output' => \$output,
+	'doGenerateToc' => 0
+});
+ok($output, "");
+
+
+#--- TestAfterDeclaration() ---------------------------------------------------
+# function: Test putting HTML comment after declaration.  
+
+sub TestAfterDeclaration {
+		# Create objects
+	my $toc         = HTML::Toc->new();
+	my $tocInsertor = HTML::TocInsertor->new();
+	my $output;
+	
+		# Set ToC options
+   $toc->setOptions({
+		'insertionPoint' => "after <!ToC>",
+   });
+		# Generate ToC
+	$tocInsertor->insert($toc, <<EOT, {'output' => \$output});
+<!ToC><body>
+   <h1>Appendix</h1>
+   <h2>Appendix Paragraph</h2>
+   <h1>Appendix</h1>
+   <h2>Appendix Paragraph</h2>
+</body>
+EOT
+		# Test ToC
+	ok($output, <<EOT);
+<!ToC>
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul>
+   <li><a href=#h-1>Appendix</a>
+   <ul>
+      <li><a href=#h-1.1>Appendix Paragraph</a>
+   </ul>
+   <li><a href=#h-2>Appendix</a>
+   <ul>
+      <li><a href=#h-2.1>Appendix Paragraph</a>
+   </ul>
+</ul>
+<!-- End of generated Table of Contents -->
+<body>
+   <a name=h-1><h1>Appendix</h1></a>
+   <a name=h-1.1><h2>Appendix Paragraph</h2></a>
+   <a name=h-2><h1>Appendix</h1></a>
+   <a name=h-2.1><h2>Appendix Paragraph</h2></a>
+</body>
+EOT
+}  # TestAfterDeclaration()
+
+
+#--- TestNumberingStyle() -----------------------------------------------------
+# function: Test numberingstyle.
+
+sub TestNumberingStyle {
+		# Create objects
+	my $toc         = HTML::Toc->new();
+	my $tocInsertor = HTML::TocInsertor->new();
+	my $output;
+	
+		# Set ToC options
+   $toc->setOptions({
+		'numberingStyle'            => 'lower-alpha',
+		'doNumberToken'             => 1,
+      'tokenToToc' => [{
+            'tokenBegin'          => '<h1>',
+			}, {
+            'tokenBegin' 			 => '<h2>',
+            'level'      			 => 2,
+				'numberingStyle'      => 'upper-alpha'
+			}, {
+            'tokenBegin' 			 => '<h3>',
+            'level'      			 => 3,
+				'numberingStyle'      => 'decimal'
+         }]
+   });
+		# Generate ToC
+	$tocInsertor->insert($toc, <<EOT, {'output' => \$output});
+<body>
+   <h1>Chapter</h1>
+   <h2>Paragraph</h2>
+   <h3>Paragraph</h3>
+   <h3>Paragraph</h3>
+   <h3>Paragraph</h3>
+</body>
+EOT
+		# Test ToC
+	ok($output, <<EOT);
+<body>
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul>
+   <li><a href=#h-a>Chapter</a>
+   <ul>
+      <li><a href=#h-a.A>Paragraph</a>
+      <ul>
+         <li><a href=#h-a.A.1>Paragraph</a>
+         <li><a href=#h-a.A.2>Paragraph</a>
+         <li><a href=#h-a.A.3>Paragraph</a>
+      </ul>
+   </ul>
+</ul>
+<!-- End of generated Table of Contents -->
+
+   <a name=h-a><h1>a &nbsp;Chapter</h1></a>
+   <a name=h-a.A><h2>a.A &nbsp;Paragraph</h2></a>
+   <a name=h-a.A.1><h3>a.A.1 &nbsp;Paragraph</h3></a>
+   <a name=h-a.A.2><h3>a.A.2 &nbsp;Paragraph</h3></a>
+   <a name=h-a.A.3><h3>a.A.3 &nbsp;Paragraph</h3></a>
+</body>
+EOT
+}  # TestNumberingStyle()
+
+
+#--- TestReplaceComment() -----------------------------------------------------
+# function: Test replacing HTML comment with ToC.
+
+sub TestReplaceComment {
+		# Create objects
+	my $toc         = HTML::Toc->new();
+	my $tocInsertor = HTML::TocInsertor->new();
+	my $output;
+	
+		# Set ToC options
+   $toc->setOptions({
+		'insertionPoint' => "replace <!-- ToC -->"
+   });
+		# Generate ToC
+	$tocInsertor->insert($toc, <<EOT, {'output' => \$output});
+<!-- ToC -->
+<body>
+   <h1>Appendix</h1>
+   <h2>Appendix Paragraph</h2>
+   <h1>Appendix</h1>
+   <h2>Appendix Paragraph</h2>
+</body>
+EOT
+		# Test ToC
+	ok($output, <<EOT);
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul>
+   <li><a href=#h-1>Appendix</a>
+   <ul>
+      <li><a href=#h-1.1>Appendix Paragraph</a>
+   </ul>
+   <li><a href=#h-2>Appendix</a>
+   <ul>
+      <li><a href=#h-2.1>Appendix Paragraph</a>
+   </ul>
+</ul>
+<!-- End of generated Table of Contents -->
+
+<body>
+   <a name=h-1><h1>Appendix</h1></a>
+   <a name=h-1.1><h2>Appendix Paragraph</h2></a>
+   <a name=h-2><h1>Appendix</h1></a>
+   <a name=h-2.1><h2>Appendix Paragraph</h2></a>
+</body>
+EOT
+}  # TestReplaceComment()
+
+
+#--- TestReplaceText() -----------------------------------------------------
+# function: Test replacing HTML comment with ToC.
+
+sub TestReplaceText {
+		# Create objects
+	my $toc         = HTML::Toc->new();
+	my $tocInsertor = HTML::TocInsertor->new();
+	my $output;
+	
+		# Set ToC options
+   $toc->setOptions({
+		'insertionPoint' => "replace ToC will be placed here[,]"
+   });
+		# Generate ToC
+	$tocInsertor->insert($toc, <<EOT, {'output' => \$output});
+The ToC will be placed here, overnight.
+<body>
+   <h1>Appendix</h1>
+   <h2>Appendix Paragraph</h2>
+   <h1>Appendix</h1>
+   <h2>Appendix Paragraph</h2>
+</body>
+EOT
+		# Test ToC
+	ok($output, <<EOT);
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul>
+   <li><a href=#h-1>Appendix</a>
+   <ul>
+      <li><a href=#h-1.1>Appendix Paragraph</a>
+   </ul>
+   <li><a href=#h-2>Appendix</a>
+   <ul>
+      <li><a href=#h-2.1>Appendix Paragraph</a>
+   </ul>
+</ul>
+<!-- End of generated Table of Contents -->
+<body>
+   <a name=h-1><h1>Appendix</h1></a>
+   <a name=h-1.1><h2>Appendix Paragraph</h2></a>
+   <a name=h-2><h1>Appendix</h1></a>
+   <a name=h-2.1><h2>Appendix Paragraph</h2></a>
+</body>
+EOT
+}  # TestReplaceText()
+
+
+	# 7.  Test 'numberingStyle'
+TestNumberingStyle();
+	# 8.  Test replace comment
+TestReplaceComment();
+	# 9.  Test after declaration
+TestAfterDeclaration();
+	# 10.  Test replace text
+TestReplaceText();
diff --git a/examples/includes/HTML-Toc-0.91/t/manualTest.t b/examples/includes/HTML-Toc-0.91/t/manualTest.t
new file mode 100644
index 0000000..cc19fff
--- /dev/null
+++ b/examples/includes/HTML-Toc-0.91/t/manualTest.t
@@ -0,0 +1,768 @@
+#--- manual.t -----------------------------------------------------------------
+# function: Test HTML::ToC generating a manual.
+
+use strict;
+use Test;
+
+BEGIN { plan tests => 3; }
+
+use HTML::Toc;
+use HTML::TocGenerator;
+use HTML::TocInsertor;
+use HTML::TocUpdator;
+
+
+#--- AssembleTocLine() --------------------------------------------------------
+# function: Assemble ToC line.
+
+sub AssembleTocLine {
+		# Get arguments
+	my ($aLevel, $aGroupId, $aNode, $aSequenceNr, $aText) = @_;
+		# Local variables
+	my ($result);
+
+		# Assemble ToC line
+	SWITCH: {
+		if ($aGroupId eq "prelude") {
+			$result = "<li>$aText\n";
+			last SWITCH;
+		}
+		if ($aGroupId eq "part") {
+			$result = "<li>Part $aNode &nbsp;$aText\n";
+			last SWITCH;
+		}
+		if ($aGroupId eq "h") {
+			$result = "<li>$aSequenceNr. &nbsp;$aText\n";
+			last SWITCH;
+		}
+		else {
+			$result = "<li>$aNode &nbsp;$aText\n";
+			last SWITCH;
+		}
+	}
+
+		# Return value
+	return $result;
+}  # AssembleTocLine()
+
+
+#--- AssembleTokenNumber() ----------------------------------------------------
+# function: Assemble token number.
+
+sub AssembleTokenNumber {
+		# Get arguments
+	my ($aNode, $aGroupId, $aFile, $aGroupLevel, $aLevel, $aToc) = @_;
+		# Local variables
+	my ($result);
+		# Assemble token number
+	SWITCH: {
+		if ($aGroupId eq "part") {
+			$result = "Part $aNode &nbsp;";
+			last SWITCH;
+		}
+		else {
+			$result = "$aNode &nbsp;";
+			last SWITCH;
+		}
+	}
+		# Return value
+	return $result;
+}  # AssembleTokenNumber()
+
+
+#--- TestInsertManualToc ------------------------------------------------------
+# function: Test inserting ToC into manual.
+
+sub TestInsertManualToc {
+	my $output;
+		# Create objects
+	my $toc          = new HTML::Toc;
+	my $tocOfFigures = new HTML::Toc;
+	my $tocOfTables  = new HTML::Toc;
+	my $tocInsertor  = new HTML::TocInsertor;
+	
+		# Set ToC options
+	$toc->setOptions({
+		'doNestGroup'          => 1,
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "replace <!-- Table of Contents -->",
+		'templateLevel'        => \&AssembleTocLine,
+      'templateLevelBegin'   => '"<ul class=toc_$groupId$level>\n"',
+      'templateLevelEnd'     => '"</ul>\n"',
+		'templateTokenNumber'  => \&AssembleTokenNumber,
+      'tokenToToc'           => [{
+            'groupId'        => 'part',
+			   'doNumberToken'  => 1,
+            'level'          => 1,
+            'tokenBegin'     => '<h1 class=part>',
+         }, {
+            'tokenBegin'     => '<h1 class=-[appendix|prelude|hidden|part]>'
+         }, {
+            'tokenBegin'     => '<h2>',
+            'level'          => 2
+         }, {
+            'tokenBegin'     => '<h3>',
+            'level'          => 3
+         }, {
+            'groupId'        => 'appendix',
+            'tokenBegin'     => '<h1 class=appendix>',
+			   'numberingStyle' => 'upper-alpha',
+         }, {
+            'groupId'        => 'appendix',
+            'tokenBegin'     => '<h2 class=appendix>',
+            'level'          => 2
+         }, {
+            'groupId'        => 'prelude',
+            'tokenBegin'     => '<h1 class=prelude>',
+            'level'          => 1,
+			   'doNumberToken'  => 0,
+         }],
+	});
+	$tocOfFigures->setOptions({
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "replace <!-- Table of Figures -->",
+		'templateLevelBegin'   => '"<ol>\n"',
+		'templateLevelEnd'     => '"</ol>\n"',
+		'templateTokenNumber'  => '"Figure $node: &nbsp;"',
+		'tokenToToc'           => [{
+				'groupId'        => 'Figure',
+				'tokenBegin'     => '<p class=captionFigure>'
+			}]
+	});
+	$tocOfTables->setOptions({
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "replace <!-- Table of Tables -->",
+		'templateLevelBegin'   => '"<ol>\n"',
+		'templateLevelEnd'     => '"</ol>\n"',
+		'templateTokenNumber'  => '"Table $node: &nbsp;"',
+		'tokenToToc'           => [{
+				'groupId'        => 'Table',
+				'tokenBegin'     => '<p class=captionTable>'
+			}]
+	});
+		# Insert ToC
+	$tocInsertor->insertIntoFile(
+		[$toc, $tocOfFigures, $tocOfTables], 
+		't/ManualTest/manualTest1.htm', {
+			 'doUseGroupsGlobal' => 1,
+			 'output'            => \$output,
+			 'outputFile'        => 't/ManualTest/manualTest2.htm'
+		}
+	);
+	ok($output, <<EOT);
+<html>
+<head>
+   <title>Manual</title>
+    <style type="text/css">
+       ul.toc_appendix1 { 
+         list-style-type: none;
+         margin-left: 0;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_h1 {
+         list-style-type: none;
+         margin-left: 1;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_h2 {
+         list-style-type: none;
+       }
+       ul.toc_h3 {
+         list-style-type: none;
+       }
+       ul.toc_part1 {
+         list-style-type: none;
+         margin-left: 1;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_prelude1 {
+         list-style: none;
+       }
+       p.captionFigure {
+         font-style: italic;
+         font-weight: bold;
+       }
+       p.captionTable {
+         font-style: italic;
+         font-weight: bold;
+       }
+    </style>
+</head>
+<body>
+
+<a name=prelude-1><h1 class=prelude>Preface</h1></a>
+Better C than never.
+
+<h1 class=hidden>Table of Contents</h1>
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul class=toc_prelude1>
+   <li><a href=#prelude-1>Preface</a>
+   <li><a href=#prelude-2>Table of Figures</a>
+   <li><a href=#prelude-3>Table of Tables</a>
+   <li><a href=#prelude-4>Introduction</a>
+   <ul class=toc_part1>
+      <li>Part 1 &nbsp;<a href=#part-1>Disks</a>
+      <ul class=toc_h1>
+         <li>1. &nbsp;<a href=#h-1>Compiler Disk v1</a>
+         <ul class=toc_h2>
+            <li>1. &nbsp;<a href=#h-1.1>System</a>
+            <li>2. &nbsp;<a href=#h-1.2>Standard Library</a>
+         </ul>
+         <li>2. &nbsp;<a href=#h-2>Compiler Disk v2</a>
+         <ul class=toc_h2>
+            <li>1. &nbsp;<a href=#h-2.1>System</a>
+            <ul class=toc_h3>
+               <li>1. &nbsp;<a href=#h-2.1.1>parser.com</a>
+               <li>2. &nbsp;<a href=#h-2.1.2>compiler.com</a>
+               <li>3. &nbsp;<a href=#h-2.1.3>linker.com</a>
+            </ul>
+            <li>2. &nbsp;<a href=#h-2.2>Standard Library</a>
+         </ul>
+         <li>3. &nbsp;<a href=#h-3>Library System Disk</a>
+      </ul>
+      <li>Part 2 &nbsp;<a href=#part-2>Personal</a>
+      <ul class=toc_h1>
+         <li>4. &nbsp;<a href=#h-4>Tips & Tricks</a>
+      </ul>
+      <li>Part 3 &nbsp;<a href=#part-3>Appendixes</a>
+      <ul class=toc_appendix1>
+         <li>A &nbsp;<a href=#appendix-A>Functions Standard Library v1</a>
+         <li>B &nbsp;<a href=#appendix-B>Functions Standard Library v2</a>
+         <li>C &nbsp;<a href=#appendix-C>Functions Graphic Library</a>
+      </ul>
+   </ul>
+   <li><a href=#prelude-5>Bibliography</a>
+</ul>
+<!-- End of generated Table of Contents -->
+
+
+<a name=prelude-2><h1 class=prelude>Table of Figures</h1></a>
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ol>
+   <li><a href=#Figure-1>Contents Compiler Disk v1</a>
+   <li><a href=#Figure-2>Contents Compiler Disk v2</a>
+</ol>
+<!-- End of generated Table of Contents -->
+
+
+<a name=prelude-3><h1 class=prelude>Table of Tables</h1></a>
+
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ol>
+   <li><a href=#Table-1>Compile Steps</a>
+</ol>
+<!-- End of generated Table of Contents -->
+
+
+<a name=prelude-4><h1 class=prelude>Introduction</h1></a>
+Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.
+<a name=Table-1><p class=captionTable>Table 1: &nbsp;Compile Steps</p></a>
+<ul><pre>
+   Parser
+   Compiler
+   Linker
+</pre></ul>
+
+<a name=part-1><h1 class=part>Part 1 &nbsp;Disks</h1></a>
+<a name=h-1><h1>1 &nbsp;Compiler Disk v1</h1></a>
+<img src=img.gif alt="Contents Compiler Disk v1">
+<a name=Figure-1><p class=captionFigure>Figure 1: &nbsp;Contents Compiler Disk v1</p></a>
+
+<a name=h-1.1><h2>1.1 &nbsp;System</h2></a>
+<a name=h-1.2><h2>1.2 &nbsp;Standard Library</h2></a>
+
+<a name=h-2><h1>2 &nbsp;Compiler Disk v2</h1></a>
+<img src=img.gif alt="Contents Compiler Disk v2">
+<a name=Figure-2><p class=captionFigure>Figure 2: &nbsp;Contents Compiler Disk v2</p></a>
+
+<a name=h-2.1><h2>2.1 &nbsp;System</h2></a>
+<a name=h-2.1.1><h3>2.1.1 &nbsp;parser.com</h3></a>
+<a name=h-2.1.2><h3>2.1.2 &nbsp;compiler.com</h3></a>
+<a name=h-2.1.3><h3>2.1.3 &nbsp;linker.com</h3></a>
+<a name=h-2.2><h2>2.2 &nbsp;Standard Library</h2></a>
+
+<a name=h-3><h1>3 &nbsp;Library System Disk</h1></a>
+<a name=part-2><h1 class=part>Part 2 &nbsp;Personal</h1></a>
+<a name=h-4><h1>4 &nbsp;Tips & Tricks</h1></a>
+<a name=part-3><h1 class=part>Part 3 &nbsp;Appendixes</h1></a>
+<a name=appendix-A><h1 class=appendix>A &nbsp;Functions Standard Library v1</h1></a>
+<a name=appendix-B><h1 class=appendix>B &nbsp;Functions Standard Library v2</h1></a>
+<a name=appendix-C><h1 class=appendix>C &nbsp;Functions Graphic Library</h1></a>
+<a name=prelude-5><h1 class=prelude>Bibliography</h1></a>
+</body>
+</html>
+EOT
+}  # TestInsertManualToc()
+
+
+#--- TestInsertManualForUpdating() --------------------------------------------
+# function: Test inserting ToC into manual.
+
+sub TestInsertManualForUpdating {
+	my $output;
+		# Create objects
+	my $toc          = new HTML::Toc;
+	my $tocOfFigures = new HTML::Toc;
+	my $tocOfTables  = new HTML::Toc;
+	my $tocUpdator   = new HTML::TocUpdator;
+	
+		# Set ToC options
+	$toc->setOptions({
+		'doNestGroup'          => 1,
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "after <!-- Table of Contents -->",
+		'templateLevel'        => \&AssembleTocLine,
+      'templateLevelBegin'   => '"<ul class=toc_$groupId$level>\n"',
+      'templateLevelEnd'     => '"</ul>\n"',
+		'templateTokenNumber'  => \&AssembleTokenNumber,
+      'tokenToToc'           => [{
+            'groupId'        => 'part',
+			   'doNumberToken'  => 1,
+            'level'          => 1,
+            'tokenBegin'     => '<h1 class=part>',
+         }, {
+            'tokenBegin'     => '<h1 class=-[appendix|prelude|hidden|part]>'
+         }, {
+            'tokenBegin'     => '<h2>',
+            'level'          => 2
+         }, {
+            'tokenBegin'     => '<h3>',
+            'level'          => 3
+         }, {
+            'groupId'        => 'appendix',
+            'tokenBegin'     => '<h1 class=appendix>',
+			   'numberingStyle' => 'upper-alpha',
+         }, {
+            'groupId'        => 'appendix',
+            'tokenBegin'     => '<h2 class=appendix>',
+            'level'          => 2
+         }, {
+            'groupId'        => 'prelude',
+            'tokenBegin'     => '<h1 class=prelude>',
+            'level'          => 1,
+			   'doNumberToken'  => 0,
+         }],
+	});
+	$tocOfFigures->setOptions({
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "after <!-- Table of Figures -->",
+		'templateLevelBegin'   => '"<ol>\n"',
+		'templateLevelEnd'     => '"</ol>\n"',
+		'templateTokenNumber'  => '"Figure $node: &nbsp;"',
+		'tokenToToc'           => [{
+				'groupId'        => 'Figure',
+				'tokenBegin'     => '<p class=captionFigure>'
+			}]
+	});
+	$tocOfTables->setOptions({
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "after <!-- Table of Tables -->",
+		'templateLevelBegin'   => '"<ol>\n"',
+		'templateLevelEnd'     => '"</ol>\n"',
+		'templateTokenNumber'  => '"Table $node: &nbsp;"',
+		'tokenToToc'           => [{
+				'groupId'        => 'Table',
+				'tokenBegin'     => '<p class=captionTable>'
+			}]
+	});
+		# Insert ToC
+	$tocUpdator->updateFile(
+		[$toc, $tocOfFigures, $tocOfTables], 
+		't/ManualTest/manualTest1.htm', {
+			 'doUseGroupsGlobal' => 1,
+			 'output'            => \$output,
+			 'outputFile'        => 't/ManualTest/manualTest3.htm'
+		}
+	);
+	ok($output, <<EOT);
+<html>
+<head>
+   <title>Manual</title>
+    <style type="text/css">
+       ul.toc_appendix1 { 
+         list-style-type: none;
+         margin-left: 0;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_h1 {
+         list-style-type: none;
+         margin-left: 1;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_h2 {
+         list-style-type: none;
+       }
+       ul.toc_h3 {
+         list-style-type: none;
+       }
+       ul.toc_part1 {
+         list-style-type: none;
+         margin-left: 1;
+         margin-top: 1em;
+         margin-bottom: 1em;
+       }
+       ul.toc_prelude1 {
+         list-style: none;
+       }
+       p.captionFigure {
+         font-style: italic;
+         font-weight: bold;
+       }
+       p.captionTable {
+         font-style: italic;
+         font-weight: bold;
+       }
+    </style>
+</head>
+<body>
+
+<!-- #BeginTocAnchorNameBegin --><a name=prelude-1><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Preface</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+Better C than never.
+
+<h1 class=hidden>Table of Contents</h1>
+<!-- Table of Contents --><!-- #BeginToc -->
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ul class=toc_prelude1>
+   <li><a href=#prelude-1>Preface</a>
+   <li><a href=#prelude-2>Table of Figures</a>
+   <li><a href=#prelude-3>Table of Tables</a>
+   <li><a href=#prelude-4>Introduction</a>
+   <ul class=toc_part1>
+      <li>Part 1 &nbsp;<a href=#part-1>Disks</a>
+      <ul class=toc_h1>
+         <li>1. &nbsp;<a href=#h-1>Compiler Disk v1</a>
+         <ul class=toc_h2>
+            <li>1. &nbsp;<a href=#h-1.1>System</a>
+            <li>2. &nbsp;<a href=#h-1.2>Standard Library</a>
+         </ul>
+         <li>2. &nbsp;<a href=#h-2>Compiler Disk v2</a>
+         <ul class=toc_h2>
+            <li>1. &nbsp;<a href=#h-2.1>System</a>
+            <ul class=toc_h3>
+               <li>1. &nbsp;<a href=#h-2.1.1>parser.com</a>
+               <li>2. &nbsp;<a href=#h-2.1.2>compiler.com</a>
+               <li>3. &nbsp;<a href=#h-2.1.3>linker.com</a>
+            </ul>
+            <li>2. &nbsp;<a href=#h-2.2>Standard Library</a>
+         </ul>
+         <li>3. &nbsp;<a href=#h-3>Library System Disk</a>
+      </ul>
+      <li>Part 2 &nbsp;<a href=#part-2>Personal</a>
+      <ul class=toc_h1>
+         <li>4. &nbsp;<a href=#h-4>Tips & Tricks</a>
+      </ul>
+      <li>Part 3 &nbsp;<a href=#part-3>Appendixes</a>
+      <ul class=toc_appendix1>
+         <li>A &nbsp;<a href=#appendix-A>Functions Standard Library v1</a>
+         <li>B &nbsp;<a href=#appendix-B>Functions Standard Library v2</a>
+         <li>C &nbsp;<a href=#appendix-C>Functions Graphic Library</a>
+      </ul>
+   </ul>
+   <li><a href=#prelude-5>Bibliography</a>
+</ul>
+<!-- End of generated Table of Contents -->
+<!-- #EndToc -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=prelude-2><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Table of Figures</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- Table of Figures --><!-- #BeginToc -->
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ol>
+   <li><a href=#Figure-1>Contents Compiler Disk v1</a>
+   <li><a href=#Figure-2>Contents Compiler Disk v2</a>
+</ol>
+<!-- End of generated Table of Contents -->
+<!-- #EndToc -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=prelude-3><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Table of Tables</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- Table of Tables --><!-- #BeginToc -->
+<!-- Table of Contents generated by Perl - HTML::Toc -->
+<ol>
+   <li><a href=#Table-1>Compile Steps</a>
+</ol>
+<!-- End of generated Table of Contents -->
+<!-- #EndToc -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=prelude-4><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Introduction</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.
+<!-- #BeginTocAnchorNameBegin --><a name=Table-1><!-- #EndTocAnchorNameBegin --><p class=captionTable><!-- #BeginTocNumber -->Table 1: &nbsp;<!-- #EndTocNumber -->Compile Steps</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<ul><pre>
+   Parser
+   Compiler
+   Linker
+</pre></ul>
+
+<!-- #BeginTocAnchorNameBegin --><a name=part-1><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 1 &nbsp;<!-- #EndTocNumber -->Disks</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-1><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->1 &nbsp;<!-- #EndTocNumber -->Compiler Disk v1</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<img src=img.gif alt="Contents Compiler Disk v1">
+<!-- #BeginTocAnchorNameBegin --><a name=Figure-1><!-- #EndTocAnchorNameBegin --><p class=captionFigure><!-- #BeginTocNumber -->Figure 1: &nbsp;<!-- #EndTocNumber -->Contents Compiler Disk v1</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=h-1.1><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->1.1 &nbsp;<!-- #EndTocNumber -->System</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-1.2><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->1.2 &nbsp;<!-- #EndTocNumber -->Standard Library</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=h-2><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->2 &nbsp;<!-- #EndTocNumber -->Compiler Disk v2</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<img src=img.gif alt="Contents Compiler Disk v2">
+<!-- #BeginTocAnchorNameBegin --><a name=Figure-2><!-- #EndTocAnchorNameBegin --><p class=captionFigure><!-- #BeginTocNumber -->Figure 2: &nbsp;<!-- #EndTocNumber -->Contents Compiler Disk v2</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=h-2.1><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->2.1 &nbsp;<!-- #EndTocNumber -->System</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.1><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.1 &nbsp;<!-- #EndTocNumber -->parser.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.2><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.2 &nbsp;<!-- #EndTocNumber -->compiler.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.3><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.3 &nbsp;<!-- #EndTocNumber -->linker.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-2.2><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->2.2 &nbsp;<!-- #EndTocNumber -->Standard Library</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+
+<!-- #BeginTocAnchorNameBegin --><a name=h-3><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->3 &nbsp;<!-- #EndTocNumber -->Library System Disk</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=part-2><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 2 &nbsp;<!-- #EndTocNumber -->Personal</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=h-4><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->4 &nbsp;<!-- #EndTocNumber -->Tips & Tricks</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=part-3><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 3 &nbsp;<!-- #EndTocNumber -->Appendixes</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=appendix-A><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->A &nbsp;<!-- #EndTocNumber -->Functions Standard Library v1</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=appendix-B><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->B &nbsp;<!-- #EndTocNumber -->Functions Standard Library v2</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=appendix-C><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->C &nbsp;<!-- #EndTocNumber -->Functions Graphic Library</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+<!-- #BeginTocAnchorNameBegin --><a name=prelude-5><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Bibliography</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
+</body>
+</html>
+EOT
+}  # TestInsertManualForUpdating()
+
+
+#--- TestUpdateManual() -------------------------------------------------------
+# function: Test inserting ToC into manual.
+
+sub TestUpdateManual {
+	my $output;
+		# Create objects
+	my $toc          = new HTML::Toc;
+	my $tocOfFigures = new HTML::Toc;
+	my $tocOfTables  = new HTML::Toc;
+	my $tocUpdator   = new HTML::TocUpdator;
+	
+		# Set ToC options
+	$toc->setOptions({
+		'doNestGroup'          => 1,
+		'doNumberToken'        => 1,
+		'insertionPoint'       => "after <!-- Table of Contents -->",
+		'templateLevel'        => \&AssembleTocLine,
+      'templateLevelBegin'   => '"<ul class=toc_$groupId$level>\n"',
+      'templateLevelEnd'     => '"</ul>\n"',
+		'templateTokenNumber'  => \&AssembleTokenNumber,
+      'tokenToToc'           => [{
+            'groupId'        => 'part',
+			   'doNumberToken'  => 1,
+            'level'          => 1,
+            'tokenBegin'     => '<h1 class=part>',
+         }, {
+            'tokenBegin'     =>