1. In globals.h, define a function replacestr, which implements the substitution of strings:intREPLACESTR (Char* SSRC,Char* Smatchstr,Char*sreplacestr) { intStringlen; Charcanewstring[1024x768]; Char*Findpos; merc_timer_handle_t Timer_replacestr=Lr_start_timer (); Lr_debug_message (Lr_msg_class_extended_log,"notify:function ' Replacestr ' started."); Findpos=(Char*) strstr (SSRC, SMATCHSTR); if((!findpos) | | (!smatchstr)) {Lr_debug_message (Lr_msg_class_extended_log,"notify:function ' Replacestr ' ended with error!"); return-1; } while(Findpos) {memset (canewstring,0,sizeof(canewstring)); Stringlen= Findpos-SSRC; strncpy (canewstring, SSRC, Stringlen); strcat (canewstring, SREPLACESTR); strcat (canewstring, Findpos+strlen (SMATCHSTR)); strcpy (SSRC, canewstring); Findpos=(Char*) strstr (SSRC, SMATCHSTR); } lr_debug_message (Lr_msg_class_extended_log,"result:%s", SSRC); Free (findpos); Lr_debug_message (Lr_msg_class_extended_log,"notify:function ' Replacestr ' ended (Duration:%LF)", Lr_end_timer (TIMER_REPLACESTR)); return 0;} 2. In init/action/End call in:Charstrview[1024x768]; Web_reg_save_param ("ViewState5", "lb=\ "javax.faces.viewstate\" value=\ "", "rb=\ "", last); sprintf (Strview,lr_eval_string ("{ViewState5}")); Replacestr (Strview,"+","%2b"); Replacestr (Strview,"/","%2f"); Replacestr (Strview,"=","%2d"); Lr_save_string (Lr_eval_string (Strview),"ViewState6"); memset (Strview,0,sizeof(Strview));
LoadRunner the custom C function to implement string substitution