📄 sm_text_down.c
字号:
} while (bytesRcvd>0);
tempchar[ToltalHeadBytesRcvd]='\0';
close(sock);
return COMMSUCCESS;
}
void Save_TempLate_File(char filenamebuf[],char templatebuff[])
{
char bufer[MaxReceiveBufSize];
//char fname[30];
// printf("%d\n",strlen(templatebuff));
char fname[80]="Template/";
strcat(fname,filenamebuf);
strcat(fname,".tpl");
//strcat(fname,".jpg");
// printf("%s\n",fname);
Copy_String(templatebuff,bufer,2);
// printf("copy success\n");
if(SavePlFlag==1)
Read_to_File(fname,templatebuff,3);
}
void Get_TempLate_File(char sendmessage[])
{
char sndmsg[]="GET /tangjun/templete.aspx?tId=";
strcat(sendmessage,sndmsg);
strcat(sendmessage,FileInfo.tempbuf1);
strcat(sendmessage," HTTP/1.1\r\n"
"host:127.0.0.1\r\n"
"Accept-Language:utf-8\r\n"
"Content-Type:test/html\r\n"
"user-Agent:Mozilla/4.0(compatible;MSIE 6.0)\r\n"
"accept:*/*\r\n\r\n");
//printf("%s\n",sendmessage);
http_socket_comm(TempLateHeadBuf,TempLateBodyBuf,sendmessage,ipaddr,ServPort2);
//printf("%s\n",TempLateHeadBuf);
}
void Get_Pic_File(char sendmsgbuf[])
{
int fd;
int res;
int piclen;
FILE *fpj=NULL;
char *filename="Template/temp.jpg";
char sndmsg[]="GET /tangjun/templete.aspx?tId=";
strcat(sendmsgbuf,sndmsg);
strcat(sendmsgbuf,FileInfo.tempbuf1);
strcat(sendmsgbuf,"&type=Pic");
strcat(sendmsgbuf," HTTP/1.1\r\n"
"host:127.0.0.1\r\n"
"Accept-Language:utf-8\r\n"
"Content-Type:image/*\r\n"
"user-Agent:Mozilla/4.0(compatible;MSIE 6.0)\r\n"
"accept:*/*\r\n\r\n");
//do{
piclen=http_socket_comm(PicHeadBuf,PicBodyBuf,sendmsgbuf,ipaddr,ServPort2);
// }while(PIC_VERYFY_SUCESS!=PicCrc32(filename,piclen));
//printf("pic verify success!\n");
}
int Get_Heart_Data(char BodyBuf[],char vbuf[])
{
char tmp_buf[MaxReceiveBufSize];
int sbuflen=0;
strLeftTrim(BodyBuf);
//printf("%c\n",BodyBuf[0]);
if(BodyBuf[0]!='Z'&&BodyBuf[0]!='z')
return (-1);
sbuflen=my_strchr(BodyBuf,FileInfo.successflag,c1);// Z
Copy_String(BodyBuf,tmp_buf,sbuflen);
//printf("successflag=%s\n",FileInfo.successflag);
sbuflen=my_strchr(BodyBuf,FileInfo.VerifyID,c1);
//printf("VerifyID=%s\n",FileInfo.VerifyID);
Copy_String(BodyBuf,tmp_buf,sbuflen);
sbuflen=my_strchr(BodyBuf,FileInfo.EncryptType,c1);
//printf("EnctyptType=%s\n",FileInfo.EncryptType);
Copy_String(BodyBuf,tmp_buf,sbuflen);
sbuflen=my_strchr(BodyBuf,FileInfo.NodeId,c2);
//printf("NodeId=%s\n",FileInfo.NodeId);
Copy_String(BodyBuf,tmp_buf,sbuflen);
sbuflen=my_strchr(BodyBuf,FileInfo.ServerTime,c2);
Copy_String(BodyBuf,tmp_buf,sbuflen);
//printf("ServerTime=%s\n",FileInfo.ServerTime);
sbuflen=my_strchr(BodyBuf,FileInfo.updateinfo,c2);
//printf("updateinfo=%s\n",FileInfo.updateinfo);
Copy_String(BodyBuf,tmp_buf,sbuflen);
sbuflen=my_strchr(BodyBuf,FileInfo.PLsave, c2);
Copy_String(BodyBuf,tmp_buf,sbuflen);
//printf("PLsave=%s\n",FileInfo.PLsave);
sbuflen=my_strchr(BodyBuf,vbuf,c2);
//printf("%s\n",vbuf);
Copy_String(BodyBuf,tmp_buf,sbuflen);
sbuflen=my_strchr(BodyBuf,FileInfo.MLsave,c2);
Copy_String(BodyBuf,tmp_buf,sbuflen);
printf("Mlsave is %s\n",FileInfo.MLsave);
if(!strncmp(FileInfo.PLsave,"1",1))
Parse_Body_Data(vbuf);
if(!strncmp(FileInfo.MLsave,"1",1))
Parse_Message_Data(BodyBuf);
return COMMSUCCESS;
}
void Parse_Body_Data(char Buffer[])
{
int j,k=0,i;
int marklen=0,marklen1=0,sbuflen1,sbuflen2;
char tmp_buf1[MaxReceiveBufSize];
char tempname[80];
char newPl[30];
char newPlFile[30];
char nextline[8]="\r\n";
FILE *fp3=NULL;
FILE *PLfp[128];
memset(Conf.Uppl,0,sizeof(Conf.Uppl));
Read_to_File(PLAYLISTFILE,newPl, 0);
Read_to_File(TempDownLoading_FileList,newPl,0);
marklen1=getmark(Buffer,c7);
j=1;
while(j<marklen1+2){
i=1;
sbuflen1=my_strchr(Buffer,FileInfo.tempbuf, c3); //校验码
Copy_String(Buffer,tmp_buf1,sbuflen1);
// printf("%s\n",FileInfo.tempbuf);
sbuflen1=my_strchr(Buffer,FileInfo.PLNumber,c3);
//节目单编号
//printf("%s\n",FileInfo.PLNumber);
Read_to_File(PLAYLISTFILE,FileInfo.PLNumber,1);
Copy_String(Buffer,tmp_buf1,sbuflen1);
sbuflen1=my_strchr(Buffer,FileInfo.PLName,c3); // 节目单名称
Copy_String(Buffer,tmp_buf1,sbuflen1);
//printf("%s\n",FileInfo.PLNumber);
sbuflen1=my_strchr(Buffer,FileInfo.tempbuf1,c3); //模板编号
Copy_String(Buffer,tmp_buf1,sbuflen1);
//printf("%s\n",FileInfo.tempbuf1);
sbuflen1=my_strchr(Buffer,FileInfo.prior,c3);
Copy_String(Buffer,tmp_buf1,sbuflen1);
Read_to_File(PLAYLISTFILE,FileInfo.prior,1);
//printf("%s\n",FileInfo.prior);
sbuflen1=my_strchr(Buffer,FileInfo.StartTime,c3);
Copy_String(Buffer,tmp_buf1,sbuflen1);
Read_to_File(PLAYLISTFILE,FileInfo.StartTime,1);
//printf("%s\n",FileInfo.StartTime);
sbuflen1=my_strchr(Buffer,FileInfo.EndTime,c3);
Copy_String(Buffer,tmp_buf1,sbuflen1);
Read_to_File(PLAYLISTFILE,FileInfo.EndTime,1);
//printf("%s\n",FileInfo.EndTime);
Read_to_File(PLAYLISTFILE,FileInfo.tempbuf,1);
Read_to_File(PLAYLISTFILE,nextline,1);
if(j<=marklen1){
sbuflen2=my_strchr(Buffer,tempchar2,c7);
Copy_String(Buffer,tmp_buf1,sbuflen2);
}else{
memset(tempchar2,0,sizeof(tempchar2));
strcpy(tempchar2,Buffer);
}
marklen=getmark(tempchar2,c4);
memset(tempname,0,sizeof(tempname));
strcat(tempname,"down/");
strcat(tempname,"PL");
strcat(tempname,FileInfo.PLNumber);
strcat(tempname,".txt");
strcat(Conf.Uppl,FileInfo.PLNumber);
//printf("%s\n",Conf.Uppl);
if(marklen1>0&&j<marklen1+1)
strcat(Conf.Uppl,",");
Read_to_File(tempname,newPlFile, 0);
//Read_to_File(TempDownLoading_FileList,FileInfo.PLNumber,4);
while(i<marklen+2){
int wmode=1;
FileInfo.FileName[0]='\0';
sbuflen2=my_strchr(tempchar2,FileInfo.FileName,c5);
Copy_String(tempchar2,tmp_buf1,sbuflen2);
//printf("filename=%s\n",FileInfo.FileName);
Read_to_File(tempname,FileInfo.FileName,1);
sbuflen2=my_strchr(tempchar2,FileInfo.Vpath,c5);
Copy_String(tempchar2,tmp_buf1,sbuflen2);
sbuflen2=my_strchr(tempchar2,FileInfo.filetype,c5);
if((FileInfo.filetype[0]-'0')!=1)
wmode=0;
else{
Read_to_File(TempDownLoading_FileList,FileInfo.FileName,5);
}
Copy_String(tempchar2,tmp_buf1,sbuflen2);
sbuflen2=my_strchr(tempchar2,FileInfo.VFileSize,c5);
Copy_String(tempchar2,tmp_buf1,sbuflen2);
Read_to_File(tempname,FileInfo.VFileSize,1);
if((FileInfo.filetype[0]-'0')==1)
Read_to_File(TempDownLoading_FileList,FileInfo.VFileSize,2);
sbuflen2=my_strchr(tempchar2,FileInfo.Vlength,c5);
Copy_String(tempchar2,tmp_buf1,sbuflen2);
sbuflen2=my_strchr(tempchar2,FileInfo.Vverify,c4);
Copy_String(tempchar2,tmp_buf1,sbuflen2);
Read_to_File(tempname,FileInfo.Vverify,4);
//Read_to_File(tempname,nextline,3);
i++;
}
j++;
}
}
void Parse_Message_Data(char Mbuf[])
{
int n;
int marklen2=0,sbuflen3;
char tmp_buf2[MaxReceiveBufSize];
char STime[30];
char ETime[30];
char Title[80];
char ContentText[MaxReceiveBufSize];
char tempname1[80]="down/";
char newMl[30];
char nextline[8]="\r\n";
memset(Conf.Upml,0,sizeof(Conf.Upml));
Read_to_File(MSGLISTFILE,newMl,0);
marklen2=getmark(Mbuf,c4);
n=1;
while(n<marklen2+2){
tempname1[0]='\0';
strcpy(tempname1,"down/");
//memset(&FileInfo,0,sizeof(FileInfo));
//printf("mbuf=%s\n",Mbuf);
sbuflen3=my_strchr(Mbuf,FileInfo.tempbuf2,c5); //校验码
Copy_String(Mbuf,tmp_buf2,sbuflen3);
sbuflen3=my_strchr(Mbuf,FileInfo.tempbuf3,c5); //单号
strcat(Conf.Upml,FileInfo.tempbuf3);
if(marklen2>0&&n<marklen2+1)
strcat(Conf.Upml,",");
//printf("%s\n",Conf.Upml);
Copy_String(Mbuf,tmp_buf2,sbuflen3);
Read_to_File(MSGLISTFILE,FileInfo.tempbuf3,1);
//printf("%s\n",FileInfo.tempbuf3);
sbuflen3=my_strchr(Mbuf,STime,c5);
Copy_String(Mbuf,tmp_buf2,sbuflen3);
Read_to_File(MSGLISTFILE,STime,1); //开始时间
//printf("%s\n",STime);
sbuflen3=my_strchr(Mbuf,ETime,c5);
Copy_String(Mbuf,tmp_buf2,sbuflen3);
Read_to_File(MSGLISTFILE,ETime,1); //结束时间
//printf("%s\n",ETime);
// sbuflen=getfather_dir(tempchar1,c5,fp4,0); //标题
sbuflen3=my_strchr(Mbuf,Title,c5);
Copy_String(Mbuf,tmp_buf2,sbuflen3);
Read_to_File(MSGLISTFILE,FileInfo.tempbuf2,1);
Read_to_File(MSGLISTFILE,nextline,1);
// printf("%s\n",Title);
strcat(tempname1,"ML");
strcat(tempname1,FileInfo.tempbuf3);
strcat(tempname1,".txt");
//printf("%s\n",tempname1);
sbuflen3=my_strchr(Mbuf,ContentText,c4);
Copy_String(Mbuf,tmp_buf2,sbuflen3);
Read_to_File(tempname1,ContentText,3);
// printf("%s\n",ContentText);
// printf("%s\n",Conf.Upml);
n++;
}
}
#if 0
int PicCrc32(const char *filename,int PicSize)
{
FILE *fp;
int lenth;
char *crc32;
fp=fopen(filename,"r");
if(fp==NULL)
{
printf("file no exist!\n");
return PICNOFOUND;
}
fseek(fp,0,SEEK_END);
lenth=ftell(fp);
fclose(fp);
if(lenth!=PicSize)
return ERROR_PIC_VERYFY;
else{
crc32=FileCrc32(filename,crc32);
}
free(crc32);
return PIC_VERYFY_SUCESS;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -