spBase
Loading...
Searching...
No Matches
Command-Line Options

Data Structures

struct  spOption
 

Macros

#define spGetOptions(argc, argv, option, file_label)   _spGetOptions(argc, argv, spArraySize(option), option, spArraySize(file_label), file_label)
 
#define spStrToBool(value)   (((*(value) == 'T') || spStrEq(value, "1") || spStrEq(value, "ON") || spStrEq(value, "On")) ? SP_TRUE : SP_FALSE)
 
#define spBoolToStr(value)   (((value) == SP_TRUE) ? "True" : "False")
 

Typedefs

typedef void(* spExitCallbackFunc) (void *)
 
typedef unsigned short spOptionType
 
typedef struct _spOptions * spOptions
 

Functions

spBool spEqType (spOptionType type1, spOptionType type2)
 
void spIgnoreUnknownOption (spOptions options, spBool flag)
 
void spSetSection (spOptions options, int section)
 
void spSetSetup (const char *filename)
 
spBool spWriteGlobalSetup (void)
 
spBool spAddExitCallback (spExitCallbackFunc callback, void *data)
 
spBool spRemoveExitCallback (spExitCallbackFunc callback, void *data)
 
void spExit (int status)
 
char * spGetOptionValue (int argc, char **argv, spOptions options)
 
void spGetOptionsValue (int argc, char **argv, spOptions options)
 
void spCheckNumFile (spOptions options)
 
const char * spGetFile (spOptions options)
 
void spSetHelpMessage (spBool *flag, const char *format,...)
 
void spPrintHelp (const char *format,...)
 
void spPrintError (const char *format,...)
 
void spPrintMan (spOptions options, const char *description, const char *author)
 
spBool spReadSetup (const char *filename, spOptions options)
 
spBool spWriteSetup (const char *filename, spOptions options)
 
void spUsage (void)
 

Detailed Description

Macro Definition Documentation

◆ spGetOptions

#define spGetOptions ( argc,
argv,
option,
file_label )   _spGetOptions(argc, argv, spArraySize(option), option, spArraySize(file_label), file_label)

Initializes spOptions which is a structure to deal with command-line options.

Examples
spcat.c.

◆ spStrToBool

#define spStrToBool ( value)    (((*(value) == 'T') || spStrEq(value, "1") || spStrEq(value, "ON") || spStrEq(value, "On")) ? SP_TRUE : SP_FALSE)

Converts a null-terminated string to a boolean value.

◆ spBoolToStr

#define spBoolToStr ( value)    (((value) == SP_TRUE) ? "True" : "False")

Converts a boolean value to a null-terminated string.

Typedef Documentation

◆ spExitCallbackFunc

typedef void(* spExitCallbackFunc) (void *)

Definition of spExitCallbackFunc used for spAddExitCallback() .

◆ spOptionType

typedef unsigned short spOptionType

Definition of spOptionType .

◆ spOptions

typedef struct _spOptions* spOptions

Definition of spOptions.

Function Documentation

◆ spEqType()

spBool spEqType ( spOptionType type1,
spOptionType type2 )
extern

Checks if two option types are the same.

◆ spIgnoreUnknownOption()

void spIgnoreUnknownOption ( spOptions options,
spBool flag )
extern

Ignores unknown options in option handling if flag is SP_TRUE.

Examples
spcat.c.

◆ spSetSection()

void spSetSection ( spOptions options,
int section )
extern

Sets the section number for a help message.

◆ spSetSetup()

void spSetSetup ( const char * filename)
extern

Sets the file name of the setup file.

◆ spWriteGlobalSetup()

spBool spWriteGlobalSetup ( void )
extern

Writes the contents of the setup file.

◆ spAddExitCallback()

spBool spAddExitCallback ( spExitCallbackFunc callback,
void * data )
extern

Adds a callback function called at exit.

◆ spRemoveExitCallback()

spBool spRemoveExitCallback ( spExitCallbackFunc callback,
void * data )
extern

Removes a callback function added by spAddExitCallback() .

◆ spExit()

void spExit ( int status)
extern

Terminates the current program.

◆ spGetOptionValue()

char * spGetOptionValue ( int argc,
char ** argv,
spOptions options )
extern

Parses a command-line option. This function parses only one option. Use spGetOptionsValue() to parse multiple options.

◆ spGetOptionsValue()

void spGetOptionsValue ( int argc,
char ** argv,
spOptions options )
extern

Parses multiple command-line options. This function calls spGetOptionValue() internally.

Examples
spcat.c.

◆ spCheckNumFile()

void spCheckNumFile ( spOptions options)
extern

Checks if the number of files in the command line is correct.

◆ spGetFile()

const char * spGetFile ( spOptions options)
extern

Gets the file name specified in the command line one by one.

Examples
spcat.c.

◆ spSetHelpMessage()

void spSetHelpMessage ( spBool * flag,
const char * format,
... )
extern

Sets the contents of a help message.

Examples
spcat.c.

◆ spPrintHelp()

void spPrintHelp ( const char * format,
... )
extern

Displays a help message.

◆ spPrintError()

void spPrintError ( const char * format,
... )
extern

Displays an error message.

◆ spPrintMan()

void spPrintMan ( spOptions options,
const char * description,
const char * author )
extern

Generates a text in man format.

◆ spReadSetup()

spBool spReadSetup ( const char * filename,
spOptions options )
extern

Reads settings from the setup file.

◆ spWriteSetup()

spBool spWriteSetup ( const char * filename,
spOptions options )
extern

Writes settings to the setup file.

◆ spUsage()

void spUsage ( void )
extern

Displays a help message and then terminates the current program.