Exemplo n.º 1
0
void	P2H_HeapHeader		(MemHeapHeaderUnionType*	pHeader)
{
    UInt16 version;
    if (! pHeader)
        return;

    // Too lazy to extract the version when the flags are in the wrong order ...
    pHeader->header.ver3.flags = BYTE_SWAP_16 (pHeader->header.ver3.flags);
    version = memUHeapVer (pHeader);
    pHeader->header.ver3.flags = BYTE_SWAP_16 (pHeader->header.ver3.flags);

    BS_HeapHeader (pHeader, version);
    switch (version)
    {
    case 4:
    case 3:
        P2H_MemMstrPtrTable (&(pHeader->header.ver3.mstrPtrTbl));
        break;
    case 2:
        P2H_MemMstrPtrTable (&(pHeader->header.ver2.mstrPtrTbl));
        break;
    case 1:
        P2H_Mem1MstrPtrTable (&(pHeader->header.ver1.mstrPtrTbl));
        break;
    default:
        fprintf (stderr, "*** P2H_HeapHeader: invalid version %d\n", version);
        break;
    }
}
Exemplo n.º 2
0
void	BS_Mem1ChunkHeader	(Mem1ChunkHeaderPtr	pChunk)
{
    if (! pChunk)
        return;

    pChunk->size = BYTE_SWAP_16(pChunk->size);
    pChunk->hOffset = BYTE_SWAP_16(pChunk->hOffset);
}
Exemplo n.º 3
0
void	BS_Mem1MstrPtrTableHeader	(Mem1MstrPtrTablePtr	pTable)
{
    if (! pTable)
        return;

    pTable->numEntries = BYTE_SWAP_16(pTable->numEntries);
    pTable->nextTblOffset = BYTE_SWAP_16(pTable->nextTblOffset);

}
Exemplo n.º 4
0
void	BS_SysNVParams	(SysNVParamsPtr	pParams)
{
    if (! pParams)
        return;

    pParams->rtcHours = BYTE_SWAP_32(pParams->rtcHours);
    pParams->rtcHourMinSecCopy = BYTE_SWAP_32(pParams->rtcHourMinSecCopy);
    pParams->splashScreenPtr = (void*)BYTE_SWAP_32(pParams->splashScreenPtr);
    pParams->hardResetScreenPtr = (void*)BYTE_SWAP_32(pParams->hardResetScreenPtr);
    pParams->localeLanguage = BYTE_SWAP_16(pParams->localeLanguage);
    pParams->localeCountry = BYTE_SWAP_16(pParams->localeCountry);
    pParams->sysNVOEMStorage1 = BYTE_SWAP_32(pParams->sysNVOEMStorage1);
    pParams->sysNVOEMStorage2 = BYTE_SWAP_32(pParams->sysNVOEMStorage2);
}
Exemplo n.º 5
0
void	BS_HeapListHeader	(HeapListPtr	pHeapList)
{
    if (! pHeapList)
        return;

    pHeapList->numHeaps = BYTE_SWAP_16(pHeapList->numHeaps);
}
Exemplo n.º 6
0
/*
 * Does not swap the record list
 */
void	BS_DatabaseHdrHeader	(DatabaseHdrPtr	pDatabase)
{
    if (! pDatabase)
        return;

    pDatabase->attributes			= BYTE_SWAP_16(pDatabase->attributes);
    pDatabase->version				= BYTE_SWAP_16(pDatabase->version);
    pDatabase->creationDate			= BYTE_SWAP_32(pDatabase->creationDate);
    pDatabase->modificationDate		= BYTE_SWAP_32(pDatabase->modificationDate);
    pDatabase->lastBackupDate		= BYTE_SWAP_32(pDatabase->lastBackupDate);
    pDatabase->modificationNumber	= BYTE_SWAP_32(pDatabase->modificationNumber);
    pDatabase->appInfoID			= BYTE_SWAP_32(pDatabase->appInfoID);
    pDatabase->sortInfoID			= BYTE_SWAP_32(pDatabase->sortInfoID);
    pDatabase->type					= BYTE_SWAP_32(pDatabase->type);
    pDatabase->creator				= BYTE_SWAP_32(pDatabase->creator);
    pDatabase->uniqueIDSeed			= BYTE_SWAP_32(pDatabase->uniqueIDSeed);
}
Exemplo n.º 7
0
void	BS_OverlaySpecHeader	(OmOverlaySpecType*	pOvly)
{
    if (! pOvly)
        return;

    pOvly->version			= BYTE_SWAP_16(pOvly->version);
    pOvly->flags			= BYTE_SWAP_32(pOvly->flags);
    pOvly->baseChecksum		= BYTE_SWAP_32(pOvly->baseChecksum);

    BS_Locale(&pOvly->targetLocale);

    pOvly->baseDBType		= BYTE_SWAP_32(pOvly->baseDBType);
    pOvly->baseDBCreator	= BYTE_SWAP_32(pOvly->baseDBCreator);

    pOvly->baseDBCreateDate	= BYTE_SWAP_32(pOvly->baseDBCreateDate);
    pOvly->baseDBModDate	= BYTE_SWAP_32(pOvly->baseDBModDate);
    pOvly->numOverlays		= BYTE_SWAP_16(pOvly->numOverlays);
}
Exemplo n.º 8
0
/*
 * Byte swap a database list.
 */
void	BS_DatabaseListHeader	(DatabaseListPtr	pList)
{
    if (! pList)
        return;

    pList->nextRecordListID = BYTE_SWAP_32(pList->nextRecordListID);
    pList->numDatabases     = BYTE_SWAP_16(pList->numDatabases);

}
Exemplo n.º 9
0
/* PROTO */
uint16_t
two_to_16(unsigned char *value)
{
	uint16_t        temp;

	memcpy(&temp, value, 2);

	if (endianness == HOST_LITTLE_ENDIAN)
		temp = BYTE_SWAP_16(temp);

	return temp;
}
Exemplo n.º 10
0
void	BS_StorageHeader	(StorageHeaderPtr	pStore)
{
    if (! pStore)
        return;

    pStore->signature			= BYTE_SWAP_32(pStore->signature);
    pStore->version				= BYTE_SWAP_16(pStore->version);
    pStore->flags				= BYTE_SWAP_16(pStore->flags);
    pStore->creationDate		= BYTE_SWAP_32(pStore->creationDate);
    pStore->backupDate			= BYTE_SWAP_32(pStore->backupDate);
    pStore->heapListOffset		= BYTE_SWAP_32(pStore->heapListOffset);
    pStore->initCodeOffset1		= BYTE_SWAP_32(pStore->initCodeOffset1);
    pStore->initCodeOffset2		= BYTE_SWAP_32(pStore->initCodeOffset2);
    pStore->databaseDirID		= BYTE_SWAP_32(pStore->databaseDirID);
    pStore->rsvSpace			= BYTE_SWAP_32(pStore->rsvSpace);
    pStore->dynHeapSpace		= BYTE_SWAP_32(pStore->dynHeapSpace);
    pStore->firstRAMBlockSize	= BYTE_SWAP_32(pStore->firstRAMBlockSize);
    BS_SysNVParams(&(pStore->nvParams));
    pStore->initCodeOffset3		= BYTE_SWAP_32(pStore->initCodeOffset3);
    pStore->crc					= BYTE_SWAP_32(pStore->crc);
}
Exemplo n.º 11
0
/* PROTO */
uint16_t
pkt_get16(pkt_t * pkt)
{
	uint16_t        val;

	memcpy(&val, pkt->data + pkt->offset, 2);

	if (endianness == HOST_LITTLE_ENDIAN)
		val = BYTE_SWAP_16(val);

	pkt->offset += 2;
	return val;
}
Exemplo n.º 12
0
void	BS_RecordListHeader	(RecordListPtr	pRecordList)
{
    UInt8*	pItem;

    if (! pRecordList)
        return;

    pItem	= (UInt8*)(&(pRecordList->firstEntry));

    pRecordList->nextRecordListID = BYTE_SWAP_32(pRecordList->nextRecordListID);
    pRecordList->numRecords		  = BYTE_SWAP_16(pRecordList->numRecords);

}
Exemplo n.º 13
0
/* Swaps only the MemHeapHeader, not the MemMstrPtrTable or its header */
void	BS_HeapHeader		(MemHeapHeaderUnionType*	pHeader,
                             UInt16						version)
{
    if (! pHeader)
        return;

    pHeader->header.ver3.flags = BYTE_SWAP_16(pHeader->header.ver3.flags);
    switch (version)
    {
    case 1:
        pHeader->header.ver1.size = BYTE_SWAP_16(pHeader->header.ver1.size);
        break;
    case 2:
        pHeader->header.ver2.size = BYTE_SWAP_32(pHeader->header.ver2.size);
        break;
    case 3:
    case 4:
        pHeader->header.ver3.size = BYTE_SWAP_32(pHeader->header.ver3.size);
        pHeader->header.ver3.firstFreeChunkOffset =
            BYTE_SWAP_32(pHeader->header.ver3.firstFreeChunkOffset);
    }
}
Exemplo n.º 14
0
void	BS_GenericList16 (void* pArray, UInt16 numEntries, UInt16 stepSize)
{
    UInt16 idex;

    if (! pArray)
        return;

    for (idex = 0; idex < numEntries; idex++)
    {
        *(UInt16*)pArray = (UInt16) BYTE_SWAP_16 (*(UInt16*)pArray);
        pArray = (UInt8*)pArray + stepSize;
    }
}
Exemplo n.º 15
0
void	BS_CardHeader	(CardHeaderPtr	pCard)
{
    if (! pCard)
        return;

    pCard->initStack			= BYTE_SWAP_32(pCard->initStack);
    pCard->resetVector			= BYTE_SWAP_32(pCard->resetVector);
    pCard->signature			= BYTE_SWAP_32(pCard->signature);
    pCard->hdrVersion			= BYTE_SWAP_16(pCard->hdrVersion);
    pCard->flags				= BYTE_SWAP_16(pCard->flags);
    pCard->version				= BYTE_SWAP_16(pCard->version);
    pCard->creationDate			= BYTE_SWAP_32(pCard->creationDate);
    pCard->numRAMBlocks			= BYTE_SWAP_16(pCard->numRAMBlocks);
    pCard->blockListOffset		= BYTE_SWAP_32(pCard->blockListOffset);
    pCard->readWriteParmsOffset	= BYTE_SWAP_32(pCard->readWriteParmsOffset);
    pCard->readWriteParmsSize	= BYTE_SWAP_32(pCard->readWriteParmsSize);
    pCard->readOnlyParmsOffset	= BYTE_SWAP_32(pCard->readOnlyParmsOffset);
    pCard->bigROMOffset			= BYTE_SWAP_32(pCard->bigROMOffset);
    pCard->checksumBytes		= BYTE_SWAP_32(pCard->checksumBytes);
    pCard->checksumValue		= BYTE_SWAP_16(pCard->checksumValue);
    pCard->readWriteWorkingOffset= BYTE_SWAP_32(pCard->readWriteWorkingOffset);
    pCard->readWriteWorkingSize	= BYTE_SWAP_32(pCard->readWriteWorkingSize);
    pCard->halCodeOffset		= BYTE_SWAP_32(pCard->halCodeOffset);
}
Exemplo n.º 16
0
/* PROTO */
IMCOMM_RET
pkt_add16(pkt_t * pkt, uint16_t val)
{
	uint16_t        tmpval;

	if (pkt_empty(pkt) < 2)
		return IMCOMM_RET_ERROR;

	if (endianness == HOST_BIG_ENDIAN) {
		memcpy(pkt->data + pkt->offset, &val, 2);
	} else {
		tmpval = BYTE_SWAP_16(val);
		memcpy(pkt->data + pkt->offset, &tmpval, 2);
	}

	pkt->offset += 2;
	return IMCOMM_RET_OK;
}
Exemplo n.º 17
0
void	BS_Locale	(OmLocaleType*	pLocale)
{
    pLocale->language	= BYTE_SWAP_16(pLocale->language);
    pLocale->country	= BYTE_SWAP_16(pLocale->country);
}