Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Data Structures | Functions
config.c File Reference

Handles the main function argument list and produces the configuration structure that drives APG. More...

#include <unistd.h>
#include "../api/api.h"
#include "./config.h"
Include dependency graph for config.c:

Go to the source code of this file.

Data Structures

struct  config_ctx
 The configuration component context. More...
 

Functions

void * vpConfigCtor (exception *spEx)
 Constructs a configuration object to hold all data relating to this instance of the configuration. More...
 
void vConfigDtor (void *vpCtx)
 The configuration destructor. More...
 
const configspConfigOptions (void *vpCtx, int iArgCount, char **cppArgs)
 Reads the command line arguments and parses them into a configuration structure. More...
 
void vConfigHelp (void)
 Prints the help screen when requested or if there is a command line options error. More...
 
void vConfigVersion (void)
 Display the version number. More...
 
void vConfigDefault (void *vpCtx, char *cpFileName)
 Prints a default configuration file. More...
 
void vConfigDisplay (const config *spConfig, int iArgCount, char **cppArgs)
 Displays the full configuration as determined from the command line or command file arguments. More...
 

Detailed Description

Handles the main function argument list and produces the configuration structure that drives APG.

This suite of functions work together to parse the command line parameters into a configuration structure that drives the generator. The parameters can be on the command line directly or in a file (see the @filename command).

Definition in file config.c.

Function Documentation

◆ spConfigOptions()

const config* spConfigOptions ( void *  vpCtx,
int  iArgCount,
char **  cppArgs 
)

Reads the command line arguments and parses them into a configuration structure.

Parameters
vpCtxPointer to the configuration context previously returned by a call to the constructor vConfigCtor().
iArgCountthe number of arguments on the command line.
cppArgsan array of pointers to the command line arguments.
Returns
Pointer to a configuration structure with all of the input from the command line in a form easily used by main();

Definition at line 194 of file config.c.

◆ vConfigDefault()

void vConfigDefault ( void *  vpCtx,
char *  cpFileName 
)

Prints a default configuration file.

A configuration file may in many cases be a more convenient than a command line for providing the main() program with its options. This program will print a default file with all options available commented out. The user can then conveniently un-comment the options desired and customize it to his/her needs. This is especially useful to avoid the need to re-type long file names onto the command line for repeated applications.

Parameters
vpCtxPointer to the configuration context previously returned by a call to the constructor vConfigCtor().
cpFileNameName of the file to open and write the default configuration to. If NULL, prints to stdout.

Definition at line 282 of file config.c.

◆ vConfigDisplay()

void vConfigDisplay ( const config spConfig,
int  iArgCount,
char **  cppArgs 
)

Displays the full configuration as determined from the command line or command file arguments.

After all options have been read from the command line, or command file if present, the final interpretation of them is stored in the configuration structure. This function displays all of the arguments passed to the main function and the configuration that results from them. It is called if the flag -dc is set.

Parameters
spConfigPointer to the configuration structure.
iArgCountThe number of option arguments.
cppArgsArray of pointers to the arguments
Returns
void

Definition at line 431 of file config.c.

◆ vConfigDtor()

void vConfigDtor ( void *  vpCtx)

The configuration destructor.

Closes the open config file, if necessary.

Parameters
vpCtxPointer to the configuration context previously returned by a call to the constructor vConfigCtor(). NULL is silently ignored. However, if non-NULL it must be a valid config context pointer.

Definition at line 171 of file config.c.

◆ vConfigHelp()

void vConfigHelp ( void  )

Prints the help screen when requested or if there is a command line options error.

Definition at line 210 of file config.c.

◆ vConfigVersion()

void vConfigVersion ( void  )

Display the version number.

Definition at line 266 of file config.c.

◆ vpConfigCtor()

void* vpConfigCtor ( exception spEx)

Constructs a configuration object to hold all data relating to this instance of the configuration.

Parameters
spExPointer to a valid exception object.
See also
XCTOR().
Returns
Pointer to the configuration context. Exception thrown on error.

Definition at line 97 of file config.c.

APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.