Example: lr_save_searched_string

In the following example, a Certificate is saved to a parameter for later use. The lr_save_searched_string function saves 16 bytes from the "olen" buffer returned by lrt_tpcal, to parameter cert1. The saved string location in the buffer is 9 bytes past 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 lr_save_searched_string function is useful in this case, because regardless of the header length, the certificate always begins nine bytes past this string.

/* Request CARRAY buffer 1 */
lrt_memcpy(data_0, sbuf_1, 41);
lrt_display_buffer("sbuf_1", data_0, 41, 41);
data_1 = lrt_tpalloc("CARRAY", "", 8192);
tpresult_int = lrt_tpcall("GetCertificate",
    data_0,
    41,
    &data_1,
    &olen,
    TPSIGRSTRT);
/* Reply CARRAY buffer 1 */
lrt_display_buffer("rbuf_1", data_1, olen, 51);
lrt_abort_on_error();
lr_save_searched_string(data_1, olen, 0, "SCertRep", 9, 16, "cert1");