powerd++  0.4.4
Enumerations | Functions | Variables
anonymous_namespace{loadplay.cpp} Namespace Reference

File local scope. More...

Enumerations

enum  OE {
  OE::USAGE, OE::FILE_IN, OE::FILE_OUT, OE::CMD,
  OE::OPT_NOOPT = CMD, OE::OPT_UNKNOWN, OE::OPT_DASH, OE::OPT_LDASH,
  OE::OPT_DONE
}
 An enum for command line parsing. More...
 

Functions

const char * filename (char const *const path)
 Performs very rudimentary file name argument checks. More...
 
void execute (char const *const file, char *const argv[])
 Executes the given command, substituting this process. More...
 
void set_library_path (int const argc, char *const argv[])
 If running from an explicit path add the path to the library search path. More...
 

Variables

const char *const USAGE = "[-h] [-i file] [-o file] command [...]"
 The short usage string.
 
const Parameter< OEPARAMETERS []
 Definitions of command line parameters. More...
 

Detailed Description

File local scope.

Enumeration Type Documentation

◆ OE

enum anonymous_namespace{loadplay.cpp}::OE
strong

An enum for command line parsing.

Enumerator
USAGE 

Print help.

FILE_IN 

Set input file instead of stdin.

FILE_OUT 

Set output file instead of stdout.

CMD 

The command to execute.

OPT_NOOPT 

Obligatory.

OPT_UNKNOWN 

Obligatory.

OPT_DASH 

Obligatory.

OPT_LDASH 

Obligatory.

OPT_DONE 

Obligatory.

Function Documentation

◆ execute()

void anonymous_namespace{loadplay.cpp}::execute ( char const *const  file,
char *const  argv[] 
)

Executes the given command, substituting this process.

This function is a wrapper around execvp(3) and does not return.

Parameters
fileThe command to execute, looked up in PATH if no path is provided
argvThe command line arguments of the command
Exceptions
errors::Exception{Exit::EEXEC}

◆ filename()

const char* anonymous_namespace{loadplay.cpp}::filename ( char const *const  path)

Performs very rudimentary file name argument checks.

  • Fail on empty path
  • Return nullptr on '-'
Parameters
pathThe file path to check
Returns
The given path or nullptr if the given path is '-'

◆ set_library_path()

void anonymous_namespace{loadplay.cpp}::set_library_path ( int const  argc,
char *const  argv[] 
)

If running from an explicit path add the path to the library search path.

This function facilitates calling loadplay directly from the build directory for testing and allows it to pick up libloadplay.so from the same directory.

Parameters
argc,argvThe command line arguments provided to loadplay
Precondition
argc >= 2
Warning
This function changes the contents of argv[0]

Variable Documentation

◆ PARAMETERS

const Parameter<OE> anonymous_namespace{loadplay.cpp}::PARAMETERS[]
Initial value:
{
{OE::USAGE, 'h', "help", "", "Show usage and exit"},
{OE::FILE_IN, 'i', "input", "file", "Input file (load recording)"},
{OE::FILE_OUT, 'o', "output", "file", "Output file (replay stats)"},
{OE::CMD, 0 , "", "command,[...]", "The command to execute"},
}

Definitions of command line parameters.

anonymous_namespace{loadplay.cpp}::USAGE
const char *const USAGE
The short usage string.
Definition: loadplay.cpp:54