📄 ospxmlparse.c
字号:
const unsigned char tag[] = { OSPC_XMLDOC_CDATAEND }; unsigned char scratch[OSPC_XMLDOC_CDATAENDLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } ospvErrCode = OSPPXMLDocSkipPast(ospvBfrAddr, ospvEncoding, tag, scratch); return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsDecl() - is the document at an XML declaration *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsDecl( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsDecl /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; unsigned char readChar = '\0'; const unsigned char tag[] = OSPC_XMLDOC_DECLBEG; unsigned char scratch[OSPC_XMLDOC_DECLBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsDecl == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } /* * The first thing we do is look for the beginning of an XML * declaration. If there's not one, we don't have any work to do. */ if (ospvErrCode == OSPC_ERR_NO_ERROR) { *ospvIsDecl = OSPC_FALSE; ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_DECLBEGLEN, scratch, ospvIsDecl); } if ((ospvErrCode == OSPC_ERR_NO_ERROR) && *ospvIsDecl) { /* * We've got a match for the header tag, so see if the next * character is a whitespace. */ OSPPXMLDocPeekCharN(ospvBfrAddr, ospvEncoding, OSPC_XMLDOC_DECLBEGLEN, &readChar, (int *)&ospvErrCode); if ((ospvErrCode != OSPC_ERR_NO_ERROR) || (!OSPPXMLIsSpace(readChar))) { /* not a whitespace; this isn't a declaration after all */ *ospvIsDecl = OSPC_FALSE; } } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsComment() - is the document at an XML comment *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsComment( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsComment /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = OSPC_XMLDOC_COMMENTBEG; unsigned char scratch[OSPC_XMLDOC_COMMENTBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsComment == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { *ospvIsComment = OSPC_FALSE; /* now look for the match of the comment beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_COMMENTBEGLEN, scratch, ospvIsComment); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsPI() - is the document at an XML processing instruction *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsPI( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsPI /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = { OSPC_XMLDOC_PIBEG }; unsigned char scratch[OSPC_XMLDOC_PIBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsPI == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* assume that it isn't a PI (in case of premature error exit) */ *ospvIsPI = OSPC_FALSE; /* now look for the match of the PI beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_PIBEGLEN, scratch, ospvIsPI); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsDTD() - is the document at an XML data type definition *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsDTD( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsDTD /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = OSPC_XMLDOC_DTDBEG; unsigned char scratch[OSPC_XMLDOC_DTDBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsDTD == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* assume that it isn't a DTD (in case of premature error exit) */ *ospvIsDTD = OSPC_FALSE; /* now look for the match of the DTD beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_DTDBEGLEN, scratch, ospvIsDTD); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsElementDecl() - is document at an XML element declaration *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsElementDecl( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsElemDecl /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = OSPC_XMLDOC_ELEMENTDECLBEG; unsigned char scratch[OSPC_XMLDOC_ELEMENTDECLBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsElemDecl == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* assume that it isn't a declaration (in case of premature error exit) */ *ospvIsElemDecl = OSPC_FALSE; /* now look for the match of the element declaration beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_ELEMENTDECLBEGLEN, scratch, ospvIsElemDecl); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsAttlist() - is document at an XML attribute list *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsAttlist( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsAttlist /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = OSPC_XMLDOC_ATTLISTBEG; unsigned char scratch[OSPC_XMLDOC_ATTLISTBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsAttlist == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* assume that it isn't a list (in case of premature error exit) */ *ospvIsAttlist = OSPC_FALSE; /* now look for the match of the attribute list beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_ATTLISTBEGLEN, scratch, ospvIsAttlist); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsEntityDecl() - is document at an XML entity declaration *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsEntityDecl( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsEntityDecl /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = OSPC_XMLDOC_ENTITYDECLBEG; unsigned char scratch[OSPC_XMLDOC_ENTITYDECLBEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsEntityDecl == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* assume that it isn't a declaration (in case of premature error exit) */ *ospvIsEntityDecl = OSPC_FALSE; /* now look for the match of the entity declaration beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_ENTITYDECLBEGLEN, scratch, ospvIsEntityDecl); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsCdata() - is document at an XML CDATA section *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPXMLDocIsCdata( OSPTBFR **ospvBfrAddr, /* buffer containing document */ OSPTXMLENC ospvEncoding, /* character encoding for the document */ unsigned *ospvIsCdata /* place to put answer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; const unsigned char tag[] = OSPC_XMLDOC_CDATABEG; unsigned char scratch[OSPC_XMLDOC_CDATABEGLEN+1]; if (ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (*ospvBfrAddr == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_BUF_EMPTY; } if (ospvEncoding == ospeXMLEncUnknown) { ospvErrCode = OSPC_ERR_XML_BAD_ENC; } if (ospvIsCdata == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_INVALID_ARGS; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* assume that it isn't CDATA (in case of premature error exit) */ *ospvIsCdata = OSPC_FALSE; /* now look for the match of the CDATA beginning */ ospvErrCode = OSPPXMLDocIsMatch(ospvBfrAddr, ospvEncoding, tag, OSPC_XMLDOC_CDATABEGLEN, scratch, ospvIsCdata); } return(ospvErrCode);}/**//*-----------------------------------------------------------------------* * OSPPXMLDocIsCdataEnd() - is document at the end of an XML CDATA section *-----
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -