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

📄 prop6.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
📖 第 1 页 / 共 2 页
字号:
			break;		default:			break;		}		if (iInfoLen <= 0) {			iInfoLen =				iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);			fail(iInfoLen <= 0);		}		iFodoOff += iInfoLen;	}} /* end of vGet6StyleInfo *//* * Build the lists with Paragraph Information for Word 6/7 files */voidvGet6PapInfo(FILE *pFile, ULONG ulStartBlock,	const ULONG *aulBBD, size_t tBBDLen,	const UCHAR *aucHeader){	row_block_type		tRow;	style_block_type	tStyle;	USHORT	*ausParfPage;	UCHAR	*aucBuffer;	ULONG	ulCharPos, ulCharPosFirst, ulCharPosLast;	ULONG	ulBeginParfInfo;	size_t	tParfInfoLen, tParfPageNum, tOffset, tSize, tLenOld, tLen;	size_t	tIndex, tIndex2, tRun;	int	iFodo, iLen;	row_info_enum	eRowInfo;	USHORT	usParfFirstPage, usCount, usIstd;	UCHAR	aucFpage[BIG_BLOCK_SIZE];	fail(pFile == NULL || aucHeader == NULL);	fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);	fail(aulBBD == NULL);	ulBeginParfInfo = ulGetLong(0xc0, aucHeader); /* fcPlcfbtePapx */	NO_DBG_HEX(ulBeginParfInfo);	tParfInfoLen = (size_t)ulGetLong(0xc4, aucHeader); /* lcbPlcfbtePapx */	NO_DBG_DEC(tParfInfoLen);	if (tParfInfoLen < 4) {		DBG_DEC(tParfInfoLen);		return;	}	aucBuffer = xmalloc(tParfInfoLen);	if (!bReadBuffer(pFile, ulStartBlock,			aulBBD, tBBDLen, BIG_BLOCK_SIZE,			aucBuffer, ulBeginParfInfo, tParfInfoLen)) {		aucBuffer = xfree(aucBuffer);		return;	}	NO_DBG_PRINT_BLOCK(aucBuffer, tParfInfoLen);	tLen = (tParfInfoLen - 4) / 6;	ausParfPage = xcalloc(tLen, sizeof(USHORT));	for (tIndex = 0, tOffset = (tLen + 1) * 4;	     tIndex < tLen;	     tIndex++, tOffset += 2) {		 ausParfPage[tIndex] = usGetWord(tOffset, aucBuffer);		 NO_DBG_DEC(ausParfPage[tIndex]);	}	DBG_HEX(ulGetLong(0, aucBuffer));	aucBuffer = xfree(aucBuffer);	tParfPageNum = (size_t)usGetWord(0x190, aucHeader); /* cpnBtePap */	DBG_DEC(tParfPageNum);	if (tLen < tParfPageNum) {		/* Replace ParfPage by a longer version */		tLenOld = tLen;		usParfFirstPage = usGetWord(0x18c, aucHeader); /* pnPapFirst */		DBG_DEC(usParfFirstPage);		tLen += tParfPageNum - 1;		tSize = tLen * sizeof(USHORT);		ausParfPage = xrealloc(ausParfPage, tSize);		/* Add new values */		usCount = usParfFirstPage + 1;		for (tIndex = tLenOld; tIndex < tLen; tIndex++) {			ausParfPage[tIndex] = usCount;			NO_DBG_DEC(ausParfPage[tIndex]);			usCount++;		}	}	(void)memset(&tRow, 0, sizeof(tRow));	ulCharPosFirst = CP_INVALID;	for (tIndex = 0; tIndex < tLen; tIndex++) {		if (!bReadBuffer(pFile, ulStartBlock,				aulBBD, tBBDLen, BIG_BLOCK_SIZE,				aucFpage,				(ULONG)ausParfPage[tIndex] * BIG_BLOCK_SIZE,				BIG_BLOCK_SIZE)) {			break;		}		tRun = (size_t)ucGetByte(0x1ff, aucFpage);		NO_DBG_DEC(tRun);		for (tIndex2 = 0; tIndex2 < tRun; tIndex2++) {			NO_DBG_HEX(ulGetLong(tIndex2 * 4, aucFpage));			iFodo = 2 * (int)ucGetByte(				(tRun + 1) * 4 + tIndex2 * 7, aucFpage);			if (iFodo <= 0) {				continue;			}			iLen = 2 * (int)ucGetByte(iFodo, aucFpage);			usIstd = (USHORT)ucGetByte(iFodo + 1, aucFpage);			vFillStyleFromStylesheet(usIstd, &tStyle);			vGet6StyleInfo(iFodo, aucFpage + 3, iLen - 3, &tStyle);			ulCharPos = ulGetLong(tIndex2 * 4, aucFpage);			NO_DBG_HEX(ulCharPos);			tStyle.ulFileOffset = ulCharPos2FileOffsetX(				ulCharPos, &tStyle.eListID);			vAdd2StyleInfoList(&tStyle);			eRowInfo = eGet6RowInfo(iFodo,					aucFpage + 3, iLen - 3, &tRow);			switch(eRowInfo) {			case found_a_cell:				if (ulCharPosFirst != CP_INVALID) {					break;				}				ulCharPosFirst = ulGetLong(						tIndex2 * 4, aucFpage);				NO_DBG_HEX(ulCharPosFirst);				tRow.ulCharPosStart = ulCharPosFirst;				tRow.ulFileOffsetStart =					ulCharPos2FileOffset(ulCharPosFirst);				DBG_HEX_C(tRow.ulFileOffsetStart == FC_INVALID,							ulCharPosFirst);				break;			case found_end_of_row:				ulCharPosLast = ulGetLong(						tIndex2 * 4, aucFpage);				NO_DBG_HEX(ulCharPosLast);				tRow.ulCharPosEnd = ulCharPosLast;				tRow.ulFileOffsetEnd =					ulCharPos2FileOffset(ulCharPosLast);				DBG_HEX_C(tRow.ulFileOffsetEnd == FC_INVALID,							ulCharPosLast);				vAdd2RowInfoList(&tRow);				(void)memset(&tRow, 0, sizeof(tRow));				ulCharPosFirst = CP_INVALID;				break;			case found_nothing:				break;			default:				DBG_DEC(eRowInfo);				break;			}		}	}	ausParfPage = xfree(ausParfPage);} /* end of vGet6PapInfo *//* * Fill the font information block with information * from a Word 6/7 file. * Returns TRUE when successful, otherwise FALSE */voidvGet6FontInfo(int iFodo, USHORT usIstd,	const UCHAR *aucGrpprl, int iBytes, font_block_type *pFont){	long	lTmp;	int	iFodoOff, iInfoLen;	USHORT	usTmp;	UCHAR	ucTmp;	TRACE_MSG("vGet6FontInfo");	fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);	iFodoOff = 0;	while (iBytes >= iFodoOff + 1) {		switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {		case  65:	/* fRMarkDel */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			if (ucTmp == 0) {				pFont->usFontStyle &= ~FONT_MARKDEL;			} else {				pFont->usFontStyle |= FONT_MARKDEL;			}			break;		case  80:	/* cIstd */			usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);			NO_DBG_DEC(usTmp);			break;		case  82:	/* cDefault */			pFont->usFontStyle &= FONT_HIDDEN;			pFont->ucFontColor = FONT_COLOR_DEFAULT;			break;		case  83:	/* cPlain */			DBG_MSG("83: cPlain");			vFillFontFromStylesheet(usIstd, pFont);			break;		case  85:	/* fBold */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			switch (ucTmp) {			case   0:	/* Unset */				pFont->usFontStyle &= ~FONT_BOLD;				break;			case   1:	/* Set */				pFont->usFontStyle |= FONT_BOLD;				break;			case 128:	/* Unchanged */				break;			case 129:	/* Negation */				pFont->usFontStyle ^= FONT_BOLD;				break;			default:				DBG_DEC(ucTmp);				DBG_FIXME();				break;			}			break;		case  86:	/* fItalic */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			switch (ucTmp) {			case   0:	/* Unset */				pFont->usFontStyle &= ~FONT_ITALIC;				break;			case   1:	/* Set */				pFont->usFontStyle |= FONT_ITALIC;				break;			case 128:	/* Unchanged */				break;			case 129:	/* Negation */				pFont->usFontStyle ^= FONT_ITALIC;				break;			default:				DBG_DEC(ucTmp);				DBG_FIXME();				break;			}			break;		case  87:	/* fStrike */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			switch (ucTmp) {			case   0:	/* Unset */				pFont->usFontStyle &= ~FONT_STRIKE;				break;			case   1:	/* Set */				pFont->usFontStyle |= FONT_STRIKE;				break;			case 128:	/* Unchanged */				break;			case 129:	/* Negation */				pFont->usFontStyle ^= FONT_STRIKE;				break;			default:				DBG_DEC(ucTmp);				DBG_FIXME();				break;			}			break;		case  90:	/* fSmallCaps */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			switch (ucTmp) {			case   0:	/* Unset */				pFont->usFontStyle &= ~FONT_SMALL_CAPITALS;				break;			case   1:	/* Set */				pFont->usFontStyle |= FONT_SMALL_CAPITALS;				break;			case 128:	/* Unchanged */				break;			case 129:	/* Negation */				pFont->usFontStyle ^= FONT_SMALL_CAPITALS;				break;			default:				DBG_DEC(ucTmp);				DBG_FIXME();				break;			}			break;		case  91:	/* fCaps */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			switch (ucTmp) {			case   0:	/* Unset */				pFont->usFontStyle &= ~FONT_CAPITALS;				break;			case   1:	/* Set */				pFont->usFontStyle |= FONT_CAPITALS;				break;			case 128:	/* Unchanged */				break;			case 129:	/* Negation */				pFont->usFontStyle ^= FONT_CAPITALS;				break;			default:				DBG_DEC(ucTmp);				DBG_FIXME();				break;			}			break;		case  92:	/* fVanish */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			switch (ucTmp) {			case   0:	/* Unset */				pFont->usFontStyle &= ~FONT_HIDDEN;				break;			case   1:	/* Set */				pFont->usFontStyle |= FONT_HIDDEN;				break;			case 128:	/* Unchanged */				break;			case 129:	/* Negation */				pFont->usFontStyle ^= FONT_HIDDEN;				break;			default:				DBG_DEC(ucTmp);				DBG_FIXME();				break;			}			break;		case  93:	/* cFtc */			usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);			if (usTmp <= (USHORT)UCHAR_MAX) {				pFont->ucFontNumber = (UCHAR)usTmp;			} else {				DBG_DEC(usTmp);				DBG_FIXME();				pFont->ucFontNumber = 0;			}			break;		case  94:	/* cKul */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			if (ucTmp == 0 || ucTmp == 5) {				pFont->usFontStyle &= ~FONT_UNDERLINE;			} else {				NO_DBG_MSG("Underline text");				pFont->usFontStyle |= FONT_UNDERLINE;				if (ucTmp == 6) {					DBG_MSG("Bold text");					pFont->usFontStyle |= FONT_BOLD;				}			}			break;		case  95:	/* cHps, cHpsPos */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			DBG_DEC(ucTmp);			if (ucTmp != 0) {				pFont->usFontSize = (USHORT)ucTmp;			}			ucTmp = ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);			DBG_DEC(ucTmp);			break;		case  98:	/* cIco */			pFont->ucFontColor =				ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			break;		case  99:	/* cHps */			pFont->usFontSize =				usGetWord(iFodo + iFodoOff + 1, aucGrpprl);			break;		case 100:	/* cHpsInc */			DBG_MSG("100: sprmCHpsInc");			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			DBG_DEC(ucTmp);			break;		case 103:	/* cMajority */			DBG_MSG("103: sprmCMajority");			break;		case 104:	/* cIss */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			ucTmp &= 0x07;			if (ucTmp == 1) {				pFont->usFontStyle |= FONT_SUPERSCRIPT;				NO_DBG_MSG("Superscript");			} else if (ucTmp == 2) {				pFont->usFontStyle |= FONT_SUBSCRIPT;				NO_DBG_MSG("Subscript");			}			break;		case 106:	/* cHpsInc1 */			usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);			lTmp = (long)pFont->usFontSize + (long)usTmp;			if (lTmp < 8) {				pFont->usFontSize = 8;			} else if (lTmp > 32766) {				pFont->usFontSize = 32766;			} else {				pFont->usFontSize = (USHORT)lTmp;			}			break;		case 108:	/* cMajority50 */			DBG_MSG("108: sprmCMajority50");			break;		case 109:	/* cHpsMul */			DBG_MSG("109: sprmCHpsMul");			usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);			DBG_DEC(usTmp);			break;		default:			break;		}		iInfoLen = iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);		fail(iInfoLen <= 0);		iFodoOff += iInfoLen;	}} /* end of vGet6FontInfo *//* * Fill the picture information block with information * from a Word 6/7 file. * Returns TRUE when successful, otherwise FALSE */static BOOLbGet6PicInfo(int iFodo,	const UCHAR *aucGrpprl, int iBytes, picture_block_type *pPicture){	int	iFodoOff, iInfoLen;	BOOL	bFound;	UCHAR	ucTmp;	TRACE_MSG("vGet6PicInfo");	fail(iFodo < 0 || aucGrpprl == NULL || pPicture == NULL);	iFodoOff = 0;	bFound = FALSE;	while (iBytes >= iFodoOff + 1) {		switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {		case  68:	/* fcPic */			pPicture->ulPictureOffset = ulGetLong(					iFodo + iFodoOff + 2, aucGrpprl);			bFound = TRUE;			break;#if 0		case  71:	/* fData */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			if (ucTmp == 0x01) {				/* Not a picture, but a form field */				return FALSE;			}			DBG_DEC_C(ucTmp != 0, ucTmp);			break;#endif		case  75:	/* fOle2 */			ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);			if (ucTmp == 0x01) {				/* Not a picture, but an OLE object */				return FALSE;			}			DBG_DEC_C(ucTmp != 0, ucTmp);			break;		default:			break;		}		iInfoLen = iGet6InfoLength(iFodo + iFodoOff, aucGrpprl);		fail(iInfoLen <= 0);		iFodoOff += iInfoLen;	}	return bFound;} /* end of bGet6PicInfo *//* * Build the lists with Character Information for Word 6/7 files */voidvGet6ChrInfo(FILE *pFile, ULONG ulStartBlock,	const ULONG *aulBBD, size_t tBBDLen, const UCHAR *aucHeader){	font_block_type		tFont;	picture_block_type	tPicture;	USHORT	*ausCharPage;	UCHAR	*aucBuffer;	ULONG	ulFileOffset, ulCharPos, ulBeginCharInfo;	size_t	tCharInfoLen, tOffset, tSize, tLenOld, tLen, tCharPageNum;	size_t	tIndex, tIndex2, tRun;	int	iFodo, iLen;	USHORT	usCharFirstPage, usCount, usIstd;	UCHAR	aucFpage[BIG_BLOCK_SIZE];	fail(pFile == NULL || aucHeader == NULL);	fail(ulStartBlock > MAX_BLOCKNUMBER && ulStartBlock != END_OF_CHAIN);	fail(aulBBD == NULL);	ulBeginCharInfo = ulGetLong(0xb8, aucHeader); /* fcPlcfbteChpx */	NO_DBG_HEX(lBeginCharInfo);	tCharInfoLen = (size_t)ulGetLong(0xbc, aucHeader); /* lcbPlcfbteChpx */	NO_DBG_DEC(tCharInfoLen);	if (tCharInfoLen < 4) {		DBG_DEC(tCharInfoLen);		return;	}	aucBuffer = xmalloc(tCharInfoLen);	if (!bReadBuffer(pFile, ulStartBlock,			aulBBD, tBBDLen, BIG_BLOCK_SIZE,			aucBuffer, ulBeginCharInfo, tCharInfoLen)) {		aucBuffer = xfree(aucBuffer);		return;	}	tLen = (tCharInfoLen - 4) / 6;	ausCharPage = xcalloc(tLen, sizeof(USHORT));	for (tIndex = 0, tOffset = (tLen + 1) * 4;	     tIndex < tLen;	     tIndex++, tOffset += 2) {		 ausCharPage[tIndex] = usGetWord(tOffset, aucBuffer);		 NO_DBG_DEC(ausCharPage[tIndex]);	}	DBG_HEX(ulGetLong(0, aucBuffer));	aucBuffer = xfree(aucBuffer);	tCharPageNum = (size_t)usGetWord(0x18e, aucHeader); /* cpnBteChp */	DBG_DEC(tCharPageNum);	if (tLen < tCharPageNum) {		/* Replace CharPage by a longer version */		tLenOld = tLen;		usCharFirstPage = usGetWord(0x18a, aucHeader); /* pnChrFirst */		DBG_DEC(usCharFirstPage);		tLen += tCharPageNum - 1;		tSize = tLen * sizeof(USHORT);		ausCharPage = xrealloc(ausCharPage, tSize);		/* Add new values */		usCount = usCharFirstPage + 1;		for (tIndex = tLenOld; tIndex < tLen; tIndex++) {			ausCharPage[tIndex] = usCount;			NO_DBG_DEC(ausCharPage[tIndex]);			usCount++;		}	}	for (tIndex = 0; tIndex < tLen; tIndex++) {		if (!bReadBuffer(pFile, ulStartBlock,				aulBBD, tBBDLen, BIG_BLOCK_SIZE,				aucFpage,				(ULONG)ausCharPage[tIndex] * BIG_BLOCK_SIZE,				BIG_BLOCK_SIZE)) {			break;		}		tRun = (size_t)ucGetByte(0x1ff, aucFpage);		NO_DBG_DEC(tRun);		for (tIndex2 = 0; tIndex2 < tRun; tIndex2++) {		  	ulCharPos = ulGetLong(tIndex2 * 4, aucFpage);			ulFileOffset = ulCharPos2FileOffset(ulCharPos);			iFodo = 2 * (int)ucGetByte(				(tRun + 1) * 4 + tIndex2, aucFpage);			iLen = (int)ucGetByte(iFodo, aucFpage);			usIstd = usGetIstd(ulFileOffset);			vFillFontFromStylesheet(usIstd, &tFont);			if (iFodo != 0) {				vGet6FontInfo(iFodo, usIstd,					aucFpage + 1, iLen - 1, &tFont);			}			tFont.ulFileOffset = ulFileOffset;			vAdd2FontInfoList(&tFont);			if (iFodo <= 0) {				continue;			}			(void)memset(&tPicture, 0, sizeof(tPicture));			if (bGet6PicInfo(iFodo, aucFpage + 1,						iLen - 1, &tPicture)) {				tPicture.ulFileOffset = ulFileOffset;				tPicture.ulFileOffsetPicture =					ulDataPos2FileOffset(						tPicture.ulPictureOffset);				vAdd2PictInfoList(&tPicture);			}		}	}	ausCharPage = xfree(ausCharPage);} /* end of vGet6ChrInfo */

⌨️ 快捷键说明

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