int STkeyMatch (const char String[], const char *KeyTable[])


Match a string to keyword strings


This subroutine searches a table for a match to a character string. The table of keywords is searched for the first match. The keyword table can optionally specify the minimum length for a match and a length beyond which characters need no longer match. The keywords are searched in order.

Each entry of the keyword table specifies the character string to be matched. An optional asterisk ('*') is used to indicate the minimum number of characters needed for a match. A second asterisk can be used to indicate that characters after this point need not match.

Keyword table entry "abc*de*f". Input strings "abc", "abcd", "abcde", and "abcdex" will match this entry. Input strings "ab", "abC" " abc" and "abcx" do not match this entry.


<- int STkeyMatch
Index of the matched keyword. This value is set to -1 if no match is found.
  -1 - No match
   0 - Match to the first keyword
   1 - Match to the second keyword
-> const char String[]
Input character string. If String is the NULL pointer, a no match condition is returned.
-> const char *KeyTable[]
Pointer array with pointers to the keyword strings. The end of the keyword table is signalled with a NULL pointer. Note that with ANSI C, if the actual parameter is not declared to have the const attribute, an explicit cast to (const char **) is required.

Author / revision

P. Kabal / Revision 1.18 2003/05/09

See Also

STfindToken, STkeyXpar

Main Index libtsp