lr_save_var

Saves a variable length string to a parameter.

int lr_save_var( char *param_value, unsigned long const value_len, unsigned long const options, char *param_name );
Alphabetical Listing - C Language Utility Functions

Arguments

NameComments
param_value The value to assign to a parameter.
value_len The length of the value in bytes.
options A parameter option, currently 0.
param_name The name of the parameter.

The lr_save_var function assigns the specified variable length string to a parameter. This function is useful in Correlating Statements. To determine the value of the parameter, use the lr_eval_string function.

Do not:

  • save an input buffer that contains null or other binary data.
  • pass a value_len longer than the actual data.

In these cases, lr_save_var saves binary data. The behavior of a script that uses the parameter value is indeterminate.

Return Values

This function returns 0 on success and 1 on failure.

Parameterization

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

Example

In the following example, lr_save_var limits the length of a parameter.

Action()
{
    #define MAX_NAME_LEN 4
			
// Create the parameter, InName
    lr_save_string("Fitzwilliam", "InName");
			
// Save the first four characters of "InName" to "ShortName"
    lr_save_var( lr_eval_string("{InName}"), 
        MAX_NAME_LEN, 0, "ShortName");
			
    lr_output_message("ShortName value is %s", lr_eval_string("{ShortName}"));	
			
    return 0;
}

Action.c(8): Notify: Saving Parameter "InName = Fitzwilliam"

Action.c(10): Notify: Saving Parameter "ShortName = Fitz"

Action.c(12): ShortName value is Fitz