예제 #1
0
파일: adt.cpp 프로젝트: yangjiao2/cs222
int PageDirectory::nextRecord(FileHandle &fh, RID &rid){
    char buffer[PAGE_SIZE];
    int pgid = rid.pageNum, slotid = -1;
    RecordPage rp;
    if (rid.pageNum != 0) {
        fh.readPage(rid.pageNum, buffer);
        rp = RecordPage(buffer);
        if ((slotid = rp.nextRecord(rid.slotNum)) != -1) { // - 1 is current. + 0 is next
            rid.slotNum = slotid;
            return 0;
        }
    }
    while (1) {
        if ((pgid = nextRecordPageID(fh, pgid)) == -1)
            return -1;
        fh.readPage(pgid, buffer);
        rp= RecordPage(buffer);
        if ((slotid = rp.nextRecord(0)) != -1) {
            rid.pageNum = pgid;
            rid.slotNum = slotid;
            return 0;
        }
    }
    return -1;
}
예제 #2
0
// record pages in given range
VOID SANDBOX::RecordPageRange(const char * beginPage, const char * endPage)
{
    for (const char * page = beginPage; page <= endPage; page += PageSize)
    {
        RecordPage(page);
    }
}
예제 #3
0
파일: draw.c 프로젝트: HuangLeo/KeyServer
int ShowNextPage(void)
{
	int iError;
	PT_PageDesc ptPage;
	unsigned char *pucTextFileMemCurPos;

	if (g_ptCurPage)
	{
		pucTextFileMemCurPos = g_ptCurPage->pucLcdNextPageFirstPosAtFile;
	}
	else
	{
		pucTextFileMemCurPos = g_pucLcdFirstPosAtFile;
	}
	iError = ShowOnePage(pucTextFileMemCurPos);
	DBG_PRINTF("%s %d, %d\n", __FUNCTION__, __LINE__, iError);
	if (iError == 0)
	{
		if (g_ptCurPage && g_ptCurPage->ptNextPage)
		{
			g_ptCurPage = g_ptCurPage->ptNextPage;
			return 0;
		}
		
		ptPage = malloc(sizeof(T_PageDesc));
		if (ptPage)
		{
			ptPage->pucLcdFirstPosAtFile         = pucTextFileMemCurPos;
			ptPage->pucLcdNextPageFirstPosAtFile = g_pucLcdNextPosAtFile;
			ptPage->ptPrePage                    = NULL;
			ptPage->ptNextPage                   = NULL;
			g_ptCurPage = ptPage;
			DBG_PRINTF("%s %d, pos = 0x%x\n", __FUNCTION__, __LINE__, (unsigned int)ptPage->pucLcdFirstPosAtFile);
			RecordPage(ptPage);
			return 0;
		}
		else
		{
			return -1;
		}
	}
	return iError;
}