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

📄 ota.c

📁 WAP browser is based on the Wireless Application Protocol web browser, WAP1.3 will enable mobile pho
💻 C
📖 第 1 页 / 共 3 页
字号:
				}
				wmldck->offset=startoffset;
				attr = getAttributes(wmldck,END,g);
				break;
			case WML_input:
				if ( (attr = getAttributes(wmldck,WML_name,g))){	
	                wmlInput(attr,g);
	                /*wmldck->offset=startoffset;
					if ( (attr = getAttributes(wmldck,WML_type_password,g))){	
		                palmWmlInputType(true, g);
					} 							
					else {
						wmldck->offset=startoffset;
		                palmWmlInputType(false, g);
					}*/	
				} 											
				wmldck->offset=startoffset;
				if ( (attr = getAttributes(wmldck,WML_value,g))){
	                wmlInputValue(attr,g);
				} 							
				wmldck->offset=startoffset;
				attr = getAttributes(wmldck,END,g);
			    break;
			case WML_select:
				if ( (attr = getAttributes(wmldck,WML_name,g))){
	                wmlSelect(attr,g);
				} 		
				else {
				wmldck->offset=startoffset;
					wmlSelect("na",g);//this is not a good way to do this. Some sites
					//such as www.nytimes.com/wap use only <select>. We need to handle it
					//but if we get more than one titleless select we are in trouble.
				}						
				wmldck->offset=startoffset;
				if ( (attr = getAttributes(wmldck,WML_ivalue,g))){
	                wmlSelectValue(attr,g);
				} 							
				wmldck->offset=startoffset;
				if ( (attr = getAttributes(wmldck,WML_value,g))){
	                wmlSelectValue(attr,g);
				} 							
				wmldck->offset=startoffset;
				attr = getAttributes(wmldck,END,g);			
				break;
			case WML_option:
				g->Render=false;
				if ( (attr = getAttributes(wmldck,WML_value,g))){
	                wmlSelectOption(attr,g);
				}
				else {
				wmldck->offset=startoffset;
					wmlSelectOption("na",g);
				}
				wmldck->offset=startoffset;
				if ( (attr = getAttributes(wmldck,WML_onpick,g))){
	                //wmlSelectOption(attr,g);
	                palmWmlSelectOptionOnPick(attr, g);
				}					
				wmldck->offset=startoffset;
				attr = getAttributes(wmldck,END,g);							
				break;		
			case WML_td://TODO: Add table support
				g->needSpace=2;
				attr = getAttributes(wmldck,END,g);
				break;
			case WML_tr://TODO: Add table support
				renderLn(g);
				attr = getAttributes(wmldck,END,g);
				break;					
			default:
				attr = getAttributes(wmldck,END,g);
			}
            break;

        case ACTION_SRC :
            srcTag(wmldck,g);                   
            getAttributes(wmldck,END,g);
            break;
        case ACTION_PARSE :
            checkCards(startoffset,wmldck,g);
            break;
        default :
            getAttributes(wmldck,END,g);

        }       
    }
    // check for content
    if (c & WBXML_has_content) {
        pushwmlstack(wmldck);
        srcString(wmldck,">\n",g);
        srcIndent(wmldck,g);
    } else {
        srcString(wmldck,"/>\n",g);
        srcIndent(wmldck,g);
    }
    return(0);
}


int wbxml_parse_header(WSPPDUPtr wsppdu, WMLDeckPtr wmldck)
{
    int j;
    int strTableSz;

    wmldck->stackDepth = 0;
    wmldck->stack = NULL;
    wmldck->offset = 0;
    wmldck->data = wsppdu->data;
    wmldck->version = wmldck->data[wmldck->offset++];
    wmldck->publicID = wmldck->data[wmldck->offset++];
    if (wmldck->publicID==0)
        wmldck->offset++;
    // get the CharSet
    wmldck->charSet = wmldck->data[wmldck->offset++]; // not implemented yet ...
    // get the StringTable size, allocate memory and load it.
    strTableSz = WspReadInt(wmldck->data,&(wmldck->offset));
    wmldck->strTable=Malloc(strTableSz+1);
	wmldck->attrstr=Malloc(256);
	wmldck->tmpstr=Malloc(256);
    if ((!wmldck->strTable)||(!wmldck->attrstr) || (!wmldck->tmpstr) ) {
        ErrDisplay("Malloc");
        return(WML_ERR_MEM);
    }
    for (j=0;j<strTableSz;j++)
        wmldck->strTable[j] = wmldck->data[wmldck->offset++];
    wmldck->strTable[j]= 0;
    wmldck->decksize = wsppdu->length - wmldck->offset;
    wmldck->data = (wsppdu->data)+wmldck->offset;
    wmldck->offset = 0;
    return(0);
}


int wbxml_parse(WSPPDUPtr wsppdu, int action, WMLDeckPtr wmldck, int offset, GlobalsType *g)
{
	unsigned char *temp,c;
    int j,l;
    Int16  					linkLen, postLen;
 	RGBColorType       color;  
	IndexedColorType   indexedColor;
	
		//For DO tags
		color.r   = ( UInt8 ) 0;//Set the amount of Red to use (0 - 255)
	    color.g   = ( UInt8 ) 0;//Set the amount of Green to use (0 - 255)
	    color.b   = ( UInt8 ) 210;//255;//Set the amount of Blue to use (0 - 255)
	    indexedColor  = WinRGBToIndex( &color );


    if (wsppdu->data==NULL) {
        return -1;
    }
	temp = Malloc (DEF_RECEIVE_BUF);
	ErrFatalDisplayIf (!temp, "Malloc Failed");
    wbxml_parse_header(wsppdu, wmldck);  
    wmldck->action = action;
	wmldck->offset = offset;
    // Parse the WBXML bytecode
    while (wmldck->offset < wmldck->decksize) {
        switch (wmldck->data[wmldck->offset]) {
        case SWITCH_PAGE :
            //DisplayError("SWITCH_PAGE WMLC");
            break;
        case END:
            c= popwmlstack(wmldck);
            if (wmldck->action== ACTION_SRC) {
                srcString(wmldck,"\n",g);
                srcIndent(wmldck,g);
                srcString(wmldck,"</",g);
                srcString(wmldck,wmltag[c-5],g);
                srcString(wmldck,">",g);
            }
			if (wmldck->action== ACTION_RENDER) {
				switch(c) {
				case WML_option:
	                wmlSelectOptionTxt(temp,g);
					g->Render=true;
					break;
				case WML_select:
					wmlSelectEnd(g);
					break;
				case WML_u:
					underline(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_strong:
					strong(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_big:
					big(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_small:
					small(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_i:
					italic(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_em:
					em(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_b:
					bold(false);
					//g->needSpace=1;//creates too many spaces. Looks funky when rendered
					break;
				case WML_img:
					break;
				case WML_tr:
				case WML_td:
					break;
				case WML_onevent:
					g->onEvent = 0;
					needTimer = false;
					break;
				case WML_go:
					isLink = false;
					g->post = false;
					if (isAnchor == true){
						WinPushDrawState();
						WinSetTextColor( indexedColor );
	    				WinSetForeColor( indexedColor );
						WinSetUnderlineMode(grayUnderline);
					} else {
						hyperLink(false,NULL,NULL,g);
						g->needSpace=1;
					}
					break;
				case WML_anchor:
					//isLink = false;
					isAnchor = false;
					/*hyperLink(false,NULL,NULL,g);
					g->needSpace=1;
					break;*/
				case WML_noop:
				case WML_prev:
				case WML_refresh:
				case WML_do:
				case WML_a:	
					isLink = false;
					hyperLink(false,NULL,NULL,g);
					g->needSpace=1;
					break;
				}
			}
            if (wmldck->stackDepth == 0){  // end of <WML>, needed because angelOne seems to sent some trailing garbage.
                freewmlstack(wmldck);
				Free(temp);
                return(0);
            }
            break;
        case ENTITY:  
		    //DisplayError("ENTITY WMLC");
            wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset)); // UCS-4 character code
			temp[0]=j; temp[1]=0;
			// TODO : should map UCS-4 to something printable ??						
            if (wmldck->action== ACTION_SRC)
                srcString(wmldck,temp,g);
            if ((wmldck->action== ACTION_RENDER)&& (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
            break;
        case STR_I: //Inline String follows
            wmldck->offset++;
            j=0;
            while (wmldck->data[wmldck->offset] != 0) {
                temp[j++]=wmldck->data[wmldck->offset++];   
            }
            temp[j] = 0;
            if (wmldck->action== ACTION_SRC)
                srcString(wmldck,temp,g);
            if ((wmldck->action== ACTION_RENDER)&& (g->Render==true)){
                renderString(wmldck,temp,g);}
            break;
        case EXT_I_0://variable
        	wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
            StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC) {
            	srcString(wmldck,"$(",g);
                srcString(wmldck,temp,g);
                srcString(wmldck,":esc)",g);
            }
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
            break;
        case EXT_I_1://variable
        	wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
            StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC) {
            	srcString(wmldck,"$(",g);
                srcString(wmldck,temp,g);
                srcString(wmldck,":unesc)",g);
            }
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
            break;
        case EXT_I_2://variable
        	wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
            StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC) {
            	srcString(wmldck,"$(",g);
                srcString(wmldck,temp,g);
                srcString(wmldck,")",g);
            }
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
        	break;
        case EXT_T_0://variable
        	wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
            StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC) {
            	srcString(wmldck,"$(",g);
                srcString(wmldck,temp,g);
                srcString(wmldck,":esc)",g);
            }
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
            break;
        case EXT_T_1://variable
        	wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
            StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC) {
            	srcString(wmldck,"$(",g);
                srcString(wmldck,temp,g);
                srcString(wmldck,":unesc)",g);
            }
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
            break;
        case EXT_T_2://variable
        	wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
            StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC) {
            	srcString(wmldck,"$(",g);
                srcString(wmldck,temp,g);
                srcString(wmldck,")",g);
            }
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
        	break;
        case EXT_0:
        case EXT_1:
        case EXT_2:
        case OPAQUE:
            //DisplayError("WML OPAQUE Extension in WMLC");
            break;
        case PI:
            //DisplayError("PI not supported in WMLC");
            break;
        case STR_T: 
            wmldck->offset++;
            j = WspReadInt(wmldck->data,&(wmldck->offset));
			StrCopy(temp,wmldck->strTable+j);
            if (wmldck->action== ACTION_SRC)
                srcString(wmldck,temp,g);
            if ((wmldck->action== ACTION_RENDER) && (g->Render==true)){
                renderString(wmldck,temp,g);}
            wmldck->offset--;
            break;
        default:
            readElement(wmldck,g);
        }
        wmldck->offset++;
    }

    freewmlstack(wmldck);
	Free(temp);
    return(0);
}

int wbxml_free_wmldck(WMLDeckPtr wmldck)
{
CardPtr tmp;

    if (wmldck->attrstr != NULL)
        Free(wmldck->attrstr);
    wmldck->attrstr = NULL;
    if (wmldck->tmpstr != NULL)
        Free(wmldck->tmpstr);
    wmldck->tmpstr = NULL;
    if (wmldck->strTable != NULL)
        Free(wmldck->strTable);
    wmldck->strTable = NULL;
    if (wmldck->stack != NULL)
        Free(wmldck->stack);
    wmldck->stack = NULL;
	while (wmldck->card != NULL){
		tmp = wmldck->card;
		wmldck->card = tmp->next;
		if(tmp->card_id){
			Free(tmp->card_id);
		}
		Free(tmp);
	}
	

    return(0);
}


⌨️ 快捷键说明

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