#include "temu-c/Support/Attributes.h"
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
TEMU_API int | temu_parseCommandLineOptions (int argc, const char *argv[]) |
|
TEMU_API void | temu_printCommandLineHelp (void) |
|
TEMU_API int | temu_execCommandFile (const char *File) |
|
TEMU_API int | temu_execCommand (const char *Cmd) |
|
TEMU_API void * | temu_createCmd (const char *Name, temu_CommandFunc F, const char *Doc, void *Data) |
|
TEMU_API void | temu_cmdAddOption (void *Cmd, const char *OptName, temu_CmdOptionKind Type, int Required, const char *Doc, const char *Default) |
|
TEMU_API void * | temu_cmdGetData (void *Ctxt) |
|
TEMU_API void * | temu_cmdGetInterpreter (void *Ctxt) |
|
TEMU_API int64_t | temu_cmdGetOptionAsInteger (void *Ctxt, const char *OptName) |
|
TEMU_API void * | temu_cmdGetOptionAsObject (void *Ctxt, const char *OptName) |
|
TEMU_API const char * | temu_cmdGetOptionAsString (void *Ctxt, const char *OptName) |
|
TEMU_API double | temu_cmdGetOptionAsReal (void *Ctxt, const char *OptName) |
|
TEMU_API size_t | temu_cmdGetPosOptSize (void *Ctxt) |
|
TEMU_API const char * | temu_cmdGetPosOpt (void *Ctxt, size_t Idx) |
|
TEMU_API int | temu_cmdOptionIsValid (void *Ctxt, const char *OptName) |
|
TEMU_API int | temu_cmdSetVariable (const char *Key, const char *Value) |
|
TEMU_API const char * | temu_cmdGetVariable (const char *Key) |
|
typedef int(* temu_CommandFunc)(void *) |
Option types.
Enumerator |
---|
teCOK_String |
|
teCOK_Path |
Path is a string, but with auto completion of file names.
|
teCOK_Object |
Object is a named object.
|
teCOK_Int |
Any integer number.
|
teCOK_Double |
|
teCOK_Prop |
|
teCOK_Iface |
|
Definition at line 61 of file CommandLine.h.
TEMU_API void temu_cmdAddOption |
( |
void * |
Cmd, |
|
|
const char * |
OptName, |
|
|
temu_CmdOptionKind |
Type, |
|
|
int |
Required, |
|
|
const char * |
Doc, |
|
|
const char * |
Default |
|
) |
| |
Add named argument to command
- Parameters
-
Cmd | Pointer to the command object |
OptName | Option name |
Type | Option type |
Required | Pass 0 if the option is not required, otherwise required |
Doc | Option documentation |
Default | Default value of the option |
TEMU_API void* temu_cmdGetData |
( |
void * |
Ctxt | ) |
|
Get data pointer from command context This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Pointer to the context of the command |
- Returns
- data pointer
TEMU_API void* temu_cmdGetInterpreter |
( |
void * |
Ctxt | ) |
|
Get pointer to the command interpreter This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Pointer to the context of the command |
- Returns
- Pointer to interpreter
TEMU_API int64_t temu_cmdGetOptionAsInteger |
( |
void * |
Ctxt, |
|
|
const char * |
OptName |
|
) |
| |
Get named option as integer from command context This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Command context |
OptName | Option name |
- Returns
- The integer bound to the named argument
TEMU_API void* temu_cmdGetOptionAsObject |
( |
void * |
Ctxt, |
|
|
const char * |
OptName |
|
) |
| |
Get named option as object pointer from command context This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Command context |
OptName | Option name |
- Returns
- Pointer to the option object
TEMU_API double temu_cmdGetOptionAsReal |
( |
void * |
Ctxt, |
|
|
const char * |
OptName |
|
) |
| |
Get named option as double from command context This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Command context |
OptName | Option name |
- Returns
- The real value of the option as double
TEMU_API const char* temu_cmdGetOptionAsString |
( |
void * |
Ctxt, |
|
|
const char * |
OptName |
|
) |
| |
Get named option as string from command context This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Command context |
OptName | Option name |
- Returns
- C-string of the name of the option
TEMU_API const char* temu_cmdGetPosOpt |
( |
void * |
Ctxt, |
|
|
size_t |
Idx |
|
) |
| |
Get positional option at index This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Command context |
Idx | Index of the option |
- Returns
- The option at position Idx as a C-string
TEMU_API size_t temu_cmdGetPosOptSize |
( |
void * |
Ctxt | ) |
|
Get number of positional options given This function shall be called in a command handler on the passed context.
- Parameters
-
- Returns
- The number of position optionals in Ctxt
TEMU_API const char* temu_cmdGetVariable |
( |
const char * |
Key | ) |
|
Get a variable in the command line
- Parameters
-
- Returns
- In case the variable is not found NULL, otherwise a borrowed string.
TEMU_API int temu_cmdOptionIsValid |
( |
void * |
Ctxt, |
|
|
const char * |
OptName |
|
) |
| |
Return 1 if the option is valid, 0 if invalid / not set This function shall be called in a command handler on the passed context.
- Parameters
-
Ctxt | Command context |
OptName | Option name |
- Returns
- 1 if the option is valid, 0 if invalid / not set
TEMU_API int temu_cmdSetVariable |
( |
const char * |
Key, |
|
|
const char * |
Value |
|
) |
| |
Set a variable in the command line
- Parameters
-
Key | Variable name (must match [A-Za-z_][A-Za-z0-9_]*) |
Value | Value to assign to variable |
- Returns
- Non-zero on errors
Create and register command
- Parameters
-
Name | Name of command |
F | Command function to invoke |
Doc | Documentation string |
Data | Data pointer. Some commands e.g. disassemble will increase the address between invocations. This must be saved in some data object which can be provided when the command is created. |
TEMU_API int temu_execCommand |
( |
const char * |
Cmd | ) |
|
Executes a single command
- Parameters
-
Cmd | The command to be executed |
- Returns
- 0 on success, otherwise a non-zero value
TEMU_API int temu_execCommandFile |
( |
const char * |
File | ) |
|
Executes the commands in the file "File"
- Parameters
-
File | Path to the file with the commands to be executed |
- Returns
- 0 on success, otherwise a non-zero value
TEMU_API int temu_parseCommandLineOptions |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Parses command line options The TEMU command supports a number of built in command line options. A simulator embedding TEMU may want initialise these options in the same way that the TEMU CLI does. Note that not all options are supported this way as some options will only be registered by the temu CLI application itself.
In general interactive options will not work (options that can be interpreted as a command). It is possible to use temu_printCommandLineHelp() to list currently registered options from an application that embedds temu.
- Parameters
-
argc | Number of arguments |
argv | Command line arguments |
- Returns
- 0 on success, otherwise non-zero value.
TEMU_API void temu_printCommandLineHelp |
( |
void |
| ) |
|
Print command line help to stdout