📄 swoutput.c
字号:
/* swoutput.c - Output routines for SQLweb/*/* Copyright (c) 1995-1999 Applied Information Technologies, Inc./* All Rights Reserved./* /* Distributed uder the GNU General Public License which was included in/* the file named "LICENSE" in the package that you recieved./* If not, write to:/* The Free Software Foundation, Inc.,/* 675 Mass Ave, Cambridge, MA 02139, USA. */#include <stdio.h>#include <stdlib.h>/* #include <sys/types.h> */#include <ctype.h>#include <string.h>#include "sqlweb.h"#include "userexit.h"/*/* Internal Functions.... */static eBoolean_t LoadPageList(LIST *lPageGenNbrList);static eBoolean_t CookPage(PAGE *pPage);static eBoolean_t CookPIA(SYMBOL *pPIA);static eBoolean_t OutputPage(PAGE *pPage);static eBoolean_t OutputPI(PI *pPI);static eBoolean_t OutputPIA(SYMBOL *pPIA);static eBoolean_t GetPIFieldNameREF(PI *pPI,char **pOutFieldName);static eBoolean_t GetPIValue(PI *pPI, char *pOutValue);static eBoolean_t GetPIValueREF(PI *pPI, char **pOutValue);static eBoolean_t GetPITagType(PI *pPI, char **pOutType);static eBoolean_t SetPIValue(PI *pPI, char *pValue);static eBoolean_t SetPIAValue(PI *pPI,char *pName, char *pOutValue);static void RawOutputHTML(char *p);static eBoolean_t DumpPI(PI *pPI);static eBoolean_t DumpPIA(SYMBOL *pPIA);/*/* Global Variables used by all modules/* but owned by this one! */eBoolean_t gbCookFlag;PAGE *gpPage;/*/* Global (local to this file) Variables... */static LIST *galPI[MAX_TAG_LEVELS] /* Array for storing the current PI List for /* each scope level */ ;static PI *gaPI[MAX_TAG_LEVELS] ;eBoolean_t gbBufferOutput = eFalse;eBoolean_tswoutput(PAGE *pPage){ DebugHTML(__FILE__,__LINE__,2,"swoutput(%x,%s)" ,pPage ,ISCOOKED ? "TRUE":"FALSE"); /* /* Create the Global PAGE, if necessary, */ /* Use the PAGE passed in */ gpPage = pPage; /* /* Cook the raw page into something juicy... */ if(ISCOOKED) { RETeFalse(CookPage(gpPage) ,"Failed to expand SQLweb Page" ); if(ISeTrue(gbBufferOutput)) { /* Time for desert.... */ if(giParseLevel==3) { DumpPage(gpPage); return(eTrue); } RETeFalse(OutputPage(gpPage),"OutputPage Failed"); } } else { RETeFalse(OutputPage(gpPage),"OutputPage Failed"); } /* OutputHTML("\n"); */ FlushHTMLBuf(); return(eTrue);}static eBoolean_tOutputPage(PAGE *pPage){ DebugHTML(__FILE__,__LINE__,3,"OutputPage(%x)",pPage); if(!pPage) return(eTrue); PrintHTMLHeader("text/html"); return( l_scan(pPage->lPI,(PFI)OutputPI) );}static eBoolean_tOutputPI(PI *pPI){ /* output tag */ if(!pPI) return(eTrue); DebugHTML(__FILE__,__LINE__,6,"OutputPI(%s)",pPI->pTagName); if(isNotHidden(pPI)) { OutputHTML("<%s",pPI->pTagName); /* /* output TagAttributes */ RETeFalse(l_scan(pPI->lPIA,(PFI)OutputPIA) ,"l_scan(PIA) OutputPIA Failed" ); /* output end-tag */ OutputHTML(">"); } /* output (normal) contents */ if(pPI && pPI->pPiContents && *(pPI->pPiContents)) { RawOutputHTML(pPI->pPiContents); } /* output lPI */ RETeFalse( l_scan(pPI->lPI,(PFI)OutputPI) ,"Recursive call failed" ); /* /* Output Trailer */ if(!isEmpty(pPI) && isNotHidden(pPI)) { OutputHTML("</%s>",pPI->pTagName); } FlushHTMLBuf(); return(eTrue);}static eBoolean_tCookPIA(SYMBOL *pPIA){ char *pBuf ; if(!pPIA) return(eTrue); DebugHTML(__FILE__,__LINE__,5,"CookPIA(%s,%x)",pPIA->pName,pPIA->pValue); /* Always expand the NAME= part of each attrib */ RETeFalse2(ExpandString(pPIA->pName,&pBuf) ,"ExpandString(%s) Failed" ,pPIA->pName ); FreeBuf(pPIA->pName); pPIA->pName = pBuf; /* /* Only expand VALUE part when it's NOT EXPR= or SQL= /* ... because the parser will deal with the : variables */ if( !(is_casematch(pBuf,"EXPR") || is_casematch(pBuf,"SQL"))) { RETeFalse2(ExpandString(pPIA->pValue,&pBuf) ,"ExpandString(%s) Failed" ,pPIA->pValue ); FreeBuf(pPIA->pValue); pPIA->pValue = pBuf; } else { /* /* Only remove charcodes from SQL and EXPR attributes /* ... because the parser doesn't deal with the > syntax */ RemoveCharCodes(pBuf); } return(eTrue);}static eBoolean_tOutputPIA(SYMBOL *pPIA){ return ( iPrintHTMLSymbol(pPIA) );}static eBoolean_tCookPage(PAGE *pPage){ if(!pPage) return(eTrue); DebugHTML(__FILE__,__LINE__,3,"CookPage(%x)",pPage); return( l_scan(pPage->lPI,(PFI)CookPI) );}eBoolean_tCookPI(PI *pPI){ char *pFieldName ,*pValue ; TAG_HANDLE *pTagHandle; eBoolean_t bExpr = eTrue; if(pPI == NULL){ MsgPush("Internal error: CookPI received NULL"); return(eTrue);/* return(eFalse); */ } DebugHTML(__FILE__,__LINE__,5,"CookPI(%x):%s (line %d)" ,pPI ,pPI->pTagName ,pPI->iLineNbr ); for(pTagHandle= &gaTagHandlers[0]; pTagHandle->pTagName;pTagHandle++){ if(is_casematch(pTagHandle->pTagName,pPI->pTagName)){ char *pBuf; DebugHTML(__FILE__,__LINE__,2,"Handling:%s (line %d)" ,pPI->pTagName ,pPI->iLineNbr ); /* /* AUTOFAIL should be set for backward compatability... /* May be set in the "INI" file or in "old" pages */ if(ISeTrue(GetSymbolValueREF("SQLWEB_AUTOFAIL",&pBuf)) && is_casematch("TRUE",pBuf)) { RETeFalse3((pTagHandle->fHandler)(pPI,&bExpr) ,"Tag Handler Failed:%s (line %d)" ,pPI->pTagName ,pPI->iLineNbr ); } else if(ISeFalse((pTagHandle->fHandler)(pPI,&bExpr))) { DebugHTML(__FILE__,__LINE__,0 ,"ERROR: Tag Handler failed on %s (line %d)" ,pPI->pTagName ,pPI->iLineNbr ); SELSym("SQLWEB_CODE","1"); SELSym("SQLWEB_MESSAGE","Handler Failed"); /* return(eFalse); */ return(eTrue); } SELSym("SQLWEB_CODE","0"); SELSym("SQLWEB_MESSAGE","Normal Successful Completion"); /* return(eTrue); */ } } if(ISeFalse(bExpr)){ /* */ DebugHTML(__FILE__,__LINE__,3 ,"fHandler says FALSE:otta here!"); /* ************************************************************ /* ************************************************************ /* BTW, don't reference pPI now, it has been FREE'd by fHandler */ /* if(ISeTrue(gbBufferOutput)) { /* pPI->lPI = l_create("QUEUE"); /* Clobber list */ /* pPI->pPiContents = DupBuf(0); /* Clobber contents */ /* } else { /* FreePI(pPI); /* } */ return(eTrue); } /* /* Expand Contents */ RETeFalse2(ExpandContents(pPI) ,"ExpandContents(%s) Failed" ,pPI->pPiContents ); /* /* Expand Attributes.... */ RETeFalse(l_scan(pPI->lPIA,(PFI)CookPIA) ,"l_scan(PIA) CookPIA Failed" ); /* /* Process (INPUT/TEXTAREA)/OPTION Tags */ if((( is_casematch(pPI->pTagName,"INPUT") ||is_casematch(pPI->pTagName,"TEXTAREA")) && (ISeTrue(GetPIFieldNameREF(pPI,&pFieldName)) && *pFieldName) && ISeTrue(GetSymbolValueREF(pFieldName,&pValue))) ||(is_casematch(pPI->pTagName,"OPTION") && (ISeTrue(GetPIFieldNameREF(pPI,&pFieldName)) && *pFieldName) && ISeTrue(GetPIValueREF(pPI,&pValue)) && ISeTrue(IsSymbolValue(pFieldName,pValue)))) { if(ISeTrue(SetPIValue(pPI,pValue))) { DebugHTML(__FILE__,__LINE__,5,"CookPI:SetPIValue(%s)OK",pFieldName); } else { DebugHTML(__FILE__,__LINE__,1 ,"CookPI:W:SetPIValue(%s) Failed" ,pFieldName ); } } if(ISeTrue(gbBufferOutput)){ return(l_scan(pPI->lPI,(PFI)CookPI)); } /******************************************** /* From here on we are only Non-Buffered Output ... */ /* /* Output <TAG and Attributes> */ if(isNotHidden(pPI)) { OutputHTML("<%s",pPI->pTagName); RETeFalse(l_scan(pPI->lPIA,(PFI)OutputPIA) ,"l_scan(PIA) OutputPIA Failed" ); OutputHTML(">"); } /* /* Output TAG Contents */ if(pPI && pPI->pPiContents && *(pPI->pPiContents)) RawOutputHTML(pPI->pPiContents); /* /* COOK and Output Subordinate TAGS, the children */ RETeFalse(l_scan(pPI->lPI,(PFI)CookPI) ,"l_scan(pPI->lPI,CookPI) Failed" ); /* /* Output the ENDING TAG </TAG> */ if(!isEmpty(pPI) && isNotHidden(pPI)) { OutputHTML("</%s>",pPI->pTagName); }/* */ FreePI(pPI);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -