📄 roswebparser.c
字号:
trim(output_resid);
trim(output_text);
find_str2 (" ",output_text,&flag,output_resid,output_text);
trim(output_resid);
trim(output_text);
sprintf(output_format,"%sleft=\"%s\" ",output_format,output_resid);
trim(output_resid);
trim(output_text);
find_str2 (" ",output_text,&flag,output_resid,output_text);
trim(output_resid);
trim(output_text);
sprintf(output_format,"%stop=\"%s\" ",output_format,output_resid);
trim(output_resid);
trim(output_text);
find_str2 (" ",output_text,&flag,output_resid,output_text);
trim(output_resid);
trim(output_text);
if (flag==0)
sprintf(output_format,"%swidth=\"%s\" height=\"%s\"></obj>\n",output_format,output_resid,output_text);
else
sprintf(output_format,"%swidth=\"%s\" height=\"%s\">DISCARDABLE</obj>\n",output_format,output_resid,output_text);
}
/*
ParserCMD3
data
input : STRINGTABLE DISCARDABLE LANG LANG_TAG LANG_TAG
input : STRINGTABLE DISCARDABLE LANG
input : STRINGTABLE LANG LANG_TAG LANG_TAG
input : STRINGTABLE
output : <obj type="STRINGTABLE">DISCARDABLE</obj>
output : <obj type="STRINGTABLE">DISCARDABLE</obj>
output : <obj type="STRINGTABLE"></obj>
output : <obj type="STRINGTABLE"></obj>
param : output_resid = empty
param : output_text = DIALOG DISCARDABLE 15, 13, 210, 63 LANG LANG_TAG LANG_TAG
param : text = type example DIALOG
param : output_format = xml data store buffer
*/
void ParserCMD3(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format)
{
long foundPos=0;
stringbugs(output_resid,false);
stringbugs(output_text,false);
find_str2 (" ",output_text,&foundPos,output_resid,output_text);
trim(output_resid);
trim(output_text);
if(strncmp("STRINGTABLE",output_text,11))
sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\">DISCARDABLE</obj>\n",output_format,output_text,output_resid);
else
sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\"></obj>\n",output_format,output_resid,output_text);
}
/*
ParserLang
data
input : LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
input : LANGUAGE LANG_ENGLISH SUBLANG_ENGLISH_US
output : <obj type="LANG" sublang="sub">lang</obj>
output : <obj type="LANG" sublang="sub">lang</obj>
param : output_resid = not in use
param : output_text = LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
param : text = type example LANGUAGE
param : output_format = xml data store buffer
*/
void ParserLang(unsigned char *text, unsigned char *output_resid, unsigned char *output_text, unsigned char *output_format)
{
long foundPos=0;
stringbugs(output_resid,false);
stringbugs(output_text,false);
sprintf(output_text,"%s",&output_text[strlen(text)+1]);
/* split the lang into two string */
find_str2 (" ",output_text,&foundPos,output_resid,output_text);
trim(output_resid);
trim(output_text);
sprintf(output_format,"%s<group name=\"%s\">\n <obj type=\"%s\" sublang=\"%s\">%s</obj>\n</group>\n",output_format,text,text,output_text,output_resid);
}
/*
ParserComment
data
input : / * sadasdas asdasd asdas ... * /
output :<obj type=\"COMMENT\"><![CDATA[ sadasdas asdasd asdas ... ]]></obj>
input : / * sadasdas asdasd asdas ... * /
output :<obj type=\"COMMENT\"><![CDATA[ sadasdas asdasd asdas ... ]]></obj>
input : #if x
output :<obj type=\"COMMENT\"><![CDATA[#if x]]></obj>
input : // hi
output :<obj type=\"COMMENT\"><![CDATA[// hi]]></obj>
param : pos = current buf position
param : buf = read in buffer from file rc
param : buf_size = buf max size
param : output_text = using internal instead alloc more memory
param : output_resid = using internal instead alloc more memory
param : output_format = xml data store buffer
*/
void ParserComment(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
{
long foundPos=0;
long foundNextPos=0;
long row_size=0;
unsigned char *row = output_text;
row_size = strlen(row);
if (strncmp("//",&row[0],2)==0)
{
sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s]]></obj>\n</group>\n",output_format,row);
return;
}
if (strncmp("#",&row[0],1)==0)
{
sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s]]></obj>\n</group>\n",output_format,row);
return;
}
for (foundNextPos=0;foundNextPos<row_size;foundNextPos++)
{
if (strncmp("*/",&row[foundNextPos],2)==0)
{
//*pos=*pos+foundNextPos+1;
//*pos=(*pos- (row_size+foundNextPos+2))+foundNextPos+2;
row[foundNextPos+2]='\0';
sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s]]></obj>\n</group>\n",output_format,row);
return;
}
}
sprintf(output_format,"%s<group name=\"COMMENT\">\n <obj type=\"COMMENT\"><![CDATA[%s\n",output_format,output_text);
while(*pos < buf_size)
{
foundPos=0;
row_size=0;
/* create a row string so we can easy scan it */
find_str('\n',&buf[*pos],&foundPos);
if (foundPos !=0)
{
row_size = foundPos - 1;
/* found a new row */
strncpy(row, &buf[*pos], foundPos);
*pos+=foundPos;
if (foundPos >=2)
{
row[row_size -1]=0;
}
}
else
{
row_size = buf_size - *pos;
/* no new row found in the buffer */
strncpy(row, &buf[*pos], buf_size - *pos);
*pos= buf_size;
}
/* Search now after end of comment */
row_size=strlen(row);
for (foundNextPos=0;foundNextPos<row_size;foundNextPos++)
{
if (strncmp("*/",&row[foundNextPos],2)==0)
{
row_size=row_size - (foundNextPos+2);
*pos-=row_size;
row[foundNextPos+2]='\0';
sprintf(output_format,"%s%s]]></obj>\n</group>\n",output_format,row);
return;
}
}
sprintf(output_format,"%s%s\n",output_format,row);
}
}
/*
ParserAccelerators
data
input : BEGIN
input : "^A", CMD_SELECT_ALL
input : END
output : <obj type="ACCELERATORS" command="BEGIN" />
output : <obj type="ACCELERATORS" rc_name="CMD_SEARCH"><![CDATA[^F]]></obj>
output : <obj type="ACCELERATORS" command="END" />
param : pos = current buf position
param : buf = read in buffer from file rc
param : buf_size = buf max size
param : output_text = using internal instead alloc more memory
param : output_resid = using internal instead alloc more memory
param : output_format = xml data store buffer
*/
void ParserAccelerators(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
{
long foundPos=0;
long foundNextPos=0;
long row_size=0;
char *row = output_text;
int start=false;
long le;
while(*pos < buf_size)
{
foundPos=0;
row_size=0;
/* create a row string so we can easy scan it */
find_str('\n',&buf[*pos],&foundPos);
if (foundPos !=0)
{
row_size = foundPos - 1;
/* found a new row */
strncpy(row, &buf[*pos], foundPos);
*pos+=foundPos;
if (foundPos >=2)
{
row[row_size -1]=0;
}
}
else
{
row_size = buf_size - *pos;
/* no new row found in the buffer */
strncpy(row, &buf[*pos], buf_size - *pos);
*pos= buf_size;
}
stringbugs(row,true);
if (start == false)
{
if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
{
start=true;
sprintf(output_format,"%s <obj type=\"ACCELERATORS\" command=\"BEGIN\" />\n",output_format);
}
continue;
}
if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
{
sprintf(output_format,"%s <obj type=\"ACCELERATORS\" command=\"END\" />\n</group>\n",output_format);
*output_resid = '\0';
break;
}
foundPos=0;
foundNextPos=0;
find_str('"',row,&foundPos);
find_str('"',&row[foundPos],&foundNextPos);
if ((foundPos!=0) && (foundNextPos!=0))
{
sprintf(output_format,"%s <obj type=\"KEY\" rc_name=\"",output_format);
le = strlen(output_format);
sprintf(output_format,"%s%s",output_format,&row[foundNextPos+foundPos]);
trim(&output_format[le]);
row[foundNextPos+foundPos]='\0';
row[foundPos-1]=' ';
foundPos=0;
find_str('"',row,&foundPos);
if (foundPos!=0)
{
row[foundPos-1]=' ';
}
trim(row);
sprintf(output_format,"%s\"><![CDATA[%s]]></obj>\n",output_format,row);
}
}
}
/*
ParserString
data
input : BEGIN
input : IDS_HINT_BLANK "text"
input : END
output : <obj type="STRINGTABLE" command="BEGIN" />
output : <obj type="STRING" rc_name="rc_id">text</obj>
output : <obj type="STRINGTABLE" command="END" />
param : pos = current buf position
param : buf = read in buffer from file rc
param : buf_size = buf max size
param : output_text = using internal instead alloc more memory
param : output_resid = using internal instead alloc more memory
param : output_format = xml data store buffer
*/
void ParserString(long *pos, unsigned char *buf, long buf_size, unsigned char * output_text, unsigned char * output_resid, unsigned char * output_format)
{
long foundPos=0;
long row_size=0;
unsigned char *row = output_text;
int start=false;
while(*pos < buf_size)
{
foundPos=0;
row_size=0;
/* create a row string so we can easy scan it */
find_str('\n',&buf[*pos],&foundPos);
if (foundPos !=0)
{
row_size = foundPos - 1;
/* found a new row */
strncpy(row, &buf[*pos], foundPos);
*pos+=foundPos;
if (foundPos >=2)
{
row[row_size -1]=0;
}
}
else
{
row_size = buf_size - *pos;
/* no new row found in the buffer */
strncpy(row, &buf[*pos], buf_size - *pos);
*pos= buf_size;
}
stringbugs(row,true);
if (start == false)
{
if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
{
start=true;
sprintf(output_format,"%s <obj type=\"STRINGTABLE\" command=\"BEGIN\" />\n",output_format);
}
continue;
}
if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
{
sprintf(output_format,"%s <obj type=\"STRINGTABLE\" command=\"END\" />\n</group>\n",output_format);
*output_resid = '\0';
break;
}
/* the split code here */
foundPos=0;
find_str2 (" ",row,&foundPos,output_resid,output_text);
if (foundPos != 0)
{
trim(output_text);
trim(output_resid);
if (*output_resid!='\0')
sprintf(output_format,"%s <obj type=\"STRING\" rc_name=\"%s\"><![CDATA[%s]]></obj>\n",output_format,output_resid,output_text);
else
sprintf(output_format,"%s <obj type=\"STRING\" rc_name=\"%s\"></obj>\n",output_format,output_resid);
}
}
}
/*
ParserDialog
data
input : BEGIN
output : <obj type="DIALOG" command="BEGIN" />
output : <obj type="DIALOGEX" command="BEGIN" />
input : END
output : <obj type="END" command="BEGIN" />
output : <obj type="END" command="BEGIN" />
input : {
output : <obj type="DIALOG" command="BEGIN" />
output : <obj type="DIALOGEX" command="BEGIN" />
input : }
output : <obj type="END" command="BEGIN" />
output : <obj type="END" command="BEGIN" />
input : FONT 8, "MS Shell Dlg"
output : <obj type="FONT" size="8" name="MS Shell Dlg"></obj>
input : FONT 8, "MS Shell Dlg", 0, 0, 0x1
output : <obj type="FONT" size="8" name="MS Shell Dlg">0 0 0x1</obj>
input : CONTROL "",101,"Static",SS_SIMPLE | SS_NOPREFIX,3,6,150,10
output : <obj type="CONTROL" rc_name="IDC_ICON_ALIGN_1" prop="Button" style="BS_OWNERDRAW |BS_BOTTOM | WS_TABSTOP" top="57" left="25" right="46" bottom="44"><![CDATA[left/top right]]></obj>
Builder1
input : DEFPUSHBUTTON "&OK",1,158,6,47,14 xx
input : PUSHBUTTON "&Cancel",2,158,23,47,14 xx
input : LTEXT "&Tooltip Text:",IDC_LABEL1,7,44,40,8 xx
input : GROUPBOX "&Display Mode",IDC_LABEL4,7,96,157,28 xx
input : ICON "",IDC_PICTURE,173,101,21,20 xx
input : EDITTEXT 201,3,29,134,12,ES_AUTOHSCROLL
input : LISTBOX IDC_LIST, 4, 16, 104, 46, WS_TABSTOP
input : COMBOBOX ID_EOLN,54,18,156,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -