Example: strupr

In this example, the group name of a Vuser is converted to upper case. However, lr_whoami returns the group name as a static buffer and such buffers cannot be manipulated with. If manipulation is required, a copy of the static buffer must be created.

strdup creates a copy of the static buffer, groupname_static. The characters in the new buffer, groupname, are then converted to upper case with strupr.

    #include <string.h>   
    int id;
    char * groupname_static, * groupname;
    // Get the groupname from VuGen 
    lr_whoami (&id, &groupname_static, NULL);
    lr_output_message ("groupname=%s", groupname_static);
    // Make a copy of groupname_static so we can change it
    groupname = (char *)strdup(groupname_static);
    groupname = (char *)strupr(groupname);
    lr_output_message ("Upper case groupname=%s", groupname);
    free(groupname);
Example: Output:
Action.c(8): groupname=None
Action.c(14): Upper case groupname=NONE