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

📄 prop8.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
📖 第 1 页 / 共 3 页
字号:
		}		if (iInfoLen <= 0) {			iInfoLen =				iGet8InfoLength(iFodo + iFodoOff, aucGrpprl);			fail(iInfoLen <= 0);		}		iFodoOff += iInfoLen;	}	if (bFound2417_1 && bFoundd608) {		return found_end_of_row;	}	if (bFound2417_0 && !bFoundd608) {		return found_not_end_of_row;	}	if (bFound2416_1 || bFound244b_1) {		return found_a_cell;	}	if (bFound2416_0 || bFound244b_0) {		return found_not_a_cell;	}	return found_nothing;} /* end of eGet8RowInfo *//* * Fill the style information block with information * from a Word 8/9/10/11 file. */voidvGet8StyleInfo(int iFodo,	const UCHAR *aucGrpprl, int iBytes, style_block_type *pStyle){	list_block_type	tList6;	const list_block_type	*pList;	int	iFodoOff, iInfoLen;	int	iTmp, iDel, iAdd, iBefore;	USHORT	usOpCode, usTmp;	short	sTmp;	fail(iFodo < 0 || aucGrpprl == NULL || pStyle == NULL);	NO_DBG_DEC_C(pStyle->usListIndex != 0, pStyle->usIstd);	NO_DBG_DEC_C(pStyle->usListIndex != 0, pStyle->usListIndex);	(void)memset(&tList6, 0, sizeof(tList6));	iFodoOff = 0;	while (iBytes >= iFodoOff + 2) {		iInfoLen = 0;		usOpCode = usGetWord(iFodo + iFodoOff, aucGrpprl);		switch (usOpCode) {		case 0x2403:	/* jc */			pStyle->ucAlignment = ucGetByte(					iFodo + iFodoOff + 2, aucGrpprl);			break;		case 0x260a:	/* ilvl */			pStyle->ucListLevel =				ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->ucListLevel);			pStyle->ucNumLevel = pStyle->ucListLevel;			break;		case 0x4600:	/* istd */			usTmp = usGetWord(iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(usTmp);			break;		case 0x460b:	/* ilfo */			pStyle->usListIndex =				usGetWord(iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->usListIndex);			break;		case 0x4610: /* Nest dxaLeft */			sTmp = (short)usGetWord(					iFodo + iFodoOff + 2, aucGrpprl);			pStyle->sLeftIndent += sTmp;			if (pStyle->sLeftIndent < 0) {				pStyle->sLeftIndent = 0;			}			DBG_DEC(sTmp);			DBG_DEC(pStyle->sLeftIndent);			break;		case 0xc60d:	/* ChgTabsPapx */		case 0xc615:	/* ChgTabs */			iTmp = (int)ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);			if (iTmp < 2) {				iInfoLen = 1;				break;			}			NO_DBG_DEC(iTmp);			iDel = (int)ucGetByte(iFodo + iFodoOff + 3, aucGrpprl);			if (iTmp < 2 + 2 * iDel) {				iInfoLen = 1;				break;			}			NO_DBG_DEC(iDel);			iAdd = (int)ucGetByte(				iFodo + iFodoOff + 4 + 2 * iDel, aucGrpprl);			if (iTmp < 2 + 2 * iDel + 2 * iAdd) {				iInfoLen = 1;				break;			}			NO_DBG_DEC(iAdd);			break;		case 0x840e:	/* dxaRight */			pStyle->sRightIndent = (short)usGetWord(					iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->sRightIndent);			break;		case 0x840f:	/* dxaLeft */			pStyle->sLeftIndent = (short)usGetWord(					iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->sLeftIndent);			break;		case 0x8411:	/* dxaLeft1 */			pStyle->sLeftIndent1 = (short)usGetWord(					iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->sLeftIndent1);			break;		case 0xa413:	/* dyaBefore */			pStyle->usBeforeIndent = usGetWord(					iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->usBeforeIndent);			break;		case 0xa414:	/* dyaAfter */			pStyle->usAfterIndent = usGetWord(					iFodo + iFodoOff + 2, aucGrpprl);			NO_DBG_DEC(pStyle->usAfterIndent);			break;		case 0xc63e:	/* anld */			iTmp = (int)ucGetByte(					iFodo + iFodoOff + 2, aucGrpprl);			DBG_DEC_C(iTmp < 84, iTmp);			if (iTmp >= 1) {				tList6.ucNFC = ucGetByte(					iFodo + iFodoOff + 3, aucGrpprl);			}			if (tList6.ucNFC != LIST_BULLETS && iTmp >= 2) {				iBefore = (int)ucGetByte(					iFodo + iFodoOff + 4, aucGrpprl);			} else {				iBefore = 0;			}			if (iTmp >= 12) {				tList6.ulStartAt = (ULONG)usGetWord(					iFodo + iFodoOff + 13, aucGrpprl);			}			if (iTmp >= iBefore + 22) {				tList6.usListChar = usGetWord(					iFodo + iFodoOff + iBefore + 23,					aucGrpprl);				DBG_HEX(tList6.usListChar);			}			break;		default:			NO_DBG_HEX(usOpCode);			break;		}		if (iInfoLen <= 0) {			iInfoLen =				iGet8InfoLength(iFodo + iFodoOff, aucGrpprl);			fail(iInfoLen <= 0);		}		iFodoOff += iInfoLen;	}	if (pStyle->usListIndex == 2047) {		/* Old style list */		pStyle->usStartAt = (USHORT)tList6.ulStartAt;		pStyle->usListChar = tList6.usListChar;		pStyle->ucNFC = tList6.ucNFC;	} else {		/* New style list */		pList = pGetListInfo(pStyle->usListIndex, pStyle->ucListLevel);		if (pList != NULL) {			pStyle->bNoRestart = pList->bNoRestart;			fail(pList->ulStartAt > (ULONG)USHRT_MAX);			pStyle->usStartAt = (USHORT)pList->ulStartAt;			pStyle->usListChar = pList->usListChar;			pStyle->ucNFC = pList->ucNFC;			if (pStyle->sLeftIndent <= 0) {				pStyle->sLeftIndent = pList->sLeftIndent;			}		}	}} /* end of vGet8StyleInfo *//* * Get the left indentation value from the style information block * * Returns the value when found, otherwise 0 */static shortsGetLeftIndent(const UCHAR *aucGrpprl, size_t tBytes){	int	iOffset, iInfoLen;	USHORT	usOpCode, usTmp;	fail(aucGrpprl == NULL);	iOffset = 0;	while (tBytes >= (size_t)iOffset + 4) {		usOpCode = usGetWord(iOffset, aucGrpprl);		if (usOpCode == 0x840f) {	/* dxaLeft */			usTmp = usGetWord(iOffset + 2, aucGrpprl);			if (usTmp <= 0x7fff) {				NO_DBG_DEC(usTmp);				return (short)usTmp;			}		}		iInfoLen = iGet8InfoLength(iOffset, aucGrpprl);		fail(iInfoLen <= 0);		iOffset += iInfoLen;	}	return 0;} /* end of sGetLeftIndent *//* * Build the list with List Information for Word 8/9/10/11 files */voidvGet8LstInfo(FILE *pFile, const pps_info_type *pPPS,	const ULONG *aulBBD, size_t tBBDLen,	const ULONG *aulSBD, size_t tSBDLen,	const UCHAR *aucHeader){	list_block_type	tList;	const ULONG	*aulBlockDepot;	UCHAR	*aucLfoInfo, *aucLstfInfo, *aucPapx, *aucXString;	ULONG	ulBeginLfoInfo, ulBeginLstfInfo, ulBeginLvlfInfo;	ULONG	ulListID, ulStart;	size_t	tBlockDepotLen, tBlockSize;	size_t	tLfoInfoLen, tLstfInfoLen, tPapxLen, tXstLen, tOff;	size_t	tLstfRecords, tStart, tIndex;	int	iNums;	USHORT	usIstd;	UCHAR	ucTmp, ucListLevel, ucMaxLevel, ucChpxLen;	UCHAR	aucLvlfInfo[28], aucXst[2];	fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);	fail(aulBBD == NULL || aulSBD == NULL);	NO_DBG_DEC(pPPS->tTable.ulSB);	NO_DBG_HEX(pPPS->tTable.ulSize);	if (pPPS->tTable.ulSize == 0) {		DBG_MSG("No list information");		return;	}	if (pPPS->tTable.ulSize < MIN_SIZE_FOR_BBD_USE) {		/* Use the Small Block Depot */		aulBlockDepot = aulSBD;		tBlockDepotLen = tSBDLen;		tBlockSize = SMALL_BLOCK_SIZE;	} else {		/* Use the Big Block Depot */		aulBlockDepot = aulBBD;		tBlockDepotLen = tBBDLen;		tBlockSize = BIG_BLOCK_SIZE;	}	/* LFO (List Format Override) */	ulBeginLfoInfo = ulGetLong(0x2ea, aucHeader); /* fcPlfLfo */	DBG_HEX(ulBeginLfoInfo);	tLfoInfoLen = (size_t)ulGetLong(0x2ee, aucHeader); /* lcbPlfLfo */	DBG_DEC(tLfoInfoLen);	if (tLfoInfoLen == 0) {		DBG_MSG("No lists in this document");		return;	}	aucLfoInfo = xmalloc(tLfoInfoLen);	if (!bReadBuffer(pFile, pPPS->tTable.ulSB,			aulBlockDepot, tBlockDepotLen, tBlockSize,			aucLfoInfo, ulBeginLfoInfo, tLfoInfoLen)) {		aucLfoInfo = xfree(aucLfoInfo);		return;	}	NO_DBG_PRINT_BLOCK(aucLfoInfo, tLfoInfoLen);	vBuildLfoList(aucLfoInfo, tLfoInfoLen);	aucLfoInfo = xfree(aucLfoInfo);	/* LSTF (LiST data on File) */	ulBeginLstfInfo = ulGetLong(0x2e2, aucHeader); /* fcPlcfLst */	DBG_HEX(ulBeginLstfInfo);	tLstfInfoLen = (size_t)ulGetLong(0x2e6, aucHeader); /* lcbPlcfLst */	DBG_DEC(tLstfInfoLen);	if (tLstfInfoLen == 0) {		DBG_MSG("No list data on file");		return;	}	aucLstfInfo = xmalloc(tLstfInfoLen);	if (!bReadBuffer(pFile, pPPS->tTable.ulSB,			aulBlockDepot, tBlockDepotLen, tBlockSize,			aucLstfInfo, ulBeginLstfInfo, tLstfInfoLen)) {		aucLstfInfo = xfree(aucLstfInfo);		return;	}	NO_DBG_PRINT_BLOCK(aucLstfInfo, tLstfInfoLen);	tLstfRecords = (size_t)usGetWord(0, aucLstfInfo);	if (2 + tLstfRecords * 28 < tLstfInfoLen) {		DBG_DEC(2 + tLstfRecords * 28);		DBG_DEC(tLstfInfoLen);		aucLstfInfo = xfree(aucLstfInfo);		return;	}	/* LVLF (List leVeL on File) */	ulBeginLvlfInfo = ulBeginLstfInfo + tLstfInfoLen;	DBG_HEX(ulBeginLvlfInfo);	aucXString = NULL;	ulStart = ulBeginLvlfInfo;	for (tIndex = 0, tStart = 2;	     tIndex < tLstfRecords;	     tIndex++, tStart += 28) {		ulListID = ulGetLong(tStart, aucLstfInfo);		NO_DBG_HEX(ulListID);		ucTmp = ucGetByte(tStart + 26, aucLstfInfo);		ucMaxLevel = odd(ucTmp) ? 1 : 9;		for (ucListLevel = 0; ucListLevel < ucMaxLevel; ucListLevel++) {			fail(aucXString != NULL);			usIstd = usGetWord(					tStart + 8 + 2 * (size_t)ucListLevel,					aucLstfInfo);			DBG_DEC_C(usIstd != STI_NIL, usIstd);			NO_DBG_HEX(ulStart);			(void)memset(&tList, 0, sizeof(tList));			/* Read the lvlf (List leVeL on File) */			if (!bReadBuffer(pFile, pPPS->tTable.ulSB,					aulBlockDepot, tBlockDepotLen,					tBlockSize, aucLvlfInfo,					ulStart, sizeof(aucLvlfInfo))) {				aucLstfInfo = xfree(aucLstfInfo);				return;			}			NO_DBG_PRINT_BLOCK(aucLvlfInfo, sizeof(aucLvlfInfo));			if (bAllZero(aucLvlfInfo, sizeof(aucLvlfInfo))) {				tList.ulStartAt = 1;				tList.ucNFC = 0x00;				tList.bNoRestart = FALSE;			} else {				tList.ulStartAt = ulGetLong(0, aucLvlfInfo);				tList.ucNFC = ucGetByte(4, aucLvlfInfo);				ucTmp = ucGetByte(5, aucLvlfInfo);				tList.bNoRestart = (ucTmp & BIT(3)) != 0;				DBG_MSG_C((ucTmp & BIT(4)) != 0 &&					(ucTmp & BIT(6)) != 0, "Found one");			}			ulStart += sizeof(aucLvlfInfo);			tPapxLen = (size_t)ucGetByte(25, aucLvlfInfo);			if (tPapxLen != 0) {				aucPapx = xmalloc(tPapxLen);				/* Read the Papx */				if (!bReadBuffer(pFile, pPPS->tTable.ulSB,						aulBlockDepot, tBlockDepotLen,						tBlockSize, aucPapx,						ulStart, tPapxLen)) {					aucPapx = xfree(aucPapx);					aucLstfInfo = xfree(aucLstfInfo);					return;				}				NO_DBG_PRINT_BLOCK(aucPapx, tPapxLen);				tList.sLeftIndent =					sGetLeftIndent(aucPapx, tPapxLen);				aucPapx = xfree(aucPapx);			}			ulStart += tPapxLen;			ucChpxLen = ucGetByte(24, aucLvlfInfo);			ulStart += (ULONG)ucChpxLen;			/* Read the length of the XString */			if (!bReadBuffer(pFile, pPPS->tTable.ulSB,					aulBlockDepot, tBlockDepotLen,					tBlockSize, aucXst,					ulStart, sizeof(aucXst))) {				aucLstfInfo = xfree(aucLstfInfo);				return;			}			NO_DBG_PRINT_BLOCK(aucXst, sizeof(aucXst));			tXstLen = (size_t)usGetWord(0, aucXst);			ulStart += sizeof(aucXst);			if (tXstLen == 0) {				tList.usListChar = DEFAULT_LISTCHAR;				vAdd2ListInfoList(ulListID,						usIstd,						ucListLevel,						&tList);				continue;			}			tXstLen *= 2;	/* Length in chars to length in bytes */			aucXString = xmalloc(tXstLen);			/* Read the XString */			if (!bReadBuffer(pFile, pPPS->tTable.ulSB,					aulBlockDepot, tBlockDepotLen,					tBlockSize, aucXString,					ulStart, tXstLen)) {				aucXString = xfree(aucXString);				aucLstfInfo = xfree(aucLstfInfo);				return;			}			NO_DBG_PRINT_BLOCK(aucXString, tXstLen);			tOff = 0;			for (iNums = 6; iNums < 15; iNums++) {				ucTmp = ucGetByte(iNums, aucLvlfInfo);				if (ucTmp == 0) {					break;				}				tOff = (size_t)ucTmp;			}			tOff *= 2;	/* Offset in chars to offset in bytes */			NO_DBG_DEC(tOff);			if (tList.ucNFC == LIST_SPECIAL ||			    tList.ucNFC == LIST_SPECIAL2 ||			    tList.ucNFC == LIST_BULLETS) {				tList.usListChar = usGetWord(0, aucXString);			} else if (tOff != 0 && tOff < tXstLen) {				tList.usListChar = usGetWord(tOff, aucXString);			} else {				tList.usListChar = DEFAULT_LISTCHAR;			}			vAdd2ListInfoList(ulListID,					usIstd,					ucListLevel,					&tList);			ulStart += tXstLen;			aucXString = xfree(aucXString);		}	}	aucLstfInfo = xfree(aucLstfInfo);} /* end of vGet8LstInfo *//* * Build the lists with Paragraph Information for Word 8/9/10/11 files */voidvGet8PapInfo(FILE *pFile, const pps_info_type *pPPS,	const ULONG *aulBBD, size_t tBBDLen,	const ULONG *aulSBD, size_t tSBDLen,	const UCHAR *aucHeader){	row_block_type		tRow;	style_block_type	tStyle;	ULONG		*aulParfPage;	UCHAR	*aucBuffer;	ULONG	ulCharPos, ulCharPosFirst, ulCharPosLast;	ULONG	ulBeginParfInfo;	size_t	tParfInfoLen, tOffset, tLen;	int	iIndex, iIndex2, iRun, iFodo, iLen;	row_info_enum	eRowInfo;	USHORT	usIstd;	UCHAR	aucFpage[BIG_BLOCK_SIZE];	fail(pFile == NULL || pPPS == NULL || aucHeader == NULL);	fail(aulBBD == NULL || aulSBD == NULL);	ulBeginParfInfo = ulGetLong(0x102, aucHeader); /* fcPlcfbtePapx */	NO_DBG_HEX(ulBeginParfInfo);	tParfInfoLen = (size_t)ulGetLong(0x106, aucHeader); /* lcbPlcfbtePapx */	NO_DBG_DEC(tParfInfoLen);	if (tParfInfoLen < 4) {		DBG_DEC(tParfInfoLen);		return;	}	aucBuffer = aucFillInfoBuffer(pFile, &pPPS->tTable,			aulBBD, tBBDLen, aulSBD, tSBDLen,			ulBeginParfInfo, tParfInfoLen);	if (aucBuffer == NULL) {		return;	}	NO_DBG_PRINT_BLOCK(aucBuffer, tParfInfoLen);	tLen = (tParfInfoLen / 4 - 1) / 2;	aulParfPage = xcalloc(tLen, sizeof(ULONG));	for (iIndex = 0, tOffset = (tLen + 1) * 4;	     iIndex < (int)tLen;	     iIndex++, tOffset += 4) {		 aulParfPage[iIndex] = ulGetLong(tOffset, aucBuffer);		 NO_DBG_DEC(aulParfPage[iIndex]);	}	DBG_HEX(ulGetLong(0, aucBuffer));	aucBuffer = xfree(aucBuffer);	NO_DBG_PRINT_BLOCK(aucHeader, HEADER_SIZE);	(void)memset(&tRow, 0, sizeof(tRow));	ulCharPosFirst = CP_INVALID;	for (iIndex = 0; iIndex < (int)tLen; iIndex++) {		fail(aulParfPage[iIndex] > ULONG_MAX / BIG_BLOCK_SIZE);		if (!bReadBuffer(pFile, pPPS->tWordDocument.ulSB,				aulBBD, tBBDLen, BIG_BLOCK_SIZE,				aucFpage,				aulParfPage[iIndex] * BIG_BLOCK_SIZE,				BIG_BLOCK_SIZE)) {			break;		}		NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);		iRun = (int)ucGetByte(0x1ff, aucFpage);		NO_DBG_DEC(iRun);

⌨️ 快捷键说明

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