=head1	NAME

stc - String table compiler

=head1	SYNOPSIS

  stc [<options>] <inputfile> <outputdirectory>

=head1	DESCRIPTION

The program converts a string table source file (*.str) into multiple
binary string table files (*.stt) which can be used by the dkstt module
in the libdkc library.

The output files are placed in the I<outputdirectory>, the program creates
a directory structure using languages and encoding (if available) for
the subdirectory names.

=head1	OPTIONS

=over	4

=item	B<-p>

writes plain (uncompressed) output files.

=back

=head1	RETURN VALUE

The program returns an exit status 0 on success, all other status codes
indicate errors.

=head1	EXAMPLES

=head2	Input file example

  # This is an example string table file.
  $version 1.0

  "msg-hello"
  de = "Guten Tag."
  en = "Hello."
  en_US = "Hi."

  "msg-goodbye"
  de = "Auf Wiedersehen."
  en = "Goodbye."

=head1	FILES

=head2	INPUT FILE SYNTAX

The input file consists of an optional file header and a list of sections.

The file header consists of a version string, it contains the
``$version'' keyword and a string table version number I<major>.I<minor>.

Each section consists of a section keyword (this keyword is used by the
application to search for a matching string) in double quotes.
The remainder of the section is a list of key/value pairs, key and value
are separated by ``=''. The key is a language, language/region,
language/encoding, or language/region/encoding combination. The structure
of the key is the same as for the LANG environment variable,
i.e. ``de'' or ``de_DE'' or ``de_DE.UTF-8''.
The value is the string to return for the key.

=head2	OUTPUT FILE STRUCTURE

The output is a set of binary files, the files can be compressed using the
zlib or bzip2 library.

Integer variables are stored in network byte order in the data stream.

The data stream consists of the following components:

=over	6

=item	File identifier, 7 bytes

The file identifier is the string ``STRT-2'' followed by a 0x00 byte.

=item	Major version number (major), 2 byte unsigned integer.

=item	Minor version number (minor), 2 byte unsigned integer.

=item	Number of entries (ne) , 2 byte unsigned integer.

=item	Reserved (co), 2 byte unsigned integer.

This value is 0.

=item	Keys array (ne times):

=over	12

=item	String length (sl), 2 byte unsigned integer.

The final 0x00 byte is included in the calculation.

=item	String (sl bytes).

The final 0x00 byte is included in the data stream.

=back

=item	Values array (ne times):

=over	12

=item	String length (sl), 2 byte unsigned integer.

The final 0x00 byte is included in the calculation.

=item	String (sl bytes).

The final 0x00 byte is included in the data stream.

=back

=item	All remaining contents of the data stream is ignored.

=back

=head1	AUTHOR

Dirk Krause

=head1	COPYRIGHT AND LICENSE

Copyright (c) 2010, Dirk Krause
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 the Dirk Krause nor the names of
   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 OWNER 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.

=head1	SEE ALSO

dkapp(3), dkstt(3), http://dktools.sourceforge.net/stc.html

