BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kparse_string_search - match a search key in a data string

LIBRARY CALL

char *kparse_string_search(
   char *data,
   char *key,
   int  mode,
   char **key_format,
   int  *status)

INPUT

OUTPUT

RETURN VALUE

This function returns a character pointer set to the address of the character following the matched search key. If an error occured, NULL is returned and status is set to the appropriate error status.

DESCRIPTION

This routine performs a regular expression search of an input data string for the first occurance of a specific search string. The search string is specified as a unix regular expression string (see syntax listed below), and it returns a pointer to the portion of the string that follows the search string. It also returns the exact format of the search string that the regular expression has matched. The formatted return string is kmalloc'ed for you.

ADDITIONAL INFORMATION

The regular expression syntax supported by the parser is: '.', '*', '[..]', '[^..]', '$', '^', and '\\'. The explainations for each construct is explained below.

. Match any single character except newline

* Match the preceding character or ranger of characters 0 or more times. This matching includes items specified within a [...] construct.

[...] or [^...] Matches any one character contained within the brackets. If the first character after the is a ']', then it is included as a character to match. If the first character after the '[' is a '^', then it will match all characters NOT included within the []. Finally, the '-' will indicate a range of characters. For example, [a-z] specifies all characters between and including the ascii values 'a' and 'z'. If the '-' follows the '[', or is right before the ']', then it is interpreted literally.

^ If it is the first character of the regular expression, it matches the beginning of the line.

$ If it is the last character of the regular expression, it matches the end of line. However, it does NOT put the \\n in your key when the matched key is returned.

\e This escapes the meaning of a special character.

EXAMPLES

none

SIDE EFFECTS

This routine mallocs data and sets the value of key_format parameter. Thus, the user should pass in an address of an unused character pointer. The calling routine is responsible for freeing the space malloc'ed for the key_format parameter.

RESTRICTIONS

It does not support the following regular expression constructs: or'ing '|', grouping of regular expressions '()', match one or more times '+', or match n to m times '\\{n,m\\}'. Finally, the '\\number' and '\\(\\)' constructs have no meaning for these routines, so they are not supported either.

Search keys and data strings should not contain the values '\\001', '\\002', '\\003', or '\\004', because these values are used as special search parameters by the parser.

MODIFICATION

none

FILES

$BOOTSTRAP/objects/library/kutils/src/parse.c

SEE ALSO

kutils(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.