コード例 #1
0
ファイル: saveload.cpp プロジェクト: 33d/scummvm
void syncScript(Common::Serializer &s, scriptInstanceStruct *entry) {
	int numScripts = 0;
	uint32 dummyLong = 0;
	uint16 dummyWord = 0;

	if (s.isSaving()) {
		// Figure out the number of scripts to save
		scriptInstanceStruct* pCurrent = entry->nextScriptPtr;
		while (pCurrent) {
			++numScripts;
			pCurrent = pCurrent->nextScriptPtr;
		}
	}
	s.syncAsSint16LE(numScripts);

	scriptInstanceStruct *ptr = entry->nextScriptPtr;
	for (int i = 0; i < numScripts; ++i) {
		if (s.isLoading())
			ptr = (scriptInstanceStruct *)mallocAndZero(sizeof(scriptInstanceStruct));

		s.syncAsUint16LE(dummyWord);
		s.syncAsSint16LE(ptr->ccr);
		s.syncAsSint16LE(ptr->scriptOffset);
		s.syncAsUint32LE(dummyLong);
		s.syncAsSint16LE(ptr->dataSize);
		s.syncAsSint16LE(ptr->scriptNumber);
		s.syncAsSint16LE(ptr->overlayNumber);
		s.syncAsSint16LE(ptr->sysKey);
		s.syncAsSint16LE(ptr->freeze);
		s.syncAsSint16LE(ptr->type);
		s.syncAsSint16LE(ptr->var16);
		s.syncAsSint16LE(ptr->var18);
		s.syncAsSint16LE(ptr->var1A);

		s.syncAsSint16LE(ptr->dataSize);

		if (ptr->dataSize) {
			if (s.isLoading())
				ptr->data = (byte *)mallocAndZero(ptr->dataSize);
			s.syncBytes(ptr->data, ptr->dataSize);
		}

		if (s.isLoading()) {
			ptr->nextScriptPtr = NULL;
			entry->nextScriptPtr = ptr;
			entry = ptr;
		} else {
			ptr = ptr->nextScriptPtr;
		}
	}
}
コード例 #2
0
ファイル: saveload.cpp プロジェクト: 33d/scummvm
static void syncCell(Common::Serializer &s) {
	int chunkCount = 0;
	cellStruct *t, *p;
	uint16 dummyWord = 0;

	if (s.isSaving()) {
		// Figure out the number of chunks to save
		t = cellHead.next;
		while (t) {
			++chunkCount;
			t = t->next;
		}
	} else {
		cellHead.next = NULL; // Not in ASM code, but I guess the variable is defaulted in the EXE
	}
	s.syncAsSint16LE(chunkCount);

	t = s.isSaving() ? cellHead.next : &cellHead;
	for (int i = 0; i < chunkCount; ++i) {
		p = s.isSaving() ? t : (cellStruct *)mallocAndZero(sizeof(cellStruct));

		s.syncAsUint16LE(dummyWord);
		s.syncAsUint16LE(dummyWord);

		s.syncAsSint16LE(p->idx);
		s.syncAsSint16LE(p->type);
		s.syncAsSint16LE(p->overlay);
		s.syncAsSint16LE(p->x);
		s.syncAsSint16LE(p->field_C);
		s.syncAsSint16LE(p->spriteIdx);
		s.syncAsSint16LE(p->color);
		s.syncAsSint16LE(p->backgroundPlane);
		s.syncAsSint16LE(p->freeze);
		s.syncAsSint16LE(p->parent);
		s.syncAsSint16LE(p->parentOverlay);
		s.syncAsSint16LE(p->parentType);
		s.syncAsSint16LE(p->followObjectOverlayIdx);
		s.syncAsSint16LE(p->followObjectIdx);
		s.syncAsSint16LE(p->animStart);
		s.syncAsSint16LE(p->animEnd);
		s.syncAsSint16LE(p->animWait);
		s.syncAsSint16LE(p->animStep);
		s.syncAsSint16LE(p->animChange);
		s.syncAsSint16LE(p->animType);
		s.syncAsSint16LE(p->animSignal);
		s.syncAsSint16LE(p->animCounter);
		s.syncAsSint16LE(p->animLoop);
		s.syncAsUint16LE(dummyWord);

		if (s.isSaving())
			t = t->next;
		else {
			p->next = NULL;
			t->next = p;
			p->prev = cellHead.prev;
			cellHead.prev = p;
			t = p;
		}
	}
}
コード例 #3
0
ファイル: saveload.cpp プロジェクト: 33d/scummvm
static void syncCT(Common::Serializer &s) {
	int v = (_vm->_polyStruct) ? 1 : 0;
	s.syncAsSint32LE(v);
	if (s.isLoading())
		_vm->_polyStruct = (v != 0) ? &_vm->_polyStructNorm : NULL;

	if (v == 0)
		// There is no further data to load or save
		return;

	s.syncAsSint16LE(numberOfWalkboxes);

	if (numberOfWalkboxes) {
		for (int i = 0; i < numberOfWalkboxes; ++i)
			s.syncAsSint16LE(walkboxColor[i]);
		for (int i = 0; i < numberOfWalkboxes; ++i)
			s.syncAsSint16LE(walkboxState[i]);
	}

	for (int i = 0; i < 10; i++) {
		v = 0;
		if (s.isSaving()) v = (persoTable[i]) ? 1 : 0;
		s.syncAsSint32LE(v);

		if (s.isLoading())
			// Set up the pointer for the next structure
			persoTable[i] = (v == 0) ? NULL : (persoStruct *)mallocAndZero(sizeof(persoStruct));

		if (v != 0)
			syncPerso(s, *persoTable[i]);
	}
}
コード例 #4
0
ファイル: nre.systemMS.cpp プロジェクト: leesab/irods
int _delayExec( char *inActionCall, char *recoveryActionCall,
                char *delayCondition,  ruleExecInfo_t *rei ) {

    char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    int i, argc;
    ruleExecSubmitInp_t *ruleSubmitInfo;
    /* char action[MAX_ACTION_SIZE]; */
    char tmpStr[NAME_LEN];
    bytesBuf_t *packedReiAndArgBBuf = NULL;
    char *ruleExecId;
    char *actionCall;


    RE_TEST_MACRO( "    Calling _delayExec" );

    actionCall = inActionCall;
    /* Get Arguments */
    actionCall = ( char * ) malloc( strlen( inActionCall ) + strlen( recoveryActionCall ) + 3 );
    sprintf( actionCall, "%s|%s", inActionCall, recoveryActionCall );
    args[1] = NULL;
    argc = 0;
    /* Pack Rei and Args */
    i = packReiAndArg( rei->rsComm, rei, args, argc, &packedReiAndArgBBuf );
    if ( i < 0 ) {
        if ( actionCall != inActionCall ) {
            free( actionCall );
        }
        return( i );
    }
    /* fill Conditions into Submit Struct */
    ruleSubmitInfo = ( ruleExecSubmitInp_t * ) mallocAndZero( sizeof( ruleExecSubmitInp_t ) );
    i  = fillSubmitConditions( actionCall, delayCondition, packedReiAndArgBBuf, ruleSubmitInfo, rei );
    if ( actionCall != inActionCall ) {
        free( actionCall );
    }
    if ( i < 0 ) {
        free( ruleSubmitInfo );
        return( i );
    }

    /* Store ReiArgs Struct in a File */
    i = rsRuleExecSubmit( rei->rsComm, ruleSubmitInfo, &ruleExecId );
    if ( packedReiAndArgBBuf != NULL ) {
        clearBBuf( packedReiAndArgBBuf );
        free( packedReiAndArgBBuf );
    }

    free( ruleSubmitInfo );
    if ( i < 0 ) {
        return( i );
    }
    free( ruleExecId );
    snprintf( tmpStr, NAME_LEN, "%d", i );
    i = pushStack( &delayStack, tmpStr );
    return( i );
}
コード例 #5
0
/**
 * \fn msiPropertiesNew( msParam_t *listParam, ruleExecInfo_t *rei )
 *
 * \brief Create a new empty property list
 *
 * \module properties
 *
 * \since pre-2.1
 *
 * \author  David R. Nadeau / University of California, San Diego
 * \date    2007
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[out] listParam - a KeyValPair_MS_T, the newly created property list
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiPropertiesNew( msParam_t *listParam, ruleExecInfo_t *rei )
{
	RE_TEST_MACRO( "    Calling msiPropertiesNew" );

	/* Create empty list */
	fillMsParam( listParam, NULL,
		KeyValPair_MS_T, mallocAndZero( sizeof(keyValPair_t) ), NULL );
	return 0;
}
コード例 #6
0
int getVolumeDataEntry(volumeDataStruct *entry) {
	char buffer[256];
	int i;

	volumeNumEntry = 0;
	volumeNumberOfEntry = 0;

	if (_vm->_currentVolumeFile.isOpen()) {
		freeDisk();
	}

	askDisk(-1);

	strcpy(buffer, entry->ident);

	_vm->_currentVolumeFile.open(buffer);

	if (!_vm->_currentVolumeFile.isOpen()) {
		return (-14);
	}

	changeCursor(CURSOR_DISK);

	volumeNumberOfEntry = _vm->_currentVolumeFile.readSint16BE();
	volumeSizeOfEntry = _vm->_currentVolumeFile.readSint16BE();

	volumeNumEntry = volumeNumberOfEntry;

	assert(volumeSizeOfEntry == 14 + 4 + 4 + 4 + 4);

	volumePtrToFileDescriptor = (fileEntry *) mallocAndZero(sizeof(fileEntry) * volumeNumEntry);

	for (i = 0; i < volumeNumEntry; i++) {
		volumePtrToFileDescriptor[i].name[0] = 0;
		volumePtrToFileDescriptor[i].offset = 0;
		volumePtrToFileDescriptor[i].size = 0;
		volumePtrToFileDescriptor[i].extSize = 0;
		volumePtrToFileDescriptor[i].unk3 = 0;
	}

	for (i = 0; i < volumeNumEntry; i++) {
		_vm->_currentVolumeFile.read(&volumePtrToFileDescriptor[i].name, 14);
		volumePtrToFileDescriptor[i].offset = _vm->_currentVolumeFile.readSint32BE();
		volumePtrToFileDescriptor[i].size = _vm->_currentVolumeFile.readSint32BE();
		volumePtrToFileDescriptor[i].extSize = _vm->_currentVolumeFile.readSint32BE();
		volumePtrToFileDescriptor[i].unk3 = _vm->_currentVolumeFile.readSint32BE();
	}

	strcpy(currentBaseName, entry->ident);

	loadPal(entry);

	return 0;
}
コード例 #7
0
ファイル: reStruct.c プロジェクト: DICE-UNC/iRODS-FUSE-Mod
int
copyRescGrpInfo(rescGrpInfo_t *from, rescGrpInfo_t *to)
{
  *to = *from;
  if (from->next != NULL) {
    to->next = (rescGrpInfo_t*)mallocAndZero(sizeof(rescGrpInfo_t));
    copyRescGrpInfo(from->next,to->next);
  }
  else
    to->next = NULL;
  return(0);
}
コード例 #8
0
ファイル: reStruct.c プロジェクト: DICE-UNC/iRODS-FUSE-Mod
int
copyCollInfo(collInfo_t *from, collInfo_t *to)
{
  *to = *from;
  if (from->next != NULL) {
    to->next = (collInfo_t*)mallocAndZero(sizeof(collInfo_t));
    copyCollInfo(from->next,to->next);
  }
  else
    to->next = NULL;
  return(0);
}
コード例 #9
0
ファイル: reStruct.c プロジェクト: DICE-UNC/iRODS-FUSE-Mod
int
copyDataObjInfo(dataObjInfo_t *from, dataObjInfo_t *to)
{
  *to = *from;
  if (from->next != NULL) {
    to->next = (dataObjInfo_t*)mallocAndZero(sizeof(dataObjInfo_t));
    copyDataObjInfo(from->next,to->next);
  }
  else
    to->next = NULL;
  return(0);
}
コード例 #10
0
/**
 * \fn msiPropertiesClone( msParam_t *listParam, msParam_t *cloneParam, ruleExecInfo_t *rei )
 *
 * \brief Clone a property list, returning a new property list
 *
 * \module properties
 *
 * \since pre-2.1
 *
 * \author  David R. Nadeau / University of California, San Diego
 * \date    2007
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] listParam - a KeyValPair_MS_T, the property list to clone
 * \param[out] cloneParam - a KeyValPair_MS_T, the returned clone (new property list)
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect a new peoperty list is created
 *
 * \return integer
 * \retval 0 on success
 * \pre none
 * \post none
 * \sa none
**/
int
msiPropertiesClone( msParam_t *listParam, msParam_t *cloneParam, ruleExecInfo_t *rei )
{
	RE_TEST_MACRO( "    Calling msiPropertiesClone" );

	/* Check parameters */
	if ( strcmp( listParam->type, KeyValPair_MS_T ) != 0 )
		return USER_PARAM_TYPE_ERR;

	fillMsParam( cloneParam, NULL,
		KeyValPair_MS_T, mallocAndZero( sizeof(keyValPair_t) ), NULL );
	replKeyVal( (keyValPair_t*)listParam->inOutStruct, (keyValPair_t*)cloneParam->inOutStruct );
	return 0;
}
コード例 #11
0
ファイル: saveload.cpp プロジェクト: 33d/scummvm
static void syncActors(Common::Serializer &s) {
	int numEntries = 0;
	actorStruct *ptr;
	uint16 dummyLong = 0;

	if (s.isSaving()) {
		ptr = actorHead.next;
		while (ptr) {
			++numEntries;
			ptr = ptr->next;
		}
	}
	s.syncAsSint16LE(numEntries);

	ptr = s.isSaving() ? actorHead.next : &actorHead;
	for (int i = 0; i < numEntries; ++i) {
		actorStruct *p = s.isSaving() ? ptr : (actorStruct *)mallocAndZero(sizeof(actorStruct));

		s.syncAsUint32LE(dummyLong);
		s.syncAsSint16LE(p->idx);
		s.syncAsSint16LE(p->type);
		s.syncAsSint16LE(p->overlayNumber);
		s.syncAsSint16LE(p->x_dest);
		s.syncAsSint16LE(p->y_dest);
		s.syncAsSint16LE(p->x);
		s.syncAsSint16LE(p->y);
		s.syncAsSint16LE(p->startDirection);
		s.syncAsSint16LE(p->nextDirection);
		s.syncAsSint16LE(p->endDirection);
		s.syncAsSint16LE(p->stepX);
		s.syncAsSint16LE(p->stepY);
		s.syncAsSint16LE(p->pathId);
		s.syncAsSint16LE(p->phase);
		s.syncAsSint16LE(p->counter);
		s.syncAsSint16LE(p->poly);
		s.syncAsSint16LE(p->flag);
		s.syncAsSint16LE(p->start);
		s.syncAsSint16LE(p->freeze);

		if (s.isSaving())
			ptr = ptr->next;
		else {
			p->next = NULL;
			ptr->next = p;
			p->prev = actorHead.prev;
			actorHead.prev = p;
			ptr = p->next;
		}
	}
}
コード例 #12
0
ファイル: rsDataObjRead.cpp プロジェクト: cchapati/irods
int
applyRuleForPostProcForRead( rsComm_t *rsComm, bytesBuf_t *dataObjReadOutBBuf, char *objPath ) {
    if ( ReadWriteRuleState != ON_STATE ) {
        return 0;
    }

    ruleExecInfo_t rei2;
    memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
    msParamArray_t msParamArray;
    memset( ( char* )&msParamArray, 0, sizeof( msParamArray_t ) );

    if ( rsComm != NULL ) {
        rei2.rsComm = rsComm;
        rei2.uoic = &rsComm->clientUser;
        rei2.uoip = &rsComm->proxyUser;
    }
    rei2.doi = ( dataObjInfo_t* )mallocAndZero( sizeof( dataObjInfo_t ) );
    snprintf( rei2.doi->objPath, sizeof( rei2.doi->objPath ), "%s", objPath );

    memset( &msParamArray, 0, sizeof( msParamArray ) );
    int * myInOutStruct = ( int* )malloc( sizeof( int ) );
    *myInOutStruct = dataObjReadOutBBuf->len;
    addMsParamToArray( &msParamArray, "*ReadBuf", BUF_LEN_MS_T, myInOutStruct,
                       dataObjReadOutBBuf, 0 );
    int status = applyRule( "acPostProcForDataObjRead(*ReadBuf)", &msParamArray, &rei2,
                    NO_SAVE_REI );
    free( rei2.doi );
    if ( status < 0 ) {
        if ( rei2.status < 0 ) {
            status = rei2.status;
        }
        rodsLog( LOG_ERROR,
                 "rsDataObjRead: acPostProcForDataObjRead error=%d", status );
        clearMsParamArray( &msParamArray, 0 );
        return status;
    }
    clearMsParamArray( &msParamArray, 0 );

    return 0;

}
コード例 #13
0
ファイル: overlay.cpp プロジェクト: St0rmcrow/scummvm
int loadOverlay(const char *scriptName) {
	int newNumberOfScript;
	bool scriptNotLoadedBefore;
	int scriptIdx;
	char fileName[50];
	int fileIdx;
	int unpackedSize;
	byte *unpackedBuffer;
	ovlDataStruct *ovlData;

	debug(1, "Load overlay: %s", scriptName);

	newNumberOfScript = numOfLoadedOverlay;

	scriptNotLoadedBefore = false;

	scriptIdx = findOverlayByName((const char *)scriptName);

	if (scriptIdx == -4) {
		scriptIdx = numOfLoadedOverlay;

		newNumberOfScript++;

		scriptNotLoadedBefore = true;
	}

	if (overlayTable[scriptIdx].alreadyLoaded) {
		return (scriptIdx);
	}

	overlayTable[scriptIdx].ovlData =
	    (ovlDataStruct *) mallocAndZero(sizeof(ovlDataStruct));

	if (!overlayTable[scriptIdx].ovlData)
		return (-2);

	if (scriptName != overlayTable[scriptIdx].overlayName)
		strcpy(overlayTable[scriptIdx].overlayName, scriptName);

	overlayTable[scriptIdx].alreadyLoaded = 1;

	numOfLoadedOverlay = newNumberOfScript;

	overlayTable[scriptIdx].ovlData->scriptNumber = scriptIdx;

	strcpy(fileName, scriptName);

	strcat(fileName, ".OVL");

	debug(1, "Attempting to load overlay file %s...", fileName);

	fileIdx = findFileInDisks(fileName);

	if (fileIdx < 0) {
		warning("Unable to load overlay %s", scriptName);
		//releaseScript(scriptName);
		return (-18);
	}

	unpackedSize = volumePtrToFileDescriptor[fileIdx].extSize + 2;

	// This memory block will be later passed to a MemoryReadStream, which will dispose of it
	unpackedBuffer = (byte *)malloc(unpackedSize);
	memset(unpackedBuffer, 0, unpackedSize);

	if (!unpackedBuffer) {
		return (-2);
	}

	if (volumePtrToFileDescriptor[fileIdx].size + 2 != unpackedSize) {
		char *pakedBuffer =
		    (char *)mallocAndZero(volumePtrToFileDescriptor[fileIdx].
		                          size + 2);

		loadPackedFileToMem(fileIdx, (uint8 *) pakedBuffer);

		delphineUnpack((uint8 *)unpackedBuffer, (const uint8 *)pakedBuffer, volumePtrToFileDescriptor[fileIdx].size);

		MemFree(pakedBuffer);
	} else {
		loadPackedFileToMem(fileIdx, (uint8 *) unpackedBuffer);
	}

	debug(1, "OVL loading done...");

	Common::MemoryReadStream s(unpackedBuffer, unpackedSize, DisposeAfterUse::YES);
	unpackedBuffer = NULL;

	ovlData = overlayTable[scriptIdx].ovlData;

	// Skip pointers
	s.skip(60);

	ovlData->arrayProc = NULL;
	ovlData->ptr1 = NULL;
	ovlData->arrayObject = NULL;
	ovlData->arrayStates = NULL;
	ovlData->arrayObjVar = NULL;
	ovlData->stringTable = NULL;
	ovlData->arraySymbGlob = NULL;
	ovlData->arrayRelocGlob = NULL;
	ovlData->arrayMsgRelHeader = NULL;
	ovlData->nameVerbGlob = NULL;
	ovlData->arrayNameObj = NULL;
	ovlData->arrayNameRelocGlob = NULL;
	ovlData->arrayNameSymbGlob = NULL;
	ovlData->data4Ptr = NULL;
	ovlData->ptr8 = NULL;
	ovlData->numProc = s.readUint16BE();
	ovlData->numRel = s.readUint16BE();
	ovlData->numSymbGlob = s.readUint16BE();
	ovlData->numRelocGlob = s.readUint16BE();
	ovlData->numMsgRelHeader = s.readUint16BE();
	ovlData->numObj = s.readUint16BE();
	ovlData->numStrings = s.readUint16BE();
	ovlData->size8 = s.readUint16BE();
	ovlData->size9 = s.readUint16BE();
	ovlData->nameExportSize = s.readUint16BE();
	ovlData->exportNamesSize = s.readUint16BE();
	ovlData->specialString2Length = s.readUint16BE();
	ovlData->sizeOfData4 = s.readUint16BE();
	ovlData->size12 = s.readUint16BE();
	ovlData->specialString1Length = s.readUint16BE();
	ovlData->scriptNumber = s.readUint16BE();

	if (ovlData->numSymbGlob)	{ // export data
		int i;
		ovlData->arraySymbGlob =
		    (exportEntryStruct *) mallocAndZero(ovlData->numSymbGlob * sizeof(exportEntryStruct));

		if (!ovlData->arraySymbGlob) {
			return (-2);
		}

		for (i = 0; i < ovlData->numSymbGlob; i++) {
			ovlData->arraySymbGlob[i].var0 = s.readUint16BE();
			ovlData->arraySymbGlob[i].var2 = s.readUint16BE();
			ovlData->arraySymbGlob[i].var4 = s.readUint16BE();
			ovlData->arraySymbGlob[i].idx = s.readUint16BE();
			ovlData->arraySymbGlob[i].offsetToName = s.readUint16BE();
		}
	}

	if (ovlData->exportNamesSize) {	// export names
		ovlData->arrayNameSymbGlob = (char *) mallocAndZero(ovlData->exportNamesSize);

		if (!ovlData->arrayNameSymbGlob) {
			return (-2);
		}

		s.read(ovlData->arrayNameSymbGlob, ovlData->exportNamesSize);
	}

	if (ovlData->numRelocGlob) {	// import data
		int i;

		ovlData->arrayRelocGlob =
		    (importDataStruct *) mallocAndZero(ovlData->numRelocGlob *
		                                       sizeof(importDataStruct));

		if (!ovlData->arrayRelocGlob) {
			return (-2);
		}

		for (i = 0; i < ovlData->numRelocGlob; i++) {
			ovlData->arrayRelocGlob[i].var0 = s.readUint16BE();
			ovlData->arrayRelocGlob[i].var1 = s.readUint16BE();
			ovlData->arrayRelocGlob[i].linkType = s.readUint16BE();
			ovlData->arrayRelocGlob[i].linkIdx = s.readUint16BE();
			ovlData->arrayRelocGlob[i].nameOffset = s.readUint16BE();
		}
	}

	if (ovlData->nameExportSize) {	// import name
		ovlData->arrayNameRelocGlob = (char *) mallocAndZero(ovlData->nameExportSize);

		if (!ovlData->arrayNameRelocGlob) {
			return (-2);
		}

		s.read(ovlData->arrayNameRelocGlob, ovlData->nameExportSize);
	}

	if (ovlData->numMsgRelHeader) {	// link data
		int i;
		ASSERT(sizeof(linkDataStruct) == 0x22);

		ovlData->arrayMsgRelHeader = (linkDataStruct *) mallocAndZero(ovlData->numMsgRelHeader * sizeof(linkDataStruct));

		if (!ovlData->arrayMsgRelHeader) {
			return (-2);
		}

		for (i = 0; i < ovlData->numMsgRelHeader; i++) {
			ovlData->arrayMsgRelHeader[i].type = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].id = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].offsetVerbeName = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].verbOverlay = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].verbNumber = s.readUint16BE();

			ovlData->arrayMsgRelHeader[i].obj1Overlay = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].obj1Number = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].obj2Overlay = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].obj2Number = s.readUint16BE();

			ovlData->arrayMsgRelHeader[i].trackX = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].trackY = s.readUint16BE();

			ovlData->arrayMsgRelHeader[i].obj1NewState = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].obj2NewState = s.readUint16BE();

			ovlData->arrayMsgRelHeader[i].obj1OldState = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].obj2OldState = s.readUint16BE();

			ovlData->arrayMsgRelHeader[i].trackDirection = s.readUint16BE();
			ovlData->arrayMsgRelHeader[i].dialog = s.readUint16BE();
		}
	}

	if (ovlData->numProc) {	// script
		ovlData3Struct *tempPtr;
		int i;

		ovlData->arrayProc =
		    (ovlData3Struct *) mallocAndZero(ovlData->numProc * sizeof(ovlData3Struct));

		if (!ovlData->arrayProc) {
			return (-2);
		}

		for (i = 0; i < ovlData->numProc; i++) {
			s.skip(4);
			ovlData->arrayProc[i].dataPtr = NULL;
			ovlData->arrayProc[i].sizeOfData = s.readUint16BE();
			ovlData->arrayProc[i].offsetToSubData3 = s.readUint16BE();
			ovlData->arrayProc[i].offsetToImportData = s.readUint16BE();
			ovlData->arrayProc[i].offsetToSubData2 = s.readUint16BE();
			ovlData->arrayProc[i].offsetToImportName = s.readUint16BE();
			ovlData->arrayProc[i].offsetToSubData5 = s.readUint16BE();
			ovlData->arrayProc[i].sysKey = s.readUint16BE();
			ovlData->arrayProc[i].var12 = s.readUint16BE();
			ovlData->arrayProc[i].numRelocGlob = s.readUint16BE();
			ovlData->arrayProc[i].subData2Size = s.readUint16BE();
			ovlData->arrayProc[i].var18 = s.readUint16BE();
			ovlData->arrayProc[i].var1A = s.readUint16BE();
		}

		tempPtr = ovlData->arrayProc;

		for (i = 0; i < ovlData->numProc; i++) {
			tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData);

			if (!tempPtr->dataPtr) {
				return (-2);
			}

			s.read(tempPtr->dataPtr, tempPtr->sizeOfData);

			if (tempPtr->offsetToImportData) {
				flipGen(tempPtr->dataPtr + tempPtr->offsetToImportData,
				        tempPtr->numRelocGlob * 10);
			}

			if (tempPtr->offsetToSubData2) {
				flipGen(tempPtr->dataPtr + tempPtr->offsetToSubData2,
				        tempPtr->subData2Size * 10);
			}

			tempPtr++;
		}
	}

	if (ovlData->numRel) {
		ovlData3Struct *tempPtr;
		int i;

		ovlData->ptr1 =
		    (ovlData3Struct *) mallocAndZero(ovlData->numRel * sizeof(ovlData3Struct));

		if (!ovlData->ptr1) {
			return (-2);
		}

		for (i = 0; i < ovlData->numRel; i++) {
			s.skip(4);
			ovlData->ptr1[i].dataPtr = NULL;
			ovlData->ptr1[i].sizeOfData = s.readUint16BE();
			ovlData->ptr1[i].offsetToSubData3 = s.readUint16BE();
			ovlData->ptr1[i].offsetToImportData = s.readUint16BE();
			ovlData->ptr1[i].offsetToSubData2 = s.readUint16BE();
			ovlData->ptr1[i].offsetToImportName = s.readUint16BE();
			ovlData->ptr1[i].offsetToSubData5 = s.readUint16BE();
			ovlData->ptr1[i].sysKey = s.readUint16BE();
			ovlData->ptr1[i].var12 = s.readUint16BE();
			ovlData->ptr1[i].numRelocGlob = s.readUint16BE();
			ovlData->ptr1[i].subData2Size = s.readUint16BE();
			ovlData->ptr1[i].var18 = s.readUint16BE();
			ovlData->ptr1[i].var1A = s.readUint16BE();
		}

		tempPtr = (ovlData3Struct *) ovlData->ptr1;

		for (i = 0; i < ovlData->numRel; i++) {
			tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData);

			if (!tempPtr->dataPtr) {
				return (-2);
			}

			s.read(tempPtr->dataPtr, tempPtr->sizeOfData);

			if (tempPtr->offsetToImportData) {
				flipGen(tempPtr->dataPtr + tempPtr->offsetToImportData,
				        tempPtr->numRelocGlob * 10);
			}

			if (tempPtr->offsetToSubData2) {
				flipGen(tempPtr->dataPtr + tempPtr->offsetToSubData2,
				        tempPtr->subData2Size * 10);
			}

			tempPtr++;
		}
	}

	if (ovlData->size12) {
		ovlData->ptr8 = (uint8 *) mallocAndZero(ovlData->size12);

		if (!ovlData->ptr8) {
			/*      releaseScript(scriptIdx,scriptName);

			      if (freeIsNeeded) {
			        freePtr(unpackedBuffer);
			      } */

			return (-2);
		}

		s.read(ovlData->ptr8, ovlData->size12);
	}

	if (ovlData->numObj) {
		int i;
		ovlData->arrayObject =
		    (objDataStruct *) mallocAndZero(ovlData->numObj *
		                                    sizeof(objDataStruct));

		if (!ovlData->arrayObject) {
			return (-2);
		}

		for (i = 0; i < ovlData->numObj; i++) {
			ovlData->arrayObject[i]._type = s.readUint16BE();
			ovlData->arrayObject[i]._class = (eClass) s.readUint16BE();
			ovlData->arrayObject[i]._nameOffset = s.readUint16BE();
			ovlData->arrayObject[i]._numStates = s.readUint16BE();
			ovlData->arrayObject[i]._varTableIdx = s.readUint16BE();
			ovlData->arrayObject[i]._firstStateIdx = s.readUint16BE();
			ovlData->arrayObject[i]._stateTableIdx = s.readUint16BE();
		}

		// allocate states for object with multiple states

		if (scriptNotLoadedBefore) {
			overlayTable[scriptIdx].state = stateID;
			stateID += getNumObjectsByClass(scriptIdx, MULTIPLE) + getNumObjectsByClass(scriptIdx, THEME);
		}
	}

	if (ovlData->size9) {
		ovlData->arrayObjVar =
		    (objectParams *) mallocAndZero(ovlData->size9 *
		                                   sizeof(objectParams));

		if (!ovlData->arrayObjVar) {
			return (-2);
		}
	}

	if (ovlData->size8) {
		int i;
		ovlData->arrayStates =
		    (objectParams *) mallocAndZero(ovlData->size8 *
		                                   sizeof(objectParams));

		if (!ovlData->arrayStates) {
			return (-2);
		}

		for (i = 0; i < ovlData->size8; i++) {
			ovlData->arrayStates[i].X = s.readUint16BE();
			ovlData->arrayStates[i].Y = s.readUint16BE();
			ovlData->arrayStates[i].Z = s.readUint16BE();
			ovlData->arrayStates[i].frame = s.readUint16BE();
			ovlData->arrayStates[i].scale = s.readUint16BE();
			ovlData->arrayStates[i].state = s.readUint16BE();
		}
	}

	if (ovlData->numStrings) {
		int i;

		ovlData->stringTable =
		    (stringEntryStruct *) mallocAndZero(ovlData->numStrings *
		                                        sizeof(stringEntryStruct));

		for (i = 0; i < ovlData->numStrings; i++) {
			ovlData->stringTable[i].idx = s.readUint16BE();
		}
	}

	if (ovlData->sizeOfData4) {
		ovlData->data4Ptr =
		    (uint8 *) mallocAndZero(ovlData->sizeOfData4);

		if (!ovlData->data4Ptr) {
			return (-2);
		}
	}

	if (ovlData->
	        specialString1Length /*|| ovlData->specialString2Length */
	        || ovlData->stringTable) {
		int i;
		//int unpackedSize;
		//int fileIdx;
		//uint8 fileName[50];
		//char* unpackedBuffer;

		strcpy(fileName, scriptName);

		strcat(fileName, ".FR");

		fileIdx = findFileInDisks(fileName);

		if (fileIdx < 0) {
			//releaseScript(scriptName);
			return (-18);
		}

		unpackedSize = volumePtrToFileDescriptor[fileIdx].extSize + 2;

		// This memory block will be later passed to a MemoryReadStream, which will dispose of it
		unpackedBuffer = (byte *)malloc(unpackedSize);
		memset(unpackedBuffer, 0, unpackedSize);

		if (!unpackedBuffer) {
			return (-2);
		}

		if (volumePtrToFileDescriptor[fileIdx].size + 2 !=
		        unpackedSize) {
			char *pakedBuffer =
			    (char *)
			    mallocAndZero(volumePtrToFileDescriptor[fileIdx].
			                  size + 2);

			loadPackedFileToMem(fileIdx, (uint8 *) pakedBuffer);

			delphineUnpack((uint8 *) unpackedBuffer, (const uint8 *)pakedBuffer, volumePtrToFileDescriptor[fileIdx].size);

			MemFree(pakedBuffer);
		} else {
			loadPackedFileToMem(fileIdx, (uint8 *) unpackedBuffer);
		}

		Common::MemoryReadStream s2(unpackedBuffer, unpackedSize, DisposeAfterUse::YES);
		unpackedBuffer = NULL;

		ovlData->specialString1Length = s2.readUint16BE();
		if (ovlData->specialString1Length) {
			ovlData->nameVerbGlob = (char *) mallocAndZero(ovlData->specialString1Length);

			if (!ovlData->nameVerbGlob) {
				/*      releaseScript(scriptIdx,scriptName);
				 *
				 * if (freeIsNeeded)
				 * {
				 * freePtr(unpackedBuffer);
				 * } */

				return (-2);
			}

			s2.read(ovlData->nameVerbGlob, ovlData->specialString1Length);
		}

		ovlData->specialString2Length = s2.readUint16BE();
		if (ovlData->specialString2Length) {
			ovlData->arrayNameObj = (char *) mallocAndZero(ovlData->specialString2Length);

			if (!ovlData->arrayNameObj) {
				/*      releaseScript(scriptIdx,scriptName);
				 *
				 * if (freeIsNeeded)
				 * {
				 * freePtr(unpackedBuffer);
				 * } */

				return (-2);
			}

			s2.read(ovlData->arrayNameObj, ovlData->specialString2Length);
		}

		for (i = 0; i < ovlData->numStrings; i++) {
			ovlData->stringTable[i].length = s2.readUint16BE();

			if (ovlData->stringTable[i].length) {
				ovlData->stringTable[i].string =
				    (char *)mallocAndZero(ovlData->
				                          stringTable[i].length);

				if (!ovlData->stringTable[i].string) {
					/*      releaseScript(scriptIdx,scriptName);
					 *
					 * if (freeIsNeeded)
					 * {
					 * freePtr(unpackedBuffer);
					 * } */

					return (-2);
				}

				s2.read(ovlData->stringTable[i].string, ovlData->stringTable[i].length);
			}
		}
	}
#ifdef DUMP_SCRIPT
	{
		int i;
		for (i = 0; i < ovlData->numProc; i++) {
			dumpScript(scriptName, ovlData, i);
		}
	}
#endif
#ifdef DUMP_OBJECT
	{
		// TODO: Rewrite this to use Common::DumpFile
		int i;
		FILE *fHandle;
		char nameBundle[100];
		sprintf(nameBundle, "%s-objs.txt", scriptName);

		fHandle = fopen(nameBundle, "w+");
		ASSERT(fHandle);

		for (i = 0; i < ovlData->numMsgRelHeader; i++) {
			linkDataStruct *var_34;
			var_34 = &ovlData->arrayMsgRelHeader[i];

			if (ovlData->arrayNameObj) {
				fprintf(fHandle, "----- object %02d -----\n",
				        i);
				if (var_34->stringNameOffset != 0xFFFF) {
					fprintf(fHandle, "name: %s\n",
					        getObjectName(var_34->
					                      stringNameOffset,
					                      ovlData->arrayNameObj));
				}
			}
		}

		fclose(fHandle);
	}
#endif

	return (scriptIdx);
}
コード例 #14
0
ファイル: ruleAdmin.cpp プロジェクト: bpow/irods
int
performAction( inStruct Sentries ) {
    int status;
    int c, i, j;
    int uFlag = 0;;
    char tmpStr[100];
    ruleExecInfo_t rei;
    char action[100];
    char *t1;
    char *args[MAX_NUM_OF_ARGS_IN_ACTION];
    char configDirEV[200];
    char retestflagEV[200];
    char reloopbackflagEV[200];

    char ruleSet[RULE_SET_DEF_LENGTH];
    hrtime_t ht1, ht2, ht3;

    bzero( &rei, sizeof( ruleExecInfo_t ) ); /*  June 17. 2009 */
    /*
     sprintf(configDirEV,"irodsConfigDir=/scratch/s1/sekar/irods/RODS/server/config");
     sprintf(configDirEV,"irodsConfigDir=/misc/www/projects/srb-secure/cgi-bin");
     putenv(configDirEV);
    */
    sprintf( retestflagEV, "RETESTFLAG=%i", HTML_TEST_1 );
    putenv( retestflagEV );
    sprintf( reloopbackflagEV, "RELOOPBACKFLAG=%i", LOOP_BACK_1 );
    putenv( reloopbackflagEV );

    fprintf( stdout, "Content-type: text/html%c%c", 10, 10 );
    fflush( stdout );
    fprintf( stdout, "<HTML>\n<HEAD>\n<TITLE>iRODS Rule Administration</TITLE>\n</HEAD>\n<BODY bgcolor=#FFFFFF>\n" );
    fprintf( stdout, "<CENTER> <B><FONT COLOR=#FF0000>iRODS Rule Application</FONT></B></CENTER>\n" );
    fflush( stdout );

    rei.doi = mallocAndZero( sizeof( dataObjInfo_t ) );
    rei.uoip = mallocAndZero( sizeof( userInfo_t ) );
    rei.uoic = mallocAndZero( sizeof( userInfo_t ) );
    rei.coi = mallocAndZero( sizeof( collInfo_t ) );
    rei.uoio = mallocAndZero( sizeof( userInfo_t ) );
    rei.next = NULL;

    strcpy( rei.doi->objPath, "" );
    strcpy( rei.doi->rescName, "" );
    strcpy( rei.doi->dataType, "" );
    strcpy( rei.uoic->authInfo.host, "" );
    rei.doi->dataSize = 100;


    rei.condInputData = NULL;

    rei.rsComm = NULL;
    strcpy( ruleSet, "" );

    for ( i = 0; i <= Sentries->m; i++ ) {

        if ( !strcmp( Sentries->entries[i].name, "action" ) ) {
            strcpy( action, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>Action:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "objPath" ) ) {
            strcpy( rei.doi->objPath, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$objPath:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "rescName" ) ) {
            strcpy( rei.doi->rescName, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$rescName:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "dataSize" ) ) {
            rei.doi->dataSize = atol( Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$dataSize:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "dataType" ) ) {
            strcpy( rei.doi->dataType, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$dataType:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "dataOwner" ) ) {
            strcpy( rei.doi->dataOwnerName, Sentries->entries[i].val );
            if ( ( t1 = strstr( rei.doi->dataOwnerName, "|" ) ) != NULL ) {
                *t1 = '\0';
                strcpy( rei.doi->dataOwnerZone, ( char * )( t1 + 1 ) );
            }
            else {
                strcpy( rei.doi->dataOwnerZone, "" );
            }
            fprintf( stdout, "<FONT COLOR=#0000FF>$dataOwner:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "dataUser" ) ) {
            strcpy( rei.uoic->userName, Sentries->entries[i].val );
            if ( ( t1 = strstr( rei.uoic->userName, "|" ) ) != NULL ) {
                *t1 = '\0';
                strcpy( rei.uoic->rodsZone, ( char * )( t1 + 1 ) );
            }
            else {
                strcpy( rei.uoic->rodsZone, "" );
            }
            fprintf( stdout, "<FONT COLOR=#0000FF>$dataUser:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "dataAccess" ) ) {
            strcpy( rei.doi->dataAccess, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$dataAccess:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "hostClient" ) ) {
            strcpy( rei.uoic->authInfo.host, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$hostClient:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "proxyUser" ) ) {
            strcpy( rei.uoip->userName, Sentries->entries[i].val );
            if ( ( t1 = strstr( rei.uoip->userName, "|" ) ) != NULL ) {
                *t1 = '\0';
                strcpy( rei.uoip->rodsZone, ( char * )( t1 + 1 ) );
            }
            else {
                strcpy( rei.uoio->rodsZone, "" );
            }
            fprintf( stdout, "<FONT COLOR=#0000FF>$otherUser:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "otherUser" ) ) {
            strcpy( rei.uoic->userName, Sentries->entries[i].val );
            if ( ( t1 = strstr( rei.uoio->userName, "|" ) ) != NULL ) {
                *t1 = '\0';
                strcpy( rei.uoio->rodsZone, ( char * )( t1 + 1 ) );
            }
            else {
                strcpy( rei.uoio->rodsZone, "" );
            }
            fprintf( stdout, "<FONT COLOR=#0000FF>$otherUser:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "otherUserType" ) ) {
            strcpy( rei.uoio->userType, Sentries->entries[i].val );
            fprintf( stdout, "<FONT COLOR=#0000FF>$otherUserType:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "ruleSet" ) ) {
            if ( strlen( Sentries->entries[i].val ) > 0 ) {
                if ( ruleSet[0] != '\0' ) {
                    strcat( ruleSet, "," );
                }
                rstrcat( ruleSet, Sentries->entries[i].val, 999 );
            }
        }
        else if ( !strcmp( Sentries->entries[i].name, "retestflag" ) ) {
            sprintf( retestflagEV, "RETESTFLAG=%s", Sentries->entries[i].val );
            putenv( retestflagEV );
            fprintf( stdout, "<FONT COLOR=#0000FF>Trace Status</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
                     Sentries->entries[i].val );
        }
        else if ( !strcmp( Sentries->entries[i].name, "configDir" ) ) {
            if ( strlen( Sentries->entries[i].val ) > 0 ) {
                snprintf( configDirEV, 199, "irodsConfigDir=%s", Sentries->entries[i].val );
            }
            else {
                sprintf( configDirEV, "irodsConfigDir=%s", MY_SERVER_CONFIG_DIR );
            }
            putenv( configDirEV );
        }

        /*
        else if (!strcmp(Sentries->entries[i].name,"")){
        strcpy(,Sentries->entries[i].val);
        fprintf(stdout,"<FONT COLOR=#0000FF></FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
        	Sentries->entries[i].val);
             }
             */
    }
    fprintf( stdout, "<FONT COLOR=#0000FF>Rule Set:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR><HR>\n", ruleSet );
    strcpy( rei.ruleSet, ruleSet );
    /*    fprintf(stdout,"<PRE>\n");fflush(stdout);*/
    ht1 = gethrtime();
    initRuleStruct( NULL, ruleSet, "core", "core" );
    ht2 = gethrtime();
    /***    i = applyRule(action, args, 0, &rei, SAVE_REI); ***/
    i = applyRuleArgPA( action, args, 0, NULL, &rei, SAVE_REI );
    ht3 = gethrtime();

    if ( reTestFlag == COMMAND_TEST_1 ||  reTestFlag == COMMAND_TEST_MSI ) {
        fprintf( stdout, "Rule Initialization Time = %.2f millisecs\n", ( float )( ht2 - ht1 ) / 1000000 );
        fprintf( stdout, "Rule Execution     Time = %.2f millisecs\n", ( float )( ht3 - ht1 ) / 1000000 );
    }
    if ( reTestFlag == HTML_TEST_1 || reTestFlag ==  HTML_TEST_MSI ) {
        fprintf( stdout, "<BR>Rule Initialization Time = %.2f millisecs<BR>\n", ( float )( ht2 - ht1 ) / 1000000 );
        fprintf( stdout, "Rule Execution     Time = %.2f millisecs<BR>\n", ( float )( ht3 - ht1 ) / 1000000 );
    }

    if ( i != 0 ) {
        rodsLogError( LOG_ERROR, i, "<BR>Rule Application Failed:" );
        /*    fprintf(stdout,"</PRE>\n</body>\n</HTML>\n");*/
        return -1;
    }
    /*    fprintf(stdout,"</PRE>\n</body>\n</HTML>\n");*/

    return 0;
}
コード例 #15
0
cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 type, int16 backgroundPlane, int16 scriptOverlay, int16 scriptNumber, int16 scriptType) {
	int16 var;

	cellStruct *newElement;
	cellStruct *currentHead = pHead;
	cellStruct *currentHead2;
	cellStruct *currentHead3;

	if (getSingleObjectParam(overlayIdx, objIdx, 2, &var) < 0) {
		return 0;
	}

	currentHead3 = currentHead;
	currentHead2 = currentHead->next;

	while (currentHead2 && (currentHead2->type != 3)) {

		if (currentHead2->type != 5) {
			int16 lvar2;

			if (getSingleObjectParam(currentHead2->overlay, currentHead2->idx, 2, &lvar2) >= 0 && lvar2 >= var)
				break;
		}

		currentHead3 = currentHead2;
		currentHead2 = currentHead2->next;
	}

	if (currentHead2) {
		if ((currentHead2->overlay == overlayIdx) &&
		        (currentHead2->backgroundPlane == backgroundPlane) &&
		        (currentHead2->idx == objIdx) &&
		        (currentHead2->type == type))

			return NULL;
	}

	currentHead = currentHead2;

	newElement = (cellStruct *) mallocAndZero(sizeof(cellStruct));

	if (!newElement)
		return 0;

	newElement->next = currentHead3->next;
	currentHead3->next = newElement;

	newElement->idx = objIdx;
	newElement->type = type;
	newElement->backgroundPlane = backgroundPlane;
	newElement->overlay = overlayIdx;
	newElement->freeze = 0;
	newElement->parent = scriptNumber;
	newElement->parentOverlay = scriptOverlay;
	newElement->gfxPtr = NULL;
	newElement->followObjectIdx = objIdx;
	newElement->followObjectOverlayIdx = overlayIdx;
	newElement->parentType = scriptType;

	newElement->animStart = 0;
	newElement->animEnd = 0;
	newElement->animWait = 0;
	newElement->animSignal = 0;
	newElement->animCounter = 0;
	newElement->animType = 0;
	newElement->animStep = 0;
	newElement->animLoop = 0;

	if (currentHead) {
		newElement->prev = currentHead->prev;
		currentHead->prev = newElement;
	} else {
		newElement->prev = pHead->prev;
		pHead->prev = newElement;
	}

	return newElement;
}
コード例 #16
0
ファイル: extractAvuMS.cpp プロジェクト: SyBernot/irods
/**
 * \fn msiReadMDTemplateIntoTagStruct(msParam_t* bufParam, msParam_t* tagParam, ruleExecInfo_t *rei)
 *
 * \brief This microservice parses a buffer containing a template-style file
 *  and stores the tags in a tag structure.
 *
 * \author  Arcot Rajasekar
 * \date    2007-02-01
 *
 * \note  The template buffer should contain triplets of the form:
 *  <PRETAG>re1</PRETAG>kw<POSTTAG>re2</POSTTAG>.
 *  re1 identifies the pre-string and re2 identifies the post-string and
 *  any value between re1 and re2 in a metadata buffer can be
 *  associated with keyword kw.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] bufParam - a msParam of type BUF_LEN_MS_T
 * \param[out] tagParam - a return msParam of type TagStruct_MS_T
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \retval USER_PARAM_TYP_ERROR when input parameter doesn't match the type
 * \retval INVALID_REGEXP if the tags are not correct
 * \retval NO_VALUES_FOUND if there are no tags identified
 * \retval from addTagStruct
 * \pre none
 * \post none
 * \sa addTagStruct
**/
int
msiReadMDTemplateIntoTagStruct( msParam_t* bufParam, msParam_t* tagParam, ruleExecInfo_t *rei ) {

    bytesBuf_t *tmplObjBuf;
    tagStruct_t *tagValues;

    char *t, *t1, *t2, *t3, *t4, *t5, *t6, *t7, *t8;
    /*
    int len;
    int l1, l2;
    */
    int i, j;
    /*  char *preg[4];*/
    regex_t preg[4];
    regmatch_t pm[4];
    char errbuff[100];

    RE_TEST_MACRO( "Loopback on msiReadMDTemplateIntoTagStruct" );

    if ( strcmp( bufParam->type, BUF_LEN_MS_T ) != 0 ||
            bufParam->inpOutBuf == NULL ) {
        return( USER_PARAM_TYPE_ERR );
    }
    tmplObjBuf = ( bytesBuf_t * ) bufParam->inpOutBuf;
    /*
    preg[0] =  regcmp("<PRETAG>", (char *)0);
    if (preg[0] == NULL)
      return(INVALID_REGEXP);
    preg[1] =  regcmp("</PRETAG>", (char *)0);
    if (preg[1] == NULL)
      return(INVALID_REGEXP);
    preg[2] =  regcmp("<POSTTAG>", (char *)0);
    if (preg[0] == NULL)
      return(INVALID_REGEXP);
    preg[3] =  regcmp("</POSTTAG>", (char *)0);
    if (preg[1] == NULL)
      return(INVALID_REGEXP);
    */
    j = regcomp( &preg[0], "<PRETAG>", REG_EXTENDED );
    if ( j != 0 ) {
        regerror( j, &preg[0], errbuff, sizeof( errbuff ) );
        rodsLog( LOG_NOTICE, "msiReadMDTemplateIntoTagStruct: Error in regcomp: %s\n", errbuff );
        return( INVALID_REGEXP );
    }
    j = regcomp( &preg[1], "</PRETAG>", REG_EXTENDED );
    if ( j != 0 ) {
        regerror( j, &preg[1], errbuff, sizeof( errbuff ) );
        rodsLog( LOG_NOTICE, "msiReadMDTemplateIntoTagStruct: Error in regcomp: %s\n", errbuff );
        return( INVALID_REGEXP );
    }
    j = regcomp( &preg[2], "<POSTTAG>", REG_EXTENDED );
    if ( j != 0 ) {
        regerror( j, &preg[2], errbuff, sizeof( errbuff ) );
        rodsLog( LOG_NOTICE, "msiReadMDTemplateIntoTagStruct: Error in regcomp: %s\n", errbuff );
        return( INVALID_REGEXP );
    }
    j = regcomp( &preg[3], "</POSTTAG>", REG_EXTENDED );
    if ( j != 0 ) {
        regerror( j, &preg[3], errbuff, sizeof( errbuff ) );
        rodsLog( LOG_NOTICE, "msiReadMDTemplateIntoTagStruct: Error in regcomp: %s\n", errbuff );
        return( INVALID_REGEXP );
    }

    t = ( char* )malloc( tmplObjBuf->len + 1 );
    t[tmplObjBuf->len] = '\0';
    memcpy( t, tmplObjBuf->buf, tmplObjBuf->len );
    tagValues = ( tagStruct_t* )mallocAndZero( sizeof( tagStruct_t ) );
    tagValues->len = 0;
    t1 = t;
#ifdef BABABA
    /*
    while ((t2 = regex(preg[0], t1)) != NULL) { / * t2 starts preTag * /
      if ((t3 = regex(preg[1], t2)) == NULL)    / * t3 starts keyValue * /
        break;
      t6 = __loc1;                              / * t6 ends preTag * /
      *t6 = '\0';
      if ((t5 = regex(preg[2], t3)) == NULL)    / *  t5 starts postTag * /
        break;
      t4 = __loc1;                              / * t4 ends keyValue * /
      *t4 = '\0';
      if ((t7 = regex(preg[3], t5)) == NULL)    / * t7 ends the line * /
        break;
      t8 = __loc1;                              / * t8 ends postTag * /
      *t8 = '\0';

      i = addTagStruct (tagValues, t2, t5, t3);
      if (i != 0)
        return(i);
      t1 = t7;
      if (*t1 == '\0')
        break;
    }
    */
#endif /*  BABABA */
    while ( regexec( &preg[0], t1, 1, &pm[0], 0 ) == 0 ) {
        t2 = t1 + pm[0].rm_eo ;                        /* t2 starts preTag */
        if ( regexec( &preg[1], t2, 1, &pm[1], 0 ) != 0 ) {
            break;
        }
        t3 = t2 + pm[1].rm_eo ;                        /* t3 starts keyValue */
        t6 = t2 + pm[1].rm_so;                            /* t6 ends preTag */
        *t6 = '\0';
        if ( regexec( &preg[2], t3, 1, &pm[2], 0 ) != 0 ) {
            break;
        }
        t5 = t3 + pm[2].rm_eo ;                        /* t5 starts postTag */
        t4 = t3 + pm[2].rm_so;                            /* t4 ends keyValue */
        *t4 = '\0';
        if ( regexec( &preg[3], t5, 1, &pm[3], 0 ) != 0 ) {
            break;
        }
        t7 = t5 + pm[3].rm_eo;                        /* t7 ends the line */
        t8 = t5 + pm[3].rm_so;                            /* t8 ends postTag */
        *t8 = '\0';
        /***    rodsLog(LOG_NOTICE,"msiReadMDTemplateIntoTagStruct:TAGS:%s::%s::%s::\n",t2, t5, t3);***/
        i = addTagStruct( tagValues, t2, t5, t3 );
        if ( i != 0 ) {
            return( i );
        }
        t1 = t7;
        if ( *t1 == '\0' ) {
            break;
        }
    }

    /*
    free(preg[0]);
    free(preg[1]);
    free(preg[2]);
    free(preg[3]);
    */
    regfree( &preg[0] );
    regfree( &preg[1] );
    regfree( &preg[2] );
    regfree( &preg[3] );
    free( t );

    if ( tagValues->len == 0 ) {
        return( NO_VALUES_FOUND );
    }

    tagParam->inOutStruct = ( void * ) tagValues;
    tagParam->type = ( char * ) strdup( TagStruct_MS_T );

    return( 0 );

}
コード例 #17
0
ファイル: extractAvuMS.cpp プロジェクト: SyBernot/irods
/**
 * \fn msiExtractTemplateMDFromBuf(msParam_t* bufParam, msParam_t* tagParam, msParam_t *metadataParam, ruleExecInfo_t *rei)
 *
 * \brief   This microservice parses a buffer containing metadata
 *  and uses the tags to identify Key-Value Pairs.
 *
 * \module core
 *
 * \since pre-2.1
 *
 * \author  Arcot Rajasekar
 * \date    2007-02-01
 *
 * \remark Terrell Russell - msi documentation, 2009-06-17
 *
 * \note  The template structure identifies triplets
 *  <pre-string-regexp,post-string-regexp,keyword> and the metadata buffer
 *  is searched for the pre and post regular expressions and the string
 *  between them is associated with the keyword.
 *  A.l  <key,value> pairs found are stored in keyValPair_t structure.
 *
 * \usage See clients/icommands/test/rules3.0/
 *
 * \param[in] bufParam - a msParam of type BUF_MS_T
 * \param[in] tagParam - a msParam of type TagStruct_MS_T
 * \param[out] metadataParam - a msParam of type KeyValPair_MS_T
 * \param[in,out] rei - The RuleExecInfo structure that is automatically
 *    handled by the rule engine. The user does not include rei as a
 *    parameter in the rule invocation.
 *
 * \DolVarDependence none
 * \DolVarModified none
 * \iCatAttrDependence none
 * \iCatAttrModified none
 * \sideeffect none
 *
 * \return integer
 * \retval 0 on success
 * \retval USER_PARAM_TYP_ERROR when input parameter doesn't match the type
 * \retval INVALID_REGEXP if the tags are not correct
 * \retval from addKeyVal
 * \pre none
 * \post none
 * \sa addKeyVal
**/
int
msiExtractTemplateMDFromBuf( msParam_t* bufParam, msParam_t* tagParam,
                             msParam_t *metadataParam, ruleExecInfo_t *rei ) {


    bytesBuf_t *metaObjBuf;
    tagStruct_t *tagValues;
    keyValPair_t *metaDataPairs;
    /*  int l1, l2; */
    int i, j;
    /*char *preg[2]; */
    regex_t preg[2];
    regmatch_t pm[2];
    char errbuff[100];
    char *t, *t1, *t2, *t3, *t4;
    char c;

    RE_TEST_MACRO( "Loopback on msiExtractTemplateMetadata" );

    if ( strcmp( bufParam->type, BUF_LEN_MS_T ) != 0 ||
            bufParam->inpOutBuf == NULL ) {
        return( USER_PARAM_TYPE_ERR );
    }
    if ( strcmp( tagParam->type, TagStruct_MS_T ) != 0 ) {
        return( USER_PARAM_TYPE_ERR );
    }
    tagValues = ( tagStruct_t * ) tagParam->inOutStruct;
    metaObjBuf = ( bytesBuf_t * )  bufParam->inpOutBuf;
    t = ( char* )malloc( metaObjBuf->len + 1 );
    t[metaObjBuf->len] = '\0';
    memcpy( t, metaObjBuf->buf, metaObjBuf->len );
    metaDataPairs = ( keyValPair_t* )mallocAndZero( sizeof( keyValPair_t ) );
    t1 = t;
    for ( i = 0; i  < tagValues->len ; i++ ) {
        t1 = t;
#ifdef BABABA
        /*
        preg[0] = regcmp(tagValues->preTag[i], (char *)0);
        if (preg[0] == NULL)
          return(INVALID_REGEXP);
        preg[1] =  regcmp(tagValues->postTag[i], (char *)0);
        if (preg[1] == NULL)
          return(INVALID_REGEXP);
        while ((t2 = regex(preg[0], t1)) != NULL) { / * t2 starts value * /
          if ((t3 = regex(preg[1], t2)) == NULL) {
        free(preg[0]);
        free(preg[1]);
        break;
          }
          t4 = __loc1;                              / * t4 ends value * /
          c = *t4;
          *t4 = '\0';
          j = addKeyVal(metaDataPairs, tagValues->keyWord[i], t2);
          *t4 = c;
          if (j != 0)
        return(j);
          t1 = t3;
          if (*t1 == '\0')
        break;
        }
        free(preg[0]);
        free(preg[1]);
        */
#endif /*  BABABA */
        j = regcomp( &preg[0], tagValues->preTag[i], REG_EXTENDED );
        if ( j != 0 ) {
            regerror( j, &preg[0], errbuff, sizeof( errbuff ) );
            rodsLog( LOG_NOTICE, "msiExtractTemplateMDFromBuf: Error in regcomp: %s\n", errbuff );
            return( INVALID_REGEXP );
        }
        j = regcomp( &preg[1], tagValues->postTag[i], REG_EXTENDED );
        if ( j != 0 ) {
            regerror( j, &preg[1], errbuff, sizeof( errbuff ) );
            rodsLog( LOG_NOTICE, "msiExtractTemplateMDFromBuf: Error in regcomp: %s\n", errbuff );
            return( INVALID_REGEXP );
        }
        while ( regexec( &preg[0], t1, 1, &pm[0], 0 ) == 0 ) {
            t2 = t1 + pm[0].rm_eo ;                     /* t2 starts value */
            if ( regexec( &preg[1], t2, 1, &pm[1], 0 ) != 0 ) {
                break;
            }
            t4 = t2 + pm[1].rm_so;                      /* t4 ends value */
            t3 = t2 + pm[1].rm_eo;
            c = *t4;
            *t4 = '\0';
            /***      rodsLog(LOG_NOTICE,"msiExtractTemplateMDFromBuf:KVAL:%s::%s::\n",tagValues->keyWord[i], t2); ***/
            j = addKeyVal( metaDataPairs, tagValues->keyWord[i], t2 );
            *t4 = c;
            if ( j != 0 ) {
                return( j );
            }
            t1 = t3;
            if ( *t1 == '\0' ) {
                break;
            }
        }
        regfree( &preg[0] );
        regfree( &preg[1] );

        continue;
    }


    metadataParam->inOutStruct = ( void * ) metaDataPairs;
    metadataParam->type = ( char * ) strdup( KeyValPair_MS_T );

    return( 0 );
}
コード例 #18
0
backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx,	int16 objectIdx, backgroundIncrustStruct *pHead, int16 scriptNumber, int16 scriptOverlay, int16 backgroundIdx, int16 saveBuffer) {
	uint8 *backgroundPtr;
	uint8 *ptr;
	objectParamsQuery params;
	backgroundIncrustStruct *newElement;
	backgroundIncrustStruct *currentHead;
	backgroundIncrustStruct *currentHead2;

	getMultipleObjectParam(overlayIdx, objectIdx, &params);

	ptr = filesDatabase[params.fileIdx].subData.ptr;

	// Don't process any further if not a sprite or polygon
	if (!ptr) return NULL;
	if ((filesDatabase[params.fileIdx].subData.resourceType != OBJ_TYPE_SPRITE) &&
		(filesDatabase[params.fileIdx].subData.resourceType != OBJ_TYPE_POLY)) {
		return NULL;
	}

	backgroundPtr = backgroundScreens[backgroundIdx];

	backgroundChanged[backgroundIdx] = true;

	assert(backgroundPtr != NULL);

	currentHead = pHead;
	currentHead2 = currentHead->next;

	while (currentHead2) {
		currentHead = currentHead2;
		currentHead2 = currentHead->next;
	}

	newElement = (backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));

	if (!newElement)
		return NULL;

	newElement->next = currentHead->next;
	currentHead->next = newElement;

	if (!currentHead2) {
		currentHead2 = pHead;
	}

	newElement->prev = currentHead2->prev;
	currentHead2->prev = newElement;

	newElement->objectIdx = objectIdx;
	newElement->type = saveBuffer;
	newElement->backgroundIdx = backgroundIdx;
	newElement->overlayIdx = overlayIdx;
	newElement->scriptNumber = scriptNumber;
	newElement->scriptOverlayIdx = scriptOverlay;
	newElement->X = params.X;
	newElement->Y = params.Y;
	newElement->scale = params.scale;
	newElement->frame = params.fileIdx;
	newElement->spriteId = filesDatabase[params.fileIdx].subData.index;
	newElement->ptr = NULL;
	strcpy(newElement->name, filesDatabase[params.fileIdx].subData.name);

	if (filesDatabase[params.fileIdx].subData.resourceType == OBJ_TYPE_SPRITE) {
		// sprite
		int width = filesDatabase[params.fileIdx].width;
		int height = filesDatabase[params.fileIdx].height;
		if (saveBuffer == 1) {
			backupBackground(newElement, newElement->X, newElement->Y, width, height, backgroundPtr);
		}

		drawSprite(width, height, NULL, filesDatabase[params.fileIdx].subData.ptr, newElement->Y,
			newElement->X, backgroundPtr, filesDatabase[params.fileIdx].subData.ptrMask);
	} else {
		// poly
		if (saveBuffer == 1) {
			int newX;
			int newY;
			int newScale;
			char *newFrame;

			int sizeTable[4];	// 0 = left, 1 = right, 2 = bottom, 3 = top

			// this function checks if the dataPtr is not 0, else it retrives the data for X, Y, scale and DataPtr again (OLD: mainDrawSub1Sub1)
			flipPoly(params.fileIdx, (int16 *)filesDatabase[params.fileIdx].subData.ptr, params.scale, &newFrame, newElement->X, newElement->Y, &newX, &newY, &newScale);

			// this function fills the sizeTable for the poly (OLD: mainDrawSub1Sub2)
			getPolySize(newX, newY, newScale, sizeTable, (unsigned char*)newFrame);

			int width = (sizeTable[1] + 2) - (sizeTable[0] - 2) + 1;
			int height = sizeTable[3] - sizeTable[2] + 1;

			backupBackground(newElement, sizeTable[0] - 2, sizeTable[2], width, height, backgroundPtr);
		}

		addBackgroundIncrustSub1(params.fileIdx, newElement->X, newElement->Y, NULL, params.scale, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptr);
	}

	return newElement;
}
コード例 #19
0
ファイル: saveload.cpp プロジェクト: 33d/scummvm
static void syncIncrust(Common::Serializer &s) {
	int numEntries = 0;
	backgroundIncrustStruct *pl, *pl1;
	uint8 dummyByte = 0;
	uint16 dummyWord = 0;
	uint32 dummyLong = 0;

	if (s.isSaving()) {
		// Figure out the number of entries to save
		pl = backgroundIncrustHead.next;
		while (pl) {
			++numEntries;
			pl = pl->next;
		}
	}
	s.syncAsSint16LE(numEntries);

	pl = s.isSaving() ? backgroundIncrustHead.next : &backgroundIncrustHead;
	pl1 = &backgroundIncrustHead;

	for (int i = 0; i < numEntries; ++i) {
		backgroundIncrustStruct *t = s.isSaving() ? pl :
			(backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));

		s.syncAsUint32LE(dummyLong);

		s.syncAsSint16LE(t->objectIdx);
		s.syncAsSint16LE(t->type);
		s.syncAsSint16LE(t->overlayIdx);
		s.syncAsSint16LE(t->X);
		s.syncAsSint16LE(t->Y);
		s.syncAsSint16LE(t->frame);
		s.syncAsSint16LE(t->scale);
		s.syncAsSint16LE(t->backgroundIdx);
		s.syncAsSint16LE(t->scriptNumber);
		s.syncAsSint16LE(t->scriptOverlayIdx);
		s.syncAsUint32LE(dummyLong);
		s.syncAsSint16LE(t->saveWidth);
		s.syncAsSint16LE(t->saveHeight);
		s.syncAsSint16LE(t->saveSize);
		s.syncAsSint16LE(t->savedX);
		s.syncAsSint16LE(t->savedY);
		s.syncBytes((byte *)t->name, 13);
		s.syncAsByte(dummyByte);
		s.syncAsSint16LE(t->spriteId);
		s.syncAsUint16LE(dummyWord);

		if (t->saveSize) {
			if (s.isLoading())
				t->ptr = (byte *)MemAlloc(t->saveSize);

			s.syncBytes(t->ptr, t->saveSize);
		}

		if (s.isSaving())
			pl = pl->next;
		else {
			t->next = NULL;
			pl->next = t;
			t->prev = pl1->prev;
			pl1->prev = t;
			pl = t;
		}
	}
}
コード例 #20
0
ファイル: reStruct.c プロジェクト: DICE-UNC/iRODS-FUSE-Mod
int 
copyRuleExecInfo(ruleExecInfo_t *from, ruleExecInfo_t *to)
{

  (*to) = (*from);

  /****
       The following structures are not copied and just the pointer is copied.

       dataObjInp_t *doinp;  
       dataOprInp_t *dinp;
       fileOpenInp_t *finp;
       dataObjInp_t *doinpo;  
       dataOprInp_t *dinpo;
       fileOpenInp_t *finpo;
       

   ***/
  if (from->doi != NULL) {
    to->doi = (dataObjInfo_t *) mallocAndZero(sizeof(dataObjInfo_t));
    copyDataObjInfo(from->doi, to->doi);
  }
  else 
    to->doi = NULL;

  if (from->rgi != NULL) {
    to->rgi = (rescGrpInfo_t*)mallocAndZero(sizeof(rescGrpInfo_t));
    copyRescGrpInfo(from->rgi, to->rgi);
  }
  else 
    to->rgi = NULL;

  if (from->uoic != NULL) {
    to->uoic = (userInfo_t*)mallocAndZero(sizeof(userInfo_t));
    copyUserInfo(from->uoic, to->uoic);
  }
  else 
    to->uoic = NULL;

  if (from->uoip != NULL) {
    to->uoip = (userInfo_t*)mallocAndZero(sizeof(userInfo_t));
    copyUserInfo(from->uoip, to->uoip);
  }
  else 
    to->uoip = NULL;

  if (from->coi != NULL) {
    to->coi = (collInfo_t*)mallocAndZero(sizeof(collInfo_t));
    copyCollInfo(from->coi, to->coi);
  }
  else 
    to->coi = NULL;

#if 0	/* XXXXX deplicate rgio */
  if (from->rgio != NULL) {
    to->rgio = mallocAndZero(sizeof(rescGrpInfo_t));
    copyRescGrpInfo(from->rgio, to->rgio);
  }
  else 
    to->rgi = NULL;
#endif

  if (from->uoio != NULL) {
    to->uoio= (userInfo_t*)mallocAndZero(sizeof(userInfo_t));
    copyUserInfo(from->uoio, to->uoio);
  }
  else 
    to->uoio = NULL;

  if (from->condInputData != NULL) {
    to->condInputData = (keyValPair_t*)mallocAndZero(sizeof(keyValPair_t));
    copyKeyValPairStruct(from->condInputData, to->condInputData);
  }
  else 
    to->condInputData = NULL;

  if (from->next != NULL) {
    to->next = (ruleExecInfo_t*)mallocAndZero(sizeof(ruleExecInfo_t));
    copyRuleExecInfo(from->next,to->next);
  }
  else
    to->next = NULL;
  return(0);
}
コード例 #21
0
ファイル: saveload.cpp プロジェクト: 33d/scummvm
static void syncOverlays2(Common::Serializer &s) {

	for (int i = 1; i < numOfLoadedOverlay; i++) {

		if (s.isSaving()) {
			// Saving code
			if (!overlayTable[i].alreadyLoaded)
				continue;

			ovlDataStruct *ovlData = overlayTable[i].ovlData;

			// save BSS
			s.syncAsSint16LE(ovlData->sizeOfData4);
			if (ovlData->sizeOfData4)
				s.syncBytes(ovlData->data4Ptr, ovlData->sizeOfData4);

			// save variables
			s.syncAsSint16LE(ovlData->size9);
			for (int j = 0; j < ovlData->size9; j++) {
				s.syncAsSint16LE(ovlData->arrayObjVar[j].X);
				s.syncAsSint16LE(ovlData->arrayObjVar[j].Y);
				s.syncAsSint16LE(ovlData->arrayObjVar[j].Z);
				s.syncAsSint16LE(ovlData->arrayObjVar[j].frame);
				s.syncAsSint16LE(ovlData->arrayObjVar[j].scale);
				s.syncAsSint16LE(ovlData->arrayObjVar[j].state);
			}
		} else {
			// Loading code
			ovlRestoreData[i]._sBssSize = ovlRestoreData[i]._sNumObj = 0;
			ovlRestoreData[i]._pBss = NULL;
			ovlRestoreData[i]._pObj = NULL;

			if (overlayTable[i].alreadyLoaded) {
				s.syncAsSint16LE(ovlRestoreData[i]._sBssSize);

				if (ovlRestoreData[i]._sBssSize) {
					ovlRestoreData[i]._pBss = (uint8 *) mallocAndZero(ovlRestoreData[i]._sBssSize);
					ASSERT(ovlRestoreData[i]._pBss);

					s.syncBytes(ovlRestoreData[i]._pBss, ovlRestoreData[i]._sBssSize);
				}

				s.syncAsSint16LE(ovlRestoreData[i]._sNumObj);

				if (ovlRestoreData[i]._sNumObj) {
					ovlRestoreData[i]._pObj = (objectParams *) mallocAndZero(ovlRestoreData[i]._sNumObj * sizeof(objectParams));
					ASSERT(ovlRestoreData[i]._pObj);

					for (int j = 0; j < ovlRestoreData[i]._sNumObj; j++) {
						s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].X);
						s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].Y);
						s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].Z);
						s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].frame);
						s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].scale);
						s.syncAsSint16LE(ovlRestoreData[i]._pObj[j].state);
					}
				}
			}
		}
	}
}
コード例 #22
0
int loadFileSub1(uint8 **ptr, const char *name, uint8 *ptr2) {
	int i;
	char buffer[256];
	int fileIdx;
	int unpackedSize;
	uint8 *unpackedBuffer;

	for (i = 0; i < 64; i++) {
		if (preloadData[i].ptr) {
			if (!strcmp(preloadData[i].name, name)) {
				error("Unsupported code in loadFIleSub1");
			}
		}
	}

	getFileExtention(name, buffer);

	if (!strcmp(buffer, ".SPL")) {
		removeExtention(name, buffer);

		/* if (useH32)
		 *{
		 *	strcat(buffer, ".H32");
		 *}
		 * else
		 * if (useAdLib)
		 * { */
		 strcat(buffer,".ADL");
		/* }
		 * else
		 * {
		 * strcatuint8(buffer,".HP");
		 * } */
	} else {
		strcpy(buffer, name);
	}

	fileIdx = findFileInDisks(buffer);

	if (fileIdx < 0)
		return (-18);

	unpackedSize = loadFileVar1 = volumePtrToFileDescriptor[fileIdx].extSize + 2;

	unpackedBuffer = (uint8 *)mallocAndZero(unpackedSize);

	if (!unpackedBuffer) {
		return (-2);
	}

	lastFileSize = unpackedSize;

	if (volumePtrToFileDescriptor[fileIdx].size + 2 != unpackedSize) {
		uint8 *pakedBuffer = (uint8 *) mallocAndZero(volumePtrToFileDescriptor[fileIdx].size + 2);

		loadPackedFileToMem(fileIdx, pakedBuffer);

		uint32 realUnpackedSize = READ_BE_UINT32(pakedBuffer + volumePtrToFileDescriptor[fileIdx].size - 4);

		lastFileSize = realUnpackedSize;

		delphineUnpack(unpackedBuffer, pakedBuffer, volumePtrToFileDescriptor[fileIdx].size);

		MemFree(pakedBuffer);
	} else {
		loadPackedFileToMem(fileIdx, unpackedBuffer);
	}

	*ptr = unpackedBuffer;

	return (1);
}
コード例 #23
0
int16 readVolCnf() {
	int i;
	Common::File fileHandle;
	short int sizeHEntry;

	volumeDataLoaded = 0;

	for (i = 0; i < 20; i++) {
		volumeData[i].ident[0] = 0;
		volumeData[i].ptr = NULL;
		volumeData[i].diskNumber = i + 1;
		volumeData[i].size = 0;
	}

	fileHandle.open("VOL.CNF");

	if (!fileHandle.isOpen()) {
		return (0);
	}

	numOfDisks = fileHandle.readSint16BE();
	sizeHEntry = fileHandle.readSint16BE();		// size of one header entry - 20 bytes

	for (i = 0; i < numOfDisks; i++) {
		//      fread(&volumeData[i],20,1,fileHandle);
		fileHandle.read(&volumeData[i].ident, 10);
		fileHandle.read(&volumeData[i].ptr, 4);
		volumeData[i].diskNumber = fileHandle.readSint16BE();
		volumeData[i].size = fileHandle.readSint32BE();

		debug(1, "Disk number: %d", volumeData[i].diskNumber);
	}

	for (i = 0; i < numOfDisks; i++) {
		dataFileName *ptr;

		volumeData[i].size = fileHandle.readSint32BE();

		ptr = (dataFileName *) mallocAndZero(volumeData[i].size);

		volumeData[i].ptr = ptr;

		if (!ptr) {
			fileHandle.close();
			return (-2);
		}

		fileHandle.read(ptr, volumeData[i].size);
	}

	fileHandle.close();

	volumeDataLoaded = 1;

//#define dumpResources
#ifdef dumpResources

	for (i = 0; i < numOfDisks; i++) {
		int j;
		char nameBuffer[256];
		fileEntry *buffer;

		sprintf(nameBuffer, "D%d.", i + 1);

		fileHandle.open(nameBuffer);

		short int numEntry;
		short int sizeEntry;

		numEntry = fileHandle.readSint16BE();
		sizeEntry = fileHandle.readSint16BE();

		buffer = (fileEntry *) mallocAndZero(numEntry * sizeEntry);

		for (j = 0; j < numEntry; j++) {
			fileHandle.seek(4 + j*0x1E);
			fileHandle.read(buffer[j].name, 14);
			buffer[j].offset = fileHandle.readSint32BE();
			buffer[j].size = fileHandle.readSint32BE();
			buffer[j].extSize = fileHandle.readSint32BE();
			buffer[j].unk3 = fileHandle.readSint32BE();

			fileHandle.seek(buffer[j].offset);

			char *bufferLocal;
			bufferLocal = (char *)mallocAndZero(buffer[j].size);

			fileHandle.read(bufferLocal, buffer[j].size);

			char nameBuffer[256];

			sprintf(nameBuffer, "%s", buffer[j].name);

			if (buffer[j].size == buffer[j].extSize) {
				Common::DumpFile fout;
				fout.open(nameBuffer);
				if (fout.isOpen())
					fout.write(bufferLocal, buffer[j].size);
			} else {
				char *uncompBuffer = (char *)mallocAndZero(buffer[j].extSize + 500);

				delphineUnpack((uint8 *) uncompBuffer, (const uint8 *) bufferLocal, buffer[j].size);

				Common::File fout;
				fout.open(nameBuffer, Common::File::kFileWriteMode);
				if (fout.isOpen())
					fout.write(uncompBuffer, buffer[j].extSize);

				//MemFree(uncompBuffer);

			}

			MemFree(bufferLocal);
		}
		fileHandle.close();
	}

#endif

	return (1);
}