Next: , Previous: str_dtoksplit, Up: Strings


4.22 str_varscan

scan a string for $VAR or ${VAR}

Synopsis

     #include <suplib/str.h>
     
     
     
int str_varscan( const char *string, void (*callback)(const char *,const char *,const char *,const char *,void *), void *udata, char **errptr );

Parameters

const char *string
the string to process
void (*callback)(const char *,const char *,const char *,const char *,void *)
callback
void *udata
extra data to pass to the callback routine
char **errptr
place to store a pointer to a bad spot in the string

Description

str_varscan scans a strings for substrings of the form ${VAR} or $VAR. VAR's first character must be in the set [a-zA-Z_], with the remaining characters being in the set [a-zA-Z0-9_].

When such a string is found, the passed callback function is called with the addresses of the first and last characters of the entire substring, as well as the first and last characters in VAR.

Returns

Upon success, it returns 0; Upon error, *errptr is set to point the the character that evoked the error, and one of the following is returned:

EDOM
There was an unbalanced ‘{

Author

Diab Jerius