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_intExtract integer value from string.
ex_uintExtract unsigned integer value from string.
ex_wordExtract word from string.
ex_commandExtract command from string.
ex_word_skipSkip a word in a string.
ex_floatExtract float value from string.
ex_hourExtract hour value from string.
ex_command_skipSkip a command in a string.
ex_onExtract boolean value from string.
ex_on_or_offExtract boolean value from string.
ex_yesExtract boolean value from string.
ex_strExtract sub-string from string.


Functions


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

Extract integer value from string.

Parameters:

Returns: The value.
Multithreading Level: Unsafe


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

Extract unsigned integer value from string.

Parameters:

Returns: The value.
Multithreading Level: Unsafe


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

Extract word from string.

Parameters:

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:

Returns: The command.
Multithreading Level: Unsafe


CONST char * ex_word_skip (CONST char *str)

Skip a word in a string.

Parameters:

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:

Returns: The value.
Multithreading Level: Unsafe


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

Extract hour value from string.

Parameters:

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:

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:

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:

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:

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:

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


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services