std::wstring DataMember::typeSpecial() const { std::wstring ret; CComPtr<IDiaSymbol> type; checkResult(sym()->get_type(&type)); if(!!type) { ret += expandTypeSpecial(type); } return ret; }
void SudokuBox::undo() { auto it = m_vctOps.rbegin(); if (it == m_vctOps.rend()) return; setNumber(it->pos, it->oldValue); m_vctOps.pop_back(); checkResult(); refreshErrorTipsLayer(); }
int main() { int i = 0, result; for (i = 0; i < 10; i++) { result = isDivBy11_2(tests[i].p, tests[i].k); checkResult(result, tests[i].result); } getchar(); return 0; }
int main() { int i, result; for (i = 0; i < 12; i++) { result = areIsoMorphic(tests[i].a, tests[i].b); checkResult(result, tests[i].expected_result); } getchar(); return 0; }
FileSystemResultCode serialize(T *data, i64 len, SerializingState *state) { usize numItems; if (state->isWriting) { numItems = fwrite(data, (usize)len * sizeof(*data), 1, state->f); } else { numItems = fread(data, (usize)len * sizeof(*data), 1, state->f); } CO_ASSERT(numItems == 1); return checkResult(numItems, state); }
std::wstring DataMember::type() const { std::wstring ret; CComPtr<IDiaSymbol> type; checkResult(sym()->get_type(&type)); if(!!type) { ret += expandType(type,getName());//name needed for function defs } return ret; }
sqlite_stmt Sqlite3Database::prepareStatement(const std::string &stmt) { sqlite3_stmt *stmt_ptr; // connection, statement string, length, OUT stmt pointer, ignored "unused // part of stmt" int res = sqlite3_prepare_v2(connection_.ptr(), stmt.c_str(), static_cast<int>(stmt.size()), &stmt_ptr, nullptr); checkResult(res, SQLITE_OK, "Error preparing statement " + stmt, true); return sqlite_stmt(stmt_ptr); }
HRESULT STDMETHODCALLTYPE CAAFEssenceFileContainer::CreateEssenceStream (const aafCharacter * pName, aafMobID_constptr pMobID, IAAFEssenceStream ** ppEssenceStream) { HRESULT hr = S_OK; CAAFEssenceFileStream *pEssenceFileStream = NULL; // Validate return argument. if (NULL == ppEssenceStream) return E_INVALIDARG; try { // First see if the stream has already been opened. checkResult(CheckExistingStreams(pName, openNew)); // Create file stream object. pEssenceFileStream = CAAFEssenceFileStream::CreateFileStream(this); checkExpression(NULL != pEssenceFileStream, E_OUTOFMEMORY); // Temporarily reuse code for obsolete CAAFEssenceFileScream checkResult(pEssenceFileStream->Create(pName, pMobID)); // Return the interface to the stream to the caller. checkResult(pEssenceFileStream->QueryInterface(IID_IAAFEssenceStream, (void **)ppEssenceStream)); } catch (HRESULT& rResult) { hr = rResult; } // // If an error occurs the following release will delete the object. if (pEssenceFileStream) pEssenceFileStream->Release(); return hr; }
int EasySocket::send(const void *buf, size_t nbyte) { if(!checkSocket(m_replySocket)) return -1; int res = 0; #ifdef _WIN32 res = ::send(m_replySocket, (const char*)buf, (int)nbyte, 0); #else res = ::write(m_replySocket,buf,nbyte); #endif checkResult(res); return res; }
Object c_Gmagick::t_readimageblob(CStrRef blob, CStrRef filename) { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::readimageblob); if (blob->size() == 0) { throwException("Zero size image string passed", BlobError); } int result = MagickReadImageBlob(magick_wand, (const unsigned char *)blob->data(), blob->size()); checkResult(result); const char * c_filename; if (filename.isNull()) { c_filename = ""; } else { c_filename = filename.data(); } result = MagickSetImageFilename(magick_wand, c_filename); checkResult(result); return this; }
int BMA180::getRegValue(int adr) { unsigned char tx[1]; unsigned char rx[1]; tx[0] = adr; i2cWrite(address, tx, 1); int result = i2cRead(address, rx, 1); checkResult(result); return (int)rx[0]; }
int main() { int i, result; for (i = 0; i < 9; i++) { rotate(tests[i].a, tests[i].length, tests[i].k, tests[i].falg); result = binarySearch(tests[i].a, tests[i].length,tests[i].key); checkResult(result, tests[i].expected_result); } getchar(); return 0; }
int SecureSocket::secureConnect(int socket) { createSSL(); // attach the socket descriptor SSL_set_fd(m_ssl->m_ssl, socket); LOG((CLOG_DEBUG2 "connecting secure socket")); int r = SSL_connect(m_ssl->m_ssl); static int retry; checkResult(r, retry); if (isFatal()) { LOG((CLOG_ERR "failed to connect secure socket")); return -1; } // If we should retry, not ready and return 0 if (retry > 0) { LOG((CLOG_DEBUG2 "retry connect secure socket")); m_secureReady = false; return 0; } // No error, set ready, process and return ok m_secureReady = true; if (verifyCertFingerprint()) { LOG((CLOG_INFO "connected to secure socket")); if (!showCertificate()) { disconnect(); return -1;// Cert fail, error } } else { LOG((CLOG_ERR "failed to verify server certificate fingerprint")); disconnect(); return -1; // Fingerprint failed, error } LOG((CLOG_DEBUG2 "connected secure socket")); const SSL_CIPHER* cipher = SSL_get_current_cipher(m_ssl->m_ssl); if(cipher != NULL) { char * cipherVersion = SSL_CIPHER_description(cipher, NULL, 0); if(cipherVersion != NULL) { LOG((CLOG_INFO "%s", cipherVersion)); OPENSSL_free(cipherVersion); } } return 1; }
void BMA180::setRegValue(int regAdr, int val, int maskPreserve) { unsigned char tx[2]; tx[0] = regAdr; int preserve=getRegValue(regAdr); int orgval=preserve & maskPreserve; tx[1] = orgval|val; int result = i2cWrite(address, tx, 2); checkResult(result); }
Object c_Gmagick::t_newimage(int64 columns, int64 rows, CStrRef background, CStrRef format) { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::newimage); char xc_str[MAX_BUFFER_SIZE]; if (background.empty()) { throwException("The color must not be empty", ImageError); } snprintf((char *)&xc_str, MAX_BUFFER_SIZE, "xc:%s", background.data()); int result = MagickReadImage(magick_wand, xc_str); checkResult(result); result = MagickScaleImage(magick_wand, columns, rows); checkResult(result); if (format.size() > 0) { result = MagickSetImageFormat(magick_wand, format.data()); checkResult(result); } return this; }
bool BrainSoundFMODEX::addSample(const char* file, int id) { if(m_sounds.find(id) == m_sounds.end()) { FMOD::Sound* sound = NULL; if(checkResult(m_system->createSound(file, FMOD_SOFTWARE, 0, &sound))) { m_sounds[id] = sound; return true; } } return false; }
int SecureSocket::secureConnect(int socket) { createSSL(); // attach the socket descriptor SSL_set_fd(m_ssl->m_ssl, socket); LOG((CLOG_DEBUG2 "connecting secure socket")); int r = SSL_connect(m_ssl->m_ssl); static int retry; checkResult(r, retry); if (isFatal()) { LOG((CLOG_ERR "failed to connect secure socket")); retry = 0; return -1; } // If we should retry, not ready and return 0 if (retry > 0) { LOG((CLOG_DEBUG2 "retry connect secure socket")); m_secureReady = false; ARCH->sleep(s_retryDelay); return 0; } retry = 0; // No error, set ready, process and return ok m_secureReady = true; if (verifyCertFingerprint()) { LOG((CLOG_INFO "connected to secure socket")); if (!showCertificate()) { disconnect(); return -1;// Cert fail, error } } else { LOG((CLOG_ERR "failed to verify server certificate fingerprint")); disconnect(); return -1; // Fingerprint failed, error } LOG((CLOG_DEBUG2 "connected secure socket")); if (CLOG->getFilter() >= kDEBUG1) { showSecureCipherInfo(); } showSecureConnectInfo(); return 1; }
void RenderingSystemOgl::setRasterizationTechnique( RasterizationTechnique::Pointer technique ) { storm_assert( technique ); if( _rasterizationTechnique == technique ) return; auto nativeTechnique = std::static_pointer_cast< RasterizationTechniqueOgl >( technique ); GLenum cullMode = nativeTechnique->getCullMode(); GLenum fillMode = nativeTechnique->getFillMode(); const bool cullingEnabled = (cullMode != GL_NONE); setBooleanGlState( GL_CULL_FACE, cullingEnabled ); if( cullingEnabled ) { ::glFrontFace( GL_CW ); checkResult( "::glFrontFace" ); ::glCullFace( cullMode ); checkResult( "::glCullFace" ); } ::glPolygonMode( GL_FRONT_AND_BACK, fillMode ); checkResult( "::glPolygonMode" ); const auto &description = nativeTechnique->getDescription(); setBooleanGlState( GL_SCISSOR_TEST, description.rectangleClippingEnabled ); setBooleanGlState( GL_DEPTH_CLAMP, !description.depthClippingEnabled ); ::glPolygonOffset( static_cast<GLfloat>(description.slopeScaleDepthBias), static_cast<GLfloat>(description.depthBias) ); checkResult( "::glPolygonOffset" ); _rasterizationTechnique = technique; return; }
void RenderingSystemOgl::setOutputTechnique( OutputTechnique::Pointer technique ) { storm_assert( technique ); if( _outputTechnique == technique ) return; auto nativeTechnique = std::static_pointer_cast< OutputTechniqueOgl >( technique ); const auto &description = nativeTechnique->getNativeDescription(); const auto &depthTest = description.depthTest; const auto &stencilTest = description.stencilTest; setBooleanGlState( GL_DEPTH_TEST, depthTest.has_value() ); setBooleanGlState( GL_STENCIL_TEST, stencilTest.has_value() ); if( depthTest ) { ::glDepthFunc( depthTest->passCondition ); checkResult( "::glDepthFunc" ); } if( stencilTest ) { ::glStencilOpSeparate( GL_FRONT, stencilTest->algorithmForFrontFaces.operationOnStencilTestFail, stencilTest->algorithmForFrontFaces.operationOnDepthTestFail, stencilTest->algorithmForFrontFaces.operationOnDepthTestPass ); checkResult( "::glStencilOpSeparate" ); ::glStencilOpSeparate( GL_BACK, stencilTest->algorithmForBackFaces.operationOnStencilTestFail, stencilTest->algorithmForBackFaces.operationOnDepthTestFail, stencilTest->algorithmForBackFaces.operationOnDepthTestPass ); checkResult( "::glStencilOpSeparate" ); ::glStencilFuncSeparate( GL_FRONT, stencilTest->algorithmForFrontFaces.passCondition, stencilTest->referenceValue, stencilTest->mask ); checkResult( "::glStencilFuncSeparate" ); ::glStencilFuncSeparate( GL_BACK, stencilTest->algorithmForBackFaces.passCondition, stencilTest->referenceValue, stencilTest->mask ); checkResult( "::glStencilFuncSeparate" ); } ::glDepthMask( description.writeDepthValues ); checkResult( "::glDepthMask" ); _outputTechnique = technique; return; }
std::string RenderingSystemOgl::getDebugMessageLog() const { std::string log; auto getIntegerParameter = []( GLenum parameter ) { GLint parameterValue = 0; ::glGetIntegerv( parameter, ¶meterValue ); checkResult( "::glGetIntegerv" ); return parameterValue; }; if( getOpenGlSupportStatus().KHR_debug ) { GLint messageCount = getIntegerParameter( GL_DEBUG_LOGGED_MESSAGES ); while( messageCount-- ) { std::string message( getIntegerParameter(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH), 0 ); GLenum severity = 0; ::glGetDebugMessageLog( /* messageCount = */ 1, static_cast<GLsizei>(message.size()), nullptr, nullptr, nullptr, &severity, nullptr, &message[0] ); checkResult( "::glGetDebugMessageLog" ); // Replace the null character. message.back() = '\n'; if( severity != GL_DEBUG_SEVERITY_NOTIFICATION ) { log += message; } } } return log; }
void RenderingSystemOgl::renderMesh( Mesh::Pointer mesh, unsigned count ) { storm_assert( mesh ); auto nativeMesh = std::static_pointer_cast< MeshOgl >( mesh ); bindVertexArray( nativeMesh->getHandle() ); const auto &indexBufferDescription = mesh->getDescription().indexBuffer->getDescription(); storm_assert( indexBufferDescription.elementSize == 2 || indexBufferDescription.elementSize == 4 ); const GLuint primitiveRestartIndex = (indexBufferDescription.elementSize == 2) ? 0xffff : 0xffffffff; if( _primitiveRestartIndex != primitiveRestartIndex ) { _primitiveRestartIndex = primitiveRestartIndex; ::glPrimitiveRestartIndex( _primitiveRestartIndex ); } const GLenum primitiveTopology = nativeMesh->getPrimitiveTopology(); const GLsizei indexCount = static_cast<GLsizei>( indexBufferDescription.size / indexBufferDescription.elementSize ); const GLenum indexFormat = (indexBufferDescription.elementSize == 2) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; const GLvoid *indexOffset = nullptr; if( count == 1 ) { ::glDrawElements( primitiveTopology, indexCount, indexFormat, indexOffset ); checkResult( "::glDrawElements" ); } else { ::glDrawElementsInstanced( primitiveTopology, indexCount, indexFormat, indexOffset, count ); checkResult( "::glDrawElementsInstanced" ); } }
std::wstring expandTypeSpecial(CComPtr<IDiaSymbol> type) { std::wstring ret; if(!type) { return ret; } DWORD tag; checkResult(type->get_symTag(&tag)); if(SymTagPointerType == tag) { CComPtr<IDiaSymbol> pointee; checkResult(type->get_type(&pointee)); ret += expandTypeSpecial(pointee); } else if(SymTagUDT == tag) { UDT udt(type); ret += udt.getName(); } return ret; }
void COrthogonalArray::bosebush(int q, int k, int *n) { if (q%2) { throw std::runtime_error("This implementation of Bose-Bush only works for a number of levels equal to a power of 2"); } k = checkMaxColumns(k, 2*q); createGaloisField(2*q); m_A = matrix<int>(2*q*q, k); checkDesignMemory(); int result = oaconstruct::bosebush(m_gf, m_A, k); checkResult(result, 2*q*q, n); m_q = q; m_ncol=k; m_nrow=*n; }
std::wstring getKind(CComPtr<IDiaSymbol> sym) { std::wstring ret; DWORD kind = 0; checkResult(sym->get_udtKind(&kind)); switch(kind) { case UdtStruct: ret += L"struct"; break; case UdtClass: ret += L"class"; break; case UdtUnion: ret += L"union"; break; } return ret; }
void APIENTRY glTexStorage1D( GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width ) { for( GLsizei level = 0; level < levels; ++level ) { const PixelDescription pixelDescription = getCompatiblePixelDescription( internalFormat ); ::glTexImage1D( target, level, internalFormat, width, 0, pixelDescription.format, pixelDescription.type, nullptr ); checkResult( "::glTexImage1D" ); width = std::max( 1, (width / 2) ); } }
int SecureSocket::secureAccept(int socket) { createSSL(); // set connection socket to SSL state SSL_set_fd(m_ssl->m_ssl, socket); LOG((CLOG_DEBUG2 "accepting secure socket")); int r = SSL_accept(m_ssl->m_ssl); static int retry; checkResult(r, retry); if (isFatal()) { // tell user and sleep so the socket isn't hammered. LOG((CLOG_ERR "failed to accept secure socket")); LOG((CLOG_INFO "client connection may not be secure")); m_secureReady = false; ARCH->sleep(1); return -1; // Failed, error out } // If not fatal and no retry, state is good if (retry == 0) { m_secureReady = true; LOG((CLOG_INFO "accepted secure socket")); const SSL_CIPHER* cipher = SSL_get_current_cipher(m_ssl->m_ssl); if(cipher != NULL) { char * cipherVersion = SSL_CIPHER_description(cipher, NULL, 0); if(cipherVersion != NULL) { LOG((CLOG_INFO "%s", cipherVersion)); OPENSSL_free(cipherVersion); } } return 1; } // If not fatal and retry is set, not ready, and return retry if (retry > 0) { LOG((CLOG_DEBUG2 "retry accepting secure socket")); m_secureReady = false; return 0; } // no good state exists here LOG((CLOG_ERR "unexpected state attempting to accept connection")); return -1; }
/** * Testing check, examine * fetchPartialBodyPart */ void testRun3(imap4Client_t* in_pimap4Client) { int l_retCode = 0; char* out_pTagID = NULL; l_retCode = imap4_select(in_pimap4Client, "INBOX", &out_pTagID); checkResult(l_retCode); l_retCode = imap4_processResponses(in_pimap4Client); checkResult(l_retCode); imap4Tag_free(&out_pTagID); l_retCode = imap4_check(in_pimap4Client, &out_pTagID); checkResult(l_retCode); l_retCode = imap4_processResponses(in_pimap4Client); checkResult(l_retCode); imap4Tag_free(&out_pTagID); l_retCode = imap4_close(in_pimap4Client, &out_pTagID); checkResult(l_retCode); l_retCode = imap4_processResponses(in_pimap4Client); checkResult(l_retCode); imap4Tag_free(&out_pTagID); l_retCode = imap4_examine(in_pimap4Client, "INBOX", &out_pTagID); checkResult(l_retCode); l_retCode = imap4_processResponses(in_pimap4Client); checkResult(l_retCode); imap4Tag_free(&out_pTagID); l_retCode = imap4_close(in_pimap4Client, &out_pTagID); checkResult(l_retCode); l_retCode = imap4_processResponses(in_pimap4Client); checkResult(l_retCode); imap4Tag_free(&out_pTagID); }
// Adds or removes a ICC, IPTC, or generic profile from an image. // If the profile is NULL, it is removed from the image otherwise added. // Use a name of '*' and a profile of NULL to remove all profiles from the image. Object c_Gmagick::t_profileimage(CStrRef name, CStrRef profile) { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::profileimage); checkNotEmpty(); int result; if (profile.isNull()) { result = MagickProfileImage(magick_wand, name, NULL, 0); } else { result = MagickProfileImage(magick_wand, name, (const unsigned char *)profile->data(), profile.size()); } checkResult(result); return this; }
Object c_Gmagick::t_resizeimage(int64 columns, int64 rows, int64 filter_type, double blur, bool fit) { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::resizeimage); checkNotEmpty(); // Adjust width and height to work like php extension of gmagick long width, height; if (! adjust_dimensions(fit, columns, rows, &width, &height)) { throwException("Unable to calculate image dimensions", ImageError); } int result = MagickResizeImage(magick_wand, width, height, static_cast<FilterTypes>(filter_type), blur); checkResult(result); return this; }
Object c_Gmagick::t_scaleimage(int64 columns, int64 rows, bool fit) { INSTANCE_METHOD_INJECTION_BUILTIN(Gmagick, Gmagick::scaleimage); checkNotEmpty(); // Adjust width and height to work like php extension of gmagick long width, height; if (! adjust_dimensions(fit, columns, rows, &width, &height)) { throwException("Unable to calculate image dimensions", ImageError); } int result = MagickScaleImage(magick_wand, width, height); checkResult(result); return this; }