# The "ex" Package

These routines are meant to provide a simple mechanism to extract numeric values and strings from strings.

Library: karma
Link With: -lkarma

#### Functions

ex_int | Extract integer value from string.
ex_uint | Extract unsigned integer value from string.
ex_word | Extract word from string.
ex_command | Extract command from string.
ex_word_skip | Skip a word in a string.
ex_float | Extract float value from string.
ex_hour | Extract hour value from string.
ex_command_skip | Skip a command in a string.
ex_on | Extract boolean value from string.
ex_on_or_off | Extract boolean value from string.
ex_yes | Extract boolean value from string.
ex_str | Extract sub-string from string.

## Functions

int ex_int (CONST char *str, CONST char **rest)

Extract integer value from string.

Parameters:

- str : The string to extract from.
- rest : A pointer beyond the value will be written here.

Returns: The value.
Multithreading Level: Unsafe

unsigned int ex_uint (CONST char *str, CONST char **rest)

Extract unsigned integer value from string.

Parameters:

- str : The string to extract from.
- rest : A pointer beyond the value will be written here.

Returns: The value.
Multithreading Level: Unsafe

char * ex_word (CONST char *str, CONST char **rest)

Extract word from string.

Parameters:

- str : The string to extract from.
- rest : A pointer beyond the word will be written here.

Returns: The word.
Multithreading Level: Unsafe

char * ex_command (CONST char *str, CONST char **rest)

This routine will extract a command from a string. The operation is similar to ex_word except that any of " \t/=?!" terminate a command.

Parameters:

- str : The string to extract from.
- rest : A pointer beyond the command will be written here.

Returns: The command.
Multithreading Level: Unsafe

CONST char * ex_word_skip (CONST char *str)

Skip a word in a string.

Parameters:

- str : The string.

Returns: The next part of the string.
Multithreading Level: Unsafe

double ex_float (CONST char *str, CONST char **rest)

Extract float value from string.

Parameters:

- str : The string to extract from.
- rest : A pointer beyond the value will be written here.

Returns: The value.
Multithreading Level: Unsafe

double ex_hour (CONST char *p, CONST char **nxt)

Extract hour value from string.

Parameters:

- p : The string to extract from.
- nxt : A pointer beyond the value will be written here.

Returns: The value.
Multithreading Level: Unsafe

CONST char * ex_command_skip (CONST char *str)

This routine skip a command in a string. The operation is similar to ex_word_skip except that any of " \t/=?!" terminate a command.

Parameters:

- str : The string.

Returns: The next part of the string.
Multithreading Level: Unsafe

int ex_on (CONST char **ptr)

This routine will extract a boolean value from string. The first command is skipped.

Parameters:

- ptr : A pointer to the string to extract from. This is advanced to the next word in the string if the current word matches "on" or "off".

Returns: TRUE unless the word is "off".
Multithreading Level: Unsafe

int ex_on_or_off (CONST char **ptr)

This routine will extract a boolean value from string.

Parameters:

- ptr : A pointer to the string to extract from. This is advanced to the next word in the string if the current word matches "on" or "off".

Returns: TRUE unless the word is "off".
Multithreading Level: Unsafe

int ex_yes (CONST char **ptr, int default_v)

This routine will extract a boolean value from string.

Parameters:

- ptr : A pointer to the string to extract from. This is advanced to the next word in the string if the current word matches "yes" or "no".
- default_v : The default value.

Returns: TRUE if the word is "yes", FALSE if the word is "no", else the default value.
Multithreading Level: Unsafe

char * ex_str (CONST char *str, CONST char **rest)

This routine will extract a sub-string from a string. The sub-string may be delimited by any number of whitespace characters. The double quote character may appear anywhere in the sub-string, and will force all whitespace characters except '\n' into the output string. A second double quote character unquotes the previous quote. These double quote characters are not copied, unless they are consecutive. If the string contains only two double quote characters, an empty string (i.e. only a '\0' character is present) is returned.

Parameters:

- str : The string to extract from.
- rest : A pointer beyond the value will be written here. If this is NULL, nothing is written here.

Returns: A pointer to a copy of the sub-string.
Multithreading Level: Unsafe

Back to Karma Home Page