C Vuser protocol

In a C Vuser script, you manually program your own script using any C code that conforms to the standard ANSI conventions.

Create a C Vuser script

To create an empty C Vuser script, select C Vuser in the Create a New Script dialog box. VuGen creates an empty C Vuser script:

Action1()
{
    return 0;
}

You can use C Vuser functions in all Vuser script types that use C functions.

For a C reference that includes syntax and examples of commonly used C functions, see the Function Reference (select the relevant version).

Back to top

Guidelines for using C functions

All standard ANSI C conventions apply to C Vuser scripts, including control flow and syntax. You can add comments and conditional statements to the script just as you do in other C programs. You declare and define variables using ANSI C conventions.

The C interpreter that is used to run Vuser scripts accepts the standard ANSI C language. It does not support any Microsoft extensions to ANSI C.

Before you add any C functions to a Vuser script, note the following limitations:

  • A Vuser script cannot pass the address of one of its functions as a callback to a library function.

  • The stdargs, longjmp, and alloca functions are not supported in Vuser scripts.

  • Vuser scripts do not support structure or union arguments or return types. Pointers to structures are supported.

  • In Vuser scripts, string literals are read-only. Any attempt to write to a string literal generates an access violation.

  • C Functions that do not return int, must be casted. For example,
    extern char * strtok();

Back to top

Calling Windows C run-time libraries (libc) functions

In a Vuser script, you can call Windows C run-time libraries (libc) functions. However, since the interpreter that is used to run Vuser scripts does not support any Microsoft extensions to ANSI C, you cannot use Microsoft's include files. Instead, use the header files located in the <LoadRunner root folder>\include folder.

Back to top

Linking mode

The C interpreter that is used to run Vuser scripts uses a "lazy" linking mode in the sense that a function need not be defined at the start of a run, as long as the function is defined before it is used. For example:

lr_load_dll("mydll.dll");
    myfun();  /* defined in mydll.dll -- can be called directly, 
                immediately after mydll.dll is loaded. */
Back to top

See also: