Index Page kxtrct_c
A B C D E F G H I J K L M N O P Q R S T U V W X
Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries
#### Procedure
       void kxtrct_c ( ConstSpiceChar       * keywd,
                       SpiceInt               termlen,
                       const void           * terms,
                       SpiceInt               nterms,
                       SpiceInt               stringlen,
                       SpiceInt               substrlen,
                       SpiceChar            * string,
                       SpiceBoolean         * found,
                       SpiceChar            * substr     )
#### Abstract
       Locate a keyword in a string and extract the substring from
       the beginning of the first word following the keyword to the
       beginning of the first subsequent recognized terminator of a list.
#### Required_Reading
       None.
#### Keywords
        SEARCH, PARSING, PARSING
#### Brief_I/O
       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       keywd      I   Word that marks the beginning of text of interest.
       termlen    I   Length of strings in string array term.
       terms      I   Set of words, any of which marks the end of text.
       nterms     I   Number of terms.
       stringlen  I   Available space in argument string.
       substrlen  I   Available space in output substring.
       string    I/O  String containing a sequence of words.
       found      O   SPICETRUE if the keyword is found in the string.
       substr     O   String from end of keywd to beginning of first
                      terms item found.
#### Detailed_Input
       keywd          is a word used to mark the start of text of interest.

       termlen        is the maximum number of characters that can be
                      accommodated in the each element of the input argument
                      terms.  This count includes room for the terminating null
                      characters.

       terms          is a set of words, any one of which may signal the
                      end of text of interest.

                      The array terms should be declared with dimensions

                         [nterms][termlen]

       nterms         is the number of elements in the array terms.

       stringlen      is the maximum number of characters that can be
                      accommodated in the in/out argument string.  This count
                      includes room for the terminating null character.
                      For example, if the maximum allowed length of the
                      output string, including the terminating null, is 25
                      characters, then stringlen should be set to 25.

       substrlen      is the maximum number of characters that can be
                      accommodated in the output argument substr.  This count
                      includes room for the terminating null character.

       string         is a character string made up of words, which may
                      contain the keyword in keywd.
#### Detailed_Output
       string         is the input string stripped of all words from
                      the beginning of the keyword keywd to the end of
                      the last word preceding one of the words in terms
                      (or the end of the string if none of the terms follows
                      keywd in the string).

       found          is a flag indicating whether keywd is present in the
                      input string.  found is set to SPICETRUE if the keyword
                      is present and SPICEFALSE otherwise.

       substr         is the substring that begins with the first word
                      following keywd up to the beginning of any of the
                      words in term or the end of the string.  If no words
                      are found between the keyword and the next terminator,
                      substr is returned empty.

                      substr cannot overwrite string.
#### Parameters
       None.
#### Exceptions
       1) If any string pointer argument is null, the error
          SPICE(NULLPOINTER) will be signaled.

       2) If keywd has string length zero, the error SPICE(EMPTYSTRING)
          will be signaled.

       3) If any of the arguments terms, string, or substr has length
          less than 2, as indicated by their associated length arguments
          termlen, stringlen and substrlen, the error SPICE(STRINGTOOSHORT)
          will be signaled.
#### Files
       None.
#### Particulars
       Definitions:

          A WORD     is a set of consecutive non-blank characters
                     delimited by blanks or either end of the string
                     that contains them.

       Given a string and a keyword this routine locates the first
       occurrence of the keyword in the string and returns the
       substring between the end of the keyword and the first occurrence
       of any of the words in a list of terminating words.  If none
       of the terminating words follows the keyword in the string,
       the routine returns all of the string following the keyword.

       If the next word following the keyword is a terminating word,
       the substring returned will be empty.

       If the keyword can not be located in the string, the variable
       found will be returned as SPICEFALSE and the input string will be
       unchanged.  The substring will be returned empty.

       In all other cases, the part of the input string from the
       beginning of the keyword to the start of the first terminating
       word will be removed.  If no terminating word follows the keyword
       the portion of the string from the keyword to the last non-blank
       character of the string will be removed.
#### Examples
       Example 1.
       ----------
         Input:  string  "FROM 1 October 1984 12:00:00 TO 1 January 1987"
                 keywd   "TO"
                 terms   "FROM"
                         "TO"
                         "BEGINNING"
                         "ENDING"

         Output: string  "FROM 1 October 1984 12:00:00"
                 found   SPICETRUE
                 substr  "1 January 1987"

       Example 2.
       ----------
         Input:  string  "FROM 1 October 1984 12:00:00 TO 1 January 1987"
                 keywd   "FROM"
                 terms   "FROM"
                         "TO"
                         "BEGINNING"
                         "ENDING"

         Output: string  " TO 1 January 1987"
                 found   SPICETRUE
                 substr  "1 October 1984 12:00:00"

       Example 3.
       ----------
         Input:  string  "ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 "
                 keywd   "ADDRESS:"
                 terms   "ADDRESS:"
                         "PHONE:"
                         "NAME:"

         Output: string  " PHONE: 354-4321"
                 found   SPICETRUE
                 substr  "4800 OAK GROVE DRIVE"

       Example 4.
       ----------
         Input:  string  "ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321 "
                 keywd   "NAME:"
                 terms   "ADDRESS:"
                         "PHONE:"
                         "NAME:"

         Output: string  "ADDRESS: 4800 OAK GROVE DRIVE PHONE: 354-4321"
                 found   SPICEFALSE
                 substr  ""
#### Restrictions
       None.
#### Literature_References
       None.
#### Author_and_Institution
       N.J. Bachman    (JPL)
       H.A. Neilan     (JPL)
       W.L. Taber      (JPL)
#### Version
       -CSPICE Version 1.0.0, 18-AUG-2002 (NJB) (HAN) (WLT)
#### Index_Entries
       extract a substring starting with a keyword
#### Link to routine kxtrct_c source file kxtrct_c.c

    Wed Jun  9 13:05:25 2010