Share this page

# lrt_save_searched_string_ext

Correlating Functions

Searches for an occurrence of string in a buffer, and saves a portion of the buffer, after the string occurrence, to a parameter.

intlrt_save_searched_string_ext( char *buffer, long buf_size, unsigned int occurrence, char *left_boundary, int offset, unsigned int string_len, char *parm_name );

buffer | The STRING or CARRAY buffer whose contents you want to save.
buf_size | The buffer size.
occurrence | The occurrence number of the left boundary (0-based count). For example, if the boundary string occurs three times, and you want the second occurrence, set occurrence to 1.
left_boundary | The string that occurs to the left of the search string. For printable characters, the syntax is `"LB=<boundary string>".` For hexadecimal strings, the syntax is `"LB/BIN=\\x<value>".` "For example: `LR/BIN=\\x02`
offset | The offset relative to the end of the left boundary where you want to begin saving.
string_len | The number of characters to save.
parm_name | Parameter name to be used in subsequent lrt statements to refer to the saved information. Name is enclosed in double-quotes.

The lrt_save_searched_string_ext function searches for a string (the left boundary) in a buffer and saves a portion of the buffer after that search string to a parameter. It counts the number of times left_boundary appears in the buffer, from 0 until the specified occurrence . (0-based count). It then adds offset to the end of this string occurrence, and saves string_len characters to a parameter named parm_name.

It is preferable to use the lrt_save_parm function to save strings from character arrays. Use lrt_save_searched_string_ext only when you need to save a portion of a character array after a string occurrence.

## Return Values

The function returns a negative value on failure. On success it returns the position of the saved string in the buffer relative to the start of the buffer.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## Example

In the following example, a Certificate is saved to a parameter for later use. The lrt_save_searched_string function saves 16 bytes from the specified olen buffer, to the parameter cert1. The saved string location in the buffer, is 1 byte past the end of the first occurrence of the string "SCertRep".

There is usually header information before the "ScertRep" string that can vary in length, depending on the recording environment. The lrt_save_searched_string function is useful in this case, because regardless of the header length, the certificate always after this string.

Copy code

    /* Request CARRAY buffer 1 */
    lrt_memcpy(data_0, sbuf_1, 41);
        data_0,
        41,
        &data_1,
        &olen,
        TPSIGRSTRT);
    lrt_display_buffer("rbuf_1", data_1, olen, 51);
        olen, 0,
        "LB=SCertRep",
        1,
        16,
        "cert2");

lrt_display_buffer("sbuf_1", data_0, 41, 41);

data_1 = lrt_tpalloc("CARRAY", "", 8192);

tpresult_int = lrt_tpcall("GetCertificate",

/* Reply CARRAY buffer 1 */

lrt_abort_on_error();

lrt_save_searched_string_ext(data_1,

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: