RefListType* NetPoco::getRefListType(){
	//Creates a RefListType from clientCache or Server response.
	try
	{	//Prepare session and path and request header

        //string url = "http://192.168.1.5/se_sv_capitals.json";
		string url = "http://10.225.113.152/se_sv_capitals.json";
        //Test server is to contain the json for parsing, make sure to have se_sv_capitals.json
        // in your apache www-directory and that the IP is correct
        //10.225.113.87
        string headKey = makeKeyFromResponse(url);
        
        
        
        
        URI uri(url);
        HTTPClientSession session(uri.getHost(), uri.getPort());
        string path(uri.getPathAndQuery());
        if (path.empty()) path = "/";

		checkCache(headKey, path, &session);
		return new RefListType(this->clientCache->get(headKey)->second);
	}
	catch (Exception &ex){
		cerr << ex.displayText() << endl;
        return 0;
	}
}
unsigned char ResourceSystem::read(unsigned char driver, unsigned int address) {
    checkCache(address);
    if (validCacheSize < 1) {
        lastOperationResult = Resource::OPERATION_ERROR_IO_ERROR;
        return 0;
    }
    return (uint8_t) cache[address - cacheMemoryAddress];
}
コード例 #3
0
ファイル: main.cpp プロジェクト: krobertson92/ECEN3000
//finds access time
static void findTime(ulong addr){
 if(checkCache(GlbDat::getL1P(),addr)){
  //hit --> Just load in

 }else{
  //miss
 }
}
コード例 #4
0
void
XWindowsClipboard::fillCache() const
{
	// get the selection data if not already cached
	checkCache();
	if (!m_cached) {
		const_cast<XWindowsClipboard*>(this)->doFillCache();
	}
}
コード例 #5
0
ファイル: LongLongNim.cpp プロジェクト: shil99/study
LongLongNim::PLAYER LongLongNim::checkWin(int curNum, 
        LongLongNim::PLAYER first)
{

    if(curNum < mMove[0])
        return swap_player(first);


    // curNum is equal to one of the number in move
    if(curNum <= mMove[mMoveLen-1])
    {
        int i=0;
        for(; i<mMoveLen && mMove[i]!=curNum; i++);
        if(i<mMoveLen) 
        {
            return first;
        }
    }


    // curNum (mMove[0], mMove[n-1]), but not equal to move[i], or
    // curNum is bigger than mMove[n-1]
    LongLongNim::PLAYER second = swap_player(first);
    LongLongNim::PLAYER winner = second;

    for(int i=0; i<mMoveLen && curNum<mMove[i]; i++)
    {
        // check mCache
        int num = curNum - mMove[i];
        winner = checkCache(num);
        if(first == winner)
        {
            break;
        }
        assert(winner == second);

        // if the first can win only one of path, it will win finally.
        winner = checkWin(num, second);
        if(first == winner)
        {
            break;
        }
    }

    // add the result into cache
    RESULT res;
    res.num = curNum;
    res.winner = winner;
    mCache->add(res);

    return winner;
}
コード例 #6
0
void WeatherWidget::downloadImg(const QString &imgName)
{
    QString request = urlRoot_ + weatherImgQuery_ + imgName + imgExtention_;

    qDebug() << request;

    const QByteArray* ba = checkCache(imgName);
    if( ba != nullptr ) {
        qDebug() << request << "From cache";
        slotImgDone(QUrl(request), *ba);
    } else {
        pdlImg_->download(QUrl(request));
    }
}
コード例 #7
0
BOOL CellInfoCache::updateCache(const P_ND_N_CELL_INFO_DATA pData, const INT32 aItemsCount)
{
    BOOL ret = FALSE;

    RIL_LOG_VERBOSE("CellInfoCache::updateCache() - aItemsCount %d \r\n",aItemsCount);
    if (NULL == pData || aItemsCount > RRIL_MAX_CELL_ID_COUNT)
    {
        RIL_LOG_INFO("CellInfoCache::updateCache() - Invalid data\r\n");
        goto Error;
    }
    else
    {
        // if there were more items in the cache before
        if (aItemsCount != m_iCacheSize)
        {
            ret = TRUE;
        }
        else
        {
            for (INT32 storeIndex= 0; storeIndex < aItemsCount; storeIndex++)
            {
                if (checkCache(pData->pnCellData[storeIndex]) < 0 ) // new item
                {
                    ret = TRUE;
                    break;
                }
            }
        }
    }

    if (ret)
    {
        RIL_LOG_INFO("CellInfoCache::updateCache() -"
                "Updating cache with %d items\r\n", aItemsCount);
        // Access mutex
        CMutex::Lock(m_pCacheLock);
        m_iCacheSize = aItemsCount;
        memset(&m_sCellInfo, 0, sizeof(S_ND_N_CELL_INFO_DATA));
        for (INT32 j = 0; j < m_iCacheSize; j++)
        {
            m_sCellInfo.pnCellData[j] = pData->pnCellData[j];
        }
        // release mutex
        CMutex::Unlock(m_pCacheLock);
    }
Error:
    return ret;
}
コード例 #8
0
ファイル: gfxcanvas.cpp プロジェクト: Camelek/qtmoko
QRect GfxCanvasText::boundingRect()
{
    checkCache();
    if(_img.isNull())
        return QRect();

    QMatrix m;
    m.translate(layerX(), layerY());
    m.scale(layerScale(), layerScale());
    m.translate(-_size.width() / 2, -_size.height() / 2);
    QRect r(getImgPoint(), _img.size());
    r = m.mapRect(r);
    r.setX(r.x() - 1);
    r.setY(r.y() - 1);
    r.setWidth(r.width() + 2);
    r.setHeight(r.height() + 2);
    return r | GfxCanvasItem::boundingRect();;
}
コード例 #9
0
ファイル: cps2emu.cpp プロジェクト: felipeota/cps2emu-rpi
void CPS2emu::on_runButton_clicked()
{
    QFileInfo rom(path);

    cps2run = new QProcess;
    if(checkCache()){
        cps2run->setWorkingDirectory(rom.dir().path());
        cps2run->start("/usr/bin/cps2emu " + rom.fileName());
        ui->runButton->setEnabled(false);
        ui->romButton->setEnabled(false);
        ui->txt->setText("CPS2emu running");
        running = true;
    }
    else{
        QMessageBox::critical(this,"CPS2emu Critical Error!",
                              "ROM file " + rom.baseName() + ", not cached!",
                              QMessageBox::Ok);
    }

}
コード例 #10
0
wxString S3D_CACHE::GetModelHash( const wxString& aModelFileName )
{
    wxString full3Dpath = m_FNResolver->ResolvePath( aModelFileName );

    if( full3Dpath.empty() || !wxFileName::FileExists( full3Dpath ) )
        return wxEmptyString;

    // check cache if file is already loaded
    std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString >::iterator mi;
    mi = m_CacheMap.find( full3Dpath );

    if( mi != m_CacheMap.end() )
        return mi->second->GetCacheBaseName();

    // a cache item does not exist; search the Filename->Cachename map
    S3D_CACHE_ENTRY* cp = NULL;
    checkCache( full3Dpath, &cp );

    if( NULL != cp )
        return cp->GetCacheBaseName();

    return wxEmptyString;
}
コード例 #11
0
ファイル: qmimeprovider.cpp プロジェクト: FlavioFalcao/qt5
bool QMimeBinaryProvider::isValid()
{
#if defined(QT_USE_MMAP)
    if (!qEnvironmentVariableIsEmpty("QT_NO_MIME_CACHE"))
        return false;

    Q_ASSERT(m_cacheFiles.isEmpty()); // this method is only ever called once
    checkCache();

    if (m_cacheFiles.count() > 1)
        return true;
    if (m_cacheFiles.isEmpty())
        return false;

    // We found exactly one file; is it the user-modified mimes, or a system file?
    const QString foundFile = m_cacheFiles.first()->file.fileName();
    const QString localCacheFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/mime.cache");

    return foundFile != localCacheFile;
#else
    return false;
#endif
}
コード例 #12
0
ファイル: Routine.cpp プロジェクト: Alexpux/firebird-git-svn
// Decrement the routine's use count.
void Routine::release(thread_db* tdbb)
{
	// Actually, it's possible for routines to have intermixed dependencies, so
	// this routine can be called for the routine which is being freed itself.
	// Hence we should just silently ignore such a situation.

	if (!useCount)
		return;

	if (intUseCount > 0)
		intUseCount--;

	--useCount;

#ifdef DEBUG_PROCS
	{
		string buffer;
		buffer.printf(
			"Called from CMP_decrement():\n\t Decrementing use count of %s\n",
			getName().toString().c_str());
		JRD_print_procedure_info(tdbb, buffer.c_str());
	}
#endif

	// Call recursively if and only if the use count is zero AND the routine
	// in the cache is different than this routine.
	// The routine will be different than in the cache only if it is a
	// floating copy, i.e. an old copy or a deleted routine.
	if (useCount == 0 && !checkCache(tdbb))
	{
		if (getStatement())
			releaseStatement(tdbb);

		flags &= ~Routine::FLAG_BEING_ALTERED;
		remove(tdbb);
	}
}
コード例 #13
0
ファイル: igate.c プロジェクト: jafo2128/saxigate
void readAx25DataForIgate(char *mycall, short verbose) {
	frame_t frame; 		//save raw ax25 frame.
	uidata_t uidata_p; 	//save decoded ax25 frame.
	short result; 		//save result from decoding.
	char igatestring[1000] = {0}; //save igate format string
	
	//check for new data
	while (mac_avl()) { 
		//read new data into frame.
		if (mac_inp(&frame) == 0) {
			//decode data.
			result = frame2uidata(&frame, &uidata_p, mycall);
			if (result == 1) {
				//show ax25 data on screen.
				dump_uidata_from(&uidata_p, verbose);
				//check cache for double data.
				if (checkCache(&uidata_p)) { 
					//format for igate transmission.
					igateformat(&uidata_p, mycall, igatestring);
					//show the data in igate format.
					if (verbose) printf("To igate: %s\n\n",igatestring);
					//send to igate.
					if (!sendDataToAPRSIS(igatestring)) {
						//we probably lost connection to the igate. Lets try to connect again.
						disconnectFromAPRSIS();
						if (verbose) printf("Connection lost. Reconnecting in 5 seconds..\n");
						sleep(5);
						connectAndLogin(verbose);
					}
				} else {
					if (verbose) printf("Double data. Already sent to APRS-IS.\n");
				} //endif (checkCache);
			} //endif (result==1)
		}	//endif(mac_inp)
	} //endwhile (mac_avl)
}
コード例 #14
0
ファイル: gfxcanvas.cpp プロジェクト: Camelek/qtmoko
QImage &GfxCanvasText::image() 
{
    checkCache();
    return _img;
}
コード例 #15
0
IClipboard::Time
XWindowsClipboard::getTime() const
{
	checkCache();
	return m_timeOwned;
}
コード例 #16
0
ファイル: deluge_admin.c プロジェクト: 135u5/dynamiclinker
void handleCommand(deluge_app* app, comBuf* pkt, uint8_t port)
{
	deluge_foot_command* command = (deluge_foot_command*)
		&pkt->data[pkt->size - sizeof(deluge_foot_command)];
	#ifdef DELUGE_PRINT_PACKETS
	printf_P(sRecvComm, command->seq, command->command, command->to);
	#endif
	if (checkCache(command->id, command->seq)) return;
	
	// Temporarily switch to max power to make sure the command gets through
	/*uint8_t oldPower;
	com_ioctl(IFACE_RADIO, CC1000_GET_TX_POWER, &oldPower);
	com_ioctl(IFACE_RADIO, CC1000_TX_POWER, 0xFF);*/
	
	// If the command is not specifically addessed to us, forward it now
	/*if (command->to != mos_node_id_get())
		net_send(pkt, DELUGE_PROTO_ID, port, port);*/
	if (command->to != -1 && command->to != mos_node_id_get()) {
		//com_ioctl(IFACE_RADIO, CC1000_TX_POWER, oldPower);
		return;
	}
	
	//extern mutex epromLock;
	
	switch(command->command) {
		case DELUGE_COMMAND_HELLO: 
			printf_P(sHello);
			logHeader(&spkt, DELUGE_COMMAND_HELLO);
			com_send(IFACE_SERIAL, &spkt);
			break;
		//case DELUGE_COMMAND_SEQNO: seqNo = 0; break;
		/*case DELUGE_COMMAND_STOPALL: 
			//app->dcb.codeSize;
			//app->dcb.programcrc;
			memset(app->dcb.pagesNeeded, 0, sizeof(app->dcb.pagesNeeded));
			//app->dcb.version;
			app->dcb.incomingPage = app->dcb.highPage = app->dcb.goalPage;
			deluge_saveState(app);
			deluge_app_init(app, app->index);
			break;*/
		#ifdef DELUGE_KEEP_STATS
		case DELUGE_COMMAND_CLEARSTATS:
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sClearStats);
			//printf_P(sClearTimer);		// reset timer
			#endif	
			memset(packet_counts, 0, sizeof(packet_counts));
			logHeader(&spkt, DELUGE_COMMAND_CLEARSTATS);
			com_send(IFACE_SERIAL, &spkt);
			break;
		case DELUGE_COMMAND_STARTRECORD:
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sStartRec);
			//printf_P(sClearTimer);		// reset timer
			#endif
			logHeader(&spkt, DELUGE_COMMAND_STARTRECORD);
			com_send(IFACE_SERIAL, &spkt);
			deluge_recordstats = 1;
			break;
		case DELUGE_COMMAND_ENDRECORD: 
			#ifdef DELUGE_PRINT_EVENT
			//printf_P(sDisplayTime);		// display timer
			printf_P(sStopRec);
			#endif
			deluge_recordstats = 0;
			/*mos_mutex_lock(&epromLock);
			dev_ioctl(DEV_AVR_EEPROM, DEV_SEEK, DELUGE_STATS_ADDR);
			dev_write(DEV_AVR_EEPROM, (uint8_t*)packet_counts, sizeof(packet_counts));
			mos_mutex_unlock(&epromLock);*/
			logHeader(&spkt, DELUGE_COMMAND_ENDRECORD);
			com_send(IFACE_SERIAL, &spkt);
			break;
		case DELUGE_COMMAND_SENDSTATS:
			if (-1 != command->to && !sendingStats) {	// it's addressed to us
				sendingStats = 1;
				statsPort = port;
				// This is a slow procedure that requires multiple packets to
				// reply, so run it in another thread.
				//mos_thread_new(statsThread, 256, PRIORITY_NORMAL);

				uint8_t r = 0;
				uint8_t i = 0;
				
				for (r=0; r<DELUGE_STATS_COUNT;)
				{
					logHeader(&spkt, DELUGE_COMMAND_SENDSTATS_REPLY);
					spkt.data[spkt.size++] = r;
					
					for (i=0; i<4 && r+i<DELUGE_STATS_COUNT; i++)
					{
						uint8_t j;
						for (j=0; j<4; j++)
						{
							uint16_t stat = packet_counts[r+i][j];
							spkt.data[spkt.size++] = (uint8_t)(stat >> 8);
							spkt.data[spkt.size++] = (uint8_t)(stat);
						}
					}
					r += i;
					com_send(IFACE_SERIAL, &spkt);
				}
				sendingStats = 0;
			}
			break;
		#endif
		case DELUGE_COMMAND_VERSION:
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sChangeVer, pkt->data[0]);
			printf_P(sClearTimer);		// clear timer
			#endif
			mos_mutex_lock(&app->delugeLock);	
			app->dcb.version = pkt->data[0];
			deluge_saveState(app);
			app->detectedInconsistency = 1;
			stateTransition(app, DELUGE_STATE_MAINTAIN);
			mos_mutex_unlock(&app->delugeLock);	
			if (command->to != -1) {
				/*command->seq = ++seqNo;
				command->command = DELUGE_COMMAND_VERSION_REPLY;
				command->to = command->id;
				command->id = mos_node_id_get();
				command->type = DELUGE_PACKET_COMMAND;
				mos_thread_sleep(1000);
				net_send(pkt, DELUGE_PROTO_ID, port, port);*/
				logHeader(&spkt, DELUGE_COMMAND_VERSION_REPLY);
				com_send(IFACE_SERIAL, &spkt);
			}
			break;
		#ifdef DELUGE_SYMMETRIC_LINKS
		/*case DELUGE_COMMAND_NEIGHBORS:
			if (-1 != command->to) {	// it's addressed to us
				memcpy(pkt->data, app->neighbors, sizeof(app->neighbors));
				pkt->size = sizeof(app->neighbors);
				//memcpy(&pkt->data[pkt->size], app->symdtbs, sizeof(app->symdtbs));
				//pkt->size += sizeof(app->symdtbs);

				command = (deluge_foot_command*)&pkt->data[pkt->size];
				command->seq = ++seqNo;
				command->command = DELUGE_COMMAND_NEIGHBORS_REPLY;
				command->to = -1;
				command->id = mos_node_id_get();
				command->type = DELUGE_PACKET_COMMAND;
				pkt->size += sizeof(deluge_foot_command);
				mos_thread_sleep(1000);
				net_send(pkt, DELUGE_PROTO_ID, port, port);
			}
			break;*/
		#endif
		/*case DELUGE_COMMAND_WIPE: {
			com_mode(IFACE_RADIO, IF_OFF);
			deluge_suspend();
			
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sWipe);
			#endif
			uint16_t zero = 0;
			uint16_t addr;
			mos_mutex_lock(&epromLock);
			for (addr = DELUGE_CONTROL_BLOCK_ADDR; addr < SIMPLE_FS_ADDR; addr += 2)
			{
				dev_ioctl(DEV_AVR_EEPROM, DEV_SEEK, addr);
				dev_write(DEV_AVR_EEPROM, (uint8_t*)&zero, 2);
			}
			simple_fs_format();
			
			uint8_t default_portmap[DELUGE_INSTANCE_COUNT];
			uint8_t i;
			for (i=0; i<DELUGE_INSTANCE_COUNT; i++)
				default_portmap[i] = i+1;
			dev_ioctl(DEV_AVR_EEPROM, DEV_SEEK, DELUGE_DIRECTORY_ADDR);
			dev_write(DEV_AVR_EEPROM, default_portmap, sizeof (default_portmap));
			mos_mutex_unlock(&epromLock);
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sDone);
			#endif
			
			deluge_init();
			
			com_mode(IFACE_RADIO, IF_LISTEN);
			break;
		}*/
		case DELUGE_COMMAND_BOOT: {
			mos_mutex_lock(&app->delugeLock);
			com_mode(IFACE_RADIO, IF_OFF);
			deluge_suspend();
			
			if (pkt->data[0]==0) {
				// Just reboot
				reboot();
				break;
			}
			
			// Open the requested backup image
			char name[4] = { 'b', 'k', '0'+pkt->data[0], 0 };
			mos_file* file = mos_file_open(name);
			if (!file) {
				printf_P(sFileErr, name);
				
				deluge_resume();
				com_mode(IFACE_RADIO, IF_LISTEN);
				break;
			}
			
			// We keep our current state, but we boot the backup image
			deluge_saveState(app);
			
			// Reboot.  This function will copy the file location into the 
			// boot control block for reprogramming
			app->image_file = file;
			runReprogram(app);
			// We shouldn't return from runReprogram
			mos_mutex_unlock(&app->delugeLock);
			break;
		}
		#if DELUGE_CACHE_PAGES > 1
		case DELUGE_COMMAND_CACHESIZE: {
			if (pkt->data[0] >= DELUGE_CACHE_PAGES) break;
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sChangeCache, pkt->data[0]);
			#endif
			mos_mutex_lock(&app->delugeLock);
			app->cacheSize = pkt->data[0];
			int8_t i;
			for (i=0; i<DELUGE_CACHE_PAGES; i++)
				app->cache_map[i] = -1;
			app->outgoingCachePage = 0;
			app->incomingCachePage = 0;
			stateTransition(app, DELUGE_STATE_MAINTAIN);
			mos_mutex_unlock(&app->delugeLock);
			break;
		}
		#endif
		case DELUGE_COMMAND_POWER: {
			#ifdef DELUGE_PRINT_EVENT
			printf_P(sChangeTx, pkt->data[0]);
			#endif
			//oldPower = pkt->data[0];	// Will get changed at the end
			com_ioctl(IFACE_RADIO, CC1000_TX_POWER, pkt->data[0]);
			break;
		}
		default:
			break;
	}
コード例 #17
0
ファイル: scache.cpp プロジェクト: jenslyn42/phd-backup
void scache::readQuery(std::pair< int, int > query)
{
	checkCache(query);
	numTotalQueries++;
}
コード例 #18
0
ファイル: check_create.c プロジェクト: ryandavid/rotobox
int
main (int argc, char *argv[])
{
    int ret;
    sqlite3 *handle;
    char *err_msg = NULL;
    sqlite3_int64 log_pk;
    void *cache = spatialite_alloc_connection ();

    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

    ret =
	sqlite3_open_v2 (":memory:", &handle,
			 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "cannot open in-memory db: %s\n",
		   sqlite3_errmsg (handle));
	  sqlite3_close (handle);
	  return -1;
      }

    spatialite_init_ex (handle, cache, 0);

    ret =
	sqlite3_exec (handle, "SELECT InitSpatialMetadata(1)", NULL, NULL,
		      &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "InitSpatialMetadata() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -2;
      }
    ret = sqlite3_exec (handle, "SELECT HasProj()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasProj() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -3;
      }
    ret = sqlite3_exec (handle, "SELECT HasGeos()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasGeos() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -4;
      }
    ret =
	sqlite3_exec (handle, "SELECT HasGeosAdvanced()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasGeosAdvanced() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -5;
      }
    ret =
	sqlite3_exec (handle, "SELECT HasGeosReentrant()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasGeosReentrant() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -6;
      }
    ret =
	sqlite3_exec (handle, "SELECT HasGeosOnlyReentrant()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasGeosOnlyReentrant() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -7;
      }
    ret = sqlite3_exec (handle, "SELECT HasIconv()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasIconv() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -8;
      }
    ret = sqlite3_exec (handle, "SELECT HasMathSql()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasMathSql() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -9;
      }
    ret =
	sqlite3_exec (handle, "SELECT HasGeoCallbacks()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasGeoCallbacks() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -10;
      }
    ret = sqlite3_exec (handle, "SELECT HasFreeXL()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasFreeXL() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -11;
      }
    ret = sqlite3_exec (handle, "SELECT HasEpsg()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasEpsg() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -12;
      }
    ret = sqlite3_exec (handle, "SELECT HasGeosTrunk()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasGeoTrunk() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -13;
      }
    ret = sqlite3_exec (handle, "SELECT HasLwGeom()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasLwGeom() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -14;
      }
    ret = sqlite3_exec (handle, "SELECT HasLibXml2()", NULL, NULL, &err_msg);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "HasLibXml2() error: %s\n", err_msg);
	  sqlite3_free (err_msg);
	  sqlite3_close (handle);
	  return -15;
      }

    gaiaInsertIntoSqlLog (handle, "test", "sql_statement_ok", &log_pk);
    gaiaUpdateSqlLog (handle, log_pk, 1, NULL);
    gaiaInsertIntoSqlLog (handle, "test", "sql_statement_no", &log_pk);
    gaiaUpdateSqlLog (handle, log_pk, 0, "some error message");

    ret = sqlite3_close (handle);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "sqlite3_close() error: %s\n",
		   sqlite3_errmsg (handle));
	  return -16;
      }

    spatialite_cleanup_ex (cache);

    ret = checkCache ();
    if (ret != 0)
	return ret;
    spatialite_shutdown ();

    return 0;
}
コード例 #19
0
ファイル: Routine.cpp プロジェクト: Alexpux/firebird-git-svn
// Remove a routine from cache.
void Routine::remove(thread_db* tdbb)
{
	SET_TDBB(tdbb);
	Jrd::Attachment* att = tdbb->getAttachment();

	// MET_procedure locks it. Lets unlock it now to avoid troubles later
	if (existenceLock)
		LCK_release(tdbb, existenceLock);

	// Routine that is being altered may have references
	// to it by other routines via pointer to current meta
	// data structure, so don't lose the structure or the pointer.
	if (checkCache(tdbb) && !(flags & Routine::FLAG_BEING_ALTERED))
		clearCache(tdbb);

	// deallocate all structure which were allocated.  The routine
	// blr is originally read into a new pool from which all request
	// are allocated.  That will not be freed up.

	if (existenceLock)
	{
		delete existenceLock;
		existenceLock = NULL;
	}

	// deallocate input param structures

	for (Array<NestConst<Parameter> >::iterator i = getInputFields().begin();
		 i != getInputFields().end(); ++i)
	{
		if (*i)
			delete i->getObject();
	}

	getInputFields().clear();

	// deallocate output param structures

	for (Array<NestConst<Parameter> >::iterator i = getOutputFields().begin();
		 i != getOutputFields().end(); ++i)
	{
		if (*i)
			delete i->getObject();
	}

	getOutputFields().clear();

	if (!useCount)
		releaseFormat();

	if (!(flags & Routine::FLAG_BEING_ALTERED) && useCount == 0)
		delete this;
	else
	{
		// Fully clear routine block. Some pieces of code check for empty
		// routine name and ID, this is why we do it.
		setName(QualifiedName());
		setSecurityName("");
		setId(0);
		setDefaultCount(0);
	}
}
コード例 #20
0
ファイル: cps2emu.cpp プロジェクト: felipeota/cps2emu-rpi
void CPS2emu::on_romButton_clicked()
{
    //Default location, load at constructor
    if(path == NULL){
        path = "";
    }
    QFileInfo recent(path);

    QString openPath = QFileDialog::getOpenFileName(this, "Select a ROM...", recent.dir().path(),
                                        "ROM files (*.zip)");

    //After change path is recentPath

    if(openPath != NULL){
        path = openPath;
        QFileInfo rom(path);

        //Check hi and nvram folders
        checkHiScore();
        checkNVRAM();

        //Check cache file
        if(checkCache()){
            ui->runButton->setEnabled(true);
            ui->romButton->setText( rom.fileName() );
        }
        else{
            QMessageBox msgBox;
            QPushButton *createBt = msgBox.addButton(tr("Create"), QMessageBox::AcceptRole);
            msgBox.addButton(QMessageBox::Abort);

            msgBox.setWindowTitle("CPS2emu - cache");
            msgBox.setText("Cache file not found!");
            msgBox.setInformativeText("Create cache file now?");

            msgBox.exec();

            if(msgBox.clickedButton() == createBt){

                cps2cache = new QProcess;
                //cps2cache->setTextModeEnabled(true);
                //cps2cache->setReadChannelMode(QProcess::MergedChannels);
                cps2cache->setWorkingDirectory(rom.dir().path());
                cps2cache->start("/usr/bin/cps2romcnv ./" + rom.fileName());

                //romcnv running...
                romcnv = true;
                //startTimer(300);
                ui->txt->setText("Caching ROM file... Please Wait!");
                ui->romButton->setText( rom.fileName() + ", caching!");

                //Disable buttons
                ui->runButton->setEnabled(false);
                ui->romButton->setEnabled(false);
            }
            else{
                ui->romButton->setText( rom.fileName() + ", not cached!");
                ui->runButton->setEnabled(false);
            }
        }
    }

}
コード例 #21
0
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCachePtr )
{
    if( aCachePtr )
        *aCachePtr = NULL;

    wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile );

    if( full3Dpath.empty() )
    {
        // the model cannot be found; we cannot proceed
        wxLogTrace( MASK_3D_CACHE, " * [3D model] could not find model '%s'\n",
            aModelFile.ToUTF8() );
        return NULL;
    }

    // check cache if file is already loaded
    wxCriticalSectionLocker lock( lock3D_cache );
    std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString >::iterator mi;
    mi = m_CacheMap.find( full3Dpath );

    if( mi != m_CacheMap.end() )
    {
        wxFileName fname( full3Dpath );
        wxDateTime fmdate = fname.GetModificationTime();
        bool reload = false;

        if( fmdate != mi->second->modTime )
        {
            unsigned char hashSum[20];
            getSHA1( full3Dpath, hashSum );
            mi->second->modTime = fmdate;

            if( !isSHA1Same( hashSum, mi->second->sha1sum ) )
            {
                mi->second->SetSHA1( hashSum );
                reload = true;
            }
        }

        if( reload )
        {
            if( NULL != mi->second->sceneData )
            {
                S3D::DestroyNode( mi->second->sceneData );
                mi->second->sceneData = NULL;
            }

            if( NULL != mi->second->renderData )
                S3D::Destroy3DModel( &mi->second->renderData );

            mi->second->sceneData = m_Plugins->Load3DModel( full3Dpath, mi->second->pluginInfo );
        }

        if( NULL != aCachePtr )
            *aCachePtr = mi->second;

        return mi->second->sceneData;
    }

    // a cache item does not exist; search the Filename->Cachename map
    return checkCache( full3Dpath, aCachePtr );
}
コード例 #22
0
ファイル: proxy.c プロジェクト: DeathByTape/UofI_undergrad
void* connection_handler(void *arg){
  tdata_t* data = (tdata_t*)arg;
  int sockfd = -1;
  int clientsock = 0;
  int * x = NULL;
  char* buffer = NULL;
  char* key = NULL;
  priqueue_t *queue = data->queue, *jobs = data->jobs;
  sem_t* semaphore = data->sem;

  while(!done) {
    sem_wait(semaphore);
    
    if(done)
      break;

    pthread_mutex_lock(&job_mutex);
    x = (int*)priqueue_delete_min(jobs);
    pthread_mutex_unlock(&job_mutex);

    if(x == NULL)
      continue;

    sockfd = *x;

    if(sockfd == -1) {
      free(x);
      continue;
    }

    /* Recv request from client */
    buffer = readFromClient(sockfd);
  
    if(buffer == NULL || done) {
      closeSocket(sockfd);
      if(buffer != NULL)
        free(buffer);
      free(x);
      if(!done)
        continue;
      break;
    }

    key = requestToKey(buffer);

    /* Check cache and serve if possible */
    if(checkCache(sockfd, queue, key) || done) {
      closeSocket(sockfd);
      free(key);
      free(buffer);
      free(x);
      if(!done)
        continue;
      break;
    }

    /* Parse request for host since not in cache */
    clientsock = initHostRequest(buffer);

    if(clientsock == -1 || done) {
      free(buffer);
      free(key);
      free(x);
      closeSocket(sockfd);
      if(!done)
        continue;
      break;
    }

    /* Actually get the data from the server */
    processHostRequest(buffer, key, data->queue, clientsock, sockfd);
  
    closeSocket(clientsock);
    closeSocket(sockfd);

    free(key);
    free(buffer);
    free(x);
  }

  return NULL;
}
void ResourceSystem::write(unsigned char driver, unsigned int address, unsigned char b) {
    checkCache(address);
    cache[address - cacheMemoryAddress] = b;
    wasCacheChanged = true;
}