Home Libraries Author Links

Format and Print Manual Page Text
[Getopts: Parse Command Line and Generate Manual Text]

Collaboration diagram for Format and Print Manual Page Text:

Detailed Description

The functions of this module format text in man page format of a configurable width and print it to a stream.


Functions

int stmPrintManText (FILE *fp, int width, const char *text)
 Format and print manual text.
int stmPrintManualHeader (FILE *fp, int width, const char *version, int dim, const char **man)
 Format and print a command's manual header.
int stmPrintManualFooter (FILE *fp, int width, int indent, const char *copyRight)
 Format and print a command's manual footer.
int stmPrintOptionHelp (FILE *fp, int width, const char *optionName, int dim, const char **man)
 Format and print a command's option help.
int stmPrintManualSection (FILE *fp, int width, const char *sectionName, int dim, const char **man)
 Format and print a command's manual section.
int stmPrintSynopsis (FILE *fp, int width, int dim, const char **man)
 Format and print a command's SYNOPSIS manual section.
int stmPrintManual (FILE *fp, int width, const char *version, const char *copyRight, int dim, const char **man)
 Format and print a command's manual.


Function Documentation

int stmPrintManText ( FILE *  fp,
int  width,
const char *  text 
)

Format and print manual text.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] text Text to format and print
Effects:
The function formats and prints text of a manual as follows to the stream designated by fp right justified in lines of at most width characters:
The number of leading space characters of the first word determines the texts's primary indentation. All following lines are indented like this, unless the first word begins with a '-' character and is followed by more than one space character. In this case that word is printed at the primary indentation level followed by its right side separator sequence and the indentation of all further lines is the beginning position of the second word. As word separators serve sequences of space and/or tabulator characters. Spaces and tabulators inside single or double quote pairs are not regarded as word separators. An empty line is printed as empty line.
width has to be at least 40 and be greater than the indentation determined. For the indentation detection to work correctly, the word separators at both sides of the first word must not contain tabulator characters.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

The last used primary indentation level.

See also:
stmPrintManualHeader(), stmPrintManualFooter(), stmPrintManualSection(), stmPrintOptionHelp(), stmPrintManual().

int stmPrintManualHeader ( FILE *  fp,
int  width,
const char *  version,
int  dim,
const char **  man 
)

Format and print a command's manual header.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] version The version string.
[in] dim The Dimension of the man array.
[in] man The dim dimensional array of strings in man format.
Effects:
The function formats and prints the header with version information of a command's manual which is supplied in the dim dimensional array man in man format using lines of at most width characters on fp.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

The man line index of the line following the NAME manual section.

See also:
stmPrintManText(), stmPrintManualFooter(), stmPrintOptionHelp(), stmPrintManualSection(), stmPrintSynopsis(), stmPrintManual().
Examples:
dsettst.c.

int stmPrintManualFooter ( FILE *  fp,
int  width,
int  indent,
const char *  copyRight 
)

Format and print a command's manual footer.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] indent Prinmary indentation level.
[in] copyRight The copyright string.
Effects:
The function formats and prints the footer with copyRight information of a command's manual in man format using lines of at most width characters on fp. As primary indentation level indent is used.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

0 on success.

See also:
stmPrintManText(), stmPrintManualHeader(), stmPrintOptionHelp(), stmPrintManualSection(), stmPrintSynopsis(), stmPrintManual().
Examples:
dsettst.c.

int stmPrintOptionHelp ( FILE *  fp,
int  width,
const char *  optionName,
int  dim,
const char **  man 
)

Format and print a command's option help.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] optionName The name of the option to print help for.
[in] dim The Dimension of the man array.
[in] man The dim dimensional array of strings in man format.
Effects:
The function formats and prints the help text of option optionName of a command's manual which is supplied in the dim dimensional array man in man format using lines of at most width characters on fp.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

The last used primary indentation level.

See also:
stmPrintManText(), stmPrintManualHeader(), stmPrintManualFooter(), stmPrintManualSection(), stmPrintSynopsis(), stmPrintManual().
Examples:
dsettst.c.

int stmPrintManualSection ( FILE *  fp,
int  width,
const char *  sectionName,
int  dim,
const char **  man 
)

Format and print a command's manual section.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] sectionName The name of the manual section to print.
[in] dim The Dimension of the man array.
[in] man The dim dimensional array of strings in man format.
Effects:
The function formats and prints the section sectionName of a command's manual which is supplied in the dim dimensional array man in man format using lines of at most width characters on fp.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

0 on success.

See also:
stmPrintManText(), stmPrintManualHeader(), stmPrintManualFooter(), stmPrintOptionHelp(), stmPrintSynopsis(), stmPrintManual().

int stmPrintSynopsis ( FILE *  fp,
int  width,
int  dim,
const char **  man 
)

Format and print a command's SYNOPSIS manual section.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] dim The Dimension of the man array.
[in] man The dim dimensional array of strings in man format.
Effects:
The function formats and prints the SYNOPSIS section of a command's manual which is supplied in the dim dimensional array man in man format using lines of at most width characters on fp.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

0 on success.

See also:
stmPrintManText(), stmPrintManualHeader(), stmPrintManualFooter(), stmPrintOptionHelp(), stmPrintManualSection(), stmPrintManual().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().

int stmPrintManual ( FILE *  fp,
int  width,
const char *  version,
const char *  copyRight,
int  dim,
const char **  man 
)

Format and print a command's manual.

Parameters:
[in] fp FILE pointer to the stream to print on.
[in] width Maximal line width.
[in] version The version string.
[in] copyRight The copyright string.
[in] dim The Dimension of the man array.
[in] man The dim dimensional array of strings in man format.
Effects:
The function formats and prints the manual of a command which is supplied in version, copyRight and the dim dimensional array man in man format using lines of at most width characters on fp.
Returns:
-1 on error. Then the variable errno reflects the error's cause.

0 on success.

See also:
stmPrintManText(), stmPrintManualHeader(), stmPrintManualFooter(), stmPrintOptionHelp(), stmPrintManualSection(), stmPrintSynopsis().
Examples:
cuglify.c, and dsettst.c.

Referenced by main().


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).