Example: lrs_save_searched_string

Example 1

If you specify a constant offset and length, with left_boundary and right_boundary set to NULL, then lrs_save_search_string is identical to lrs_save_param.

For example:

int offset = 2;
int length = 8;
lrs_save_searched_string ("socket0", NULL, "param_x", NULL, NULL, -1, offset, length);

Example 2

Suppose that data.ws contains the following buffer, buf1:

    "\x00\x01\x85\x80\x00\x01\x00\x01\x00\x00\x00\x00\x07"

    "ABC"

    "\x02"

    "co"

    "\x02"

    "il"

    "\x00\x00\x01\x00\x01\xc0"

Suppose that the value of Param1 in the parameter list is "\x01", a string indicating the group name.

lrs_save_searched_string ("socket0", "buf1", "correlation", "LB/BIN=\\x00{Param1}", "RB/BIN=\\x02", 2, 3, -1);

The above function saves the string appearing at offset 3 from the second occurrence of \x00\x01 into a parameter called "correlation.".

After this call, the "correlation" parameter will contain:

\x00\x00\x00\x07ABC

The left boundary is "\x00\x01" which appears 5 times in the buffer. The second ordinal is:

"\x00\x01\x85\x80\x00\x01".

Offset 3 from this boundary is:

"\x00\x01\x85\x80\x00\x01\x00\x01\x00".