当前位置: 首页>>代码示例>>C++>>正文


C++ HandleError函数代码示例

本文整理汇总了C++中HandleError函数的典型用法代码示例。如果您正苦于以下问题:C++ HandleError函数的具体用法?C++ HandleError怎么用?C++ HandleError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HandleError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetOptions

CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe) {
    penv = NULL;
    readoptions.verify_checksums = true;
    iteroptions.verify_checksums = true;
    iteroptions.fill_cache = false;
    syncoptions.sync = true;
    options = GetOptions(nCacheSize);
    options.create_if_missing = true;
    if (fMemory) {
        penv = leveldb::NewMemEnv(leveldb::Env::Default());
        options.env = penv;
    } else {
        if (fWipe) {
            LogPrintf("Wiping LevelDB in %s\n", path.string().c_str());
            leveldb::DestroyDB(path.string(), options);
        }
        boost::filesystem::create_directory(path);
        LogPrintf("Opening LevelDB in %s\n", path.string().c_str());
    }
    leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb);
    HandleError(status);
    LogPrintf("Opened LevelDB successfully\n");
}
开发者ID:Soldy,项目名称:lincoin,代码行数:23,代码来源:leveldbwrapper.cpp

示例2: MOZ_ASSERT

nsresult
SourceBuffer::ExpectLength(size_t aExpectedLength)
{
  MOZ_ASSERT(aExpectedLength > 0, "Zero expected size?");

  MutexAutoLock lock(mMutex);

  if (MOZ_UNLIKELY(mStatus)) {
    MOZ_ASSERT_UNREACHABLE("ExpectLength after SourceBuffer is complete");
    return NS_OK;
  }

  if (MOZ_UNLIKELY(mChunks.Length() > 0)) {
    MOZ_ASSERT_UNREACHABLE("Duplicate or post-Append call to ExpectLength");
    return NS_OK;
  }

  if (MOZ_UNLIKELY(NS_FAILED(AppendChunk(CreateChunk(aExpectedLength))))) {
    return HandleError(NS_ERROR_OUT_OF_MEMORY);
  }

  return NS_OK;
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:23,代码来源:SourceBuffer.cpp

示例3: UE_LOG

void FOutputDeviceWindowsError::Serialize( const TCHAR* Msg, ELogVerbosity::Type Verbosity, const class FName& Category )
{
	FPlatformMisc::DebugBreak();
   
	if( !GIsCriticalError )
	{   
		const int32 LastError = ::GetLastError();

		// First appError.
		GIsCriticalError = 1;
		TCHAR ErrorBuffer[1024];
		ErrorBuffer[0] = 0;

		// Windows error.
		UE_LOG( LogWindows, Error, TEXT( "Windows GetLastError: %s (%i)" ), FPlatformMisc::GetSystemErrorMessage( ErrorBuffer, 1024, LastError ), LastError );
	}
	else
	{
		UE_LOG(LogWindows, Error, TEXT("Error reentered: %s"), Msg );
	}

	if( GIsGuarded )
	{
		// Propagate error so structured exception handler can perform necessary work.
#if PLATFORM_EXCEPTIONS_DISABLED
		FPlatformMisc::DebugBreak();
#endif
		FPlatformMisc::RaiseException( 1 );
	}
	else
	{
		// We crashed outside the guarded code (e.g. appExit).
		HandleError();
		FPlatformMisc::RequestExit( true );
	}
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:36,代码来源:WindowsPlatformOutputDevices.cpp

示例4: sqlite3Codec

// Encrypt/Decrypt functionality, called by pager.c
void* sqlite3Codec(void *pCodec, void *data, Pgno nPageNum, int nMode)
{
    if (pCodec == NULL) //Db not encrypted
        return data;

    switch(nMode)
    {
    case 0: // Undo a "case 7" journal file encryption
    case 2: // Reload a page
    case 3: // Load a page
        if (HasReadKey(pCodec))
            Decrypt(pCodec, nPageNum, (unsigned char*) data);
        break;
    case 6: // Encrypt a page for the main database file
        if (HasWriteKey(pCodec))
            data = Encrypt(pCodec, nPageNum, (unsigned char*) data, 1);
        break;
    case 7: // Encrypt a page for the journal file
    /*
    *Under normal circumstances, the readkey is the same as the writekey.  However,
    *when the database is being rekeyed, the readkey is not the same as the writekey.
    *(The writekey is the "destination key" for the rekey operation and the readkey
    *is the key the db is currently encrypted with)
    *Therefore, for case 7, when the rollback is being written, always encrypt using
    *the database's readkey, which is guaranteed to be the same key that was used to
    *read and write the original data.
    */
        if (HasReadKey(pCodec))
            data = Encrypt(pCodec, nPageNum, (unsigned char*) data, 0);
        break;
    }
    
    HandleError(pCodec);

    return data;
}
开发者ID:BenjaminSchiborr,项目名称:safe,代码行数:37,代码来源:codecext.c

示例5: while

    void TCPSocket::WriteThread()
    {
        this->mutex.lock();
        while (!this->writeQueue.empty())
        {
            BytesRef data = this->writeQueue.front();
            char* buffer = data->Pointer();
            size_t remaining = data->Length();

            // Release lock while sending data to avoid blocking write().
            this->mutex.unlock();
            while (true)
            {
                try
                {
                    size_t sent = this->socket.sendBytes(buffer, remaining);
                    if (sent == remaining) break;

                    buffer += sent;
                    remaining -= sent;
                }
                catch (Poco::Exception& e)
                {
                    HandleError(e);
                    return;
                }
            }

            this->mutex.lock();
            this->writeQueue.pop();
        }

        // Notify listeners we have fully drained the queue.
        this->mutex.unlock();
        FireEvent("drain");
    }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:36,代码来源:tcp_socket.cpp

示例6: find_libdir

void
find_libdir (void)
{
    const char searchfile[] = "Colour.pal";
    /* default_dir will be something like "C:\\LINCITY1.11" */
    const char default_dir[] = "C:\\LINCITY" VERSION;

    /* Check 1: environment variable */
    _searchenv (searchfile, "LINCITY_HOME", LIBDIR);
    if (*LIBDIR != '\0') {
	int endofpath_offset = strlen (LIBDIR) - strlen (searchfile) - 1;
	LIBDIR[endofpath_offset] = '\0';
	return;
    }

    /* Check 2: default location */
    if ((_access (default_dir, 0)) != -1) {
	strcpy (LIBDIR, default_dir);
	return;
    }

    /* Finally give up */
    HandleError ("Error. Can't find LINCITY_HOME", FATAL);
}
开发者ID:BackupTheBerlios,项目名称:lincity-ng-svn,代码行数:24,代码来源:fileutil.c

示例7: HandleError

BOOL 
CUdpCommClient::Push(CUdpPacketNode* pcPktNode)
{
	if (pcPktNode->GetRawLen() >= m_ulMaxSndPktLen)
	{
		HandleError(OCFCLIENT_ERROR_USERDEF, OCFCLIENT_ERROR_USERDEF_CATEGORY_PKTMAXSIZE, 0, pcPktNode->GetRawLen(), pcPktNode->GetRawBuff());
		return FALSE;
	}

	//
	Lock();

	m_cSndPktList.Add(pcPktNode);

	if (TRUE == m_bConnectFlag && FALSE == m_bWouldBlock)
	{
		SetEvent(m_hWrEvent);
	}

	//
	Unlock();

	return TRUE;
}
开发者ID:BornHunter,项目名称:CGSF,代码行数:24,代码来源:UdpCommClient.cpp

示例8: printMetadataResults

/**
* Prints out the name value records of the matching results.
*/
int printMetadataResults(hc_nvr_t *nvr, hc_session_t *session)
{
	char **names = NULL;
	char **values = NULL;
	int count = 0;

	hcerr_t hcError = hc_nvr_convert_to_string_arrays(nvr,
							  &names,
							  &values,
							  &count);

	if (hcError != HCERR_OK)
	{
		HandleError(session, hcError);	
		hc_session_free(session);
		return RETURN_STORAGETEK_ERROR;
	}	/* if error occurred */

	/* Print metadata record. printMetadataRecord is example specific code (in example_metadata.h) */
	/* and is not part of the @[email protected] API. */
	printMetadataRecord(names, values, count);
	
	return RETURN_SUCCESS;
}   /* printMetadataResults */
开发者ID:elambert,项目名称:honeycomb,代码行数:27,代码来源:Query.c

示例9: HandleError

BOOL CUdpClient::ProcessNetworkEvent()
{
	BOOL bContinue = TRUE;
	WSANETWORKEVENTS events;
	
	int rc = ::WSAEnumNetworkEvents(m_soClient, m_evSocket, &events);

	if(rc == SOCKET_ERROR)
		bContinue = HandleError();

	if(bContinue && events.lNetworkEvents & FD_READ)
		bContinue = HandleRead(events);

	if(bContinue && events.lNetworkEvents & FD_WRITE)
		bContinue = HandleWrite(events);

	if(m_bAsyncConnect && bContinue && events.lNetworkEvents & FD_CONNECT)
		bContinue = HandleConnect(events);

	if(bContinue && events.lNetworkEvents & FD_CLOSE)
		bContinue = HandleClosse(events);

	return bContinue;
}
开发者ID:NothingInMyEye,项目名称:HP-Socket,代码行数:24,代码来源:UdpClient.cpp

示例10: cfi

bool CFI::CompileCFI(const string &str)
{
    // strip the 'epubcfi(...)' wrapping
    string cfi(str);
    if ( str.find("epubcfi(") == 0 )
    {
        cfi = cfi.substr(8, (str.size()-1)-8);
    }
    else if ( str.size() == 0 )
    {
        HandleError(EPUBError::CFIParseFailed, "Empty CFI string");
        return false;
    }
    else if ( str[0] != '/' )
    {
        HandleError(EPUBError::CFINonSlashStartCharacter);
    }
    
    StringList rangePieces = RangedCFIComponents(cfi);
    if ( rangePieces.size() != 1 && rangePieces.size() != 3 )
    {
        HandleError(EPUBError::CFIRangeComponentCountInvalid, _Str("Expected 1 or 3 range components, got ", rangePieces.size()));
        if ( rangePieces.size() == 0 )
            return false;
    }
    
    if ( CompileComponentsToList(CFIComponentStrings(rangePieces[0]), &_components) == false )
        return false;
    
    if ( rangePieces.size() >= 3 )
    {
        if ( CompileComponentsToList(CFIComponentStrings(rangePieces[1]), &_rangeStart) == false )
            return false;
        if ( CompileComponentsToList(CFIComponentStrings(rangePieces[2]), &_rangeEnd) == false )
            return false;
        
        // now sanity-check the range delimiters:
        
        // neither should be empty
        if ( _rangeStart.empty() || _rangeEnd.empty() )
        {
            HandleError(EPUBError::CFIRangeInvalid, "One of the supplied range components was empty.");
            return false;
        }
        
        // check the offsets at the end of each— they should be the same type
        if ( (_rangeStart.back().flags & Component::OffsetsMask) != (_rangeEnd.back().flags & Component::OffsetsMask) )
        {
            HandleError(EPUBError::CFIRangeInvalid, "Offsets at the end of range components are of different types.");
            return false;
        }
        
        // ensure that there are no side-bias values
        if ( (_rangeStart.back().sideBias != SideBias::Unspecified) ||
             (_rangeEnd.back().sideBias != SideBias::Unspecified) )
        {
            HandleError(EPUBError::CFIRangeContainsSideBias);
            // can safely ignore this one
        }
        
        // where the delimiters' component ranges overlap, start must be <= end
        auto maxsz = std::max(_rangeStart.size(), _rangeEnd.size());
        bool inequalNodeIndexFound = false;
        for ( decltype(maxsz) i = 0; i < maxsz; i++ )
        {
            if ( _rangeStart[i].nodeIndex > _rangeEnd[i].nodeIndex )
            {
                HandleError(EPUBError::CFIRangeInvalid, "Range components appear to be out of order.");
            }
            else if ( !inequalNodeIndexFound && _rangeStart[i].nodeIndex < _rangeEnd[i].nodeIndex )
            {
                inequalNodeIndexFound = true;
            }
        }
        
        // if the two ranges are equal aside from their offsets, the end offset must be > the start offset
        if ( !inequalNodeIndexFound && _rangeStart.size() == _rangeEnd.size() )
        {
            Component &s = _rangeStart.back(), &e = _rangeEnd.back();
            if ( s.HasCharacterOffset() && s.characterOffset > e.characterOffset )
            {
                HandleError(EPUBError::CFIRangeInvalid, "Range components appear to be out of order.");
            }
            else
            {
                if ( s.HasTemporalOffset() && s.temporalOffset > e.temporalOffset )
                    HandleError(EPUBError::CFIRangeInvalid, "Range components appear to be out of order.");
                if ( s.HasSpatialOffset() && s.spatialOffset > e.spatialOffset )
                    HandleError(EPUBError::CFIRangeInvalid, "Range components appear to be out of order.");
            }
        }
        
        _options |= RangeTriplet;
    }
    
    return true;
}
开发者ID:datalogics-bhaugen,项目名称:SDKLauncher-Windows,代码行数:97,代码来源:cfi.cpp

示例11: fprintf

void
ClientUserLua::Diff( FileSys *f1, FileSys *f2, int doPage,
					char *diffFlags, Error *e )
{

	if ( P4LUADEBUG_CALLS )
		fprintf( stderr, "[P4] Diff() - comparing files\n" );

	//
	// Duck binary files. Much the same as ClientUser::Diff, we just
	// put the output into Ruby space rather than stdout.
	//
	if( !f1->IsTextual() || !f2->IsTextual() )
	{
		if ( f1->Compare( f2, e ) )
			results.AddOutput( "(... files differ ...)" );
		return;
	}

	// Time to diff the two text files. Need to ensure that the
	// files are in binary mode, so we have to create new FileSys
	// objects to do this.

	FileSys *f1_bin = FileSys::Create( FST_BINARY );
	FileSys *f2_bin = FileSys::Create( FST_BINARY );
	FileSys *t = FileSys::CreateGlobalTemp( f1->GetType() );

	f1_bin->Set( f1->Name() );
	f2_bin->Set( f2->Name() );

	{
		//
		// In its own block to make sure that the diff object is deleted
		// before we delete the FileSys objects.
		//
#ifndef OS_NEXT
		::
#endif
			Diff d;

		d.SetInput( f1_bin, f2_bin, diffFlags, e );
		if ( ! e->Test() ) d.SetOutput( t->Name(), e );
		if ( ! e->Test() ) d.DiffWithFlags( diffFlags );
		d.CloseOutput( e );

		// OK, now we have the diff output, read it in and add it to
		// the output.
		if ( ! e->Test() ) t->Open( FOM_READ, e );
		if ( ! e->Test() )
		{
			StrBuf 	b;
			while( t->ReadLine( &b, e ) )
				results.AddOutput( b.Text() );
		}
	}

	delete t;
	delete f1_bin;
	delete f2_bin;

	if ( e->Test() ) HandleError( e );
}
开发者ID:Malaar,项目名称:luaplus51-all,代码行数:62,代码来源:clientuserlua.cpp

示例12: main

int main(int argc, char* argv[])
{
	hc_session_t *session = NULL;

	hc_oid returnedOid;
	hc_long_t count = 0;
	int finished = 0;
	int32_t response_code = RETURN_SUCCESS;
	hc_query_result_set_t *rset = NULL;
	hc_nvr_t *nvr = NULL;
	hc_long_t query_integrity_time;
	int query_complete;

	
	hcerr_t	res = HCERR_OK;

	int parametersUsed = USES_SERVERADDRESS | USES_QUERY | USES_SELECT_METADATA | USES_MAXRESULTS;

	/* Initialize commandline structure */
	cmdLine.storagetekServerAddress = NULL;
	cmdLine.query = NULL;
	cmdLine.help = 0;
	cmdLine.debug_flags = 0;
	cmdLine.storagetekPort = 0;
	cmdLine.maxResults = DEFAULT_MAX_RESULTS;

	/* Initialize metadata map.  The metadata map structure is not part of the API but common */
	/* code written for the convenience of these examples.  See example_metadata.c. */
        if (initMetadataMap(&cmdLine.cmdlineMetadata) == 0)
        {
                return exitApp(RETURN_MAPINITERROR);
        }       /* if initMetadataMap == 0 */

	/* Get commandline (see example_commandline.c) */
	if (parseCommandline(	argc,
				argv,
				parametersUsed) == 0)
	{
		printUsage();
		return RETURN_COMMANDLINE_ERROR;
	}	/* if parseCommandline failed */
	else
	{
		if (cmdLine.help == 1)
		{
			printUsage();
			return RETURN_SUCCESS;
		}	/* if help requested */
	}	/* else parseCommandline succeeded */

	/* Initialize @[email protected] API */
        res = hc_init(malloc,free,realloc);
        if (res != HCERR_OK)
        {
                printf("An error occurred while initializing the API.\n");
                return res;
        }  /* if error */

       if (cmdLine.debug_flags) {
		/* Internal debug flags */
		hc_set_global_parameter(HCOPT_DEBUG_FLAGS, cmdLine.debug_flags);
       }

	res = hc_session_create_ez(cmdLine.storagetekServerAddress, 
				(cmdLine.storagetekPort > 0 ? 
				 cmdLine.storagetekPort : 
				 STORAGETEK_PORT),
				&session);
	
	if (res != HCERR_OK)
	{
		HandleError(session,res);
		return RETURN_STORAGETEK_ERROR;
	}	/* if initialization failed */

	/* Run queryplus if we have a select clause (-s option on the commandline), otherwise run query */
	if (cmdLine.cmdlineMetadata.mapSize > 0)
	{
		res = hc_query_ez(session,
				cmdLine.query,
				cmdLine.cmdlineMetadata.namePointerArray,	
				cmdLine.cmdlineMetadata.mapSize,
                                100,
				&rset);
	}	/* if outputing metadata */
	else
	{	
		res = hc_query_ez(session,
				cmdLine.query,
                                NULL,
                                0,
                                100,
				&rset);
	}

	if (res != HCERR_OK)
        {
                HandleError(session, res);
                hc_session_free(session);
                hc_cleanup();
//.........这里部分代码省略.........
开发者ID:elambert,项目名称:honeycomb,代码行数:101,代码来源:Query.c

示例13: PRINTMARK

PyObject *Connection_connect(Connection *self, PyObject *args)
{
  /*
  Args:
  UMConnection conn, const char *_host, int _port, const char *_username, const char *_password, const char *_database, int _autoCommit, const char *_charset*/

  char *host;
  int port;
  char *username;
  char *password;
  char *database;

  int autoCommit;
  char *pstrCharset = NULL;
  PyObject *acObj = NULL;

  if (!PyArg_ParseTuple (args, "sisss|Os", &host, &port, &username, &password, &database, &acObj, &pstrCharset))
  {
    return NULL;
  }

  if (acObj)
  {
    PRINTMARK();
    autoCommit = (PyObject_IsTrue(acObj) == 1) ? 1 : 0;
  }
  if (pstrCharset)
  {
    if (strcmp (pstrCharset, "utf8") == 0)
    {
      self->charset = MCS_utf8_general_ci;
      self->PFN_PyUnicode_Encode = PyUnicode_EncodeUTF8;
    }
    else
      if (strcmp (pstrCharset, "latin1") == 0)
      {
        self->charset = MCS_latin1_general_ci;
        self->PFN_PyUnicode_Encode = PyUnicode_EncodeLatin1;
      }
      else
        if (strcmp (pstrCharset, "ascii") == 0)
        {
          self->charset = MCS_ascii_general_ci;
          self->PFN_PyUnicode_Encode = PyUnicode_EncodeASCII;
        }
        else
          if (strcmp (pstrCharset, "cp1250") == 0)
          {
            self->charset = MCS_cp1250_general_ci;
            self->PFN_PyUnicode_Encode = PyUnicode_EncodeCP1250Helper;
          }
          else
          {
            return PyErr_Format (PyExc_ValueError, "Unsupported character set '%s' specified", pstrCharset);
          }
  }
  else
  {
    self->charset = MCS_utf8_general_ci;
    self->PFN_PyUnicode_Encode = PyUnicode_EncodeUTF8;
  }

  if (!UMConnection_Connect (self->conn, host, port, username, password, database, acObj ? &autoCommit : NULL, self->charset))
  {
    return HandleError(self, "connect");
  }

  Py_RETURN_NONE;
}
开发者ID:LeeXiaolan,项目名称:ultramysql,代码行数:69,代码来源:umysql.c

示例14: GenPrepare

/* This function generates a batch named prepare.bat (default).
 * The batch contains 6 experiments
 * Exp1: SPE - (Special) - runs IOCount SR then IOCount RW then IOCount SR
 * 		 The goal is here to determine the Pause value
 * Exp2: SIO.SR - runs IOCount2 SR - goal: determine IOIgnoreSR and IOCountSR
 * Exp3-5 : same for RR, SW, RW
 * Exp6 : Random format of the device 
 */ 
 	void GenPrepare(sParams* PB) {
	FILE*		fp2 = NULL;	// file pointer
	int32 		size;

	fp2 = fopen(PB->outName, "w");
	if (fp2 == NULL) HandleError("GenBench", "Could not open output file", GetLastError(), ERR_ABORT);
	strcpy(PB->comment, "SPE");
	strcpy(PB->base, "SR");
	PB->expID = 1;
	PB->microBenchID = 0;
	PB->pauseExp = 10000;
	size = PB->IOSize * PB->IOCount;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	PB->IOCount = PB->IOCount2;
	size = PB->IOSize * PB->IOCount;
	strcpy(PB->comment, "SIO.SR");
	PB->expID = 2;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	strcpy(PB->base, "RR");
	strcpy(PB->comment, "SIO.RR");
	PB->expID++;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	strcpy(PB->base, "SW");
	strcpy(PB->comment, "SIO.SW");
	PB->expID++;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	strcpy(PB->base, "RW");
	strcpy(PB->comment, "SIO.RW");
	PB->expID++;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	PB->expID++;
	fprintf(fp2, "FlashIO RandomFormat Dev %d Bench %d Exp %d ", PB->deviceNum, PB->microBenchID, PB->expID);

	if (PB->trimBeforeRun == TRUE)
			fprintf(fp2, "TrimBeforeRun True\n");
		else
			fprintf(fp2, "\n");

	if (PB->fake == TRUE) 
		fprintf(fp2, "Fake True\n Pause\n");
	else
		fprintf(fp2, "\n Pause\n");

	fclose(fp2);
}
开发者ID:ClydeProjects,项目名称:FlashIO,代码行数:73,代码来源:genBench.cpp

示例15: DoPrepared

bool DoPrepared(HDBC	lpDbc, TCHAR* szInput)
{
	int arrIdx = 0;
	RETCODE		RetCode;
	SQLSMALLINT	sNumResults;
	HSTMT	lpStmt = NULL;
	TCHAR* szIter = szInput;
	int cnt = 0;

	TRYODBCP(lpDbc,
	         SQL_HANDLE_DBC,
	         SQLAllocHandle(SQL_HANDLE_STMT, lpDbc, &lpStmt));

	RetCode = SQLPrepare(lpStmt, (SQLCHAR*) szInput, SQL_NTS);

	while (NULL != (szIter = strstr(szIter, "?"))) {
		++cnt;
		++szIter;
	}

	TCHAR	szParams[MAX_PARAMS][SQL_QUERY_SIZE];
	SQLLEN	lenParams[MAX_PARAMS];
	for (int sqlIdx = 1; sqlIdx <= cnt; ++sqlIdx) {
		arrIdx = sqlIdx - 1;
		_fgetts(szParams[arrIdx], SQL_QUERY_SIZE - 1, stdin);
		lenParams[arrIdx] = strlen(szParams[arrIdx]);
		szParams[arrIdx][lenParams[arrIdx]] = '\0';
		lenParams[arrIdx] -= 1;
		TRYODBCP(lpStmt, SQL_HANDLE_STMT,
		         SQLBindParameter(lpStmt, sqlIdx, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 255, 0, szParams[arrIdx],
		                          SQL_QUERY_SIZE, &lenParams[arrIdx]));
	}

	RetCode = SQLExecute(lpStmt);

	switch (RetCode)
	{
	case	SQL_SUCCESS_WITH_INFO:
	{
		HandleError(lpStmt, SQL_HANDLE_STMT, RetCode);
		// fall through
	}
	case	SQL_SUCCESS:
	{
		// If this is a row-returning query, display
		// results
		TRYODBCP(lpStmt,
		         SQL_HANDLE_STMT,
		         SQLNumResultCols(lpStmt, &sNumResults));

		if (sNumResults > 0)
		{
			DisplayResults(lpStmt, sNumResults);
		} else
		{
			SQLLEN		siRowCount;

			TRYODBCP(lpStmt,
			         SQL_HANDLE_STMT,
			         SQLRowCount(lpStmt, &siRowCount));
			if (siRowCount >= 0)
			{
				_tprintf(TEXT("%ld %s affected\n"),
				         static_cast<long>(siRowCount),
				         siRowCount == 1 ? TEXT("row") : TEXT("rows"));
			}
		}
		break;
	}

	case	SQL_ERROR:
	{
		HandleError(lpStmt, SQL_HANDLE_STMT, RetCode);
		break;
	}

	default:
		fprintf(stderr, "Unexpected return code %d!\n", RetCode);
	}

	SQLFreeStmt(lpStmt, SQL_DROP);
	return true;
ExitP:
	return false;
}
开发者ID:austinarmbruster,项目名称:o2jb,代码行数:85,代码来源:odbcsql.c


注:本文中的HandleError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。