@c *************************************************************************
@c CHAPTER: How to port VVcode to a new environment
@c *************************************************************************
@c node-name, next, previous, up
@node Porting Guide, Porting Guide, Top, Top
@chapter How to port VVcode to a new environment
This chapter introduces the facilities provided for porting VVcode to a new
environment and recommends the approach that should be taken for particular
examples.
@itemize @bullet
@item introduction and philosophy
@item @file{machine.h}
@item @file{specific.h} and @file{xxx.c}
@item local.h
@end itemize
@c =========================================================================
@c SECTION: The @file{os.h} header file
@c =========================================================================
@c node-name, next, previous, up
@section The @file{os.h} header file
The @file{os.h} file contains tests to identify the environment on which
VVcode is being built. Once the environment has been identified the file
defines preprocessor macros to define the environment in the format
expected by VVcode. Environments are defined as the operating system and
variants due to dialects of the operating system or the compiler.
@itemize @bullet
@item explain the @samp{OS_xxxx} macros, including the operating systems
currently supported
@item explain the @samp{UNIX_yyyy} and related macros
@end itemize
@c =========================================================================
@c SECTION: The @file{machine.h} header file
@c =========================================================================
@c node-name, next, previous, up
@section The @file{machine.h} header file
The header file @file{machine.h}
@itemize @bullet
@item defines macros to control the behaviour and compilation of VVcode
@item several categories of definition required:
@itemize @bullet
@item definitions for the environment in which VVcode is built
@end itemize
@subsubsection @code{VV_OPERATING_SYSTEM}
A string recording the operating system for which this version of VVcode
has been implemented. This value is recorded in the VVE file and used by
VVdecode to detect whether the original file was encoded on a different
operating system. For example:
@example
#define VV_OPERATING_SYSTEM "MS-DOS"
@end example
@subsubsection @code{VV_IMPLEMENTATION}
A string describing the implementation of VVcode. Displayed when VVcode
programs are started and recorded in log and VVE files. For example:
@example
#define VV_IMPLEMENTATION "MS-DOS Turbo-C version 09.1-001 (31 May 1992)"
@end example
@subsubsection @code{ANSI_SYNTAX}
Define as @code{TRUE} if the compiler supports the draft ANSI standard for
C syntax (it shouldn't matter if the run time library is not fully ANSI
compliant). Define as @code{FALSE} if this syntax is not supported. The
macro is used to control the declaration of functions and the use of new
ANSI keywords such as @samp{const}. If your compiler requires old-style
function declarations like:
you should define @code{ANSI_SYNTAX} to @code{FALSE}. Many Unix systems
have compilers that fall into this category, though the GNU C compiler is a
notable exception. If you have a modern compiler that accepts ANSI style
function declarations like:
you should define @code{ANSI_SYNTAX} to @code{TRUE}. The GNU C compiler
and most of the PC compilers support the ANSI standard.
@c -------------------------------------------------------------------------
@c SECTION: VVcode Command Line Interface
@c -------------------------------------------------------------------------
@subsection{VVcode Command Line Interface}
@itemize @bullet
@item defines how to start VVcode and how it interprets the command line
@item explain concepts of @dfn{parameters} and @dfn{qualifiers}
@item @dfn{parameters} -
@item @dfn{qualifiers} - modify the behaviour of a command#
@item give an example and compare the commands @code{rm -i foo} and
@code{delete /confirm foo}
@item this does not preclude implementations that may not usually use
a command line interface (e.g. Mac). For example VMS does use a
CLI but provides a set of system services to handle the CL. Under
these circumstances these definitions will only be used to display
help text in the correct format
@end itemize
@subsubsection @code{QUAL_INTRO}
A string containing a set of characters, each of which may be used to
introduce a command line qualifier. For example:
The examples above indicate that on a Unix system @samp{-} would be used to
introduce a command qualifier, whereas on MS-DOS either @samp{-} or
@samp{/} could be used.
@subsubsection @code{QUAL_SEP}
A string containing a set of characters, each of which may be used to
separate a command line qualifier from its value. For example:
The examples above indicate that on an MS-DOS system the qualifier value is
separated from the qualifier by one of the characters @samp{=}, @samp{:} or
@samp{-}. The Unix example indicates that the value is separated from the
qualifier by a space, i.e. it is the next command line parameter.
@subsubsection @code{OPTIONAL_QUALIFIER_VALUES}
Define as @code{TRUE} if the operating system convention can handle command
line qualifiers with optional values. On systems such as MS-DOS, VAX/VMS
and VM/CMS the qualifiers are separated from each other by spaces and from
their values by another character such as an equals sign (@samp{=}). In
the following example it is obvious whether the optional value for the
@samp{log} qualifier is present:
On Unix, the convention is to separate qualifiers from each other by spaces
and from their qualifiers by spaces. In the following example it is
difficult if not impossible to determine whether the @samp{log} qualifier
value is present:
This problem could be overcome by forcing Unix users to use a different
character like @samp{=} to introduce the qualifier value or by imposing
strict rules on the ordering of parameters and qualifiers. Neither of
these approaches is likely to be popular so we take the easy way out and
specify whether such optional qualifier values are supported. If they are
not supported, the qualifiers which could take optional values are modified
either to require a value or to take no value.
Define as @code{TRUE} if the VVcode programs should apply default file
names when determining output file specifications. For example, on Unix
the definition would usually be:
@example
#define STICKY_DEFAULTS FALSE /* Unix */
@end example
and the commands:
@example
vvencode one
vvencode one two
vvencode one two -log three
@end example
would create the files @file{one.vve}, @file{two}, and @file{two} plus a
log file @file{three} respectively. On other systems such as MS-DOS and
VAX/VMS where default file names are customary the definition would usually
be
@example
#define STICKY_DEFAULTS TRUE /* MS-DOS, VMS */
@end example
and the commands:
@example
vvencode one
vvencode one two
vvencode one two -log three
@end example
would create the files @file{one.vve}, @file{two.vve} and @file{two.vve}
plus a log file @file{three.log} respectively.
@subsubsection @code{STDOUT_OUTPUT}
Define as @code{TRUE} if the VVencode program should write to standard
output if an output file is not explicitly specified on the command line.
The command:
@example
vvencode ip-file
@end example
would write the VVE file to standard output if @code{STDOUT_OUTPUT} is defined
as @code{TRUE} or to @file{ip-file.vve} if it is defined as @code{FALSE}.
Define as @code{TRUE} if the VVcode programs should support reading from
standard input and/or writing to standard output so that they may be used
as filters. The programs do not behave as true filters since an input file
must always be specified, but specifying a certain string (e.g. @samp{-})
as the input file specification will cause the program to read from
standard input. The string used is defined by the macro
@code{STDIO_SYMBOL}.
A string which when used as a file specification will cause the VVcode
programs to read/write to standard input/output depending on whether that
file is an input or output file. This string is only used if the macro
@code{SUPPORT_PIPING} is defined as @code{TRUE}. If it is unused, define
it as "".
On a Unix system, the following definitions would be usual:
The maximum number of characters in the preamble component of a file
specification. If the system does not support a preamble component, define
as zero.
The maximum number of characters in the extension component of a file
specification. If the system does not support an extension component,
define as zero.
The maximum number of characters in the postamble component of a file
specification. If the system does not support a postamble component,
define as zero.
A string containing a set of characters, each of which may be used to
denote the end of the preamble component of a file specification. If the
system does not support a preamble component, define as "".
The single character that may be used to denote the start of the extension
component of a file specification. If the system does not support an
extension component, define as @samp{\000}.
A string containing a set of characters, each of which may be used to denote
the start of the postamble component of a file specification. If the system
does not support a postamble component, define as "".
Define as @code{TRUE} if the file system is case insensitive. For the
benefit of file systems that do care (where lower case names are usual),
VVencode will convert file specifications to lower case before recording
them in the VVE file.
The extra number of characters written by the file system when writing
lines to text files. For example, when writing to text files MS-DOS
converts @samp{\n} to @samp{\r\n} and therefore has an overhead of 1.
Define as the default mode for file encoding & decoding to be used if the
mode is not specified on the command line and cannot be determined from the
input file. It must be @code{MODE_BINARY} or @code{MODE_TEXT}.
Example:
@example
#define DEF_MODE MODE_BINARY /* most systems */
@end example
@subsubsection @code{DEF_TEXT_FMT}
Define as the default file format for text files. It must be one of
@code{FMT_FIXED}, @code{FMT_STREAM} and @code{FMT_VARIABLE} and only a
supported format may be specified.
Define as the default file format for text files. It must be one of
@code{FMT_FIXED}, @code{FMT_STREAM} and @code{FMT_VARIABLE} and only a
supported format may be specified.
The minimum record length in bytes supported by the file system for
variable length record format files. Must be within the VVcode limits of 0
to 65535. If the system doesn't support variable length record format files
define as @code{INV_RECORD_LEN}.
The maximum record length in bytes supported by the file system for
variable length record format files. Must be within the VVcode limits of 0
to 65535. If the system doesn't support variable length record format files
define as @code{INV_RECORD_LEN}.
The default maximum record length in bytes supported by the file system for
variable length record format files. Must be in the range defined by
@code{MIN_VARIABLE_RECORD_LEN} and @code{MAX_VARIABLE_RECORD_LEN}. If the
system doesn't support variable length record format files define as
@code{INV_RECORD_LEN}.
The minimum record length in bytes supported by the file system for fixed
length record format files. Must be within the VVcode limits of 0 to
65535. If the system doesn't support fixed length record format files
define as @code{INV_RECORD_LEN}.
The maximum record length in bytes supported by the file system for fixed
length record format files. Must be within the VVcode limits of 0 to
65535. If the system doesn't support fixed length record format files
define as @code{INV_RECORD_LEN}.
The default record length in bytes supported by the file system for fixed
length record format files. Must be in the range defined by
@code{MIN_FIXED_RECORD_LEN} and @code{MAX_FIXED_RECORD_LEN}. If the system
doesn't support fixed length record format files define as
@code{INV_RECORD_LEN}.
Define as the default character used to pad out short records in text fixed
length record format files. Must be a valid character constant and will
usually be a space character. If the system doesn't support fixed length
record format files, define as @samp{\000}.
Define as the default character used to pad out short records in binary
fixed length record format files. Must be a valid character constant and
will usually be a null character. If the system doesn't support fixed
length record format files, define as '\000'.
@c =========================================================================
@c SECTION: The @file{xxx.c} operating system specific module
@c =========================================================================
@section The @file{xxx.c} operating system specific module
@c =========================================================================
@c SECTION: Porting VVcode - an example
@c =========================================================================
@section Porting VVcode - an example