BOOTSTRAP (kutils) functions


LIBRARY ROUTINE

kparse_file_scan_delimit - break a section of a Khoros Data Transport Stream into an array of strings

LIBRARY CALL

char **kparse_file_scan_delimit(
   kfile    *file,
   char     *key1,
   char     *key2,
   int       mode,
   char     *delimiters,
   char    **key1_format,
   char    **key2_format,
   ssize_t  *num,
   int      *status)

INPUT

OUTPUT

RETURN VALUE

an array of of strings that were delimited.

DESCRIPTION

This routine looks for an area of text between two user specified keys in a Khoros Data Transport Stream; then, copies the section into a string, and parses it according to the user's set of delimiters. Delimiters can be escaped by a '\\' character if a delimiter must appear in the text. This routine is a combination of the routines kparse_file_scan() and kparse_string_delimit(). This routine cleans up the strings to be returned via the kstring_cleanup() routine.

ADDITIONAL INFORMATION

The regular expression syntax supported by the parser is: '.', '*', '[..]', '[^..]', '$', '^', and '\\'. The explainations for each syntax 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 the key1_format and key2_format parameters. Thus, the user should pass in addresses of an unused character pointers for them. The calling routine is responsible for freeing the space malloc'ed for the key1_format and key2_format parameters.

This routine mallocs the space for the return string; and hence, is responsible for freeing the that space via kfree_and_NULL() when they are done with it.

This routine creates a new array of strings, and the calling routine is responsible for freeing the space allocated while creating the array via a call to karray_free().

RESTRICTIONS

none

MODIFICATION

none

FILES

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

SEE ALSO

kparse_file_scan(kutils), kparse_string_delimit(kutils), karray_add(kutils), karray_free(kutils)

COPYRIGHT

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