cmd_ln.h File Reference

Command-line and other configurationparsing and handling. More...

`#include <stdio.h>`
`#include <stdarg.h>`
`#include <sphinxbase/sphinxbase_export.h>`
`#include <sphinxbase/prim_type.h>`

Go to the source code of this file.

## Data Structures

struct | arg_s

## Typedefs

typedef struct arg_s | arg_t

## Values for arg_t::type

#define | ARG_REQUIRED (1<<0)
| Bit indicating a required argument.
#define | ARG_INTEGER (1<<1)
| Integer argument (optional).
#define | ARG_FLOATING (1<<2)
| Floating point argument (optional).
#define | ARG_STRING (1<<3)
| String argument (optional).
#define | ARG_BOOLEAN (1<<4)
| Boolean (true/false) argument (optional).
#define | ARG_STRING_LIST (1<<5)
| Boolean (true/false) argument (optional).
#define | REQARG_INTEGER (ARG_INTEGER | ARG_REQUIRED)
| Required integer argument.
#define | REQARG_FLOATING (ARG_FLOATING | ARG_REQUIRED)
| Required floating point argument.
#define | REQARG_STRING (ARG_STRING | ARG_REQUIRED)
| Required string argument.
#define | REQARG_BOOLEAN (ARG_BOOLEAN | ARG_REQUIRED)
| Required boolean argument.
#define | ARG_INT32 ARG_INTEGER
#define | ARG_FLOAT32 ARG_FLOATING
#define | ARG_FLOAT64 ARG_FLOATING
#define | REQARG_INT32 (ARG_INT32 | ARG_REQUIRED)
#define | REQARG_FLOAT32 (ARG_FLOAT32 | ARG_REQUIRED)
#define | REQARG_FLOAT64 (ARG_FLOAT64 | ARG_REQUIRED)
#define | ARG_STRINGIFY(s)
| Helper macro to stringify enums and other non-string values for default arguments.
#define | ARG_STRINGIFY1(s)
#define | cmd_ln_boolean_r(c, n)
| Retrieve a boolean value from a command-line object.
#define | cmd_ln_set_boolean_r(c, n, b)
| Set a boolean value in a command-line object.
#define | cmd_ln_int32_r(c, n)
#define | cmd_ln_float32_r(c, n)
#define | cmd_ln_float64_r(c, n)
#define | cmd_ln_set_int32_r(c, n, i)
#define | cmd_ln_set_float32_r(c, n, f)
#define | cmd_ln_set_float64_r(c, n, f)
#define | cmd_ln_exists(name)
| Test the existence of a command-line argument in the global set of definitions.
#define | cmd_ln_access(name)
| Return a pointer to the previously parsed value for the given argument name.
#define | cmd_ln_str(name)
| Retrieve a string from the global command line.
#define | cmd_ln_str_list(name)
| Retrieve an array of strings in the global command line.
#define | cmd_ln_int32(name)
| Retrieve a 32-bit integer from the global command line.
#define | cmd_ln_float32(name)
| Retrieve a 32-bit float from the global command line.
#define | cmd_ln_float64(name)
| Retrieve a 64-bit float from the global command line.
#define | cmd_ln_boolean(name)
| Retrieve a boolean from the global command line.
#define | cmd_ln_set_str(n, s)
| Set a string in the global command line.
#define | cmd_ln_set_int32(n, i)
| Set a 32-bit integer value in the global command line.
#define | cmd_ln_set_float32(n, f)
| Set a 32-bit float in the global command line.
#define | cmd_ln_set_float64(n, f)
| Set a 64-bit float in the global command line.
#define | cmd_ln_set_boolean(n, b)
| Set a boolean value in the global command line.
#define | cmd_ln_print_help(f, d)
| Print a help message listing the valid argument names, and the associated attributes as given in defn.
typedef struct cmd_ln_s | cmd_ln_t
SPHINXBASE_EXPORT cmd_ln_t * | cmd_ln_init (cmd_ln_t *inout_cmdln, arg_t const *defn, int32 strict,...)
| Create a cmd_ln_t from NULL-terminated list of arguments.
SPHINXBASE_EXPORT cmd_ln_t * | cmd_ln_retain (cmd_ln_t *cmdln)
| Retain ownership of a command-line argument set.
SPHINXBASE_EXPORT int | cmd_ln_free_r (cmd_ln_t *cmdln)
| Release a command-line argument set and all associated strings.
SPHINXBASE_EXPORT cmd_ln_t * | cmd_ln_parse_r (cmd_ln_t *inout_cmdln, arg_t const *defn, int32 argc, char *argv[], int32 strict)
| Parse a list of strings into argumetns.
SPHINXBASE_EXPORT cmd_ln_t * | cmd_ln_parse_file_r (cmd_ln_t *inout_cmdln, arg_t const *defn, char const *filename, int32 strict)
| Parse an arguments file by deliminating on " \r\t\n" and putting each tokens into an argv[] for cmd_ln_parse().
SPHINXBASE_EXPORT anytype_t * | cmd_ln_access_r (cmd_ln_t *cmdln, char const *name)
| Access the generic type union for a command line argument.
SPHINXBASE_EXPORT char const * | cmd_ln_str_r (cmd_ln_t *cmdln, char const *name)
| Retrieve a string from a command-line object.
SPHINXBASE_EXPORT char const ** | cmd_ln_str_list_r (cmd_ln_t *cmdln, char const *name)
| Retrieve an array of strings from a command-line object.
SPHINXBASE_EXPORT long | cmd_ln_int_r (cmd_ln_t *cmdln, char const *name)
| Retrieve an integer from a command-line object.
SPHINXBASE_EXPORT double | cmd_ln_float_r (cmd_ln_t *cmdln, char const *name)
| Retrieve a floating-point number from a command-line object.
SPHINXBASE_EXPORT void | cmd_ln_set_str_r (cmd_ln_t *cmdln, char const *name, char const *str)
| Set a string in a command-line object.
SPHINXBASE_EXPORT void | cmd_ln_set_str_extra_r (cmd_ln_t *cmdln, char const *name, char const *str)
| Set a string in a command-line object even if it is not present in argument description.
SPHINXBASE_EXPORT void | cmd_ln_set_int_r (cmd_ln_t *cmdln, char const *name, long iv)
| Set an integer in a command-line object.
SPHINXBASE_EXPORT void | cmd_ln_set_float_r (cmd_ln_t *cmdln, char const *name, double fv)
| Set a floating-point number in a command-line object.
SPHINXBASE_EXPORT int | cmd_ln_exists_r (cmd_ln_t *cmdln, char const *name)
| Re-entrant version of cmd_ln_exists().
SPHINXBASE_EXPORT void | cmd_ln_print_help_r (cmd_ln_t *cmdln, FILE *fp, const arg_t *defn)
| Print a help message listing the valid argument names, and the associated attributes as given in defn.
SPHINXBASE_EXPORT void | cmd_ln_print_values_r (cmd_ln_t *cmdln, FILE *fp, const arg_t *defn)
| Print current configuration values and defaults.
SPHINXBASE_EXPORT int32 | cmd_ln_parse (const arg_t *defn, int32 argc, char *argv[], int32 strict)
| Non-reentrant version of cmd_ln_parse().
SPHINXBASE_EXPORT int32 | cmd_ln_parse_file (const arg_t *defn, char const *filename, int32 strict)
| Parse an arguments file by deliminating on " \r\t\n" and putting each tokens into an argv[] for cmd_ln_parse().
SPHINXBASE_EXPORT void | cmd_ln_appl_enter (int argc, char *argv[], char const *default_argfn, const arg_t *defn)
| Old application initialization routine for Sphinx3 code.
SPHINXBASE_EXPORT void | cmd_ln_appl_exit (void)
| Finalization routine corresponding to cmd_ln_appl_enter().
SPHINXBASE_EXPORT cmd_ln_t * | cmd_ln_get (void)
| Retrieve the global cmd_ln_t object used by non-re-entrant functions.
SPHINXBASE_EXPORT void | cmd_ln_free (void)
| Free the global command line, if any exists.

## Detailed Description

Command-line and other configurationparsing and handling.

Configuration parameters, optionally parsed from the command line.

Definition in file cmd_ln.h.

## Macro Definition Documentation

## ARG_BOOLEAN

#define ARG_BOOLEAN (1<<4)

Boolean (true/false) argument (optional).

Definition at line 118 of file cmd_ln.h.

## ARG_FLOAT32

#define ARG_FLOAT32 ARG_FLOATING

Deprecated
  Use ARG_FLOATING instead.

Definition at line 148 of file cmd_ln.h.

## ARG_FLOAT64

#define ARG_FLOAT64 ARG_FLOATING

Deprecated
  Use ARG_FLOATING instead.

Definition at line 152 of file cmd_ln.h.

## ARG_FLOATING

#define ARG_FLOATING (1<<2)

Floating point argument (optional).

Definition at line 110 of file cmd_ln.h.

## ARG_INT32

#define ARG_INT32 ARG_INTEGER

Deprecated
  Use ARG_INTEGER instead.

Definition at line 144 of file cmd_ln.h.

## ARG_INTEGER

#define ARG_INTEGER (1<<1)

Integer argument (optional).

Definition at line 106 of file cmd_ln.h.

## ARG_REQUIRED

#define ARG_REQUIRED (1<<0)

Bit indicating a required argument.

Definition at line 102 of file cmd_ln.h.

Referenced by cmd_ln_parse_r().

## ARG_STRING

#define ARG_STRING (1<<3)

String argument (optional).

Definition at line 114 of file cmd_ln.h.

Referenced by cmd_ln_parse_r(), and cmd_ln_set_str_extra_r().

## ARG_STRING_LIST

#define ARG_STRING_LIST (1<<5)

Boolean (true/false) argument (optional).

Definition at line 122 of file cmd_ln.h.

## ARG_STRINGIFY

#define ARG_STRINGIFY | ( |  | s | ) |

Value:
ARG_STRINGIFY1(s)

Helper macro to stringify enums and other non-string values for default arguments.

Definition at line 172 of file cmd_ln.h.

## ARG_STRINGIFY1

#define ARG_STRINGIFY1 | ( |  | s | ) |

Value:
#s

Definition at line 173 of file cmd_ln.h.

## cmd_ln_access

#define cmd_ln_access | ( |  | name | ) |

Value:
cmd_ln_access_r(cmd_ln_get(), name)
cmd_ln_access_r
SPHINXBASE_EXPORT anytype_t * cmd_ln_access_r(cmd_ln_t *cmdln, char const *name)
Access the generic type union for a command line argument.
Definition cmd_ln.c:938
cmd_ln_get
SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_get(void)
Retrieve the global cmd_ln_t object used by non-re-entrant functions.
Definition cmd_ln.c:493

Return a pointer to the previously parsed value for the given argument name.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_access_r().

Definition at line 505 of file cmd_ln.h.

## cmd_ln_boolean

#define cmd_ln_boolean | ( |  | name | ) |

Value:
cmd_ln_boolean_r(cmd_ln_get(), name)
cmd_ln_boolean_r
#define cmd_ln_boolean_r(c, n)
Retrieve a boolean value from a command-line object.
Definition cmd_ln.h:334

Retrieve a boolean from the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_boolean_r().

Definition at line 550 of file cmd_ln.h.

## cmd_ln_boolean_r

#define cmd_ln_boolean_r | ( |  | c,
|  |  | n )

Value:
(cmd_ln_int_r(c,n) != 0)
cmd_ln_int_r
SPHINXBASE_EXPORT long cmd_ln_int_r(cmd_ln_t *cmdln, char const *name)
Retrieve an integer from a command-line object.
Definition cmd_ln.c:969

Retrieve a boolean value from a command-line object.

Definition at line 334 of file cmd_ln.h.

## cmd_ln_exists

#define cmd_ln_exists | ( |  | name | ) |

Value:
cmd_ln_exists_r(cmd_ln_get(), name)
cmd_ln_exists_r
SPHINXBASE_EXPORT int cmd_ln_exists_r(cmd_ln_t *cmdln, char const *name)
Re-entrant version of cmd_ln_exists().
Definition cmd_ln.c:929

Test the existence of a command-line argument in the global set of definitions.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_exists_r().

Returns
  True if the command line argument exists (i.e. it was one of the arguments defined in the call to cmd_ln_parse().

Definition at line 497 of file cmd_ln.h.

## cmd_ln_float32

#define cmd_ln_float32 | ( |  | name | ) |

Value:
(float32)cmd_ln_float_r(cmd_ln_get(), name)
cmd_ln_float_r
SPHINXBASE_EXPORT double cmd_ln_float_r(cmd_ln_t *cmdln, char const *name)
Retrieve a floating-point number from a command-line object.
Definition cmd_ln.c:979

Retrieve a 32-bit float from the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_float_r().

Definition at line 536 of file cmd_ln.h.

## cmd_ln_float32_r

#define cmd_ln_float32_r | ( |  | c,
|  |  | n )

Value:
(float32)cmd_ln_float_r(c,n)

Definition at line 389 of file cmd_ln.h.

## cmd_ln_float64

#define cmd_ln_float64 | ( |  | name | ) |

Value:
(float64)cmd_ln_float_r(cmd_ln_get(), name)

Retrieve a 64-bit float from the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_float_r().

Definition at line 543 of file cmd_ln.h.

## cmd_ln_float64_r

#define cmd_ln_float64_r | ( |  | c,
|  |  | n )

Value:
(float64)cmd_ln_float_r(c,n)

Definition at line 390 of file cmd_ln.h.

## cmd_ln_int32

#define cmd_ln_int32 | ( |  | name | ) |

Value:
(int32)cmd_ln_int_r(cmd_ln_get(), name)

Retrieve a 32-bit integer from the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_int_r().

Definition at line 529 of file cmd_ln.h.

## cmd_ln_int32_r

#define cmd_ln_int32_r | ( |  | c,
|  |  | n )

Value:
(int32)cmd_ln_int_r(c,n)

Definition at line 388 of file cmd_ln.h.

## cmd_ln_print_help

#define cmd_ln_print_help | ( |  | f,
|  |  | d )

Value:
cmd_ln_print_help_r(cmd_ln_get(),f,d)
cmd_ln_print_help_r
SPHINXBASE_EXPORT void cmd_ln_print_help_r(cmd_ln_t *cmdln, FILE *fp, const arg_t *defn)
Print a help message listing the valid argument names, and the associated attributes as given in defn...
Definition cmd_ln.c:911

Print a help message listing the valid argument names, and the associated attributes as given in defn.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_print_help_r().

Definition at line 595 of file cmd_ln.h.

Referenced by cmd_ln_appl_enter().

## cmd_ln_set_boolean

#define cmd_ln_set_boolean | ( |  | n,
|  |  | b )

Value:
cmd_ln_set_boolean_r(cmd_ln_get(),n,b)
cmd_ln_set_boolean_r
#define cmd_ln_set_boolean_r(c, n, b)
Set a boolean value in a command-line object.
Definition cmd_ln.h:383

Set a boolean value in the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_set_boolean_r().

Definition at line 586 of file cmd_ln.h.

## cmd_ln_set_boolean_r

#define cmd_ln_set_boolean_r | ( |  | c,
|  |  | n,
|  |  | b )

Value:
(cmd_ln_set_int_r(c,n,(b)!=0))
cmd_ln_set_int_r
SPHINXBASE_EXPORT void cmd_ln_set_int_r(cmd_ln_t *cmdln, char const *name, long iv)
Set an integer in a command-line object.
Definition cmd_ln.c:1015

Set a boolean value in a command-line object.

Definition at line 383 of file cmd_ln.h.

## cmd_ln_set_float32

#define cmd_ln_set_float32 | ( |  | n,
|  |  | f )

Value:
cmd_ln_set_float_r(cmd_ln_get(),n,f)
cmd_ln_set_float_r
SPHINXBASE_EXPORT void cmd_ln_set_float_r(cmd_ln_t *cmdln, char const *name, double fv)
Set a floating-point number in a command-line object.
Definition cmd_ln.c:1027

Set a 32-bit float in the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_set_float_r().

Definition at line 572 of file cmd_ln.h.

## cmd_ln_set_float32_r

#define cmd_ln_set_float32_r | ( |  | c,
|  |  | n,
|  |  | f )

Value:
cmd_ln_set_float_r(c,n,(double)f)

Definition at line 392 of file cmd_ln.h.

## cmd_ln_set_float64

#define cmd_ln_set_float64 | ( |  | n,
|  |  | f )

Value:
cmd_ln_set_float_r(cmd_ln_get(),n,f)

Set a 64-bit float in the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_set_float_r().

Definition at line 579 of file cmd_ln.h.

## cmd_ln_set_float64_r

#define cmd_ln_set_float64_r | ( |  | c,
|  |  | n,
|  |  | f )

Value:
cmd_ln_set_float_r(c,n,(double)f)

Definition at line 393 of file cmd_ln.h.

## cmd_ln_set_int32

#define cmd_ln_set_int32 | ( |  | n,
|  |  | i )

Value:
cmd_ln_set_int_r(cmd_ln_get(),n,i)

Set a 32-bit integer value in the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_set_int_r().

Definition at line 565 of file cmd_ln.h.

## cmd_ln_set_int32_r

#define cmd_ln_set_int32_r | ( |  | c,
|  |  | n,
|  |  | i )

Value:
cmd_ln_set_int_r(c,n,i)

Definition at line 391 of file cmd_ln.h.

## cmd_ln_set_str

#define cmd_ln_set_str | ( |  | n,
|  |  | s )

Value:
cmd_ln_set_str_r(cmd_ln_get(),n,s)
cmd_ln_set_str_r
SPHINXBASE_EXPORT void cmd_ln_set_str_r(cmd_ln_t *cmdln, char const *name, char const *str)
Set a string in a command-line object.
Definition cmd_ln.c:989

Set a string in the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_set_str_r().

Definition at line 558 of file cmd_ln.h.

## cmd_ln_str

#define cmd_ln_str | ( |  | name | ) |

Value:
cmd_ln_str_r(cmd_ln_get(), name)
cmd_ln_str_r
SPHINXBASE_EXPORT char const * cmd_ln_str_r(cmd_ln_t *cmdln, char const *name)
Retrieve a string from a command-line object.
Definition cmd_ln.c:949

Retrieve a string from the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_str_r().

Definition at line 513 of file cmd_ln.h.

## cmd_ln_str_list

#define cmd_ln_str_list | ( |  | name | ) |

Value:
cmd_ln_str_list_r(cmd_ln_get(), name)
cmd_ln_str_list_r
SPHINXBASE_EXPORT char const ** cmd_ln_str_list_r(cmd_ln_t *cmdln, char const *name)
Retrieve an array of strings from a command-line object.
Definition cmd_ln.c:959

Retrieve an array of strings in the global command line.

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_str_list_r().

Definition at line 521 of file cmd_ln.h.

## REQARG_BOOLEAN

#define REQARG_BOOLEAN (ARG_BOOLEAN | ARG_REQUIRED)

Required boolean argument.

Definition at line 139 of file cmd_ln.h.

## REQARG_FLOAT32

#define REQARG_FLOAT32 (ARG_FLOAT32 | ARG_REQUIRED)

Deprecated
  Use REQARG_FLOATING instead.

Definition at line 160 of file cmd_ln.h.

## REQARG_FLOAT64

#define REQARG_FLOAT64 (ARG_FLOAT64 | ARG_REQUIRED)

Deprecated
  Use REQARG_FLOATING instead.

Definition at line 164 of file cmd_ln.h.

## REQARG_FLOATING

#define REQARG_FLOATING (ARG_FLOATING | ARG_REQUIRED)

Required floating point argument.

Definition at line 131 of file cmd_ln.h.

## REQARG_INT32

#define REQARG_INT32 (ARG_INT32 | ARG_REQUIRED)

Deprecated
  Use REQARG_INTEGER instead.

Definition at line 156 of file cmd_ln.h.

## REQARG_INTEGER

#define REQARG_INTEGER (ARG_INTEGER | ARG_REQUIRED)

Required integer argument.

Definition at line 127 of file cmd_ln.h.

## REQARG_STRING

#define REQARG_STRING (ARG_STRING | ARG_REQUIRED)

Required string argument.

Definition at line 135 of file cmd_ln.h.

## Typedef Documentation

## cmd_ln_t

typedef struct cmd_ln_s cmd_ln_t

Definition at line 179 of file cmd_ln.h.

## Function Documentation

## cmd_ln_access_r()

SPHINXBASE_EXPORT anytype_t * cmd_ln_access_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name )

Access the generic type union for a command line argument.

Definition at line 938 of file cmd_ln.c.

References cmd_ln_access_r(), E_ERROR, and hash_table_lookup().

Referenced by cmd_ln_access_r(), cmd_ln_float_r(), cmd_ln_int_r(), cmd_ln_set_float_r(), cmd_ln_set_int_r(), cmd_ln_set_str_r(), cmd_ln_str_list_r(), and cmd_ln_str_r().

## cmd_ln_appl_enter()

SPHINXBASE_EXPORT void cmd_ln_appl_enter | ( | int | argc,
|  | char * | argv[],
|  | char const * | default_argfn,
|  | const arg_t * | defn )

Old application initialization routine for Sphinx3 code.

Deprecated
  This is deprecated in favor of the re-entrant API.

Parameters

  argc | In: Number of actual arguments
  argv | In: Number of actual arguments
  default_argfn | In: default argument file name
  defn | Command-line argument definition

Definition at line 499 of file cmd_ln.c.

References cmd_ln_appl_enter(), cmd_ln_parse(), cmd_ln_parse_file(), cmd_ln_print_help, E_INFO, and E_INFOCONT.

Referenced by cmd_ln_appl_enter().

## cmd_ln_appl_exit()

SPHINXBASE_EXPORT void cmd_ln_appl_exit | ( | void |  | ) |

Finalization routine corresponding to cmd_ln_appl_enter().

Deprecated
  This is deprecated in favor of the re-entrant API.

Definition at line 549 of file cmd_ln.c.

References cmd_ln_free().

## cmd_ln_exists_r()

SPHINXBASE_EXPORT int cmd_ln_exists_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name )

Re-entrant version of cmd_ln_exists().

Returns
  True if the command line argument exists (i.e. it was one of the arguments defined in the call to cmd_ln_parse_r().

Definition at line 929 of file cmd_ln.c.

References cmd_ln_exists_r(), and hash_table_lookup().

Referenced by cmd_ln_exists_r(), cmd_ln_parse_r(), and ngram_model_read().

## cmd_ln_float_r()

SPHINXBASE_EXPORT double cmd_ln_float_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name )

Retrieve a floating-point number from a command-line object.

Parameters

  cmdln | Command-line object.
  name | the command-line flag to retrieve.

Returns
  the float value associated with name, or 0.0 if name does not exist. You must use cmd_ln_exists_r() to distinguish between cases where a value is legitimately zero and where the corresponding flag is unknown.

Definition at line 979 of file cmd_ln.c.

References cmd_ln_access_r(), and cmd_ln_float_r().

Referenced by cmd_ln_float_r().

## cmd_ln_free()

SPHINXBASE_EXPORT void cmd_ln_free | ( | void |  | ) |

Free the global command line, if any exists.

Deprecated
  Use the re-entrant API instead.

Definition at line 1082 of file cmd_ln.c.

References cmd_ln_free_r().

Referenced by cmd_ln_appl_exit().

## cmd_ln_free_r()

SPHINXBASE_EXPORT int cmd_ln_free_r | ( | cmd_ln_t * | cmdln | ) |

Release a command-line argument set and all associated strings.

Returns
  new reference count (0 if freed completely)

Definition at line 1046 of file cmd_ln.c.

References ckd_free(), cmd_ln_free_r(), glist_free(), gnode_ptr, hash_table_free(), hash_table_tolist(), and hash_entry_s::val.

Referenced by cmd_ln_free(), cmd_ln_free_r(), and cmd_ln_parse_r().

## cmd_ln_get()

SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_get | ( | void |  | ) |

Retrieve the global cmd_ln_t object used by non-re-entrant functions.

Deprecated
  This is deprecated in favor of the re-entrant API.

Returns
  global cmd_ln_t object.

Definition at line 493 of file cmd_ln.c.

## cmd_ln_init()

SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_init | ( | cmd_ln_t * | inout_cmdln,
|  | arg_t const * | defn,
|  | int32 | strict,
|  |  | ... )

Create a cmd_ln_t from NULL-terminated list of arguments.

This function creates a cmd_ln_t from a NULL-terminated list of argument strings. For example, to create the equivalent of passing "-hmm foodir -dsratio 2 -lm bar.lm" on the command-line:

config = cmd_ln_init(NULL, defs, TRUE, "-hmm", "foodir", "-dsratio", "2", "-lm", "bar.lm", NULL);

Note that for simplicity, all arguments are passed as strings, regardless of the actual underlying type.

Parameters

  inout_cmdln | Previous command-line to update, or NULL to create a new one.
  defn | Array of argument name definitions, or NULL to allow any arguments.
  strict | Whether to fail on duplicate or unknown arguments.

Returns
  A cmd_ln_t* containing the results of command line parsing, or NULL on failure.

Definition at line 709 of file cmd_ln.c.

References ckd_calloc, ckd_salloc, cmd_ln_init(), and E_ERROR.

Referenced by cmd_ln_init().

## cmd_ln_int_r()

SPHINXBASE_EXPORT long cmd_ln_int_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name )

Retrieve an integer from a command-line object.

Parameters

  cmdln | Command-line object.
  name | the command-line flag to retrieve.

Returns
  the integer value associated with name, or 0 if name does not exist. You must use cmd_ln_exists_r() to distinguish between cases where a value is legitimately zero and where the corresponding flag is unknown.

Definition at line 969 of file cmd_ln.c.

References cmd_ln_access_r(), and cmd_ln_int_r().

Referenced by cmd_ln_int_r().

## cmd_ln_parse()

SPHINXBASE_EXPORT int32 cmd_ln_parse | ( | const arg_t * | defn,
|  | int32 | argc,
|  | char * | argv[],
|  | int32 | strict )

Non-reentrant version of cmd_ln_parse().

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_parse_r().

Returns
  0 if successful, <0 if error.

Parameters

  defn | In: Array of argument name definitions
  argc | In: Number of actual arguments
  argv | In: Actual arguments
  strict | In: Fail on duplicate or unknown arguments, or no arguments?

Definition at line 746 of file cmd_ln.c.

References cmd_ln_parse(), cmd_ln_parse_r(), and E_ERROR.

Referenced by cmd_ln_appl_enter(), and cmd_ln_parse().

## cmd_ln_parse_file()

SPHINXBASE_EXPORT int32 cmd_ln_parse_file | ( | const arg_t * | defn,
|  | char const * | filename,
|  | int32 | strict )

Parse an arguments file by deliminating on " \r\t\n" and putting each tokens into an argv[] for cmd_ln_parse().

Deprecated
  This is deprecated in favor of the re-entrant API function cmd_ln_parse_file_r().

Returns
  0 if successful, <0 on error.

Parameters

  defn | In: Array of argument name definitions
  filename | In: A file that contains all the arguments
  strict | In: Fail on duplicate or unknown arguments, or no arguments?

Definition at line 895 of file cmd_ln.c.

References cmd_ln_parse_file(), and cmd_ln_parse_file_r().

Referenced by cmd_ln_appl_enter(), and cmd_ln_parse_file().

## cmd_ln_parse_file_r()

SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_parse_file_r | ( | cmd_ln_t * | inout_cmdln,
|  | arg_t const * | defn,
|  | char const * | filename,
|  | int32 | strict )

Parse an arguments file by deliminating on " \r\t\n" and putting each tokens into an argv[] for cmd_ln_parse().

Returns
  A cmd_ln_t containing the results of command line parsing, or NULL on failure.

Parameters

  inout_cmdln | In/Out: Previous command-line to update, or NULL to create a new one.
  defn | In: Array of argument name definitions
  filename | In: A file that contains all the arguments
  strict | In: Fail on duplicate or unknown arguments, or no arguments?

Definition at line 764 of file cmd_ln.c.

References ckd_calloc, ckd_free(), ckd_realloc, ckd_salloc, cmd_ln_parse_file_r(), E_ERROR, and E_WARN.

Referenced by cmd_ln_parse_file(), and cmd_ln_parse_file_r().

## cmd_ln_parse_r()

SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_parse_r | ( | cmd_ln_t * | inout_cmdln,
|  | arg_t const * | defn,
|  | int32 | argc,
|  | char * | argv[],
|  | int32 | strict )

Parse a list of strings into argumetns.

Parse the given list of arguments (name-value pairs) according to the given definitions. Argument values can be retrieved in future using cmd_ln_access(). argv[0] is assumed to be the program name and skipped. Any unknown argument name causes a fatal error. The routine also prints the prevailing argument values (to stderr) after parsing.

Note
  It is currently assumed that the strings in argv are allocated statically, or at least that they will be valid as long as the cmd_ln_t returned from this function. Unpredictable behaviour will result if they are freed or otherwise become invalidated.

Returns
  A cmd_ln_t containing the results of command line parsing, or NULL on failure.

Parameters

  inout_cmdln | In/Out: Previous command-line to update, or NULL to create a new one.
  defn | In: Array of argument name definitions
  argc | In: Number of actual arguments
  argv | In: Actual arguments
  strict | In: Fail on duplicate or unknown arguments, or no arguments?

Definition at line 556 of file cmd_ln.c.

References ARG_REQUIRED, ARG_STRING, ckd_calloc, cmd_ln_exists_r(), cmd_ln_free_r(), cmd_ln_parse_r(), cmd_ln_print_help_r(), cmd_ln_print_values_r(), E_ERROR, err_get_logfp(), hash_table_enter(), hash_table_free(), hash_table_lookup(), hash_table_new(), and hash_table_replace().

Referenced by cmd_ln_parse(), and cmd_ln_parse_r().

## cmd_ln_print_help_r()

SPHINXBASE_EXPORT void cmd_ln_print_help_r | ( | cmd_ln_t * | cmdln,
|  | FILE * | fp,
|  | const arg_t * | defn )

Print a help message listing the valid argument names, and the associated attributes as given in defn.

Parameters

  cmdln | command-line object
  fp | output stream
  defn | array of argument name definitions.

Definition at line 911 of file cmd_ln.c.

References cmd_ln_print_help_r().

Referenced by cmd_ln_parse_r(), and cmd_ln_print_help_r().

## cmd_ln_print_values_r()

SPHINXBASE_EXPORT void cmd_ln_print_values_r | ( | cmd_ln_t * | cmdln,
|  | FILE * | fp,
|  | const arg_t * | defn )

Print current configuration values and defaults.

Parameters

  cmdln | command-line object
  fp | output stream
  defn | array of argument name definitions.

Definition at line 920 of file cmd_ln.c.

References cmd_ln_print_values_r().

Referenced by cmd_ln_parse_r(), and cmd_ln_print_values_r().

## cmd_ln_retain()

SPHINXBASE_EXPORT cmd_ln_t * cmd_ln_retain | ( | cmd_ln_t * | cmdln | ) |

Retain ownership of a command-line argument set.

Returns
  pointer to retained command-line argument set.

Definition at line 1039 of file cmd_ln.c.

References cmd_ln_retain().

Referenced by cmd_ln_retain().

## cmd_ln_set_float_r()

SPHINXBASE_EXPORT void cmd_ln_set_float_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name,
|  | double | fv )

Set a floating-point number in a command-line object.

Parameters

  cmdln | Command-line object.
  name | The command-line flag to set.
  fv | Integer value to set.

Definition at line 1027 of file cmd_ln.c.

References cmd_ln_access_r(), cmd_ln_set_float_r(), and E_ERROR.

Referenced by cmd_ln_set_float_r().

## cmd_ln_set_int_r()

SPHINXBASE_EXPORT void cmd_ln_set_int_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name,
|  | long | iv )

Set an integer in a command-line object.

Parameters

  cmdln | Command-line object.
  name | The command-line flag to set.
  iv | Integer value to set.

Definition at line 1015 of file cmd_ln.c.

References cmd_ln_access_r(), cmd_ln_set_int_r(), and E_ERROR.

Referenced by cmd_ln_set_int_r().

## cmd_ln_set_str_extra_r()

SPHINXBASE_EXPORT void cmd_ln_set_str_extra_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name,
|  | char const * | str )

Set a string in a command-line object even if it is not present in argument description.

Useful for setting extra values computed from configuration, propagated to other parts.

Parameters

  cmdln | Command-line object.
  name | The command-line flag to set.
  str | String value to set. The command-line object does not retain ownership of this pointer.

Definition at line 1002 of file cmd_ln.c.

References ARG_STRING, ckd_free(), ckd_salloc, cmd_ln_set_str_extra_r(), hash_table_enter(), and hash_table_lookup().

Referenced by cmd_ln_set_str_extra_r().

## cmd_ln_set_str_r()

SPHINXBASE_EXPORT void cmd_ln_set_str_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name,
|  | char const * | str )

Set a string in a command-line object.

Parameters

  cmdln | Command-line object.
  name | The command-line flag to set.
  str | String value to set. The command-line object does not retain ownership of this pointer.

Definition at line 989 of file cmd_ln.c.

References ckd_free(), ckd_salloc, cmd_ln_access_r(), cmd_ln_set_str_r(), and E_ERROR.

Referenced by cmd_ln_set_str_r().

## cmd_ln_str_list_r()

SPHINXBASE_EXPORT char const ** cmd_ln_str_list_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name )

Retrieve an array of strings from a command-line object.

The command-line object retains ownership of this array, so you should not attempt to free it manually.

Parameters

  cmdln | Command-line object.
  name | the command-line flag to retrieve.

Returns
  the array of strings associated with name, or NULL if name does not exist. You must use cmd_ln_exists_r() to distinguish between cases where a value is legitimately NULL and where the corresponding flag is unknown.

Definition at line 959 of file cmd_ln.c.

References cmd_ln_access_r(), and cmd_ln_str_list_r().

Referenced by cmd_ln_str_list_r().

## cmd_ln_str_r()

SPHINXBASE_EXPORT char const * cmd_ln_str_r | ( | cmd_ln_t * | cmdln,
|  | char const * | name )

Retrieve a string from a command-line object.

The command-line object retains ownership of this string, so you should not attempt to free it manually.

Parameters

  cmdln | Command-line object.
  name | the command-line flag to retrieve.

Returns
  the string value associated with name, or NULL if name does not exist. You must use cmd_ln_exists_r() to distinguish between cases where a value is legitimately NULL and where the corresponding flag is unknown.

Definition at line 949 of file cmd_ln.c.

References cmd_ln_access_r(), and cmd_ln_str_r().

Referenced by cmd_ln_str_r().