LoadRunner the custom C function to implement string substitution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.