[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    cfht_string(3) manual page Table of Contents

Name

cfht_string - general purpose string manipulation and sanity checking routines

Synopsis


#include <cfht/cfht.h>char *cfht_string(in_str, operation, rangeinfo)char
*in_str;int operation;cfht_range_t rangeinfo;
libcfht.a

Description

This routine provides a number of operations useful for performing sanity checks on user-supplied input. It is intended as an aid in avoiding such horrors as whitespace in filenames and unprintable characters in input strings.

The string may contain any ascii characters. The NULL character terminates the string. A number of different operations are available.

Operations

Cfht_str_match

rangeinfo provides an array of pointers to strings. The input string is tested against each of these strings. If an exact match is found, a copy of the input string is made and the function returns a pointer to this new copy. If an exact match is not found, the function returns a pointer to a null string. If an error occurs, the function returns NULL. Possible errors are: INVALID_RANGE - range structure is bad.

Cfht_str_include

rangeinfo provides a string of characters. Each character in the input string is tested against the rangeinfo. If it is found, the character is copied to the output string. If an error occurs, the function returns NULL. Possible errors are: INVALID_RANGE - range structure is bad.

Cfht_str_exclude

rangeinfo provides a string of characters. Each character in the input string is tested against the rangeinfo. If it is not found, the character is copied to the output string. If an error occurs, the function returns NULL. Possible errors are: INVALID_RANGE - range structure is bad.

Cfht_str_nowhite

Each character in the input string which is not a whitespace character is copied to the output string. Whitespace characters are space, tab, carriage return, new line, vertical tab and form feed. rangeinfo is ignored; it is suggested that NULL be used.

Cfht_str_notrail

The input string is copied to the output string, but all whitespace characters at the end of the string are removed. Whitespace characters are as above. rangeinfo is ignored; it is suggested that NULL be used.

Cfht_str_escape

Currently unimplemented.

Cfht_str_unescape

Currently unimplemented.

Return Value

All of these routines return a pointer to the result string. The input string is always left unmodified. Space for the return value is dynamically allocated; it is the responsibility of the caller to call free(3) to return the memory after use. If an error occurs, NULL is returned and cfht_errno is set.

See Also

cfht_tok(3) , cfp_getval(3)

Warnings

Remember that a NULL pointer and a pointer to a NULL string are not the same.

Remember to free the memory used by the output strings.


Table of Contents