📄 avc_e00read.c
字号:
* For some reason the file could not be opened... abort now. * An error message should have already been produced by * AVCBinReadOpen() *------------------------------------------------------------*/ if (psInfo->hFile == NULL) return NULL; pszLine = AVCE00GenStartSection(psInfo->hGenInfo, psSect->eType, psSect->pszName); /*------------------------------------------------------------- * Reset the AVCE00GenInfo struct. so that it returns NULL, * which will force reading of the first object from the * file on the next call to AVCE00ReadNextLine() *------------------------------------------------------------*/ AVCE00GenReset(psInfo->hGenInfo); psInfo->iCurStep = AVC_GEN_DATA; } else if (psInfo->iCurStep == AVC_GEN_DATA && (psSect->eType == AVCFileARC || psSect->eType == AVCFilePAL || psSect->eType == AVCFileRPL || psSect->eType == AVCFileCNT || psSect->eType == AVCFileLAB || psSect->eType == AVCFileTOL || psSect->eType == AVCFileTXT || psSect->eType == AVCFileTX6 || psSect->eType == AVCFileRXP ) ) { /*----------------------------------------------------------------- * Return the next line of an ARC/PAL/CNT/TOL/TXT object... * if necessary, read the next object from the binary file. *----------------------------------------------------------------*/ pszLine = AVCE00GenObject(psInfo->hGenInfo, psSect->eType, (psSect->eType==AVCFileARC?(void*)(psInfo->hFile->cur.psArc): psSect->eType==AVCFilePAL?(void*)(psInfo->hFile->cur.psPal): psSect->eType==AVCFileRPL?(void*)(psInfo->hFile->cur.psPal): psSect->eType==AVCFileCNT?(void*)(psInfo->hFile->cur.psCnt): psSect->eType==AVCFileLAB?(void*)(psInfo->hFile->cur.psLab): psSect->eType==AVCFileTOL?(void*)(psInfo->hFile->cur.psTol): psSect->eType==AVCFileTXT?(void*)(psInfo->hFile->cur.psTxt): psSect->eType==AVCFileTX6?(void*)(psInfo->hFile->cur.psTxt): psSect->eType==AVCFileRXP?(void*)(psInfo->hFile->cur.psRxp): NULL), TRUE); if (pszLine == NULL) { /*--------------------------------------------------------- * Current object is finished generating... we need to read * a new one from the file. *--------------------------------------------------------*/ if (AVCBinReadNextObject(psInfo->hFile) != NULL) { pszLine = AVCE00GenObject(psInfo->hGenInfo, psSect->eType, (psSect->eType==AVCFileARC?(void*)(psInfo->hFile->cur.psArc): psSect->eType==AVCFilePAL?(void*)(psInfo->hFile->cur.psPal): psSect->eType==AVCFileRPL?(void*)(psInfo->hFile->cur.psPal): psSect->eType==AVCFileCNT?(void*)(psInfo->hFile->cur.psCnt): psSect->eType==AVCFileLAB?(void*)(psInfo->hFile->cur.psLab): psSect->eType==AVCFileTOL?(void*)(psInfo->hFile->cur.psTol): psSect->eType==AVCFileTXT?(void*)(psInfo->hFile->cur.psTxt): psSect->eType==AVCFileTX6?(void*)(psInfo->hFile->cur.psTxt): psSect->eType==AVCFileRXP?(void*)(psInfo->hFile->cur.psRxp): NULL), FALSE); } } if (pszLine == NULL) { /*--------------------------------------------------------- * Still NULL ??? This means we finished reading this file... * Start returning the "end of section" line(s)... *--------------------------------------------------------*/ AVCBinReadClose(psInfo->hFile); psInfo->hFile = NULL; psInfo->iCurStep = AVC_GEN_ENDSECTION; pszLine = AVCE00GenEndSection(psInfo->hGenInfo, psSect->eType, FALSE); } } /*================================================================= * PRJ *================================================================*/ else if (psInfo->iCurStep == AVC_GEN_NOTSTARTED && psSect->eType == AVCFilePRJ ) { /*------------------------------------------------------------- * Start processing of PRJ section... return first header line. *------------------------------------------------------------*/ pszLine = AVCE00GenStartSection(psInfo->hGenInfo, psSect->eType, NULL); psInfo->hFile = NULL; psInfo->iCurStep = AVC_GEN_DATA; } else if (psInfo->iCurStep == AVC_GEN_DATA && psSect->eType == AVCFilePRJ ) { /*------------------------------------------------------------- * Return the next line of a PRJ section *------------------------------------------------------------*/ if (psInfo->hFile == NULL) { /*--------------------------------------------------------- * File has not been read yet... * Read the PRJ file, and return the first PRJ line. *--------------------------------------------------------*/ psInfo->hFile = AVCBinReadOpen(psInfo->pszCoverPath, psSect->pszFilename, psInfo->eCoverType, psSect->eType, psInfo->psDBCSInfo); /* For some reason the file could not be opened... abort now. * An error message should have already been produced by * AVCBinReadOpen() */ if (psInfo->hFile == NULL) return NULL; pszLine = AVCE00GenPrj(psInfo->hGenInfo, psInfo->hFile->cur.papszPrj, FALSE); } else { /*--------------------------------------------------------- * Generate the next line of output. *--------------------------------------------------------*/ pszLine = AVCE00GenPrj(psInfo->hGenInfo, psInfo->hFile->cur.papszPrj, TRUE); } if (pszLine == NULL) { /*--------------------------------------------------------- * Still NULL ??? This means we finished generating this PRJ * section... * Start returning the "end of section" line(s)... *--------------------------------------------------------*/ AVCBinReadClose(psInfo->hFile); psInfo->hFile = NULL; psInfo->iCurStep = AVC_GEN_ENDSECTION; pszLine = AVCE00GenEndSection(psInfo->hGenInfo, psSect->eType, FALSE); } } else if (psInfo->iCurStep != AVC_GEN_ENDSECTION) { /* We should never get here! */ CPLAssert(FALSE); } /*================================================================= * End of section, for all files *================================================================*/ /*----------------------------------------------------------------- * Finished processing of an ARC, PAL, CNT, LAB, TOL, PRJ file ... * continue returning the "end of section" line(s), and move the pointer * to the next section once we're done. *----------------------------------------------------------------*/ if (psInfo->iCurStep == AVC_GEN_ENDSECTION && pszLine == NULL) { pszLine = AVCE00GenEndSection(psInfo->hGenInfo, psSect->eType, TRUE); if (pszLine == NULL) { /*--------------------------------------------------------- * Finished returning the last lines of the section... * proceed to the next section... * OK, I don't really like recursivity either... but it was * the simplest way to do this, and anyways we should never * have more than one level of recursivity. *--------------------------------------------------------*/ if (psInfo->bReadAllSections) psInfo->iCurSection++; else psInfo->iCurSection = psInfo->numSections; psInfo->iCurStep = AVC_GEN_NOTSTARTED; pszLine = AVCE00ReadNextLine(psInfo); } } return pszLine;}/********************************************************************** * AVCE00ReadSectionsList() * * Returns an array of AVCE00Section structures that describe the * squeleton of the whole coverage. The value of *numSect will be * set to the number of sections in the array. * * You can scan the returned array, and use AVCE00ReadGotoSection() to move * the read pointer directly to the beginning of a given section * of the file. * * Sections of type AVCFileUnknown correspond to lines in the * E00 output that are not directly linked to any coverage file, like * the "EXP 0" line, the "IFO X", "SIN X", etc. * * THE RETURNED ARRAY IS AN INTERNAL STRUCTURE AND SHOULD NOT BE * MODIFIED OR FREED BY THE CALLER... its contents will be valid * for as long as the coverage will remain open. **********************************************************************/AVCE00Section *AVCE00ReadSectionsList(AVCE00ReadPtr psInfo, int *numSect){ CPLErrorReset(); *numSect = psInfo->numSections; return psInfo->pasSections;}/********************************************************************** * AVCE00ReadGotoSection() * * Move the read pointer to the E00 section (coverage file) described in * the psSect structure. Call AVCE00ReadListSections() to get the list of * sections for the current coverage. * * if bContinue=TRUE, then reading will automatically continue with the * next sections of the file once the requested section is finished. * Otherwise, if bContinue=FALSE then reading will stop at the end * of this section (i.e. AVCE00ReadNextLine() will return NULL when * it reaches the end of this section) * * Sections of type AVCFileUnknown returned by AVCE00ReadListSections() * correspond to lines in the E00 output that are not directly linked * to any coverage file, like the "EXP 0" line, the "IFO X", "SIN X", etc. * You can jump to these sections or any other one without problems. * * This function returns 0 on success or -1 on error. **********************************************************************/int AVCE00ReadGotoSection(AVCE00ReadPtr psInfo, AVCE00Section *psSect, GBool bContinue){ int iSect; GBool bFound = FALSE; CPLErrorReset(); /*----------------------------------------------------------------- * Locate the requested section in the array. *----------------------------------------------------------------*/ for(iSect=0; iSect<psInfo->numSections; iSect++) { if (psInfo->pasSections[iSect].eType == psSect->eType && EQUAL(psInfo->pasSections[iSect].pszName, psSect->pszName)) { bFound = TRUE; break; } } /*----------------------------------------------------------------- * Not found ... generate an error... *----------------------------------------------------------------*/ if (!bFound) { CPLError(CE_Failure, CPLE_IllegalArg, "Requested E00 section does not exist!"); return -1; } /*----------------------------------------------------------------- * Found it ... close current section and get ready to read * the new one. *----------------------------------------------------------------*/ if (psInfo->hFile) { AVCBinReadClose(psInfo->hFile); psInfo->hFile = NULL; } psInfo->bReadAllSections = bContinue; psInfo->iCurSection = iSect; psInfo->iCurStep = AVC_GEN_NOTSTARTED; return 0;}/********************************************************************** * AVCE00ReadRewind() * * Rewinds the AVCE00ReadPtr just like the stdio rewind() * function would do if you were reading an ASCII E00 file. * * Returns 0 on success or -1 on error. **********************************************************************/int AVCE00ReadRewind(AVCE00ReadPtr psInfo){ CPLErrorReset(); return AVCE00ReadGotoSection(psInfo, &(psInfo->pasSections[0]), TRUE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -