コード例 #1
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes an executable file from the disk.
  NOTE: 1. Memory copy is committed to disk.
	2. Due to a technical glitch any string which is already stored on the disk will have to be searched in the
	  memory copy after appending a newline.

*/
int deleteExecutableFromDisk(char *name)
{
	int locationOfFat,i,blockAddresses[SIZE_EXEFILE_BASIC];   //0-basic block , 1,2,3-code+data blocks
	for(i=0;i<SIZE_EXEFILE_BASIC;i++)
		blockAddresses[i]=0;
	locationOfFat = CheckRepeatedName(name);
	if(locationOfFat >= FAT_SIZE){
		printf("File \'%s\' not found!\n",name);
		return -1;
	}
	if(strstr(name,".xsm") == NULL)
	{
		printf("\'%s\' is not a valid executable file!\n",name);
		return -1;
	}

	getDataBlocks(blockAddresses,locationOfFat);
	FreeUnusedBlock(blockAddresses, SIZE_EXEFILE_BASIC);
	removeFatEntry(locationOfFat);
	for(i = FAT ; i < FAT + NO_OF_FAT_BLOCKS ; i++){
		writeToDisk(i,i);
	}
	for( i=DISK_FREE_LIST ; i<DISK_FREE_LIST + NO_OF_FREE_LIST_BLOCKS; i++)
		writeToDisk(i,i);

	return 0;
}
コード例 #2
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes a data file from the disk.
*/
int deleteDataFromDisk(char *name)
{
	int locationOfFat,i,blockAddresses[MAX_DATAFILE_SIZE_BASIC+1];
	for(i=0;i<MAX_DATAFILE_SIZE_BASIC;i++)
		blockAddresses[i]=0;
	locationOfFat = CheckRepeatedName(name);
	if(locationOfFat >= FAT_SIZE)
	{
		printf("File \'%s\' not found!\n",name);
		return -1;
	}
	if(strstr(name,".dat") == NULL)
	{
		printf("\'%s\' is not a valid data file!\n",name);
		return -1;
	}

	getDataBlocks(blockAddresses,locationOfFat);
	FreeUnusedBlock(blockAddresses, MAX_DATAFILE_SIZE_BASIC);
	removeFatEntry(locationOfFat);
	for(i = FAT ; i < FAT + NO_OF_FAT_BLOCKS ; i++){
		writeToDisk(i,i);
	}
	for( i=DISK_FREE_LIST ; i<DISK_FREE_LIST + NO_OF_FREE_LIST_BLOCKS; i++)
		writeToDisk(i,i);
	return 0;
}
コード例 #3
0
ファイル: dfs.c プロジェクト: shadowfax6894/Network-Systems
void handlePutRequest(int socket){
	printf("\nHandling PUT request...\n");
	char *mesg;
	mesg = malloc(256);
	char *file_piece1;
	file_piece1 = malloc(1);
	char *file_piece2;
	file_piece2 = malloc(1);
	int filename_bytes;
	int filepart1_bytes;
	int filepart2_bytes;
	char *buffer1;
	char *buffer2;
	char *filename;
	file_partition file1;
	file_partition file2;

	if (recv(socket, &filename_bytes, 4, 0) >= 1){
		printf("Received filenamebytes: %d\n", filename_bytes);
		filename = malloc(filename_bytes);
	}
	if (recv(socket, mesg, filename_bytes, 0) >= 1){
		printf("Received filename: %s\n", mesg);
		filename = mesg;
	}			
	if (recv(socket, file_piece1, 1, 0) >= 1){
		printf("Received file piece part num: %s\n", file_piece1);
		file1.num = malloc(1);
		file1.num = file_piece1;
	}
	if (recv(socket, file_piece2, 1, 0) >= 1){
		printf("Received file piece part num: %s\n", file_piece2);
		file2.num = malloc(1);
		file2.num = file_piece2;
	}
	if (recv(socket, &filepart1_bytes, 4, 0) >= 1){
		printf("Received file part 1 bytes: %d\n", filepart1_bytes);
		buffer1 = malloc(filepart1_bytes);
	}	
	if (recv(socket, &filepart2_bytes, 4, 0) >= 1){
		printf("Received file part 2 bytes: %d\n", filepart2_bytes);
		buffer2 = malloc(filepart2_bytes);
	}
	if (recv(socket, buffer1, filepart1_bytes, 0) >= 1){
		
		file1.name = malloc(filename_bytes);
		file1.name = filename;
		file1.buffer = malloc(filepart1_bytes);
		file1.buffer = buffer1;
		writeToDisk(file1);
	}	
	if (recv(socket, buffer2, filepart2_bytes, 0) >= 1){
		file2.name = malloc(filename_bytes);
		file2.name = filename;
		file2.buffer = malloc(filepart2_bytes);
		file2.buffer = buffer2;
		writeToDisk(file2);		
	}			
}
コード例 #4
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function loads the OS startup code specified by the first arguement to its appropriate location on disk.
  The code is first copied to memory copy. If this copying proceeds properly then the memory copy is committed to the disk.
*/
int loadOSCode(char* fileName){

	emptyBlock(TEMP_BLOCK);
	writeToDisk(TEMP_BLOCK,OS_STARTUP_CODE);
	expandpath(fileName);
	FILE* fp = fopen(fileName, "r");
	int i,j;
	if(fp == NULL)
	{
		printf("File \'%s\' not found.\n", fileName);
		return -1;
	}

	for(i=0;i<OS_STARTUP_CODE_SIZE;i++)
	{
		j = writeFileToDisk(fp, OS_STARTUP_CODE + i, ASSEMBLY_CODE);
		if (j != 1)
			break;
	}
	if(j==1)
	{
		printf("OS Code exceeds %d block\n",OS_STARTUP_CODE_SIZE);
		deleteOSCodeFromDisk();
		//emptyBlock(TEMP_BLOCK);
		//writeToDisk(TEMP_BLOCK,OS_STARTUP_CODE);
	}
	close(fp);
	return 0;
}
コード例 #5
0
ファイル: createDisk.c プロジェクト: Suraj-Yadav/myxos
/*
  createDisk creates  the disk file if not present.
  if format is equal to zero then the function creates the disk but does not format it.
  if format is not equal to zero then the function will create and format the disk.
  Formatting is done as follows:
    1. A memory copy of the disk is maintained. This copy contains NO_BLOCKS_TO_COPY + EXTRA_BLOCKS (in this case 13 + 1) blocks.
      The extra block is a temporary block. This memory copy is called the virtual disk. This is first cleared.
    2. Then the memory freelist is initialised.
    3. The fat blocks are also initialised. The basic block entries are all set to -1. The memory copy is then committed to the
      disk file.
    4. Finally the entry for init process is made.
*/
void createDisk(int format)
{
    int fd;
    if(format)
    {
        fd = open(DISK_NAME, O_CREAT | O_TRUNC , 0666);
        clearVirtDisk();
        close(fd);
        int i=0,j=0;

        for(j=0; j<(NO_OF_FREE_LIST_BLOCKS*BLOCK_SIZE); j++)
        {
            i=j/BLOCK_SIZE;
            if( (j>=DATA_START_BLOCK) && (j<NO_OF_DISK_BLOCKS ))
                storeValue(disk[DISK_FREE_LIST+i].word[j], 0);
            else
                storeValue(disk[DISK_FREE_LIST+i].word[j], 1);
        }

        for(i=0; i<NO_OF_FREE_LIST_BLOCKS; i++)
            writeToDisk(DISK_FREE_LIST+i, DISK_FREE_LIST+i);

        for(j=0; j<NO_OF_FAT_BLOCKS; j++)
        {
            for(i=FATENTRY_BASICBLOCK; i<BLOCK_SIZE; i=i+FATENTRY_SIZE)
            {
                storeValue(disk[FAT + j].word[i], -1);
            }
            for(i=FATENTRY_FILENAME; i<BLOCK_SIZE; i=i+FATENTRY_SIZE)
            {
                storeValue(disk[FAT + j].word[i], -1);
            }
            for(i=FATENTRY_FILESIZE; i<BLOCK_SIZE; i=i+FATENTRY_SIZE)
            {
                storeValue(disk[FAT + j].word[i], 0);
            }
            writeToDisk(FAT+j, FAT+j);
        }
    }
    else
    {
        fd = open(DISK_NAME, O_CREAT, 0666);
        close(fd);
    }

}
コード例 #6
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes the Exception Handler from the disk.
*/
int deleteExHandlerFromDisk()
{
	emptyBlock(TEMP_BLOCK);
	int i;
	for (i=0;i<EX_HANDLER_SIZE; i++)
		writeToDisk(TEMP_BLOCK,EX_HANDLER + i);
	return 0;
}
コード例 #7
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes the OS code from the disk.
*/
int deleteOSCodeFromDisk()
{
	emptyBlock(TEMP_BLOCK);
	int i;
	for (i=0;i<OS_STARTUP_CODE_SIZE; i++)
		writeToDisk(TEMP_BLOCK,OS_STARTUP_CODE+i);
	return 0;
}
コード例 #8
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes the Timer Interrupt from the disk.
*/
int deleteTimerFromDisk()
{
	emptyBlock(TEMP_BLOCK);
	int i;
	for (i=0;i<TIMERINT_SIZE; i++)
		writeToDisk(TEMP_BLOCK,TIMERINT+i);
	return 0;
}
コード例 #9
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes the Interrupt <intNo> from the disk.
*/
int deleteIntCode(int intNo)
{
	emptyBlock(TEMP_BLOCK);
	int i;
	for (i=0;i<INT1_SIZE; i++)
		writeToDisk(TEMP_BLOCK,((intNo - 1) * INT1_SIZE)  + INT1 + i);
	return 0;
}
コード例 #10
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function frees the blocks specified by the block number present in the first arguement. The second arguement is the size
  of the first argument.
  The memory copy is not committed.
*/
void FreeUnusedBlock(int *freeBlock, int size){
	int i=0;
	for( i = 0 ; i < size && freeBlock[i] != -1 && freeBlock[i] != 0; i++){
		//printf("Block Num = %d\nLocation = %d", freeBlock[i],freeBlock[i] % BLOCK_SIZE );
		storeValue( disk[DISK_FREE_LIST + freeBlock[i] / BLOCK_SIZE].word[freeBlock[i] % BLOCK_SIZE] , 0 );
		emptyBlock(TEMP_BLOCK);
		writeToDisk(TEMP_BLOCK,freeBlock[i]);
	}
}
コード例 #11
0
ファイル: hash.c プロジェクト: sagar13/temp
int main()
{
	int choice;
	char ans = 'y';
	char fname[SIZE];
	struct linknode *hashTable[TABLESIZE];
	initializeHashTable(hashTable);
	
	while(ans == 'y')
	{
		printf("\n1. Create file\n");
		printf("2. Delete File\n");
		printf("3. Search File\n");
		printf("4. Display Table\n");
		printf("5. Exit\n");
		printf("6. Write to disk\n");
		printf("7. Read from disk\n");
		printf("\nEnter choice: ");
		scanf("%d", &choice);
		switch(choice)
		{
			case 1:
				printf("Enter file name: ");
				scanf("%s", fname);
				insertFile(fname, hashTable);
				break;

			case 2:
				printf("Enter file name: ");
				scanf("%s", fname);
				deleteFile(fname, hashTable);
				break;

			case 3:
				printf("Enter file name: ");
				scanf("%s", fname);
				searchFile(fname, hashTable);
				break;

			case 4:
				displayTable(hashTable);
				break;

			case 5:
				exit(0);

			case 6:
				writeToDisk(hashTable);
				break;

			case 7:
				readFromDisk(hashTable);
				break;
		}
	}
	return (0);
}
コード例 #12
0
//////////////////////////////////////////////////////////////////////////////////////////
// Consumer thread function
void 
receiveAndProcess ()
{
	while (true)
	{
		if (is_done)
			break;
		writeToDisk (buff.getFront ());
	}

	{
		boost::mutex::scoped_lock io_lock (io_mutex);
		std::cout << "Writing remaing " << buff.getSize () << " clouds in the buffer to disk..." << std::endl;
	}
	while (!buff.isEmpty ())
	{
		writeToDisk (buff.getFront ());
	}
}
コード例 #13
0
ファイル: record_maps_rgb.cpp プロジェクト: hobu/pcl
//////////////////////////////////////////////////////////////////////////////////////////
// Consumer thread function
void 
receiveAndProcess ()
{
  while (true)
  {
    if (is_done)
      break;
    writeToDisk (buff.getFront (false));
  }

  {
    boost::mutex::scoped_lock io_lock (io_mutex);
    PCL_INFO ("Writing remaining %d maps in the buffer to disk...\n", buff.getSize ());
  }
  while (!buff.isEmpty ())
  {
    writeToDisk (buff.getFront (true));
  }
}
コード例 #14
0
ファイル: b_tree.c プロジェクト: daltonbr/ED2
/**
 * Function that initiates a B-tree
 * @return root [a pointer to the new created tree]
 */
bTreeNode* createEmptyTree(FILE* file) {

  bTreeNode *root = (bTreeNode*) malloc(sizeof(bTreeNode));
  root->leaf = 1;
  root->numKeys = 0;
  // TODO: implement the function to write to disk
  writeToDisk(file, root);

  return root;
}
コード例 #15
0
ファイル: pintool.cpp プロジェクト: boohyung/callgraph
VOID PIN_FAST_ANALYSIS_CALL startRoutineEnter(UINT64 *counter , THREADID threadid)
{
  if(threadid!=0)return;
  RTN_COUNT *r = reinterpret_cast<RTN_COUNT*>(counter);
  TUP *t = new TUP;
  t->ptr=r->_address;
  t->call=1;
  //  tdata->calltrace.push_back(t);
  writeToDisk(t);
  guard=true;
  LOG("Started logging\n");
}
コード例 #16
0
ファイル: fileSystem.c プロジェクト: Suraj-Yadav/myxos
/*
  This function deletes the INIT code from the disk.
*/
int deleteINITFromDisk()
{
	emptyBlock(TEMP_BLOCK);
	int i;
	for (i=0; i<NO_OF_INIT_BLOCKS; i++)
		writeToDisk(TEMP_BLOCK,INIT_BASIC_BLOCK+i);

	//writeToDisk(TEMP_BLOCK,INIT_BASIC_BLOCK);
	//writeToDisk(TEMP_BLOCK,INIT_BASIC_BLOCK+1);
	//writeToDisk(TEMP_BLOCK,INIT_BASIC_BLOCK+2);
	return 0;
}
コード例 #17
0
ファイル: EventsXML.cpp プロジェクト: ARM-software/gator
void write(const char *path, lib::Span<const Driver * const> drivers, lib::Span<const GatorCpu> clusters)
{
    char file[PATH_MAX];

    // Set full path
    snprintf(file, PATH_MAX, "%s/events.xml", path);

    if (writeToDisk(file, getXML(drivers, clusters).get()) < 0) {
        logg.logError("Error writing %s\nPlease verify the path.", file);
        handleException();
    }
}
コード例 #18
0
ファイル: pintool.cpp プロジェクト: boohyung/callgraph
VOID PIN_FAST_ANALYSIS_CALL routineExit(UINT64 *counter , THREADID threadid)
{
  if(!guard)return;
  if(threadid!=0)return;

  RTN_COUNT *r = reinterpret_cast<RTN_COUNT*>(counter);
 
  TUP *t = new TUP;
  t->ptr=r->_address;
  t->call=0;
  //tdata->calltrace.push_back(t);
  writeToDisk(t);
}
コード例 #19
0
/*
  createDisk creates  the disk file if not present.
  if format is equal to zero then the function creates the disk but does not format it.
  if format is not equal to zero then the function will create and format the disk.
  Formatting is done as follows:
    1. A memory copy of the disk is maintained. This copy contains NO_BLOCKS_TO_COPY + EXTRA_BLOCKS (in this case 13 + 1) blocks.
      The extra block is a temporary block. This memory copy is called the virtual disk. This is first cleared.
    2. Then the memory freelist is initialised.
    3. The fat blocks are also initialised. The basic block entries are all set to -1. The memory copy is then committed to the 
      disk file.
    4. Finally the entry for init process is made.
*/
void createDisk(int format){
    int fd;
    if(format)
    {
		fd = open(DISK_NAME, O_CREAT | O_TRUNC | O_SYNC, 0666);
		clearVirtDisk();
		close(fd);
		// loadFileToVirtualDisk();		note: commented this line
		int i=0,j=0;
		
		for(j=0; j<(NO_OF_FREE_LIST_BLOCKS*BLOCK_SIZE); j++)
		{
			i=j/BLOCK_SIZE;
			if( (j>=DATA_START_BLOCK) && (j<(DATA_START_BLOCK+NO_OF_DATA_BLOCKS) ))
				storeValue(disk[DISK_FREE_LIST+i].word[j], 0);
			else
				storeValue(disk[DISK_FREE_LIST+i].word[j], 1);
		}
		
		for(i=0; i<NO_OF_FREE_LIST_BLOCKS;i++)
			writeToDisk(DISK_FREE_LIST+i, DISK_FREE_LIST+i);
			
		for(j=0; j<NO_OF_FAT_BLOCKS; j++)
		{
			for(i=FATENTRY_BASICBLOCK; i<BLOCK_SIZE; i=i+FATENTRY_SIZE)
			{
				storeValue(disk[FAT + j].word[i], -1);
			}
			writeToDisk(FAT+j, FAT+j);
		}
		initializeINIT();
	}
	else
	{
		fd = open(DISK_NAME, O_CREAT, 0666);
		close(fd);
	}
	
}
コード例 #20
0
ファイル: TableManagement.cpp プロジェクト: MIniBase/database
int TableManagement::addTable(TableInfo t){
	if (hasTable(t.Tablename))
	{
		cerr << "Table already has been existed\n";
		return false;
	}
	else{
		TableInfomation.push_back(t);
		TableNum++;
		writeToDisk();
		return true;
	}
}
コード例 #21
0
ファイル: createDisk.c プロジェクト: expos/Exposv1.2
/*
  createDisk creates  the disk file if not present.
  if format is equal to zero then the function creates the disk but does not format it.
  if format is not equal to zero then the function will create and format the disk.
  Formatting is done as follows:
    1. A memory copy of the disk is maintained. This copy contains NO_BLOCKS_TO_COPY + EXTRA_BLOCKS (in this case 13 + 1) blocks.
      The extra block is a temporary block. This memory copy is called the virtual disk. This is first cleared.
    2. Then the memory freelist is initialised.
    3. The fat blocks are also initialised. The basic block entries are all set to -1. The memory copy is then committed to the 
      disk file.
    4. Finally the entry for init process is made.
*/
void createDisk(int format){
    int fd;
      if(format){
	 fd = open(DISK_NAME, O_CREAT | O_TRUNC | O_SYNC, 0666);
	 clearVirtDisk();
	 close(fd);
	// loadFileToVirtualDisk();		note: commented this line
	 int i=0,j=0;
	 for(j=0; j<NO_OF_FREE_LIST_BLOCKS; j++){
		if(j == 0)
		  for(i=0;i<DATA_START_BLOCK + INIT_SIZE ;i++)
		      storeInteger(disk[FREE_LIST_START_BLOCK].word[i], 1);
		else
			i=0;
		
		for( ;i<BLOCK_SIZE;i++)
			storeInteger(disk[FREE_LIST_START_BLOCK + j].word[i], 0);
		writeToDisk(FREE_LIST_START_BLOCK + j, FREE_LIST_START_BLOCK+j);
	    }
	    
	    
	for(j=0; j<NO_OF_FAT_BLOCKS; j++){
		for(i=FAT_BASICBLOCK; i<BLOCK_SIZE; i=i+FAT_ENTRY_SIZE){
			storeInteger(disk[FAT_START_BLOCK + j].word[i], -1);
		}
		writeToDisk(FAT_START_BLOCK+j, FAT_START_BLOCK+j);
	}
	
	initializeINIT();
      }
      else
      {
	fd = open(DISK_NAME, O_CREAT, 0666);
	close(fd);
      }
	
}
コード例 #22
0
ファイル: StreamlineSetup.cpp プロジェクト: alexhe/gator
void StreamlineSetup::writeConfiguration(char* xml) {
	char path[PATH_MAX];

	ConfigurationXML::getPath(path);

	if (writeToDisk(path, xml) < 0) {
		logg.logError("Error writing %s\nPlease verify write permissions to this path.", path);
		handleException();
	}

	// Re-populate gSessionData with the configuration, as it has now changed
	{ ConfigurationXML configuration; }

	if (gSessionData.mCountersError != NULL) {
		logg.logError("%s", gSessionData.mCountersError);
		handleException();
	}
}
コード例 #23
0
ファイル: sglAdditions.c プロジェクト: timburrow/ovj3
/********************************************************************
* Function Name: writeOutputGradient
* Example:		writeOutputGradient( &outputGradient, shift )
* Purpose: 	writes an output gradient for a compound gradient axis
* Input
*	Formal:	outputGradient	- pointer to a output gradient
*				shift
*	Private:	none
*	Public:	none
* Output
*	Return:	none
*	Formal:	none
*	Private:	none
*	Public:	none
* Notes:		none
*********************************************************************/
double writeOutputGradientDBStr(SGL_GRADIENT_T *aOutputGradient,
			double aStartTime, double aDuration, char *aGradParams )
{
   char *gradParams;
   char _tempname[MAX_STR];
   int	_error;
	int _startIdx, _endIdx;
	
	double *_vec;
	long _nPts;
	
	_vec = getDataPoints( aOutputGradient );
	_nPts = getNumPoints( aOutputGradient );
	
	_startIdx = (long)ROUND(aStartTime/GRADIENT_RES);
	_endIdx = (long)ROUND((aStartTime + aDuration)/GRADIENT_RES);

	if( _startIdx >= 0 && _endIdx <= _nPts )
	{
		_vec += _startIdx;
		_nPts = _endIdx - _startIdx;
	}
   
	gradParams = NULL;
	appendFormattedString( &gradParams, "%g %ld", getAmplitude(aOutputGradient), _nPts);

	if( aGradParams != NULL )
	{
		appendFormattedString( &gradParams, " %s", aGradParams );
	}

	if( !gradShapeWritten( getName(aOutputGradient), gradParams, _tempname ) )
	{
		setName( aOutputGradient, _tempname );
		_error = writeToDisk( _vec, _nPts, _vec[0],
      					getResolution(aOutputGradient), 1, getName(aOutputGradient) );
	}
	else
	{
		setName( aOutputGradient, _tempname );
	}
	
	return _nPts*GRADIENT_RES;
}
コード例 #24
0
ファイル: bitcoindclient.c プロジェクト: danys/bitcoindclient
int main(int argc, char* argv[])
{	
    int socketFd,ret;
    int startBlock, stopBlock;
    if (argc!=3)
    {
        printf("Syntax: ./bitcoindclient <startBlockHeight> <stopBlockHeight>\n");
        exit(EXIT_FAILURE);
    }
    startBlock=atoi(argv[1]);
    stopBlock=atoi(argv[2]);
    printf("Start block heigth: %i, stop block height: %i\n",startBlock,stopBlock);
    /* Creating a socket */
    socketFd = socket(AF_INET, SOCK_STREAM, 0);
    if (socketFd==-1) printErrorAndExit("Error creating socket!\n");
    memset(&serverAddr, 0, sizeof(serverAddr));
    serverAddr.sin_family = AF_INET;
    serverAddr.sin_port = htons(port);
    ret = inet_pton(AF_INET, ip, &serverAddr.sin_addr);
    if (ret!=1) printErrorAndExit("Unable to convert given IP address!\n");
     /* Connect to server */
    ret = connect(socketFd, (struct sockaddr *)&serverAddr, sizeof serverAddr);
    if (ret==-1) printErrorAndExit("Can't connect to remote server!\n");
    printf("Successfully connected to remote server!\n");
    char* block;
    if (startBlock>stopBlock) startBlock = stopBlock;
    /* Query for the blocks */
    for(int i=startBlock;i<=stopBlock;i++)
    {
        printf("At block %i\n",i);
        block = getRawBlock(socketFd, i);
        if (block!=NULL)
        {
            if (writeToDisk(block,i)!=0) printf("Error writing file for block %i\n",i);
            free(block);
        }
        else printf("Got NULL for block %i\n",i);
    }
    /* close the socket */
    ret = close(socketFd);
	if (ret==-1) printErrorAndExit("Error closing socket!\n");
    printf("Closed socket successfully!\n");
    return 0;
}
コード例 #25
0
ファイル: alclipboard.cpp プロジェクト: alwynd/PublicGitRepo
bool AlClipboard::readFromClipboard(char *pKey)
{
	logger->debug("AlClipboard::readFromClipboard:-- START\n");

	char tbuf[128];
	ZeroMemory(tbuf, sizeof(char) * 128);


	if (!OpenClipboard(NULL))
	{
		logger->debug("\t OpenClipboard() FAILED..\n");
		return false;
	}

	char *pBuffer = NULL;
	

	if (	IsClipboardFormatAvailable(CF_TEXT)
		||  IsClipboardFormatAvailable(CF_OEMTEXT))
	{
		logger->debug("\t Getting text clipboard data..\n");
		HANDLE hClipboardData = GetClipboardData(CF_TEXT);
		char *pchData = (char*)GlobalLock(hClipboardData);
		pBuffer = new char[strlen(pchData)];

		strcpy(pBuffer, pchData);
		GlobalUnlock(hClipboardData);
	}

	logger->debug("\t CloseClipboard()..\n");
	CloseClipboard();

	writeToDisk(pKey, pBuffer);
	SAFE_DEL(pBuffer);

	return true;
}
コード例 #26
0
ファイル: sglWrappers.c プロジェクト: DanIverson/OpenVnmrJ
double calc_zfill_gradient2(FLOWCOMP_T *grad0, FLOWCOMP_T  *grad1,
                         GENERIC_GRADIENT_T  *grad2)

{ 
   
   double time    = 0.0;                    /* longest duration of gradient */
   double duration0, duration1, duration2;  /* gradient durations */
   
   ZERO_FILL_GRADIENT_T zf_grad0,zf_grad1, zf_grad2; /* define zero-fill grad structure in case of flow comp */

   if ((ix > 1) && !sglarray) return(grad0->duration);
   

   /* find longest gradient duration */
   duration0 = grad0->duration;//- grad[0]->tramp; /* duration of a square gradient with same integral & amplitude */
   duration1 = grad1->duration;// - grad[1]->tramp;
   duration2 = grad2->duration;// - grad[2]->tramp;
  
   time = MAX(MAX(duration0,duration1),duration2);  /* should already be granulated */
   text_message("time is %f", time);

/* zerofill new duration for each gradient */

    initZeroFillGradient(&zf_grad0); /* initialize zerofill structure for pe grad */
   // strcpy(zf_grad0.name,"zfgrad0");   /*fill in the unique name, otherwise the name will be repeated for each zerofill pattern*/
     strcpy(zf_grad0.name,"zfgrad0");  
   

    zf_grad0.numPoints= grad0->numPoints ;/* assign number of waveform points */
    zf_grad0.dataPoints = grad0->dataPoints; /* assign waveform to be zero-filled */
    zf_grad0.newDuration= time; /* duration of the fc grad for readout */
    zf_grad0.location = FRONT; /* add zero at front of waveform */
    zeroFillGradient(&zf_grad0);
    if (zf_grad0.error) abort_message("Gradient library error --> Check text window \n");
    //Now put it back
    grad0->duration=time ;
    grad0->numPoints=zf_grad0.numPoints ;/* assign number of waveform points */
    grad0->dataPoints= zf_grad0.dataPoints ;  /* assign waveform to be zero-filled */
    writeToDisk(grad0->dataPoints, grad0->numPoints, 0, grad0->resolution,
				     TRUE /*rolout*/, grad0->name); 
    initZeroFillGradient(&zf_grad1); /* initialize zerofill structure for pe grad */
    strcpy(zf_grad1.name,"zfgrad1");   /*fill in the unique name, otherwise the name will be repeated for each zerofill pattern*/
   

    zf_grad1.numPoints= grad1->numPoints ;/* assign number of waveform points */
    zf_grad1.dataPoints = grad1->dataPoints; /* assign waveform to be zero-filled */
    zf_grad1.newDuration= time; /* duration of the fc grad for readout */
    zf_grad1.location = FRONT; /* add zero at front of waveform */
    zeroFillGradient(&zf_grad1);
    if (zf_grad1.error) abort_message("Gradient library error --> Check text window \n");
    //Now put it back
    grad1->duration=time ;
    grad1->numPoints=zf_grad1.numPoints ;/* assign number of waveform points */
    grad1->dataPoints= zf_grad1.dataPoints ;  /* assign waveform to be zero-filled */
    writeToDisk(grad1->dataPoints, grad1->numPoints, 0, grad1->resolution,
				     grad1->rollOut, grad1->name); 

    initZeroFillGradient(&zf_grad2); /* initialize zerofill structure for pe grad */
    strcpy(zf_grad2.name,"zfgrad2");   /*fill in the unique name, otherwise the name will be repeated for each zerofill pattern*/
    

    zf_grad2.numPoints= grad2->numPoints ;/* assign number of waveform points */
    zf_grad2.dataPoints = grad2->dataPoints; /* assign waveform to be zero-filled */
    zf_grad2.newDuration= time; /* duration of the fc grad for readout */
    zf_grad2.location = FRONT; /* add zero at front of waveform */
    zeroFillGradient(&zf_grad2);
    if (zf_grad2.error) abort_message("Gradient library error --> Check text window \n");
    //Now put it back
    grad2->duration=time ;
    grad2->numPoints=zf_grad2.numPoints ;/* assign number of waveform points */
    grad2->dataPoints= zf_grad2.dataPoints ;  /* assign waveform to be zero-filled */
    writeToDisk(grad2->dataPoints, grad2->numPoints, 0, grad2->resolution,
				     grad2->rollOut, grad2->name); 
   

   return(time); 

}
コード例 #27
0
ファイル: sglEPI.c プロジェクト: timburrow/OpenVnmrJ
void calc_epi(EPI_GRADIENT_T          *epi_grad, 
              READOUT_GRADIENT_T      *ro_grad,
              PHASE_ENCODE_GRADIENT_T *pe_grad,
              REFOCUS_GRADIENT_T      *ror_grad,
              PHASE_ENCODE_GRADIENT_T *per_grad,
              READOUT_GRADIENT_T      *nav_grad,
              int write_flag) {

  /* Variables for generating gradient shapes */
  double dwint,blipint,skip,dw;
  int    np_ramp, np_flat, npro;
  double *dwell, *dac;
  double pos, neg;
  int    pt, pts, inx=0, lobe, lobes, blippts, zeropts;
    
  /* Variables for generating tables */
  int  n, seg, steps;
  char order_str[MAXSTR],gpe_tab[MAXSTR],tab_file[MAXSTR];
  FILE *fp;

  /********************************************************************************/
  /* Error Checks */
  /********************************************************************************/
  /* make sure that the combination of nseg, ky_order and fract_ky make sense */
  if (ky_order[0] == 'c') {
    /* Can't do just one segment with centric */
    if (nseg == 1) {
      if (ix == 1) {
        warn_message("WARNING %s: ky_order set to 'l'\n",seqfil);
        warn_message("            Only linear ordering allowed with single-shot acquisition\n");
      }
      ky_order[0] = 'l';
    }
    /* Must have even number of shots with centric ordering */
    if (((int) nseg % 2) == 1)
      abort_message("ERROR %s: Must do even number of shots with centric ordering\n",seqfil);

    /* Can't do fractional ky with centric acquisition */
    if (fract_ky != pe_grad->steps/2)
      abort_message("ERROR %s: fract_ky must be = nv/2 (%d) for centric acquisition\n",seqfil,(int) (pe_grad->steps/2));
  }

  if (fract_ky > pe_grad->steps/2)
    abort_message("ERROR %s: fract_ky must be <= nv/2 (%d)\n",seqfil,(int) (pe_grad->steps/2));


  /* calculate etl */
  switch(ky_order[0]) {
    case 'l': 
      epi_grad->etl = (pe_grad->steps/2 + fract_ky)/nseg; 
      epi_grad->center_echo = fract_ky/nseg - 1;

      if (epi_grad->etl - ((int) epi_grad->etl) > 0.005)
        abort_message("%s: Echo train length ((%d/2+%d)/%d = %.2f) not an integer\n",
	  seqfil,(int)pe_grad->steps,(int) fract_ky, (int) nseg,epi_grad->etl);

      break;
    case 'c': 
      epi_grad->etl = pe_grad->steps/nseg; 
      epi_grad->center_echo = 0;
      if (epi_grad->etl - ((int) epi_grad->etl) > 0.005)
        abort_message("%s: Echo train length (%d/%d) not an integer\n",
	  seqfil,(int)pe_grad->steps,(int) nseg);

      break;
    default:
      abort_message("%s: ky_order %s not recognized, use 'l' (linear) or 'c' (centric)\n",
                     seqfil, ky_order);
      break;
  }	    
  epi_grad->center_echo += ssepi*2;


  /********************************************************************************/
  /* Generate a single phase encoding blip and the dephaser                       */
  /********************************************************************************/
  blipint = 1/(pe_grad->fov/10*nuc_gamma()); /* base step in PE dimension */
  switch(ky_order[0]) {
    case 'l': /* each blip will jump nseg lines in ky: */
      pe_grad->m0     = blipint*nseg;
      per_grad->steps = pe_grad->steps;   /* each increment is = one blip unit */
      per_grad->m0    = blipint*per_grad->steps/2; /* start at nv/2, step 1 */
      break;
    case 'c': /* each blip will jump nseg/2 lines in ky: */
      pe_grad->m0     = blipint*nseg/2;
      per_grad->steps = nseg; 
      per_grad->m0    = blipint*per_grad->steps/2;  /* start at nseg/2, step 1 */
      break;
    default:  
      abort_message("ky_order %s not recognized, use 'l' (linear) or 'c' (centric)\n",ky_order);
      break;
  }

  /* Phase encoding blip */
  pe_grad->calcFlag  = SHORTEST_DURATION_FROM_MOMENT;
  pe_grad->writeToDisk = FALSE;
  calcPhase(pe_grad);
 
  if ((pe_grad->duration < epi_grad->tblip) || (pe_grad->amp/pe_grad->tramp > pe_grad->slewRate)) {
    pe_grad->tramp    = granularity(MAX(epi_grad->tblip/2,pe_grad->amp/pe_grad->slewRate),pe_grad->resolution);
    pe_grad->duration = 2*pe_grad->tramp;
    pe_grad->calcFlag = AMPLITUDE_FROM_MOMENT_DURATION_RAMP;
    calcPhase(pe_grad);
  }

  /* Phase encoding dephaser */
  per_grad->calcFlag = SHORTEST_DURATION_FROM_MOMENT;
  per_grad->maxGrad *= glim;
  per_grad->writeToDisk = write_flag;
  calcPhase(per_grad);
  
  /* Now adjust the initial dephaser for fractional k-space */
  per_grad->amp *= (fract_ky/(pe_grad->steps/2));

  /* Create an array for dwell times */
  npro = ro_grad->numPointsFreq; 
  if ((dwell = (double *)malloc(sizeof(double)*npro)) == NULL) {
    abort_message("Can't allocate memory for dwell");
  }

  /********************************************************************************/
  /* Generate a single readout lobe */  
  /********************************************************************************/
  ro_grad->writeToDisk = nav_grad->writeToDisk = FALSE;
  calcReadout(ro_grad);

  dw    = granularity(1/sw,1/epi_grad->ddrsr);
  dwint = dw*ro_grad->amp;

  skip  = getval("skip");              /* User specified min delay between acquisitions */
  skip  = MAX(skip,pe_grad->duration); /* Is PE blip longer? Then use that */
  skip /= 2;  /* in further calculations, skip is the skipped part on either ramp */

  /* If RO ramp - skip isn't at least one dwell, then we can't do ramp sampling */
  if (ro_grad->tramp - (skip + dw + getval("aqtm") - at) < dw) {
    if (rampsamp[0] == 'y') {
      printf("Blip duration or Min echo spacing is long (%.2fus), ramp sampling turned off",2*skip*1e6);
      rampsamp[0] = 'n';
    }
    /* set ramp time and recalculate */
    ro_grad->tramp = skip + (dw + getval("aqtm") - at); 
    calcReadout(ro_grad);
  }
    
  /********************************************************************************/
  if (rampsamp[0] == 'n') {  /* No rampsampling, just use simple RO shape */
  /********************************************************************************/
    np_ramp = 0; 
    np_flat = npro;
    
    skip = (ro_grad->atDelayFront + ro_grad->atDelayBack)/2;

    /* Set dwell array */
    for (pt = 0; pt < npro; pt++) 
      dwell[pt] = dw;
    dwell[npro-1] = 2*dw;  /* gradient duration is actually dw too long */

  }
  /********************************************************************************/
  else {  /* rampsampling */
  /********************************************************************************/
    calc_readout_rampsamp(ro_grad,dwell,&skip,&np_ramp);
    np_flat = npro - 2*np_ramp;

  }  /* end if rampsampling = 'y' */

  switch (ro_grad->error) {
    case ERR_NO_ERROR:
      break;
    case ERR_AMPLITUDE:
      abort_message("Readout gradient too large, increase FOV to %.2fmm",
        ro_grad->bandwidth/(ro_grad->gamma * ro_grad->maxGrad * MM_TO_CM));
      break;
    default:
      abort_message("Error in calculation of readout gradient (error %d)",
        (int)ro_grad->error);
      break;
      
  }


  /* We now have a single lobe, keep that for the navigator echo */
  nav_grad->amp        = ro_grad->amp; 
  nav_grad->duration   = ro_grad->duration; 
  nav_grad->tramp      = ro_grad->tramp; 
  nav_grad->m0         = ro_grad->m0;
  nav_grad->m0ref      = ro_grad->m0ref;
  nav_grad->dataPoints = ro_grad->dataPoints;
  nav_grad->numPoints  = ro_grad->numPoints;
  nav_grad->slewRate   = ro_grad->slewRate;


  /********************************************************************************/
  /* Readout dephaser */
  /********************************************************************************/
  ror_grad->balancingMoment0  = nav_grad->m0ref; /* ideal moment */
  /* adjust with grora tweaker */
  if (grora == 0) {
    warn_message("grora tweaker is 0, probably using old protocol - changed to 1.0");
    grora = 1.0;
  }
  ror_grad->balancingMoment0 *= grora;
  ror_grad->writeToDisk       = write_flag;
  
  calcRefocus(ror_grad);

  /********************************************************************************/
  /* Expand gradient shapes to full echo train                                    */
  /********************************************************************************/
  /* Readout - The navigator shape holds a single lobe                            */
  /********************************************************************************/
  /* Does positive or negative lobe need to be adjusted for tweaker? */
  pos = neg = 1;
  if (groa >= 0)  /* Adjust negative downwards, since positive is already at max */
    neg = (1 - groa/nav_grad->amp);
  else /* groa < 0, Adjust positive downwards */
    pos = (1 + groa/nav_grad->amp);

  /* Increase the size of ro shape to hold full shape */
  /* free(ro_grad->dataPoints); Don't free this, it's now assigned to the navigator echo */
  lobes = (epi_grad->etl + ssepi*2);
  ro_grad->numPoints *= lobes;
  
  if ((ro_grad->dataPoints = (double *)malloc(ro_grad->numPoints*sizeof(double))) == NULL) 
    abort_message("%s: Problem allocating memory for EPI readout gradient",seqfil);
  ro_grad->duration *= lobes;

  /* Concatenate positive and negative lobes        */
  /* until we have a full echo train (plus ssepi)  */
  pts = nav_grad->numPoints;
  inx = 0;
  for (lobe = 0; lobe < lobes/2; lobe++) {
    for (pt = 0; pt < pts; pt++)
      ro_grad->dataPoints[inx++] =  nav_grad->dataPoints[pt] * pos;
    for (pt = 0; pt < pts; pt++)
      ro_grad->dataPoints[inx++] = -nav_grad->dataPoints[pt] * neg;
  }


  /********************************************************************************/
  /* Phase encoding  */
  /********************************************************************************/
  /* Keep blip */
  blippts = pe_grad->numPoints;
  if ((dac = (double *)malloc(blippts*sizeof(double))) == NULL) 
    abort_message("%s: Problem allocating memory for EPI blip",seqfil);

  for (pt = 0; pt < blippts; pt++)
    dac[pt] = pe_grad->dataPoints[pt];

  /* Increase the size of pe shape to hold full shape */
  free(pe_grad->dataPoints);
  if ((pe_grad->dataPoints = (double *)malloc(ro_grad->numPoints*sizeof(double))) == NULL) 
    abort_message("%s: Problem allocating memory for EPI phase encoding gradient",seqfil);

  /* Pad front of shape - including ssepi time - with zeros */
  inx = 0;
  lobes = ssepi*2;
  zeropts = nav_grad->numPoints;
  for (lobe = 0; lobe < lobes; lobe++) {
    for (pt = 0; pt < zeropts; pt++) {
      pe_grad->dataPoints[inx++] = 0;
    }
  }
  zeropts = nav_grad->numPoints - blippts/2;
  for (pt = 0; pt < zeropts; pt++)
    pe_grad->dataPoints[inx++] = 0;

  lobes = epi_grad->etl-1;
  zeropts = nav_grad->numPoints - blippts;
  for (lobe=0; lobe < lobes; lobe++) {
    for (pt = 0; pt < blippts; pt++)    
      pe_grad->dataPoints[inx++] = dac[pt];
    for (pt = 0; pt < zeropts; pt++)
      pe_grad->dataPoints[inx++] = 0;
  }
  
  /* Add a few zeros, half the duration of the blip + one lobe, at the very end */
  zeropts = blippts/2 + nav_grad->numPoints;
  zeropts = blippts/2;
  for (pt = 0; pt < zeropts; pt++)
    pe_grad->dataPoints[inx++] = 0;

  pe_grad->numPoints = ro_grad->numPoints;
  pe_grad->duration  = ro_grad->duration;
  
  /********************************************************************************/
  /* Keep some parameters in EPI struct */
  /********************************************************************************/
  epi_grad->skip      = skip;
  epi_grad->np_flat   = np_flat;
  epi_grad->np_ramp   = np_ramp;
  epi_grad->dwell     = dwell;
  epi_grad->duration  = ro_grad->duration;
  epi_grad->numPoints = ro_grad->numPoints;
  epi_grad->amppos    =  nav_grad->amp*pos;
  epi_grad->ampneg    = -nav_grad->amp*neg;
  epi_grad->amppe     =  pe_grad->amp;

  
  /********************************************************************************/
  /* Write shapes to disk */
  /********************************************************************************/
  if (writeToDisk(ro_grad->dataPoints, ro_grad->numPoints, 0, 
                  ro_grad->resolution, TRUE /* rollout */,
                  ro_grad->name) != ERR_NO_ERROR)
    abort_message("Problem writing shape %s (%d points) to disk",
                  ro_grad->name,(int) ro_grad->numPoints);

  if (writeToDisk(nav_grad->dataPoints, nav_grad->numPoints, 0, 
                  nav_grad->resolution, TRUE /* rollout */,
                  nav_grad->name) != ERR_NO_ERROR)
    abort_message("Problem writing shape %s (%d points) to disk",
                  nav_grad->name,(int) nav_grad->numPoints);

  if (writeToDisk(pe_grad->dataPoints, pe_grad->numPoints, 0, 
                  pe_grad->resolution, TRUE /* rollout */, 
                  pe_grad->name) != ERR_NO_ERROR)
    abort_message("Problem writing shape %s (%d points) to disk",
                  pe_grad->name,(int) pe_grad->numPoints);
 

  /********************************************************************************/
  /* Create EPI tables */
  /********************************************************************************/
  /* Generates two tables:  */ 
  /* t1 that specifies the k-space ordering, used by recon_all */
  /* t2 that specifies which direction in k-space to go in a given shot */
  /*     1 = positive blips, and -1 = negative blips */
  if ((epi_grad->table1 = (int *)malloc(pe_grad->steps*sizeof(int))) == NULL) 
    abort_message("%s: Problem allocating memory for EPI table1",seqfil);
  if ((epi_grad->table2 = (int *)malloc(nseg*sizeof(int))) == NULL) 
    abort_message("%s: Problem allocating memory for EPI table2",seqfil);
  
  switch(ky_order[0]) {
    case 'l':
      inx = 0;
      for (seg = 0; seg < nseg; seg++) {
        epi_grad->table1[inx++] = -fract_ky + seg;
        for (n = 0; n < epi_grad->etl-1; n++) {
          epi_grad->table1[inx] = (int) (epi_grad->table1[inx-1]+nseg);
          inx++;
        }
      }
      for (seg = 0; seg < nseg; seg++) 
        epi_grad->table2[seg] = 1;
      break;
 
    case 'c':
      inx = 0;
      for (seg = 0; seg < nseg; seg++) {
        epi_grad->table1[inx++] = -(nseg/2 - seg);
        for (n = 0; n < epi_grad->etl-1; n++) {
          if (epi_grad->table1[inx-1] >= 0)
            epi_grad->table1[inx] = (int) (epi_grad->table1[inx-1] + nseg/2);
          else
            epi_grad->table1[inx] = (int) (epi_grad->table1[inx-1] - nseg/2);
          inx++;
        }
      }
      for (seg = 0; seg < nseg; seg++)
        epi_grad->table2[seg] = ((nseg/2 - 1 - seg >= 0) ? -1 : 1);
      break;

      default:  /* This should have been caught earlier */
        break;
  }
  steps = inx;

  /* Print table t1 to file in tablib */
  switch(ky_order[0]) {
    case 'l': sprintf(order_str,"lin"); break;
    case 'c': sprintf(order_str,"cen"); break;
    default:  
      abort_message("%s: ky_order %s not recognized, use 'l' (linear) or 'c' (centric)\n",
                     seqfil,ky_order);
  } 

  if (ky_order[1] == 'r')  /* not reversed */
    sprintf(gpe_tab,"%s_nv%d_f%d_%s%d_rev",seqfil,
       (int)pe_grad->steps,(int)fract_ky,order_str,(int)nseg);
  else
    sprintf(gpe_tab,"%s_nv%d_f%d_%s%d",seqfil,
       (int)pe_grad->steps,(int)fract_ky,order_str,(int)nseg);
  sprintf(tab_file,"%s/tablib/%s",userdir,gpe_tab);

  if ((fp = fopen(tab_file,"w")) == NULL) {
    abort_message("Error opening file %s\n",gpe_tab);
  }

  fprintf(fp,"t1 = ");
  for (inx = 0; inx < steps; inx++) {
    if (ky_order[1] == 'r')
      fprintf(fp,"%d ", epi_grad->table1[inx]);
    else
      fprintf(fp,"%d ", -epi_grad->table1[inx]);
  }
  fprintf(fp,"\n"); 
  fclose(fp);
  strcpy(petable,gpe_tab);
  putstring("petable",gpe_tab);

  /* Return values in VnmrJ parameter pe_table */
  putCmd("exists('pe_table','parameter'):$ex\n");
  putCmd("if ($ex > 0) then\n");
  putCmd("  pe_table = 0\n"); //reset pe_table array
  for (inx = 0; inx < steps; inx++) {
    putCmd("  pe_table[%d] = %d\n",inx+1,
      ((ky_order[1] == 'r') ? 1 : -1)*epi_grad->table1[inx]);
  }
  putCmd("endif\n");
}
コード例 #28
0
ファイル: utility.c プロジェクト: lenywv/xsm
int performLoadStore(int X, int flagX, int Y, int flagY, int instruction) {
	if (mode == USER_MODE) {
		raiseException(newException(EX_ILLINSTR, "Call to Privileged Instruction in USER mode", 0));		
		return 0;
	}
	Exception e = isSafeState2();
	if (e.code != EX_NONE) {
		raiseException(e);
		return 0;
	}
	switch (flagX) {
		case REG:
		case SP:
		case BP:
		case IP:
		case PTBR:
		case PTLR:
		case EFR:
			e = isRegisterInaccessible(X);
			if (e.code != EX_NONE) {
				raiseException(e);
				return 0;
			}
			if (getType(reg[X]) == TYPE_STR) {
				raiseException(newException(EX_ILLOPERAND, "Illegal operand", 0));
				return 0;
			} else X = getInteger(reg[X]);					
			break;
		case NUM:
			break;
		default:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand", 0));
			return 0;
			break;
	}
	switch (flagY) {
		case REG:
		case SP:
		case BP:
		case IP:
		case PTBR:
		case PTLR:
		case EFR:
			e = isRegisterInaccessible(Y);
			if (e.code != EX_NONE) {
				raiseException(e);
				return 0;
			}
			if (getType(reg[Y]) == TYPE_STR) {
				raiseException(newException(EX_ILLOPERAND, "Illegal operand", 0));
				return 0;
			} else Y = getInteger(reg[Y]);					
			break;
		case NUM:
			break;
		default:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand", 0));
			return 0;
			break;
	}
	if (instruction == LOAD) {			
		emptyPage(X);
		readFromDisk(X, Y);
	} else if (instruction == STORE) writeToDisk(Y, X);
	return 1;
}
コード例 #29
0
ファイル: file.cpp プロジェクト: Etrnls/evangel
qint64 File::readData(char *data, qint64 maxSize)
{
	writeToDisk();
	return QFile::readData(data, maxSize);
}
コード例 #30
0
ファイル: file.cpp プロジェクト: Etrnls/evangel
void File::close()
{
	writeToDisk();
	QFile::close();
}