⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 roswebparser.c

📁 这是一个开放源代码的与WINNT/WIN2K/WIN2003兼容的操作系统
💻 C
📖 第 1 页 / 共 4 页
字号:
  output : <obj type="COMBOBOX" rc_name="ID_ENCODING" top="54" left="0" right="156" bottom="80" style="CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP"></obj>
  output : <obj type="COMBOBOX" rc_name="ID_ENCODING" top="54" left="0" right="156" bottom="80"></obj>

  output : <obj type="GROUPBOX" rc_name="IDC_LABEL4" top="7" left="96" right="157" bottom="28" style="CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP"><![CDATA[&Display Mode]]></obj>
  output : <obj type="GROUPBOX" rc_name="IDC_LABEL4" top="7" left="96" right="157" bottom="28"><![CDATA[&Display Mode]]></obj>
    
  builder2
  input  : CAPTION "Execute"     
  input  : EXSTYLE WS_EX_APPWINDOW
  input  : STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

  output : <obj type="STYLE">DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU</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 ParserDialog(unsigned char *text, 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; 
  long commandfound=0;
  long le;

  *output_resid='\0';
  le=0;

  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);
	  trim(row);
     
	  if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
	     commandfound=1;
	  if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
	     commandfound=2;

	  if (strncmp("STYLE ",row,6)==0)
	     commandfound=3;
	  if (strncmp("CAPTION ",row,8)==0)
	     commandfound=3;
	  if (strncmp("FONT ",row,5)==0)
	     commandfound=3;
	  if (strncmp("CONTROL ",row,8)==0)
	     commandfound=3;
	  if (strncmp("EDITTEXT ",row,9)==0)
	     commandfound=3;
	  if (strncmp("DEFPUSHBUTTON ",row,14)==0)
	     commandfound=3;
	  if (strncmp("PUSHBUTTON ",row,11)==0)
	     commandfound=3;
	  if (strncmp("LTEXT ",row,6)==0)
	     commandfound=3;
	  if (strncmp("GROUPBOX ",row,9)==0)
	     commandfound=3;
	  if (strncmp("ICON ",row,5)==0)
	     commandfound=3;
	  if (strncmp("EXSTYLE ",row,8)==0)
	     commandfound=3;
	  if (strncmp(row,"LISTBOX ",8)==0) 		  
         commandfound=3;
	  if (strncmp(row,"COMBOBOX ",9)==0) 		  
         commandfound=3;

      if ((*output_resid!=0) && (commandfound!=0))
	  {
		  /* Builder 1*/
          if (strncmp(output_resid,"LTEXT ",6)==0)		  
             DialogCMDBuild1(output_resid, output_format, 5, "LTEXT");
          if (strncmp(output_resid,"GROUPBOX ",9)==0)
              DialogCMDBuild1(output_resid, output_format, 8, "GROUPBOX");
		  if (strncmp(output_resid,"DEFPUSHBUTTON ",14)==0)
			  DialogCMDBuild1(output_resid, output_format, 13, "DEFPUSHBUTTON");
          if (strncmp(output_resid,"PUSHBUTTON ",11)==0)
			  DialogCMDBuild1(output_resid, output_format, 10, "PUSHBUTTON");
		  if (strncmp("ICON ",output_resid,5)==0)
			  DialogCMDBuild1(output_resid, output_format, 4, "ICON");
		  if (strncmp("EDITTEXT ",output_resid,9)==0)
			  DialogCMDBuild1(output_resid, output_format, 8, "EDITTEXT");
		  if (strncmp("LISTBOX ",output_resid,8)==0)
			  DialogCMDBuild1(output_resid, output_format, 7, "LISTBOX");
		  if (strncmp("COMBOBOX ",output_resid,9)==0)
			  DialogCMDBuild1(output_resid, output_format, 8, "COMBOBOX");
          
		  /* Builder 2*/
		  if (strncmp("STYLE ",output_resid,6)==0)
		      DialogCMDBuild2(output_resid, output_format, 5, "STYLE");
		  if (strncmp("EXSTYLE ",output_resid,8)==0)
		      DialogCMDBuild2(output_resid, output_format, 7, "EXSTYLE");
		  if (strncmp("CAPTION ",output_resid,8)==0)
			  DialogCMDBuild2(output_resid, output_format, 7, "CAPTION");
		  if (strncmp("CONTROL ",output_resid,8)==0)
			  DialogCMDBuild3(output_resid, output_format, 7, "CONTROL");

		  /* no builder */
		  if (strncmp(output_resid,"FONT ",5)==0) 
		  {
             stringbugs(output_resid,true);
			 /* FONT */
			 sprintf(output_resid,"%s",&output_resid[5]);
			 trim(output_resid);
			 sprintf(output_format,"%s  <obj type=\"FONT\" size=\"",output_format);
			 le = strlen(output_format);
             sprintf(output_format,"%s%s",output_format,output_resid);
             
			 foundPos=0;
			 find_str('\"',output_resid,&foundPos);			 
			 output_format[le+foundPos-1]='\0';
			 trim(&output_format[le]);
			 sprintf(output_format,"%s\" name=",output_format);
             le = strlen(output_format);
			 sprintf(output_format,"%s%s",output_format,&output_resid[foundPos-1]);
             
			 foundNextPos=0;
			 find_str('\"',&output_resid[foundPos],&foundNextPos);
			 output_format[le+foundPos+foundNextPos-1]='\0';
			 trim(&output_format[le+foundPos]);
			 if (output_resid[foundPos+foundNextPos]=='\0')
			 {				  
				sprintf(output_format,"%s></obj>\n",output_format);
			 }
			 else
			 {
				 sprintf(output_format,"%s\">%s</obj>\n",output_format,&output_resid[foundPos]);
			 }

             *output_resid=0;
		  }

	    *output_resid='\0';
	  }
	 		 
	  if (commandfound==1)
	  {
		  sprintf(output_format,"%s  <obj type=\"%s\" command=\"BEGIN\" />\n",output_format,text);
	  }
	  if (commandfound==2)
	  {
		  sprintf(output_format,"%s  <obj type=\"%s\" command=\"END\" />\n</group>\n",output_format,text);
		  break;
	  }

	  sprintf(output_resid,"%s%s",output_resid,row);
	  commandfound=0;      
  }

}
//////////////////////////
/*
  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" />
 
  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 ParserMenu(unsigned char *text, 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; 
  long commandfound=0;
  long le;
  long count=0;

  *output_resid='\0';
  le=0;

  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);
	  stringbugs2(row,true);
     
	  if ((strcmp(row,"BEGIN")==0) || (strcmp(row,"{")==0))
	     commandfound=1;
	  if ((strcmp(row,"END")==0) || (strcmp(row,"}")==0))
	     commandfound=2;

	  if (strncmp("POPUP ",row,6)==0)
	     commandfound=3;
	  if (strncmp("MENUITEM ",row,8)==0)
	     commandfound=3;
	 

      if ((*output_resid!=0) && (commandfound!=0))
	  {		   
          if (strncmp(output_resid,"POPUP ",6)==0)		  
		  {
			 sprintf(output_resid,"%s",&output_resid[5]);   
             trim(output_resid);			 
			 sprintf(output_format,"%s<obj type=\"POPUP\"><![CDATA[%s]]></obj>\n",output_format,output_resid);   
             *output_resid='\0'; 
		  }

		  if (strncmp(output_resid,"MENUITEM ",9)==0)
		  {
              sprintf(output_resid,"%s",&output_resid[8]);			  
			  trim(output_resid);
			  if (strcmp(output_resid,"SEPARATOR")==0)
			  {
				 sprintf(output_format,"%s<obj type=\"MENUITEMSEPERATOR\"></obj>\n",output_format);   
				 *output_resid='\0';
			  }
			  else
			  {
				  foundPos=0;
				  foundNextPos=0;
				  find_str('"',output_resid,&foundPos);
				  find_str('"',&output_resid[foundPos],&foundNextPos);
                  
				  stringbugs(&output_resid[foundPos+foundNextPos],true);

				  if ((foundPos+foundNextPos)==0)
				  {
					 sprintf(output_format,"%s<obj type=\"MENUITEM\" rc_name=\"%s\"></obj>\n",output_format,&output_resid[foundPos+foundNextPos]);   
				  }
				  else
				  {
				    sprintf(output_format,"%s<obj type=\"MENUITEM\" rc_name=\"%s\">",output_format,&output_resid[foundPos+foundNextPos]);   
					
					output_resid[foundPos+foundNextPos]='\0';
					trim(output_resid);
						                   
                    sprintf(output_format,"%s<![CDATA[%s]]></obj>\n",output_format,output_resid);    
				  }
                   


                 *output_resid='\0';
			  }
		  }

      
		 
	    *output_resid='\0';
	  }
	 		 
	  if (commandfound==1)
	  {
		  count++;
		  if (count==1)
		      sprintf(output_format,"%s<obj type=\"%s\" command=\"BEGIN\" />\n",output_format,text);
		  else
			  sprintf(output_format,"%s<obj type=\"POPUP\" command=\"BEGIN\" />\n",output_format);

		  *output_resid='\0';
	  }
	  if (commandfound==2)
	  {
		  count--;
		  *output_resid='\0';

		  if (count<1)
		      sprintf(output_format,"%s<obj type=\"%s\" command=\"END\" />\n",output_format,text);
		  else
			  sprintf(output_format,"%s<obj type=\"POPUP\" command=\"END\" />\n",output_format);
		  
		  if (count<1)
		  {
			  sprintf(output_format,"%s</group>\n",output_format);
			  break;
		  }
	  }

	  sprintf(output_resid,"%s%s",output_resid,row);
	  commandfound=0;      
  }

}

void stringbugs(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],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)
	     {
		     buf[t]=' ';
	     }

	     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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -