int (*) (int
c)
The type for a characteristic function on characters. Such a function is passed a character c, converted to an ‘int’; it should return non-zero iff c has some property. An example would be the standard C function ‘isalpha’.1
Returns the first position in astr at which the contents of target are found. The first position to look at is the next position after index, or zero if index is negative. If target is not found, -1 is returned.
Returns the first position in astr at which the characters referenced by chars are found. The first position to look at is the next position after index, or zero if index is negative. If the target is not found, -1 is returned.
Returns the first position in astr at which the single character c s found. The first position to look at is the next position after index, or zero if index is negative. If c is not found, -1 is returned.
Returns the first position in astr at which a character in set is found. The first position to look at is the next position after index, or zero if index is negative. If no such character is found, -1 is returned.
Returns the first position in astr at which a character for which func returns a non-zero value is found. The first position to look at is the next position after index, or zero if index is negative. If no suc character is found, -1 is returned.
These functions behave exactly as ‘astr_find_match’, ‘astr_find_match_s’ and ‘astr_find_nmatch_s’ respectively, with the exception that the sense of matching is reversed. That is, ‘astr_find_nmatch’ returns the index of the first character in astr after index which is not found in set, for example.
Returns the last position in astr at which the character c is found, or -1 if c was not found.
An example of using these functions may be helpful here. Note the similarity between the calling idiom for these functions and for standard C library functions such as ‘getchar’.
/* Call bar() on ASTR at every position where S is found. */ void foo (const Autostr *astr, const char *s) { ssize_t i = -1; while ((i = astr_find_s (astr, i, s)) != -1) bar (astr, i); }
[1] Many implementations of the standard C library provide macros for functions such as ‘isalpha’ and ‘isspace’. However, note that macros are only recognised as such when they look syntactically like function calls, and that the `ctype' facilities must be provided as functions whose address can be taken.