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
Functions
int
ex_int (char *str, 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 (char *str, 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 (char *str, 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 (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:
- str :
The string to extract from.
- rest :
A pointer beyond the command will be written here.
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:
- 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 (char *p, 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
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:
- 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 (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 (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 (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:
- 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
Contact: Richard Gooch
Web Development: Ariel Internet Services