void LuaUtils::CallMethod(std::string name, int numArgs, int numRets) { if(!lua_state) { Initialise(); } lua_getglobal(lua_state, name.c_str()); if(!lua_isfunction(lua_state, stackTop)) { //Error SetErrorCode(Lua_Error::Method_Not_Registered); return; } else { int err = lua_pcall(lua_state, numArgs, numRets, 0); if(err) { if(err = LUA_ERRRUN) { SetErrorCode(Lua_Error::Run_Time_Error); } if(err == LUA_ERRERR) { SetErrorCode(Lua_Error::Error_Handle_Error); } } } }
int wxMysqlPreparedStatementWrapper::RunQuery() { MYSQL_BIND* pBoundParameters = m_Parameters.GetMysqlParameterBindings(); int nBindReturn = m_pInterface->GetMysqlStmtBindParam()(m_pStatement, pBoundParameters); if (nBindReturn != 0) { SetErrorCode(wxMysqlDatabase::TranslateErrorCode(m_pInterface->GetMysqlStmtErrno()(m_pStatement))); SetErrorMessage(ConvertFromUnicodeStream(m_pInterface->GetMysqlStmtError()(m_pStatement))); wxDELETEA(pBoundParameters); ThrowDatabaseException(); return wxDATABASE_QUERY_RESULT_ERROR; } else { int nReturn = m_pInterface->GetMysqlStmtExecute()(m_pStatement); if (nReturn != 0) { SetErrorCode(wxMysqlDatabase::TranslateErrorCode(m_pInterface->GetMysqlStmtErrno()(m_pStatement))); SetErrorMessage(ConvertFromUnicodeStream(m_pInterface->GetMysqlStmtError()(m_pStatement))); wxDELETEA(pBoundParameters); ThrowDatabaseException(); return wxDATABASE_QUERY_RESULT_ERROR; } } wxDELETEA(pBoundParameters); return m_pInterface->GetMysqlStmtAffectedRows()(m_pStatement); }
LWorkItem& LWorkItem::GetData(void* pData, size_t sDataLen) { if (m_pWorkContentBuf == NULL) { SetErrorCode(PACKET_BASE_ERROR_CODE_BUF_NOT_INIT); return *this; } if (pData == NULL) { SetErrorCode(PACKET_BASE_ERROR_CODE_OUTPUT_PARAM_WRONG); return *this; } if (sDataLen > m_usWorkContentBufLen) { SetErrorCode(PACKET_BASE_ERROR_CODE_DATA_TOO_LONG); return *this; } if (!CheckHaveEnoughData(sDataLen)) { SetErrorCode(PACKET_BASE_ERROR_CODE_DATA_NOT_ENOUGH); } else { // 拷贝数据到缓存中 memcpy(pData, m_pWorkContentBuf + m_usReadPos, sDataLen); m_usReadPos += sDataLen; } return *this; }
wxDatabaseResultSet* wxMysqlPreparedStatementWrapper::RunQueryWithResults() { wxMysqlPreparedStatementResultSet* pResultSet = NULL; MYSQL_BIND* pBoundParameters = m_Parameters.GetMysqlParameterBindings(); if (m_pInterface->GetMysqlStmtBindParam()(m_pStatement, pBoundParameters)) { SetErrorCode(wxMysqlDatabase::TranslateErrorCode(m_pInterface->GetMysqlStmtErrno()(m_pStatement))); SetErrorMessage(ConvertFromUnicodeStream(m_pInterface->GetMysqlStmtError()(m_pStatement))); wxDELETEA(pBoundParameters); ThrowDatabaseException(); return NULL; } else { if (m_pInterface->GetMysqlStmtExecute()(m_pStatement) != 0) { SetErrorCode(wxMysqlDatabase::TranslateErrorCode(m_pInterface->GetMysqlStmtErrno()(m_pStatement))); SetErrorMessage(ConvertFromUnicodeStream(m_pInterface->GetMysqlStmtError()(m_pStatement))); wxDELETEA(pBoundParameters); ThrowDatabaseException(); return NULL; } else { pResultSet = new wxMysqlPreparedStatementResultSet(m_pInterface, m_pStatement); if (pResultSet) pResultSet->SetEncoding(GetEncoding()); } } wxDELETEA(pBoundParameters);; return pResultSet; }
LWorkItem& LWorkItem::AddData(void* pData, size_t sDataLen) { if (m_pWorkContentBuf == NULL) { SetErrorCode(PACKET_BASE_ERROR_CODE_BUF_NOT_INIT); return *this; } if (pData == NULL) { SetErrorCode(PACKET_BASE_ERROR_CODE_INPUT_PARAM_WRONG); return *this; } if (sDataLen >= m_usWorkContentBufLen) { SetErrorCode(PACKET_BASE_ERROR_CODE_DATA_TOO_LONG); return *this; } if (!CheckHaveEnoughBuf((unsigned short)sDataLen)) { SetErrorCode(PACKET_BASE_ERROR_CODE_DATA_TOO_LONG); } else { memcpy(m_pWorkContentBuf + m_usWritePos, pData, sDataLen); m_usWritePos += sDataLen; } return *this; }
void LuaUtils::RegisterMethod(int (*pMethod)(lua_State*), std::string name) { if(!lua_state) { Initialise(); } //Check if it is already registered lua_getglobal(lua_state, name.c_str()); if(lua_iscfunction(lua_state, stackTop)) { //Methods is already registered return; } else { //Register the method lua_register(lua_state, name.c_str(), pMethod); lua_getglobal(lua_state, name.c_str()); if(lua_iscfunction(lua_state, stackTop)) { //No error SetErrorCode(Lua_Error::None); return; } else { //We have an error SetErrorCode(Lua_Error::Method_Registration_Failed); return; } } }
DatabaseResultSet* PostgresPreparedStatement::RunQueryWithResults() { for (unsigned int i=0; i<(m_Statements.size()-1); i++) { m_Statements[i].RunQuery(); if (m_Statements[i].GetErrorCode() != DATABASE_LAYER_OK) { SetErrorCode(m_Statements[i].GetErrorCode()); SetErrorMessage(m_Statements[i].GetErrorMessage()); ThrowDatabaseException(); return NULL; } } PostgresPreparedStatementWrapper* pLastStatement = &(m_Statements[m_Statements.size()-1]); DatabaseResultSet* pResultSet = pLastStatement->RunQueryWithResults(); if (pLastStatement->GetErrorCode() != DATABASE_LAYER_OK) { SetErrorCode(pLastStatement->GetErrorCode()); SetErrorMessage(pLastStatement->GetErrorMessage()); ThrowDatabaseException(); } LogResultSetForCleanup(pResultSet); return pResultSet; }
JSONReader::Token JSONReader::ParseStringToken() { Token token(Token::STRING, json_pos_, 1); wchar_t c = token.NextChar(); while('\0' != c) { if('\\' == c) { ++token.length; c = token.NextChar(); // 确保转义的正确. switch(c) { case 'x': if(!ReadHexDigits(token, 2)) { SetErrorCode(JSON_INVALID_ESCAPE, json_pos_+token.length); return Token::CreateInvalidToken(); } break; case 'u': if(!ReadHexDigits(token, 4)) { SetErrorCode(JSON_INVALID_ESCAPE, json_pos_+token.length); return Token::CreateInvalidToken(); } break; case '\\': case '/': case 'b': case 'f': case 'n': case 'r': case 't': case 'v': case '"': break; default: SetErrorCode(JSON_INVALID_ESCAPE, json_pos_+token.length); return Token::CreateInvalidToken(); } } else if('"' == c) { ++token.length; return token; } ++token.length; c = token.NextChar(); } return Token::CreateInvalidToken(); }
void FirebirdDatabaseLayer::InterpretErrorCodes() { //wxLogDebug(_("FirebirdDatabaseLayer::InterpretErrorCodes()")); long nSqlCode = m_pInterface->GetIscSqlcode()(*(ISC_STATUS_ARRAY*)m_pStatus); SetErrorMessage(FirebirdDatabaseLayer::TranslateErrorCodeToString(m_pInterface, nSqlCode, *(ISC_STATUS_ARRAY*)m_pStatus)); if (nSqlCode < -900) // Error codes less than -900 indicate that it wasn't a SQL error but an ibase system error { SetErrorCode(FirebirdDatabaseLayer::TranslateErrorCode(*((ISC_STATUS_ARRAY*)m_pStatus)[1])); } else { SetErrorCode(FirebirdDatabaseLayer::TranslateErrorCode(nSqlCode)); } }
Value* JSONReader::JsonToValue(const std::string& json, bool check_root, bool allow_trailing_comma) { // 输入必须是UTF-8编码. if(!IsStringUTF8(json.c_str())) { error_code_ = JSON_UNSUPPORTED_ENCODING; return NULL; } // 从UTF8到wstring的转换会移除空字节(好事). std::wstring json_wide(UTF8ToWide(json)); start_pos_ = json_wide.c_str(); // 当输入的JSON字符串开头有UTF-8的Byte-Order-Mark(0xEF, 0xBB, 0xBF), // UTF8ToWide()函数会把它转换成BOM(U+FEFF). 为防止JSONReader::BuildValue() // 函数把它当成非法字符而返回NULL, 如果存在Unicode的BOM则先跳过. if(!json_wide.empty() && start_pos_[0]==0xFEFF) { ++start_pos_; } json_pos_ = start_pos_; allow_trailing_comma_ = allow_trailing_comma; stack_depth_ = 0; error_code_ = JSON_NO_ERROR; scoped_ptr<Value> root(BuildValue(check_root)); if(root.get()) { if(ParseToken().type == Token::END_OF_INPUT) { return root.release(); } else { SetErrorCode(JSON_UNEXPECTED_DATA_AFTER_ROOT, json_pos_); } } // "语法错误". if(error_code_ == 0) { SetErrorCode(JSON_SYNTAX_ERROR, json_pos_); } return NULL; }
wxMysqlPreparedStatementParameter::wxMysqlPreparedStatementParameter(MYSQL_BIND* pBind, MYSQL_FIELD* pField) : wxDatabaseErrorReporter() { m_pBind = pBind; m_pBind->is_null = &m_bIsNull; // Set the binding properties m_pBind->buffer_type = pField->type; m_pBind->buffer_length = pField->length + 1; //int nType = m_pBind->buffer_type; //if (nType == MYSQL_TYPE_STRING || nType == MYSQL_TYPE_VAR_STRING || nType == MYSQL_TYPE_BLOB // || nType == MYSQL_TYPE_TINY_BLOB || nType == MYSQL_TYPE_MEDIUM_BLOB || nType == MYSQL_TYPE_LONG_BLOB) //{ //wxLogDebug(_("Allocating %ld bytes in the MYSQL_BIND buffer\n"), pField->length); void* pBuffer = m_Data.bufferValue.GetWriteBuf(m_pBind->buffer_length); if (pBuffer == 0) { SetErrorCode(wxMysqlDatabase::TranslateErrorCode(0)); SetErrorMessage(_("Error allocating buffer")); ThrowDatabaseException(); } m_pBind->buffer = pBuffer; ClearBuffer(); // } // else // { // pCurrentBinding->buffer = malloc(1); // } int nType = m_pBind->buffer_type; if (nType == MYSQL_TYPE_BLOB || nType == MYSQL_TYPE_TINY_BLOB || nType == MYSQL_TYPE_MEDIUM_BLOB || nType == MYSQL_TYPE_LONG_BLOB) m_pBind->length = &m_Data.nBufferLength; }
wxDatabaseResultSet* wxSqlitePreparedStatement::RunQueryWithResults() { ResetErrorCodes(); if (m_Statements.size() > 1) { for (unsigned int i=0; i<m_Statements.size()-1; i++) { int nReturn = sqlite3_step(m_Statements[i]); if (nReturn != SQLITE_ROW) sqlite3_reset(m_Statements[i]); if ((nReturn != SQLITE_ROW) && (nReturn != SQLITE_DONE)) { wxLogError(_("Error with RunQueryWithResults\n")); SetErrorCode(wxSqliteDatabase::TranslateErrorCode(nReturn)); SetErrorMessage(ConvertFromUnicodeStream(sqlite3_errmsg(m_pDatabase))); ThrowDatabaseException(); return NULL; } } } // Work off the assumption that only the last statement will return result wxSqliteResultSet* pResultSet = new wxSqliteResultSet(this); if (pResultSet) pResultSet->SetEncoding(GetEncoding()); LogResultSetForCleanup(pResultSet); return pResultSet; }
int wxSqlitePreparedStatement::RunQuery() { ResetErrorCodes(); wxSqliteStatementVector::iterator start = m_Statements.begin(); wxSqliteStatementVector::iterator stop = m_Statements.end(); while (start != stop) { int nReturn = sqlite3_step((sqlite3_stmt*)(*start)); if (nReturn != SQLITE_ROW) sqlite3_reset((sqlite3_stmt*)(*start)); if ((nReturn != SQLITE_ROW) && (nReturn != SQLITE_DONE)) { SetErrorCode(wxSqliteDatabase::TranslateErrorCode(nReturn)); SetErrorMessage(ConvertFromUnicodeStream(sqlite3_errmsg(m_pDatabase))); ThrowDatabaseException(); return wxDATABASE_QUERY_RESULT_ERROR; } start++; } return sqlite3_changes(m_pDatabase); }
FirebirdDatabaseLayer::FirebirdDatabaseLayer(const wxString& strServer, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword) : DatabaseLayer() { m_pDatabase = NULL; m_pTransaction = NULL; m_pStatus = new ISC_STATUS_ARRAY(); #ifndef DONT_USE_DYNAMIC_DATABASE_LAYER_LINKING m_pInterface = new FirebirdInterface(); if (!m_pInterface->Init()) { SetErrorCode(DATABASE_LAYER_ERROR_LOADING_LIBRARY); SetErrorMessage(wxT("Error loading Firebird library")); ThrowDatabaseException(); return; } #endif m_strServer = strServer; m_strUser = strUser; m_strPassword = strPassword; m_strRole = wxEmptyString; Open(strDatabase); }
//void wxOdbcDatabase::InterpretErrorCodes( long nCode, SQLHSTMT stmth_ptr ) void wxOdbcDatabase::InterpretErrorCodes( long WXUNUSED(nCode), void* stmth_ptr ) { wxLogDebug(_("wxOdbcDatabase::InterpretErrorCodes()\n")); //if ((nCode != SQL_SUCCESS) ) // && (nCode != SQL_SUCCESS_WITH_INFO)) //{ SQLINTEGER iNativeCode; SQLTCHAR strState[ERR_STATE_LEN]; SQLTCHAR strBuffer[ERR_BUFFER_LEN]; SQLSMALLINT iMsgLen; memset(strState, 0, ERR_STATE_LEN*sizeof(SQLTCHAR)); memset(strBuffer, 0, ERR_BUFFER_LEN*sizeof(SQLTCHAR)); if (stmth_ptr) m_pInterface->GetSQLGetDiagRec()(SQL_HANDLE_STMT, (SQLHSTMT)stmth_ptr, 1, strState, &iNativeCode, strBuffer, ERR_BUFFER_LEN, &iMsgLen); else m_pInterface->GetSQLGetDiagRec()(SQL_HANDLE_DBC, (SQLHDBC)m_sqlHDBC, 1, strState, &iNativeCode, strBuffer, ERR_BUFFER_LEN, &iMsgLen); SetErrorCode((int)iNativeCode); SetErrorMessage(ConvertFromUnicodeStream((char*)strBuffer)); //AML //AML SetErrorMessage(wxString((wxChar*)strBuffer)); //} }
wxDatabaseResultSet* wxOdbcDatabase::RunQueryWithResults(const wxString& strQuery) { ResetErrorCodes(); wxOdbcPreparedStatement* pStatement = (wxOdbcPreparedStatement*)PrepareStatement( strQuery, true ); if ( pStatement ) { try { pStatement->SetOneTimer(true); wxDatabaseResultSet* pResults = pStatement->RunQueryWithResults(false /*false for "Don't log this result set for cleanup*/); LogResultSetForCleanup(pResults); return pResults; } catch (...) { SetErrorCode(pStatement->GetErrorCode()); SetErrorMessage(pStatement->GetErrorMessage()); wxDELETE( pStatement ); ThrowDatabaseException(); return NULL; } } else return NULL; }
// ctor OTLResultSet::OTLResultSet(otl_stream *otlstream, bool bManageStatement /*= false*/) { try { m_pResultSet = otlstream; m_bManageStatement = bManageStatement; m_readIt.attach(*m_pResultSet); otl_column_desc* otldesc = m_pResultSet->describe_select(m_colCount); int nCounter = 1; for (int i = 0; i < m_colCount; i++) { otl_column_desc *newItem = new otl_column_desc(); *newItem = otldesc[i]; m_otldesc.push_back(newItem); wxString strField = ConvertFromUnicodeStream(otldesc[i].name); m_FieldLookupMap[strField.Upper()] = nCounter; nCounter++; } } catch (otl_exception& e) { SetErrorCode(OTLDatabaseLayer::TranslateErrorCode(e.code)); SetErrorMessage(ConvertFromUnicodeStream((char*)e.msg)); ThrowDatabaseException(); } }
bool SqliteResultSet::Next() { if (m_pSqliteStatement == NULL) m_pSqliteStatement = m_pStatement->GetLastStatement(); int nReturn = sqlite3_step(m_pSqliteStatement); if (nReturn != SQLITE_ROW) sqlite3_reset(m_pSqliteStatement); if ((nReturn != SQLITE_ROW) && (nReturn != SQLITE_DONE)) { wxLogError(_("Error with RunQueryWithResults\n")); SetErrorCode(SqliteDatabaseLayer::TranslateErrorCode(nReturn)); #if SQLITE_VERSION_NUMBER>=3002002 // sqlite3_db_handle wasn't added to the SQLite3 API until version 3.2.2 SetErrorMessage(ConvertFromUnicodeStream(sqlite3_errmsg(sqlite3_db_handle(m_pSqliteStatement)))); #else SetErrorMessage(_("Unknown error advancing result set")); #endif ThrowDatabaseException(); return false; } return (nReturn == SQLITE_ROW); }
int wxOdbcDatabase::RunQuery( const wxString& strQuery, bool bParseQuery ) { ResetErrorCodes(); //wxPrintf("Running: '%s'\n", strQuery.c_str()); wxOdbcPreparedStatement* pStatement = (wxOdbcPreparedStatement*)PrepareStatement( strQuery, bParseQuery ); if ( pStatement ) { try { int nRows = pStatement->RunQuery(); wxDELETE( pStatement ); return nRows; } catch (...) { SetErrorCode(pStatement->GetErrorCode()); SetErrorMessage(pStatement->GetErrorMessage()); wxDELETE( pStatement ); ThrowDatabaseException(); return wxDATABASE_QUERY_RESULT_ERROR; } } else return wxDATABASE_QUERY_RESULT_ERROR; }
// query database int wxPostgresDatabase::RunQuery(const wxString& strQuery, bool WXUNUSED(bParseQuery)) { // PostgreSQL takes care of parsing the queries itself so bParseQuery is ignored ResetErrorCodes(); wxCharBuffer sqlBuffer = ConvertToUnicodeStream(strQuery); PGresult* pResultCode = m_pInterface->GetPQexec()((PGconn*)m_pDatabase, sqlBuffer); if ((pResultCode == NULL) || (m_pInterface->GetPQresultStatus()(pResultCode) != PGRES_COMMAND_OK)) { SetErrorCode(wxPostgresDatabase::TranslateErrorCode(m_pInterface->GetPQresultStatus()(pResultCode))); SetErrorMessage(ConvertFromUnicodeStream(m_pInterface->GetPQerrorMessage()((PGconn*)m_pDatabase))); m_pInterface->GetPQclear()(pResultCode); ThrowDatabaseException(); return wxDATABASE_QUERY_RESULT_ERROR; } else { wxString rowsAffected = ConvertFromUnicodeStream(m_pInterface->GetPQcmdTuples()(pResultCode)); long rows = -1; rowsAffected.ToLong(&rows); m_pInterface->GetPQclear()(pResultCode); return (int)rows; } }
// query database int OTLDatabaseLayer::RunQuery(const wxString& strQuery, bool bParseQuery) { try { wxArrayString QueryArray; if (bParseQuery) QueryArray = ParseQueries(strQuery); else QueryArray.push_back(strQuery); wxArrayString::iterator start = QueryArray.begin(); wxArrayString::iterator stop = QueryArray.end(); while (start != stop) { wxCharBuffer sqlBuffer = ConvertToUnicodeStream((*start)); std::string strSQL(sqlBuffer); strSQL = RemoveLastSemiColon(strSQL); //wxPrintf(_("RunQuery: '%s'\n"), strSQL.c_str()); otl_stream otlStream(1,strSQL.c_str(),m_database); start++; } } catch (otl_exception& e) { SetErrorCode(OTLDatabaseLayer::TranslateErrorCode(e.code)); SetErrorMessage(ConvertFromUnicodeStream((char*)e.msg)); ThrowDatabaseException(); return false; } return true; }
void CClientConnection::OnRawData(_U32 len, const _U8* data) { _U16 pkglen; while(len>0 && GetClient()->GetClientApp()->IsEnableTick()) { _U32 copylen = len; if(m_nRecvBuffLen+copylen>m_nRecvBuffSize) copylen = m_nRecvBuffSize - m_nRecvBuffLen; memcpy(m_pRecvBuff+m_nRecvBuffLen, data, copylen); m_nRecvBuffLen += copylen; len -= copylen; data = data + copylen; while(m_nRecvBuffLen>=sizeof(pkglen)) { pkglen = *((const _U16*)m_pRecvBuff); if(pkglen>m_nRecvBuffSize-sizeof(pkglen)) { SetErrorCode(CClient::ERRCODE_UNKOWN); Disconnect(); return; } if(pkglen+sizeof(pkglen)>m_nRecvBuffLen) break; ProcessPacket(pkglen, m_pRecvBuff+sizeof(pkglen)); _U32 ulen = pkglen + sizeof(pkglen); m_nRecvBuffLen -= ulen; memmove(m_pRecvBuff, m_pRecvBuff+ulen, m_nRecvBuffLen); } } }
bool CClientConnection::Login(const char* pUrl, const CClientLoginMethod* pMethod) { ASOCK_ADDR sa; if(!sock_str2addr(pUrl, &sa)) { m_nErrCode = CClient::ERRCODE_UNKOWN; return false; } if(pMethod->GetType()!=CClientLoginMethodByToken::METHOD_TYPE) { m_nErrCode = CClient::ERRCODE_UNKOWN; return false; } const Zion::String& token = ((const CClientLoginMethodByToken*)pMethod)->GetToken(); m_nErrCode = CClient::ERRCODE_SUCCESSED; _U16 len = (_U16)token.size()+1; *((_U16*)(m_LoginData)) = len; memcpy(m_LoginData+sizeof(_U16), token.c_str(), len); m_nLoginDataSize = sizeof(_U16) + len; m_nState = CClient::STATE_LOGINING; if(!Connect(sa)) { m_nState = CClient::STATE_FAILED; SetErrorCode(CClient::ERRCODE_NETWORK); return false; } return true; }
void CClientConnection::OnRawDisconnected() { if(m_bNeedRedirect) { m_bNeedRedirect = false; if(!Connect(m_saRedirectAddr)) { m_nState = CClient::STATE_FAILED; m_nErrCode = CClient::ERRCODE_NETWORK; return; //connect session failed } } else { ZION_ASSERT(m_nState!=CClient::STATE_NA); if(m_nState==CClient::STATE_LOGINED) { m_nState = CClient::STATE_NA; GetClient()->GetClientApp()->QueueDisconnected(GetClient()); } else { SetErrorCode(CClient::ERRCODE_NETWORK); m_nState = CClient::STATE_FAILED; GetClient()->GetClientApp()->QueueLoginFailed(GetClient()); } } }
// EPOC default constructor void CSuplServer::ConstructL() { DEBUG_TRACE("CSuplServer::ConstructL", __LINE__) // Settings TInt keyValue; TInt err = KErrNone; CRepository* repository = NULL; TRAP(err, repository = CRepository::NewL(KCRUidSuplConfiguration)); CleanupStack::PushL(repository); if (err != KErrNone) { SetErrorCode(err); } if (err == KErrNone) { TInt ret = repository->Get(KSuplConfigurationShutdownTimer, keyValue); if (keyValue <= 0) { DEBUG_TRACE("Invalid value in configuratin file for shutdown timer, using default value of 2 sec", __LINE__) iServerShutdownDelay = KSuplServerShutdownTimer; } else iServerShutdownDelay = keyValue; } else iServerShutdownDelay = KSuplServerShutdownTimer; CleanupStack::PopAndDestroy(repository); // Initialize Network Initiated registry iSuplNetInitRegistry=CSuplNetInitiatedRegistry::NewL(); // Shutdown timer iShutdown = CSuplServerDelayedShutdown::NewL(*this); // Session manager iSessionManager = CSuplSessionManager::NewL(); iServerStartup = CSuplServerStartupRequest::NewL(this,*iSessionManager); iDeInitRequest = CSuplServerDeInitRequest::NewL(*iSessionManager); iConnectFlag=FALSE; SetErrorCode(KErrNone); iNumNetMessages=0; iIpcSessionCount = 0; StartL(KSuplServerName); }
DatabaseResultSet* SqliteDatabaseLayer::RunQueryWithResults(const wxString& strQuery) { ResetErrorCodes(); if (m_pDatabase != NULL) { wxArrayString QueryArray = ParseQueries(strQuery); for (unsigned int i=0; i<(QueryArray.size()-1); i++) { char* szErrorMessage = NULL; wxString strErrorMessage = _(""); wxCharBuffer sqlBuffer = ConvertToUnicodeStream(QueryArray[i]); int nReturn = sqlite3_exec((sqlite3*)m_pDatabase, sqlBuffer, 0, 0, &szErrorMessage); if (szErrorMessage != NULL) { SetErrorCode(SqliteDatabaseLayer::TranslateErrorCode(sqlite3_errcode((sqlite3*)m_pDatabase))); strErrorMessage = ConvertFromUnicodeStream(szErrorMessage); sqlite3_free(szErrorMessage); return NULL; } if (nReturn != SQLITE_OK) { SetErrorCode(SqliteDatabaseLayer::TranslateErrorCode(sqlite3_errcode((sqlite3*)m_pDatabase))); SetErrorMessage(strErrorMessage); ThrowDatabaseException(); return NULL; } } // Create a Prepared statement for the last SQL statement and get a result set from it SqlitePreparedStatement* pStatement = (SqlitePreparedStatement*)PrepareStatement(QueryArray[QueryArray.size()-1], false); SqliteResultSet* pResultSet = new SqliteResultSet(pStatement, true); if (pResultSet) pResultSet->SetEncoding(GetEncoding()); LogResultSetForCleanup(pResultSet); return pResultSet; } else { return NULL; } }
void TdsPreparedStatement::SetErrorInformationFromDatabaseLayer() { TdsDatabaseLayer* pDatabaseLayer = TdsDatabaseLayer::LookupTdsLayer(m_pDatabase->tds_ctx); if (pDatabaseLayer != NULL) { SetErrorCode(pDatabaseLayer->GetErrorCode()); SetErrorMessage(pDatabaseLayer->GetErrorMessage()); } }
void CErrorMessage::SetErrorCodeFormatted_VL(EError err, PSZUC pszuFmtTemlate, va_list vlArgs) { Assert(pszuFmtTemlate != NULL); SetErrorCode(err); // Make sure m_strErrorDescription is empty. Assert(m_strErrorDescription.FIsEmptyString()); // If this happens, it is because err is the same as m_err, and the method SetErrorCode() did nothing. // Format the new error m_strErrorDescription.Format_VL((PSZAC)pszuFmtTemlate, vlArgs); }
// open database bool wxPostgresDatabase::Open() { ResetErrorCodes(); wxCharBuffer serverCharBuffer; const char* pHost = NULL; wxCharBuffer pDatabaseBuffer = ConvertToUnicodeStream(m_strDatabase); const char* pDatabase = pDatabaseBuffer; wxCharBuffer userCharBuffer; const char* pUser = NULL; wxCharBuffer passwordCharBuffer; const char* pPassword = NULL; const char* pTty = NULL; const char* pOptions = NULL; wxCharBuffer portCharBuffer; const char* pPort = NULL; if (m_strServer != _("localhost") && m_strServer != wxT("")) { serverCharBuffer = ConvertToUnicodeStream(m_strServer); pHost = serverCharBuffer; } if (m_strUser != wxT("")) { userCharBuffer = ConvertToUnicodeStream(m_strUser); pUser = userCharBuffer; } if (m_strPassword != wxT("")) { passwordCharBuffer = ConvertToUnicodeStream(m_strPassword); pPassword = passwordCharBuffer; } if (m_strPort != wxT("")) { portCharBuffer = ConvertToUnicodeStream(m_strPort); pPort = portCharBuffer; } m_pDatabase = m_pInterface->GetPQsetdbLogin()(pHost, pPort, pOptions, pTty, pDatabase, pUser, pPassword); if (m_pInterface->GetPQstatus()((PGconn*)m_pDatabase) == CONNECTION_BAD) { SetErrorCode(wxPostgresDatabase::TranslateErrorCode(m_pInterface->GetPQstatus()((PGconn*)m_pDatabase))); SetErrorMessage(ConvertFromUnicodeStream(m_pInterface->GetPQerrorMessage()((PGconn*)m_pDatabase))); ThrowDatabaseException(); return false; } m_pInterface->GetPQsetClientEncoding()((PGconn*)m_pDatabase, "UTF-8"); wxCSConv conv((const wxChar*)(m_pInterface->GetPQencodingToChar()(m_pInterface->GetPQclientEncoding()((PGconn*)m_pDatabase)))); SetEncoding(&conv); return true; }
PERROR MakeKeyMaterial( FRAME *frame, UBYTE *passphrase, struct PPTBase *PPTBase ) { ROWPTR cp, tmprow; WORD row; struct ExecBase *SysBase = PPTBase->lb_Sys; SHA_INFO sha = {0}; PERROR res = PERR_OK; sha_init( &sha ); InitProgress(frame,"Building key...", 0, frame->pix->height ); /* * First, use the passphrase for the key. */ if( strlen(passphrase) > 0 ) sha_update( &sha, passphrase, strlen(passphrase) ); if( tmprow = AllocVec( frame->pix->bytes_per_row, 0L ) ) { for( row = 0; row < frame->pix->height; row++ ) { WORD col; cp = GetPixelRow( frame, row ); if( Progress( frame, row ) ) { res = PERR_BREAK; break; } for( col = 0; col < frame->pix->bytes_per_row; col++ ) { /* Use only significant bytes */ tmprow[col] = cp[col] & 0xFE; } sha_update( &sha, tmprow, frame->pix->bytes_per_row ); } // Use the passphrase again (why?) if( strlen(passphrase) > 0 ) sha_update( &sha, passphrase, strlen(passphrase) ); FinishProgress( frame ); sha_final( &sha ); memcpy( key, &sha.digest[0], SHA_DIGESTSIZE ); D(sha_print( &sha ) ); FreeVec( tmprow ); } else { SetErrorCode( frame, PERR_OUTOFMEMORY ); res = PERR_OUTOFMEMORY; } return res; }