#!/usr/bin/tclsh
#
# Use this script to build C-language source code for a program that uses
# tclsqlite.c together with custom TCL scripts and/or C extensions for
# either SQLite or TCL.
#
# Usage example:
#
# tclsh mktclsqliteprog.tcl demoapp.c.in >demoapp.c
#
# The demoapp.c.in file contains a mixture of C code, TCL script, and
# processing directives used by mktclsqliteprog.tcl to build the final C-code
# output file. Most lines of demoapp.c.in are copied straight through into
# the output. The following control directives are recognized:
#
# BEGIN_STRING
#
# This marks the beginning of large string literal - usually a TCL
# script of some kind. Subsequent lines of text through the first
# line that begins with END_STRING are converted into a C-language
# string literal.
#
# INCLUDE path
#
# The path argument is the name of a file to be inserted in place of
# the INCLUDE line. The path can begin with $ROOT to signify the
# root of the SQLite source tree, or $HOME to signify the directory
# that contains the demoapp.c.in input script itself. If the path does
# not begin with either $ROOT or $HOME, then it is interpreted relative
# to the current working directory.
#
# If the INCLUDE occurs in the middle of BEGIN_STRING...END_STRING
# then all of the text in the input file is converted into C-language
# string literals.
#
# None of the control directives described above will nest. Only the
# top-level input file ("demoapp.c.in" in the example) is interpreted.
# referenced files are copied verbatim.
#
if
set infile
set ROOT
set HOME
set in
puts
set instr 0
while