lr_eval_string_ext
Creates a buffer and assigns it the input string after evaluating embedded parameters.
int lr_eval_string_ext( const char *in_string, unsigned long const in_len, char ** const out_str, unsigned long * const out_len, unsigned long const options, const char *file, long const line );
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| in_str | The string to be evaluated. |
| in_len | The length of the name of argument in_str +2 to account for the parentheses. |
| out_str | A pointer to the output buffer. |
| out_len | The length of the output buffer. |
| options | Reserved for future use. Currently set to "0". |
| file | Reserved for future use. Currently set to "0". |
| line | Reserved for future use. Currently set to "-1". |
The lr_eval_string_ext function evaluates in_str by replacing parameters with their string value. It creates a buffer containing the expanded string and sets out_str to point to that buffer. It also assigns the length of the buffer to out_len.
Note that in_len is the length of the argument you pass, and not the length of the value of the parameter. For example, if parameter ABC contains the string "1234567890", the call is:
lr_eval_string_ext ("{ABC}", 5, …);
After using lr_eval_string_ext, free the memory allocated for the output buffer with lr_eval_string_ext_free. This is especially true when the function does not find an instantiated parameter or if the pointer to the output buffer returns NULL.
This function is useful when correlating statements that use binary data, for example, data with embedded NULL characters.
Use this function in conjunction with lr_eval_string_ext_free in preference to lr_eval_string when evaluating strings in a loop. Using lr_eval_string in a loop uses more memory.
Return Values
This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.
Parameterization
All arguments can be parameterized using standard parameterization.
Example
char* out_str;
unsigned long out_len;
lr_eval_string_ext("{NewParam}", 10, &out_str, &out_len, 0, 0, -1);
lr_log_message("this is the value of the NewParam: %s", out_str);
lr_log_message("this is the length of the NewParam: %d", out_len);

