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

strings.h File Reference

#include "cuf-global.h"
#include "win32lacks.h"

Go to the source code of this file.

Functions

char * search_replace (char *str, char *mat, char *rep, int allinst)
char * search_replace_env (char *str)
char * slashes_decode (char *str, char *exclude, int decodeliterals)
char * slashes_encode (char *str, char *exclude, char *literals, int hexadecimal)
char * slashed_to_quoted (char *str, char *keepescaped, int doublequotes)
char * quoted_to_slashed (char *str, char *includeescape)
char * strcasestr (char *phaystack, char *pneedle)
char * strcpyto (char *haystack, int delim)
char * strcpyout (char *haystack, char *acceptlist)
char * strcutout (char *haystack, char *start, char *end)
char * strstripq (char *str)
char * strltrim (char *str)
char * strrtrim (char *str)
char * strtrim (char *str)
Comparison alpha_compare (char *a, char *b)


Detailed Description

String parseing functions.

Function Documentation

Comparison alpha_compare char *  a,
char *  b
 

Parameters:
a The first string to compare.
b The second strimg to compare.
Return values:
#CLessThan If string 'a' is less than string 'b'.
#CEqualTo If string 'a' is equal to string 'b'.
#CGreaterThan If string 'a' is greater than string 'b'.
Description:
Compares two strings and returns weather the first string was lest than, equal to, or greater than the second string.

char* quoted_to_slashed char *  str,
char *  includeescape
 

Parameters:
str The string to un-encapsulate.
includeescape A list of non-standard literals to escape while processing. If '\' or the encapsulating quote is specified, it is ignored.
Return values:
char * Of the newly allocated string.
NULL On error. Encodes a quoted string to escaped sequences. Quotes either inside the same type of quotes or outside of any quotes will need to be escaped or this function will conceder them a delimiter.

char* search_replace char *  str,
char *  mat,
char *  rep,
int  allinst
 

Parameters:
str The string to search through.
mat The string to match.
rep The replacement string.
allinst Set if allinstances of 'mat' are to be replaced.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Searches the string 'str' for text matching 'mat', and replaces it with the text 'rep'. If 'allinst' is set every instance of 'mat' will be replaced, otherwise only the first occurrence will be replaced.

char* search_replace_env char *  str  ) 
 

Parameters:
str The string to search.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Searches for the occurrence of strings encapsulated in $(). Then attempts to locate an environment variable matching the encapsulated string. If a match is found the encapsulated string is replaced with the value from the environment variable.
Note:
If a matching environment variable was not found, the $() encapsulation is not affected. So the strings may need to be checked if the variable to replace is not a standard environment varialble.

char* slashed_to_quoted char *  str,
char *  keepescaped,
int  doublequotes
 

Parameters:
str The string to quote.
keepescaped A list of characters to exclude from the encoding. The quote type is automaticly added to this list. If a '\' is specified it will be ignored.
doublequotes Set to TRUE if the end string is to be encapsulated in double quotes. Set to FALSE for single quotes.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Returns a string wrapped in quotes with any escaped charters decoded. If a quote of the type used appears in the string it is escaped so it can be literally translated later.

char* slashes_decode char *  str,
char *  exclude,
int  decodeliterals
 

Parameters:
str The string to decode.
exclude A list of charters to exclude from decoding.
decodeliterals Set if non standard escaped literals are to be deocded.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Takes a string with escaped charters including decimal and hexadecimal escapes and decodes them to the literal charter. This function supports only standard C/C++ escaped literals.

char* slashes_encode char *  str,
char *  exclude,
char *  literals,
int  hexadecimal
 

Parameters:
str The string to encode.
exclude A list of charters to exclude from encoding.
literals A list of printable characters to be included in the encodeing.
hexadecimal If TRUE, non-standard, non-printable charecters will be encoded in hexadecimal. If FALSE they will be encoded in octal format.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
This encodes charters that are not printable or can be encode with one of the C/C++ standard escape sequences. The 'exclude' list is a list of chars to exclude from the encoding process. Since the '' is used to determine the end of the string and will not be encoded.

char* strcasestr char *  phaystack,
char *  pneedle
 

Parameters:
phaystack The string to search.
pneedle The string to find.
Return values:
char * Of the starting location inside 'phaystack' of the found string.
NULL When no match was found or on error.
Description:
My personal strstr() implementation that beats most other algorithms. Until someone tells me otherwise, I assume that this is the fastest implementation of strstr() in C. I deliberately chose not to comment it. You should have at least as much fun trying to understand it, as I had to write it :-).

Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de

Modifyed by Alex Scott <magister AT kfa.cx> to be case insensitive.

char* strcpyout char *  haystack,
char *  acceptlist
 

Parameters:
haystack The string to search.
acceptlist A list of characters to allow in the finial string.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Copy's charecters from 'haystack' until it reaches a charecter which is not in 'acceptlist'.

char* strcpyto char *  haystack,
int  delim
 

Parameters:
haystack The string to copy from.
delim The delimiter to stop at.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Copies a string from the beginning of 'haystack' until it reaches the delimiter 'delim'.

char* strcutout char *  haystack,
char *  start,
char *  end
 

Parameters:
haystack The string to search.
start The string to start from.
end The string to end before.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Searches for 'start' in 'haystack', copies from the end of start to 'end' if found, otherwise to the first ''.
Note:
This function is case insensitive. This could change and a case insensitive version be made separately.

char* strltrim char *  str  ) 
 

Parameters:
str The string to trim.
Return values:
char * Of the newly allocated string.
NULL On error. Removes leading whitespace from the supplied string.

char* strrtrim char *  str  ) 
 

Parameters:
str The string to trim.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Removes trailing white space from the supplied string.

char* strstripq char *  str  ) 
 

Parameters:
str The string to un-encapsulate.
Return values:
char * Of the newly allocated un-encapsulated string.
NULL on error.
Description:
Strips quotational encapsulation. No slashed conversion is done.
Note:
The encapsulating quote must be the first character in the string 'str'.

char* strtrim char *  str  ) 
 

Parameters:
str The string to trim.
Return values:
char * Of the newly allocated string.
NULL On error.
Description:
Removes leading and trailing white space from the supplied string.


Generated on Fri Jun 4 18:35:20 2004 for cuf by doxygen 1.3.6