Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

string_util.h File Reference

String utilities. More...

Go to the source code of this file.

Functions


Detailed Description

String utilities.


Function Documentation

int string_util_bool_to_int const char *  txt  ) 
 

converts a true/false string to an int.

Parameters:
txt input text.
Returns:
Returns 1 if the input string equals "TRUE", "true", or "True", and 0 otherwise.

void string_util_cat char *  dest,
const char *  src,
int  maxlen
 

Appends a source string to a destination string.

Parameters:
dest Destination string.
src Source string.
maxlen Maximal length of the destination string.

int string_util_divide char *  buffer,
char  separator,
char **  first,
char **  second
 

Divides a string into two parts.

Divide a string buffer into two parts, separated by a separator character. The content of the string is changed by this function!

Parameters:
buffer The string to be separated.
separator The separator character.
first Pointer to the first string.
second Pointer to the second string.
Returns:
1 if successful, 0 if separator not found

int string_util_fast_trim char *  txt,
char **  dest,
int  remove_quote
 

Remove leading and trailing whitespaces.

Parameters:
txt Input string.
dest A pointer where to store the result.
remove_quote If != 0, also remove enclosing double quote characters. In opposite to string_util_trim(), this function does not left-shift the string, but returns a pointer to the first non-whitespace character.
Returns:
Length of the resulting string.

int string_util_split_command char *  cmdline,
char **  cmd,
char **  args,
int  mxargs
 

Split a command line into an argument list.

This function splits a command line buffer into commands and arguments. If a number of subsequent whitespaces occurs, the first whitespace (end of substring) will be replaced by 0, and a pointer to the first following non-whitespace character (beginning of substring) will be stored in args[].

The function returns an array of arguments and a pointer to a command string as required by execv & friends. These pointers are addresses in the specified command line buffer.

Warning:
Make sure that *cmdline contains a copy of the original command line, since this string will be modified.
Parameters:
cmdline Buffer comtaining the command line - must be zero-terminated!
cmd Pointer to a pointer where the filename is stored
args Array to store char pointers
mxargs Size of args[]
Returns:
Number of arguments

char* string_util_strncpy char *  dest,
const char *  src,
size_t  n
 

A safe wrapper for strncpy.

Guarantees that the result is zero-terminated.

Parameters:
dest Destination.
src Source.
n Maxmial length.

int string_util_trim char *  txt  ) 
 

Remove leading and trailing whitespaces from a string.

Parameters:
txt A Text String.


Generated on Fri Jan 20 10:12:18 2006 by  doxygen 1.4.2