Home Libraries Author Links

getopts.h File Reference


Detailed Description

Specification of data types and functions for the parsing of commend line options and the generation and output of manual text in man page format.

Version:
1.10-r67
Date:
2007-11-03 15:21:05 (Tom)
Author:
Tom Michaelis
SysToMath
Wittelsbacherstr. 7
D-80469 Munich
Contact:
http://www.SysToMath.com
mailto:Tom.Michaelis@SysToMath.com
This C header file contains declarations of data types and functions specifying the parsing of commend line options and the generation and output of manual text in man page format. They are implemented in the C program file getopts.c belonging to the SysToMath Base C Library stmbase.

Definition in file getopts.h.

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  StmCmdOptSpec
 Type specifying a command line option. More...

StmCmdLine Method Functions

#define stmCmdLineGetOpterr   stmCmdLineGetError
 Alternative name for stmCmdLineGetError().
#define stmCmdLineSetOpterr   stmCmdLineSetError
 Alternative name for stmCmdLineSetError().
enum  StmCmdLineFlags { StmCmdLineAllowDirectlyFollowingOptArgs = 0x00000001 }
 Constants used to influence the operation of a StmCmdLine object. More...
enum  StmCmdLineErrors {
  StmCmdLineSystemError = -1,
  StmCmdLineOk = 0,
  StmCmdLineOptionError = 1,
  StmCmdLineOptionArgError = 2,
  StmCmdLineArgumentError = 3,
  StmCmdLineWrongUsage = 4
}
 Error values of StmCmdLine objects. More...
StmDword stmCmdLineGetFlags (StmCmdLine cmdLine)
 Get the operation flags of the StmCmdLine object cmdLine.
int stmCmdLineSetFlags (StmCmdLine cmdLine, StmDword flags)
 Set the operation flags of the StmCmdLine object cmdLine to flags.
int stmCmdLineGetError (StmCmdLine cmdLine)
 Get the error state of the StmCmdLine object cmdLine.
int stmCmdLineSetError (StmCmdLine cmdLine, int error)
 Set the error state of the StmCmdLine object cmdLine to error.
const char * stmCmdLineGetErrbuf (StmCmdLine cmdLine)
 Get the error message buffer of the StmCmdLine object cmdLine.
int stmCmdLinePrintfErrbuf (StmCmdLine cmdLine, const char *format,...)
 Print formatted to the error message buffer of the StmCmdLine object cmdLine.
FILE * stmCmdLineGetErrfp (StmCmdLine cmdLine)
 Get the error output stream of the StmCmdLine object cmdLine.
int stmCmdLineSetErrfp (StmCmdLine cmdLine, FILE *errfp)
 Set the error output stream of the StmCmdLine object cmdLine to errfp.
StmDword stmCmdLineGetFirstOptionId (StmCmdLine cmdLine)
 Get the ID of the first option of the StmCmdLine object cmdLine.
StmDword stmCmdLineGetCurrentOptionId (StmCmdLine cmdLine)
 Get the ID of the current option of the StmCmdLine object cmdLine.
StmDword stmCmdLineGetNextOptionId (StmCmdLine cmdLine)
 Get the ID of the next option of the StmCmdLine object cmdLine.
const char * stmCmdLineGetProg (StmCmdLine cmdLine)
 Get the program name of the StmCmdLine object cmdLine.
size_t stmCmdLineGetCurrentArgIndex (StmCmdLine cmdLine)
 Get the current argument index of the StmCmdLine object cmdLine.
size_t stmCmdLineGetCurrentOptionIndex (StmCmdLine cmdLine)
 Get the current option index of the StmCmdLine object cmdLine.
const char * stmCmdLineGetCurrentOptionName (StmCmdLine cmdLine)
 Get the current option name of the StmCmdLine object cmdLine.
const char * stmCmdLineGetCurrentOptionArg (StmCmdLine cmdLine)
 Get the argument of the current option of the StmCmdLine object cmdLine.
size_t stmCmdLineGetArgCount (StmCmdLine cmdLine)
 Get the argument count of the StmCmdLine object cmdLine.
const char * stmCmdLineGetArg (StmCmdLine cmdLine, size_t argIndex)
 Get the argument at index argIndex of the StmCmdLine object cmdLine.

StmCmdLine Creation and Destruction

StmCmdLine stmCmdLineCreate (int argc, const char **argv, const StmCmdOptSpec *optSpec)
 Creation of a new StmCmdLine object.
void stmCmdLineDestroy (StmCmdLine cmdLine)
 Destruction of the StmCmdLine object cmdLine.

Typedefs

typedef struct StmCmdOptSpec StmCmdOptSpec
 Type name for structure StmCmdOptSpec.

Enumerations

enum  StmCmdOptSpecFlags {
  StmCmdOptSpecHasArg = 0x00000001,
  StmCmdOptSpecRequiresArg = 0x00000003,
  StmCmdOptSpecArgsEnvOption = 0x00000004,
  StmCmdOptSpecArgsFromOption = 0x00000008,
  StmCmdOptSpecFirstOption = 0x00000010,
  StmCmdOptSpecLastOption = 0x00000020,
  StmCmdOptSpecOnlyOption = 0x00000030
}
 Constants used for the flags member of StmCmdOptSpec. More...
enum  StmGetoptsErrnos {
  StmGetoptsSystemError = -1,
  StmGetoptsOk = 0,
  StmGetoptsOptionError = 1,
  StmGetoptsOptionArgError = 2,
  StmGetoptsArgumentError = 3,
  StmGetoptsWrongUsage = 4
}
 Constants used for the variable stmGetoptsOpterr. More...
enum  StmGetoptsResults {
  StmGetoptsQuestion = (int) '?',
  StmGetoptsEnd = EOF
}
 Constants used as specal return values of stmGetopts(). More...

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.
int stmGetopts (int argc, const char **argv, const char *optSpec)
 Parse command line options.
int stmFprintfStrArray (FILE *fp, int width, int dim, const char **strArray)
 Format and print an array of character strings.

Variables

const char * stmGetoptsProg
 Program name.
const char * stmGetoptsOptarg
 Option argument.
int stmGetoptsOptind
 Option index.
int stmGetoptsOpterr
 Option error number.
char * stmGetoptsErrbuf
 Option error message.
FILE * stmGetoptsOptfp
 Option error file stream.
StmBool stmGetoptsStrict
 Strict flag.


© Copyright Tom Michaelis 2002-2007

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