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 (char *str, char **rest)

Extract integer value from string.

Parameters:

Returns: The value.
Multithreading Level: Unsafe


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

Extract unsigned integer value from string.

Parameters:

Returns: The value.
Multithreading Level: Unsafe


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

Extract word from string.

Parameters:

Returns: The word.
Multithreading Level: Unsafe


char * ex_command (char *str, 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


char * ex_word_skip (char *str)

Skip a word in a string.

Parameters:

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


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

Extract float value from string.

Parameters:

Returns: The value.
Multithreading Level: Unsafe


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

Extract hour value from string.

Parameters:

Returns: The value.
Multithreading Level: Unsafe


char * ex_command_skip (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 (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 (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 (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 (char *str, 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.

Parameters:

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


Contact: Richard Gooch
Web Development: Ariel Internet Services