51Testing软件测试论坛

标题: 请教win协议的脚本函数 [打印本页]

作者: flyingkite    时间: 2006-5-25 17:50
标题: 请教win协议的脚本函数
我这段时间在学习lr的win协议的脚本函数,是看帮助,其中遇到了这个函数lrs_get_buffer_by_name ,帮助里的例子是:
In the following example, lrs_get_buffer_by_name gets the buffer and its size for the buffer descriptor "buff2".

char *ActualBuffer;

int NumberOfBytes;

lrs_get_buffer_by_name("buff2", &ActualBuffer, &NumberOfBytes);

lr_output_message("The buffer's size is: %d/n", NumberOfBytes);

The contents of the buffer, as shown in the data file data.ws are:

recv buff2 3
       "\xff\xfe\x01"

The output generated by the above code, as seen in the VuGen Execution log is:

Message from run.c(52): The buffer size is: 3 bytes

The ActualBuffer variable is a pointer to binary data; therefore you should not use string functions to manipulate it. To save the content of the buffer to a parameter for later use:

/* Save the contents of ActualBuffer into a parameter called "new_parameter" */

lrs_save_param_ex("socket2", "user", ActualBuffer, 0, NumberOfBytes, "ascii", "new_parameter");
lrs_free_buffer(ActualBuffer);

lr_output_message("The buffer contains \"%s\"\n", lr_eval_string("< new_parameter >"));

The output generated by the above code, as seen in the VuGen Execution log is:

Message from run.c(52): The buffer contains:                                                                                                                                                                 "\xff\xfe\n"

我的问题是:这个函数为什么输出的内容是  "\xff\xfe\n" ,而不是 "\xff\xfe\x01"
哪位知道的一定奉告:)多谢




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2