📄 roswebparser.c
字号:
/* have remove all wrong syntax */
}
void stringbugs2(unsigned char *buf, int shift2)
{
long foundPos=0;
long foundNextPos=0;
long t=0;
/* remove , */
if (shift2== false)
{
for (t=0;t<strlen(buf);t++)
{
if (foundPos==0)
{
if (strncmp("\"",&buf[t],1)==0)
{
buf[t]=' ';
}
if (strncmp("/*",&buf[t],2)==0)
{
foundPos=t;
buf[t]=' ';
buf[t+1]=' ';
}
}
else
{
if (strncmp("*/",&buf[t],2)==0)
{
buf[t]=' ';
buf[t+1]=' ';
foundPos=0;
}
else
{
buf[t]=' ';
}
}
}
}
else
{
/* shift */
for (t=0;t<strlen(buf);t++)
{
if ((foundPos==0) && (foundNextPos==0))
{
if (strncmp("\"",&buf[t],1)==0)
{
foundNextPos=t;
}
if (strncmp("/*",&buf[t],2)==0)
{
foundPos=t;
buf[t]=' ';
buf[t+1]=' ';
}
}
else
{
if (foundPos!=0)
{
if (strncmp("*/",&buf[t],2)==0)
{
buf[t]=' ';
buf[t+1]=' ';
foundPos=0;
}
else
{
buf[t]=' ';
}
}
if (foundNextPos!=0)
{
if (strncmp("\"",&buf[t],1)==0)
{
foundNextPos=0;
}
}
}
}
}
trim(buf);
/* have remove all wrong syntax */
}
void trim(unsigned char* buf)
{
size_t le;
if (buf==NULL)
return;
if (*buf==0)
return;
le=strlen(buf);
while(le>0)
{
if (isspace(buf[le-1])!=0)
{
buf[le-1]=0;
le=strlen(buf);
}
else
{
break;
}
}
le=strlen(buf);
while(le>0)
{
if (isspace(buf[0])!=0)
{
strncpy(&buf[0],&buf[1],le-1);
buf[le-1]=0;
le=strlen(buf);
}
else
{
break;
}
}
}
void find_str(unsigned char asc,unsigned char *buf, long *foundPos)
{
int t;
size_t le;
le=strlen(buf);
for (t=0;t<le;t++)
{
if (buf[t]==asc)
{
*foundPos = *foundPos+t+1;
break ;
}
}
/* for end of line the \ is a special case */
if ((asc == '\n') && (foundPos!=0) && (buf[t-2]=='\\'))
{
long extra=t+1;
find_str(asc, &buf[extra], foundPos);
}
}
void find_str2(unsigned char *asc, unsigned char *buf, long *foundPos,
unsigned char * output_resid, unsigned char *output_text)
{
int t=0;
size_t le;
size_t lec;
le=strlen(buf);
lec=strlen(asc);
if ((lec==0) || (le==0))
{
return;
}
for (t=0;t<le;t++)
{
if (strncmp(&buf[t],asc,lec)==0)
{
long softfoundPos=0;
*foundPos = *foundPos+t+lec;
softfoundPos = *foundPos;
strncpy(output_resid, &buf[0], t);
output_resid[t]=0;
strncpy(output_text, &buf[t], le-t);
output_text[ le-t ]=0;
break ;
}
}
}
void DialogCMDBuild1(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text)
{
unsigned char extra[1000];
long foundPos=0;
long foundNextPos=0;
long le;
long size;
stringbugs(output_resid,true);
sprintf(output_resid,"%s",&output_resid[pos]);
trim(output_resid);
find_str('"',output_resid,&foundPos);
find_str('"',&output_resid[foundPos],&foundNextPos);
if ((foundPos!=0) && (foundPos!=0))
{
strcpy(extra,&output_resid[foundPos+foundNextPos]);
trim(extra);
output_resid[foundPos+foundNextPos]='\0';
trim(output_resid);
}
else
{
strcpy(extra,output_resid);
*output_resid='\0';
}
// \0
sprintf(output_format,"%s <obj type=\"%s\" rc_name=\"%s",output_format,text,extra);
foundPos=0;
find_str(' ',extra,&foundPos);
le = (strlen(output_format) - strlen(extra))+foundPos-1;
output_format[le]='\0';
sprintf(extra,"%s",&extra[foundPos]);
trim(extra);
/* top */
// \0
sprintf(output_format,"%s\" left=\"%s",output_format,extra);
foundPos=0;
find_str(' ',extra,&foundPos);
le = (strlen(output_format) - strlen(extra))+foundPos-1;
output_format[le]='\0';
sprintf(extra,"%s",&extra[foundPos]);
trim(extra);
/* left */
// \0
sprintf(output_format,"%s\" top=\"%s",output_format,extra);
foundPos=0;
find_str(' ',extra,&foundPos);
le = (strlen(output_format) - strlen(extra))+foundPos-1;
output_format[le]='\0';
sprintf(extra,"%s",&extra[foundPos]);
trim(extra);
/* right */
// \0
sprintf(output_format,"%s\" width=\"%s",output_format,extra);
foundPos=0;
find_str(' ',extra,&foundPos);
le = (strlen(output_format) - strlen(extra))+foundPos-1;
output_format[le]='\0';
sprintf(extra,"%s",&extra[foundPos]);
trim(extra);
/* bottom */
// \0
sprintf(output_format,"%s\" height=\"%s",output_format,extra);
foundPos=0;
find_str(' ',extra,&foundPos);
if (foundPos!=0)
{
le = (strlen(output_format) - strlen(extra))+foundPos-1;
size = strlen(&output_format[le]);
output_format[le]='\0';
sprintf(extra,"%s",&output_format[le+1]);
trim(extra);
/* style */
size = strlen(output_format) + strlen(extra) + 9;
sprintf(output_format,"%s\" style=\"%s",output_format,extra);
output_format[size]='\0';
foundPos=0;
find_str(' ',extra,&foundPos);
if (*output_resid!='\0')
{
sprintf(output_format,"%s\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
}
else
{
sprintf(output_format,"%s\"></obj>\n",output_format);
}
}
else
{
if (*output_resid!='\0')
sprintf(output_format,"%s\" style=\"\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
else
sprintf(output_format,"%s\" style=\"\"></obj>\n",output_format);
}
*output_resid='\0';
}
void DialogCMDBuild2(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text)
{
long le;
stringbugs(output_resid,true);
sprintf(output_resid,"%s",&output_resid[pos]);
trim(output_resid);
le = strlen(output_resid);
if (*output_resid=='"')
*output_resid=' ';
if (output_resid[le-1]=='"')
output_resid[le-1]=' ';
trim(output_resid);
sprintf(output_format,"%s <obj type=\"%s\"><![CDATA[%s]]></obj>\n",output_format,text,output_resid);
*output_resid='\0';
}
// input : CONTROL "",101,"Static",SS_SIMPLE | SS_NOPREFIX,3,6,150,10
void DialogCMDBuild3(unsigned char *output_resid, unsigned char *output_format, long pos, unsigned char * text)
{
long foundPos=0;
long foundNextPos=0;
long le;
long count=0;
long save1;
long save2;
sprintf(output_resid,"%s",&output_resid[pos]);
trim(output_resid);
find_str('"',output_resid,&foundPos);
find_str('"',&output_resid[foundPos],&foundNextPos);
save1=foundPos;
save2=foundNextPos;
sprintf(output_format,"%s <obj type=\"%s\" rc_name=\"",output_format,text);
le=strlen(output_format);
count=foundNextPos+foundPos;
if (output_resid[count]==',')
output_resid[count]=' ';
foundPos=0;
find_str(',',&output_resid[count],&foundPos);
sprintf(output_format,"%s%s\"",output_format,&output_resid[count]);
output_format[le+foundPos]='\0';
stringbugs(&output_format[le],false);
count+=foundPos;
/* prop */
sprintf(output_format,"%s\" prop=\"",output_format);
le=strlen(output_format);
sprintf(output_format,"%s%s",output_format,&output_resid[count]);
if (output_resid[count]==',')
output_resid[count]=' ';
foundPos=0;
find_str(',',&output_resid[count],&foundPos);
output_format[le+foundPos]='\0';
stringbugs(&output_format[le],false);
count+=foundPos;
/* style */
sprintf(output_format,"%s\" style=\"",output_format);
le=strlen(output_format);
sprintf(output_format,"%s%s",output_format,&output_resid[count]);
if (output_resid[count]==',')
output_resid[count]=' ';
foundPos=0;
find_str(',',&output_resid[count],&foundPos);
output_format[le+foundPos]='\0';
stringbugs(&output_format[le],false);
count+=foundPos;
/* top */
sprintf(output_format,"%s\" left=\"",output_format);
le=strlen(output_format);
sprintf(output_format,"%s%s",output_format,&output_resid[count]);
if (output_resid[count]==',')
output_resid[count]=' ';
foundPos=0;
find_str(',',&output_resid[count],&foundPos);
output_format[le+foundPos]='\0';
stringbugs(&output_format[le],false);
count+=foundPos;
/* left */
sprintf(output_format,"%s\" top=\"",output_format);
le=strlen(output_format);
sprintf(output_format,"%s%s",output_format,&output_resid[count]);
if (output_resid[count]==',')
output_resid[count]=' ';
foundPos=0;
find_str(',',&output_resid[count],&foundPos);
output_format[le+foundPos]='\0';
stringbugs(&output_format[le],false);
count+=foundPos;
/* right */
sprintf(output_format,"%s\" width=\"",output_format);
le=strlen(output_format);
sprintf(output_format,"%s%s",output_format,&output_resid[count]);
if (output_resid[count]==',')
output_resid[count]=' ';
foundPos=0;
find_str(',',&output_resid[count],&foundPos);
output_format[le+foundPos]='\0';
stringbugs(&output_format[le],false);
count+=foundPos;
/* bottom */
sprintf(output_format,"%s\" height=\"",output_format);
le=strlen(output_format);
sprintf(output_format,"%s%s",output_format,&output_resid[count]);
stringbugs(&output_format[le],false);
/* string */
output_resid[save1+save2]='\0';
stringbugs(output_resid,true);
if (*output_resid!='\0')
sprintf(output_format,"%s\"><![CDATA[%s]]></obj>\n",output_format,output_resid);
else
sprintf(output_format,"%s\"></obj>\n",output_format);
*output_resid='\0';
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -