OSFI-C  3.10.0
OpenSF Integration Library
Parsing command-line arguments

Utilities to parse command line arguments compliant to the E2E-ICD module interface. More...

Modules

 Legacy API
 Deprecated prior version of the CLP functionality.
 

Data Structures

struct  osfi_clp_files
 List of files of a specific type, allocated by osfiClpParseArgs(). More...
 
struct  osfi_clp_args
 Result of parsing CLI arguments, contains the files of each type passed to the module. More...
 

Typedefs

typedef struct osfi_clp_files osfi_clp_files_t
 List of files of a specific type, allocated by osfiClpParseArgs(). More...
 
typedef struct osfi_clp_args osfi_clp_args_t
 Result of parsing CLI arguments, contains the files of each type passed to the module. More...
 

Functions

osfi_clp_args_tosfiClpParseArgs (int argc, char *argv[])
 Parse the command-line arguments provided to the module. More...
 
void osfiClpFree (osfi_clp_args_t *p)
 Release a previously allocated result returned by osfiClpParseArgs(). More...
 

Detailed Description

Utilities to parse command line arguments compliant to the E2E-ICD module interface.

CLP parses the command line arguments of a module, generating lists of tokens grouped as:

The command line must follow one of the following formats (flag or positional). In particular, if any flagged option (-/--) appears, passing positional arguments is an error.

In either form, file names must be valid OS-dependant file locations. Per the E2E-ICD, the configuration, input and output file names can be either a full-path name or a relative path name. Relative path names are interpreted by the module as relative to the current working directory. In particular, no reference is made to the possible E2E_HOME variable.

Flag inputs:
<command_line> ::= <executable> <options>
<options> ::= (<global_configuration> | <local_configuration> | <input_file> | <output_file>)*
<executable> ::= <file_name>
<global_configuration> ::= (--global|-g) <file_name>
<local_configuration> ::= (--local|-l) <file_name>
<input_file> ::= (--input|-i) <file_name>
<output_file> ::= (--output|-o) <file_name>
<file_name> ::= (<alphanumeric>)+

If the "local" or "global" options are provided multiple times, only the last value specified is kept for each of the flags.

Positional arguments:
<command_line> ::= <executable_name> <whitespaces> <configuration_files> <whitespaces>
<input_files> <whitespaces> <output_files> <EOL>
<executable_name> ::= <file_name>
<whitespace> ::= (“ “)
<whitespaces> ::= <whitespace>+
<file_name> ::= (<alphanumeric>)+
<configuration_files> ::= <list_of_files>
<input_files> ::= <list_of_files>
<output_files> ::= <list_of_files>
<list_of_files> ::= <file_name> (“,” <file_name>)*

Note that since the comma character is used as a separator inside the positional arguments, it cannot be part of a file name in this mode, even if it would be a legal path value.

Examples
See an usage example here.

Typedef Documentation

◆ osfi_clp_args_t

Result of parsing CLI arguments, contains the files of each type passed to the module.

On a successful return from osfiClpParseArgs(), all members will point to a valid (non-null) substructure. However, depending on the actual arguments, some of them may contain 0 entries e.g. if no input files exist then input is allocated but input->count==0.

See also
osfiClpFree() to release the resources.

◆ osfi_clp_files_t

List of files of a specific type, allocated by osfiClpParseArgs().

This object is allocated by OSFI and should not be freed directly by caller code.

Function Documentation

◆ osfiClpFree()

void osfiClpFree ( osfi_clp_args_t p)

Release a previously allocated result returned by osfiClpParseArgs().

Parameters
pObject to free. May be a null pointer, in which case the call does nothing.
Examples
CLP.c.

◆ osfiClpParseArgs()

osfi_clp_args_t* osfiClpParseArgs ( int  argc,
char *  argv[] 
)

Parse the command-line arguments provided to the module.

Parameters
argcnumber of arguments, as would be passed to main
argvargument values, as would be passed to main
Returns
An OSFI-allocated struct with the results of parsing, or null on error.
See also
osfiClpFree() to release the resources.
Examples
CLP.c.