char *GenerateCheckSum( char *buf, long bufLen )
{
static char tmpBuf[ 4 ];
long idx;
unsigned int cks;
for( idx = 0L, cks = 0; idx < bufLen; cks += (unsigned int)buf[ idx++ ] );
sprintf( tmpBuf, "%03d", (unsigned int)( cks % 256 ) );
return( tmpBuf );
}
Action()
{
/*8=FIX.4.2\x019=225
\x0135=D\x0134=2
\x0149=CSY\x0152=20120628-05:08:19.398
\x0156=GTA\x011=010000000408\x0111=csy12062850301
\x0115=HKD\x0121=1\x0138=10000000\x0140=2\x0144=0\x0154=1\x0155=00001\x0160=20120628-05:08:19
\x01110=1000\x01207=XHKG\x019000=TWAP\x019001=20120628-07:00:00\x019002=20120628-08:00:00\x0110=022\x01
*/
char fullpath[2024];
char* jishuan_jiege="";
//8=FIX.4.2\x019=220
char* changdu_before="8=FIX.4.2\x019=";
char* changdu_param=lr_eval_string("<changdu>");
//
// 8=FIX.4.2\x019=220\x0135=D\x0134= 2
//char* xuhao_before="8=FIX.4.2\x019=220\x0135=D\x0134=";
char* xuhao_before="\x0135=D\x0134=";
char* xuhao_param=lr_eval_string("<xuhao>");
//
// \x0149=csy\x0152=20120509-01:56:22.481
char* time1_before="\x0149=CSY\x0152=";
char* time1_param=lr_eval_string("<time1>");
//
// \x0156=GTA\x011=010000000408\x0111=csy12050900201
char* danhao_before="\x0156=GTA\x011=010000000408\x0111=";
char* danhao_param=lr_eval_string("<danhao>");
//
// \x0115=CNY\x0121=1\x0138=1000\x0140=2\x0144=0\x0154=1\x0155=000002\x0160=20120509-01:56:22
char* time2_before="\x0115=HKD\x0121=1\x0138=10000000\x0140=2\x0144=0\x0154=1\x0155=00001\x0160=";
char* time2_param=lr_eval_string("<time2>");
char* end_string="\x01110=1000\x01207=XHKG\x019000=TWAP\x019001=20120710-07:30:00\x019002=20120710-08:00:00\x01";
strcpy(fullpath,changdu_before);
strcat(fullpath,changdu_param);
lr_output_message("开始1%s",fullpath);
strcat(fullpath, xuhao_before);
strcat(fullpath, xuhao_param);
//lr_output_message("开始2%s",fullpath);
strcat(fullpath, time1_before);
strcat(fullpath, time1_param);
//lr_output_message("开始3%s",fullpath);
strcat(fullpath, danhao_before);
strcat(fullpath, danhao_param);
//lr_output_message("开始4%s",fullpath);
strcat(fullpath, time2_before);
strcat(fullpath, time2_param);
strcat(fullpath, end_string);
//lr_output_message("开始5%s",fullpath);
lr_output_message ("完整字符串的值为:%s", fullpath);
jishuan_jiege=GenerateCheckSum(fullpath,strlen(fullpath));
lr_save_string(jishuan_jiege,"check_ID");//将计算得到的值保存为check_ID参数,做计算检查值用
lr_save_string(xuhao_param,"param_xuhao");//做标识用
lr_save_string(time1_param,"param_time1");//做第一个时间点用
lr_save_string(danhao_param,"param_danhao");//做单号用
lr_save_string(time2_param,"param_time2");//做第二个时间点用
//lr_save_string(changdu_param,"param_changdu");//chang du
lr_output_message(lr_eval_string("<check_ID>"));//相差63
lr_output_message("计算的值为:%s",lr_eval_string("<check_ID>"));
lr_output_message("标识的值为:%s",lr_eval_string("<param_xuhao>"));
lr_output_message("时间1的值为:%s",lr_eval_string("<param_time1>"));
lr_output_message("单号的值为:%s",lr_eval_string("<param_danhao>"));
lr_output_message("时间2的值为:%s",lr_eval_string("<param_time2>"));
lr_output_message("长度:%s",lr_eval_string("<param_changdu>"));