std::string render(const bool propper, const std::string syntax_s, const std::string date_format = DATE_FORMAT_S, const DWORD langId = 0) const { std::wstring syntax = utf8::cvt<std::wstring>(syntax_s); if (propper) { // To obtain the appropriate message string from the message file, load the message file with the LoadLibrary function and use the FormatMessage function strEx::replace(syntax, _T("%message%"), render_message(langId)); } else { strEx::replace(syntax, _T("%message%"), _T("%message% needs the descriptions flag set!")); } strEx::replace(syntax, _T("%source%"), get_source()); strEx::replace(syntax, _T("%computer%"), get_computer()); strEx::replace(syntax, _T("%generated%"), strEx::format_date(get_time_generated(), utf8::cvt<std::wstring>(date_format))); strEx::replace(syntax, _T("%written%"), strEx::format_date(get_time_written(), utf8::cvt<std::wstring>(date_format))); strEx::replace(syntax, _T("%generated-raw%"), strEx::itos(pevlr_->TimeGenerated)); strEx::replace(syntax, _T("%written-raw%"), strEx::itos(pevlr_->TimeWritten)); strEx::replace(syntax, _T("%type%"), translateType(eventType())); strEx::replace(syntax, _T("%category%"), strEx::itos(pevlr_->EventCategory)); strEx::replace(syntax, _T("%facility%"), strEx::itos(facility())); strEx::replace(syntax, _T("%qualifier%"), strEx::itos(facility())); strEx::replace(syntax, _T("%customer%"), strEx::itos(customer())); strEx::replace(syntax, _T("%rawid%"), strEx::itos(raw_id())); strEx::replace(syntax, _T("%severity%"), translateSeverity(severity())); strEx::replace(syntax, _T("%strings%"), enumStrings()); strEx::replace(syntax, _T("%level%"), translateType(eventType())); strEx::replace(syntax, _T("%log%"), utf8::cvt<std::wstring>(file_)); strEx::replace(syntax, _T("%file%"), utf8::cvt<std::wstring>(file_)); strEx::replace(syntax, _T("%id%"), strEx::itos(eventID())); strEx::replace(syntax, _T("%user%"), userSID()); return utf8::cvt<std::string>(syntax); }
TString buildArrayConstructorString(const TType& type) { std::stringstream constructor; constructor << getTypeString(translateType(&type)) << '[' << type.getArraySize() << ']'; return TString(constructor.str().c_str()); }
/** Create a shader from ASCII string. * @param [in] type Shader type. * @param [in] in Shader source code. * @return true the shader was successfully created and compiled. */ bool Shader::create(Shader::Type type, char const * in) { GLenum internalType; /* Sanity check. */ if(NULL == in) { return false; } internalType = translateType(type); if(GL_INVALID_ENUM == internalType) { return false; } _type = type; _id = glCreateShader(internalType); /* @todo check for errors */ glShaderSource(_id, 1, const_cast<GLchar const **>(&in), NULL); /* @todo check for errors */ glCompileShader(_id); /* @todo check for error */ GLint result; glGetShaderiv(_id, GL_COMPILE_STATUS, &result); if(GL_FALSE == result) { infoLog(); return false; } return true; }
static int loadCertFile(SSL_CTX *pCtx, const char *pFile, int type) { char *pBegin, buf[MAX_CERT_LENGTH]; BIO *in; X509 *cert = NULL; int len; int ret; unsigned int digestlen; unsigned char digest[EVP_MAX_MD_SIZE]; /* THIS FILE TYPE WILL NOT BE HANDLED HERE. * Just left this here in case of future implementation.*/ if (translateType(type) == SSL_FILETYPE_ASN1) return LS_FAIL; len = loadPemWithMissingDash(pFile, buf, MAX_CERT_LENGTH, &pBegin); if (len == -1) return LS_FAIL; in = BIO_new_mem_buf((void *)pBegin, len); cert = PEM_read_bio_X509(in, NULL, 0, NULL); BIO_free(in); if (!cert) return LS_FAIL; if (( ret = SSL_CTX_use_certificate(pCtx, cert)) == 1 ) { if ( X509_digest(cert, EVP_sha1(), digest, &digestlen) == 0) LS_DBG_L("Creating cert digest failed"); else if (SslContext::setupIdContext(pCtx, digest, digestlen) != LS_OK) LS_DBG_L("Digest id context failed"); } X509_free(cert); return ret; }
bool TGlslOutputTraverser::parseInitializer( TIntermBinary *node ) { TIntermTyped *left, *right; left = node->getLeft(); right = node->getRight(); if (!left->getAsSymbolNode()) return false; //Something is likely seriously wrong TIntermSymbol *symNode = left->getAsSymbolNode(); if (symNode->getBasicType() == EbtStruct) return false; GlslSymbol * sym = NULL; if ( !current->hasSymbol( symNode->getId() ) ) { int array = symNode->getTypePointer()->isArray() ? symNode->getTypePointer()->getArraySize() : 0; const char* semantic = ""; if (symNode->getInfo()) semantic = symNode->getInfo()->getSemantic().c_str(); sym = new GlslSymbol( symNode->getSymbol().c_str(), semantic, symNode->getId(), translateType(symNode->getTypePointer()), m_UsePrecision?node->getPrecision():EbpUndefined, translateQualifier(symNode->getQualifier()), array); current->addSymbol(sym); } else return false; //can't init already declared variable if (right->getAsTyped()) { std::stringstream ss; std::stringstream* oldOut = ¤t->getActiveOutput(); current->pushDepth(0); current->setActiveOutput(&ss); right->getAsTyped()->traverse(this); current->setActiveOutput(oldOut); current->popDepth(); sym->setInitializer(ss.str()); } return true; }
int SSLContext::setCertificateFile( const char * pFile, int type, int chained ) { if ( !pFile ) return 0; ::stat( pFile, &m_stCert ); if ( init( m_iMethod ) ) return 0; // m_sCertfile.setStr( pFile ); if ( chained ) return SSL_CTX_use_certificate_chain_file( m_pCtx, pFile ); else return SSL_CTX_use_certificate_file( m_pCtx, pFile, translateType( type ) ); }
void TGlslOutputTraverser::traverseConstantUnion( TIntermConstant *node, TIntermTraverser *it ) { TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it); GlslFunction *current = goit->current; std::stringstream& out = current->getActiveOutput(); EGlslSymbolType type = translateType( node->getTypePointer()); GlslStruct *str = 0; current->beginStatement(); if (type == EgstStruct) { str = goit->createStructFromType( node->getTypePointer()); } writeConstantConstructor (out, type, goit->m_UsePrecision?node->getPrecision():EbpUndefined, node, str); }
void TGlslOutputTraverser::traverseParameterSymbol(TIntermSymbol *node, TIntermTraverser *it) { TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it); GlslFunction *current = goit->current; int array = node->getTypePointer()->isArray() ? node->getTypePointer()->getArraySize() : 0; const char* semantic = ""; if (node->getInfo()) semantic = node->getInfo()->getSemantic().c_str(); GlslSymbol * sym = new GlslSymbol( node->getSymbol().c_str(), semantic, node->getId(), translateType(node->getTypePointer()), goit->m_UsePrecision?node->getPrecision():EbpUndefined, translateQualifier(node->getQualifier()), array); current->addParameter(sym); if (sym->getType() == EgstStruct) { GlslStruct *s = goit->createStructFromType( node->getTypePointer()); sym->setStruct(s); } }
int SslContext::setCertificateFile(const char *pFile, int type, int chained) { int ret; if (!pFile) return 0; ::stat(pFile, &m_stCert); if (init(m_iMethod)) return 0; if (chained) return SSL_CTX_use_certificate_chain_file(m_pCtx, pFile); else { ret = loadCertFile(m_pCtx, pFile, type); if (ret == -1) return SSL_CTX_use_certificate_file(m_pCtx, pFile, translateType(type)); return ret; } }
void TGlslOutputTraverser::traverseSymbol(TIntermSymbol *node, TIntermTraverser *it) { TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it); GlslFunction *current = goit->current; std::stringstream& out = current->getActiveOutput(); current->beginStatement(); if ( ! current->hasSymbol( node->getId())) { //check to see if it is a global we can share if ( goit->global->hasSymbol( node->getId())) { current->addSymbol( &goit->global->getSymbol( node->getId())); } else { int array = node->getTypePointer()->isArray() ? node->getTypePointer()->getArraySize() : 0; const char* semantic = ""; if (node->getInfo()) semantic = node->getInfo()->getSemantic().c_str(); GlslSymbol * sym = new GlslSymbol( node->getSymbol().c_str(), semantic, node->getId(), translateType(node->getTypePointer()), goit->m_UsePrecision?node->getPrecision():EbpUndefined, translateQualifier(node->getQualifier()), array); sym->setIsGlobal(node->isGlobal()); current->addSymbol(sym); if (sym->getType() == EgstStruct) { GlslStruct *s = goit->createStructFromType( node->getTypePointer()); sym->setStruct(s); } } } // If we're at the global scope, emit the non-mutable names of uniforms. bool globalScope = current == goit->global; out << current->getSymbol(node->getId()).getName(!globalScope); }
void LogManager::printLog() { for (int index = head; index < tail; index++) { LogRecord rec = log[index]; cout << endl; cout << "LSN: " << rec.LSN << endl; cout << "Transaction: " << rec.transID << endl; cout << "Type: " << translateType(rec.type) << endl; cout << "Previous: " << rec.prevLSN << endl; if (rec.type == 2) { char* oldData = rec.oldData; cout << "Old data: "; for (int i = 0; i < 16; i++) { cout << oldData[i]; } cout << endl; char* newData = rec.newData; cout << "New data: "; for (int i = 0; i < 16; i++) { cout << newData[i]; } cout << endl; } } }
static WORD subtractType(WORD dwType, std::wstring sType) { return dwType & (!translateType(sType)); }
static WORD appendType(WORD dwType, std::wstring sType) { return dwType | translateType(sType); }
bool TGlslOutputTraverser::traverseDeclaration(bool preVisit, TIntermDeclaration* decl, TIntermTraverser* it) { TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it); GlslFunction *current = goit->current; std::stringstream& out = current->getActiveOutput(); EGlslSymbolType symbol_type = translateType(decl->getTypePointer()); TType& type = *decl->getTypePointer(); bool emit_osx10_6_arrays = goit->m_EmitSnowLeopardCompatibleArrayInitializers && decl->containsArrayInitialization(); if (emit_osx10_6_arrays) { assert(decl->isSingleInitialization() && "Emission of multiple in-line array declarations isn't supported when running in OS X 10.6 compatible mode."); current->indent(out); out << "#if defined(OSX_SNOW_LEOPARD)" << std::endl; current->increaseDepth(); TQualifier q = type.getQualifier(); if (q == EvqConst) q = EvqTemporary; current->beginStatement(); if (q != EvqTemporary && q != EvqGlobal) out << type.getQualifierString() << " "; TIntermBinary* assign = decl->getDeclaration()->getAsBinaryNode(); TIntermSymbol* sym = assign->getLeft()->getAsSymbolNode(); TIntermSequence& init = assign->getRight()->getAsAggregate()->getSequence(); writeType(out, symbol_type, NULL, goit->m_UsePrecision ? decl->getPrecision() : EbpUndefined); out << "[" << type.getArraySize() << "] " << sym->getSymbol(); current->endStatement(); unsigned n_vals = init.size(); for (unsigned i = 0; i != n_vals; ++i) { current->beginStatement(); sym->traverse(goit); out << "[" << i << "]" << " = "; init[i]->traverse(goit); current->endStatement(); } current->decreaseDepth(); current->indent(out); out << "#else" << std::endl; current->increaseDepth(); } current->beginStatement(); if (type.getQualifier() != EvqTemporary && type.getQualifier() != EvqGlobal) out << type.getQualifierString() << " "; if (type.getBasicType() == EbtStruct) out << type.getTypeName(); else writeType(out, symbol_type, NULL, goit->m_UsePrecision ? decl->getPrecision() : EbpUndefined); if (type.isArray()) out << "[" << type.getArraySize() << "]"; out << " "; decl->getDeclaration()->traverse(goit); current->endStatement(); if (emit_osx10_6_arrays) { current->decreaseDepth(); current->indent(out); out << "#endif" << std::endl; } return false; }
GlslStruct *TGlslOutputTraverser::createStructFromType (TType *type) { GlslStruct *s = 0; std::string structName = type->getTypeName().c_str(); //check for anonymous structures if (structName.size() == 0) { std::stringstream temp; TTypeList &tList = *type->getStruct(); //build a mangled name that is hopefully mangled enough to prevent collisions temp << "anonStruct"; for (TTypeList::iterator it = tList.begin(); it != tList.end(); it++) { TString typeString; it->type->buildMangledName(typeString); temp << "_" << typeString.c_str(); } structName = temp.str(); } //try to find the struct name if ( structMap.find(structName) == structMap.end() ) { //This is a new structure, build a type for it TTypeList &tList = *type->getStruct(); s = new GlslStruct(structName, type->getLine()); for (TTypeList::iterator it = tList.begin(); it != tList.end(); it++) { GlslStruct::member m; m.name = it->type->getFieldName().c_str(); if (it->type->hasSemantic()) m.semantic = it->type->getSemantic().c_str(); if (it->type->getBasicType() == EbtStruct) { m.structType = createStructFromType(it->type); } else m.structType = NULL; m.type = translateType( it->type); m.arraySize = it->type->isArray() ? it->type->getArraySize() : 0; m.precision = m_UsePrecision ? it->type->getPrecision() : EbpUndefined; s->addMember(m); } //add it to the list structMap[structName] = s; structList.push_back(s); } else { s = structMap[structName]; } return s; }
bool TGlslOutputTraverser::traverseAggregate( bool preVisit, TIntermAggregate *node, TIntermTraverser *it ) { TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it); GlslFunction *current = goit->current; std::stringstream& out = current->getActiveOutput(); int argCount = (int) node->getSequence().size(); if (node->getOp() == EOpNull) { goit->infoSink.info << "node is still EOpNull!\n"; return true; } switch (node->getOp()) { case EOpSequence: if (goit->generatingCode) { goit->outputLineDirective (node->getLine()); TIntermSequence::iterator sit; TIntermSequence &sequence = node->getSequence(); for (sit = sequence.begin(); sit != sequence.end(); ++sit) { goit->outputLineDirective((*sit)->getLine()); (*sit)->traverse(it); //out << ";\n"; current->endStatement(); } } else { TIntermSequence::iterator sit; TIntermSequence &sequence = node->getSequence(); for (sit = sequence.begin(); sit != sequence.end(); ++sit) { (*sit)->traverse(it); } } return false; case EOpFunction: { GlslFunction *func = new GlslFunction( node->getPlainName().c_str(), node->getName().c_str(), translateType(node->getTypePointer()), goit->m_UsePrecision?node->getPrecision():EbpUndefined, node->getSemantic().c_str(), node->getLine()); if (func->getReturnType() == EgstStruct) { GlslStruct *s = goit->createStructFromType( node->getTypePointer()); func->setStruct(s); } goit->functionList.push_back( func); goit->current = func; goit->current->beginBlock( false); TIntermSequence::iterator sit; TIntermSequence &sequence = node->getSequence(); for (sit = sequence.begin(); sit != sequence.end(); ++sit) { (*sit)->traverse(it); } goit->current->endBlock(); goit->current = goit->global; return false; } case EOpParameters: it->visitSymbol = traverseParameterSymbol; { TIntermSequence::iterator sit; TIntermSequence &sequence = node->getSequence(); for (sit = sequence.begin(); sit != sequence.end(); ++sit) (*sit)->traverse(it); } it->visitSymbol = traverseSymbol; return false; case EOpConstructFloat: writeFuncCall( "float", node, goit); return false; case EOpConstructVec2: writeFuncCall( "vec2", node, goit); return false; case EOpConstructVec3: writeFuncCall( "vec3", node, goit); return false; case EOpConstructVec4: writeFuncCall( "vec4", node, goit); return false; case EOpConstructBool: writeFuncCall( "bool", node, goit); return false; case EOpConstructBVec2: writeFuncCall( "bvec2", node, goit); return false; case EOpConstructBVec3: writeFuncCall( "bvec3", node, goit); return false; case EOpConstructBVec4: writeFuncCall( "bvec4", node, goit); return false; case EOpConstructInt: writeFuncCall( "int", node, goit); return false; case EOpConstructIVec2: writeFuncCall( "ivec2", node, goit); return false; case EOpConstructIVec3: writeFuncCall( "ivec3", node, goit); return false; case EOpConstructIVec4: writeFuncCall( "ivec4", node, goit); return false; case EOpConstructMat2FromMat: case EOpConstructMat2: writeFuncCall( "mat2", node, goit); return false; case EOpConstructMat3FromMat: case EOpConstructMat3: writeFuncCall( "mat3", node, goit); return false; case EOpConstructMat4: writeFuncCall( "mat4", node, goit); return false; case EOpConstructStruct: writeFuncCall( node->getTypePointer()->getTypeName(), node, goit); return false; case EOpConstructArray: writeFuncCall( buildArrayConstructorString(*node->getTypePointer()), node, goit); return false; case EOpComma: { TIntermSequence::iterator sit; TIntermSequence &sequence = node->getSequence(); for (sit = sequence.begin(); sit != sequence.end(); ++sit) { (*sit)->traverse(it); if ( sit+1 != sequence.end()) out << ", "; } } return false; case EOpFunctionCall: current->addCalledFunction(node->getName().c_str()); writeFuncCall( node->getPlainName(), node, goit); return false; case EOpLessThan: writeFuncCall( "lessThan", node, goit); return false; case EOpGreaterThan: writeFuncCall( "greaterThan", node, goit); return false; case EOpLessThanEqual: writeFuncCall( "lessThanEqual", node, goit); return false; case EOpGreaterThanEqual: writeFuncCall( "greaterThanEqual", node, goit); return false; case EOpVectorEqual: writeFuncCall( "equal", node, goit); return false; case EOpVectorNotEqual: writeFuncCall( "notEqual", node, goit); return false; case EOpMod: writeFuncCall( "mod", node, goit, true); return false; case EOpPow: writeFuncCall( "pow", node, goit, true); return false; case EOpAtan2: writeFuncCall( "atan", node, goit, true); return false; case EOpMin: writeFuncCall( "min", node, goit, true); return false; case EOpMax: writeFuncCall( "max", node, goit, true); return false; case EOpClamp: writeFuncCall( "clamp", node, goit, true); return false; case EOpMix: writeFuncCall( "mix", node, goit, true); return false; case EOpStep: writeFuncCall( "step", node, goit, true); return false; case EOpSmoothStep: writeFuncCall( "smoothstep", node, goit, true); return false; case EOpDistance: writeFuncCall( "distance", node, goit); return false; case EOpDot: writeFuncCall( "dot", node, goit); return false; case EOpCross: writeFuncCall( "cross", node, goit); return false; case EOpFaceForward: writeFuncCall( "faceforward", node, goit); return false; case EOpReflect: writeFuncCall( "reflect", node, goit); return false; case EOpRefract: writeFuncCall( "refract", node, goit); return false; case EOpMul: { //This should always have two arguments assert(node->getSequence().size() == 2); current->beginStatement(); out << '('; node->getSequence()[0]->traverse(goit); out << " * "; node->getSequence()[1]->traverse(goit); out << ')'; return false; } //HLSL texture functions case EOpTex1D: if (argCount == 2) writeTex( "texture1D", node, goit); else { current->addLibFunction(EOpTex1DGrad); writeTex( "xll_tex1Dgrad", node, goit); } return false; case EOpTex1DProj: writeTex( "texture1DProj", node, goit); return false; case EOpTex1DLod: current->addLibFunction(EOpTex1DLod); writeTex( "xll_tex1Dlod", node, goit); return false; case EOpTex1DBias: current->addLibFunction(EOpTex1DBias); writeTex( "xll_tex1Dbias", node, goit); return false; case EOpTex1DGrad: current->addLibFunction(EOpTex1DGrad); writeTex( "xll_tex1Dgrad", node, goit); return false; case EOpTex2D: if (argCount == 2) writeTex( "texture2D", node, goit); else { current->addLibFunction(EOpTex2DGrad); writeTex( "xll_tex2Dgrad", node, goit); } return false; case EOpTex2DProj: writeTex( "texture2DProj", node, goit); return false; case EOpTex2DLod: current->addLibFunction(EOpTex2DLod); writeTex( "xll_tex2Dlod", node, goit); return false; case EOpTex2DBias: current->addLibFunction(EOpTex2DBias); writeTex( "xll_tex2Dbias", node, goit); return false; case EOpTex2DGrad: current->addLibFunction(EOpTex2DGrad); writeTex( "xll_tex2Dgrad", node, goit); return false; case EOpTex3D: if (argCount == 2) writeTex( "texture3D", node, goit); else { current->addLibFunction(EOpTex3DGrad); writeTex( "xll_tex3Dgrad", node, goit); } return false; case EOpTex3DProj: writeTex( "texture3DProj", node, goit); return false; case EOpTex3DLod: current->addLibFunction(EOpTex3DLod); writeTex( "xll_tex3Dlod", node, goit); return false; case EOpTex3DBias: current->addLibFunction(EOpTex3DBias); writeTex( "xll_tex3Dbias", node, goit); return false; case EOpTex3DGrad: current->addLibFunction(EOpTex3DGrad); writeTex( "xll_tex3Dgrad", node, goit); return false; case EOpTexCube: if (argCount == 2) writeTex( "textureCube", node, goit); else { current->addLibFunction(EOpTexCubeGrad); writeTex( "xll_texCUBEgrad", node, goit); } return false; case EOpTexCubeProj: writeTex( "textureCubeProj", node, goit); return false; case EOpTexCubeLod: current->addLibFunction(EOpTexCubeLod); writeTex( "xll_texCUBElod", node, goit); return false; case EOpTexCubeBias: current->addLibFunction(EOpTexCubeBias); writeTex( "xll_texCUBEbias", node, goit); return false; case EOpTexCubeGrad: current->addLibFunction(EOpTexCubeGrad); writeTex( "xll_texCUBEgrad", node, goit); return false; case EOpTexRect: writeTex( "texture2DRect", node, goit); return false; case EOpTexRectProj: writeTex( "texture2DRectProj", node, goit); return false; case EOpModf: current->addLibFunction(EOpModf); writeFuncCall( "xll_modf", node, goit); break; case EOpLdexp: current->addLibFunction(EOpLdexp); writeFuncCall( "xll_ldexp", node, goit); break; case EOpSinCos: current->addLibFunction(EOpSinCos); writeFuncCall ( "xll_sincos", node, goit); break; case EOpLit: current->addLibFunction(EOpLit); writeFuncCall( "xll_lit", node, goit); break; default: goit->infoSink.info << "Bad aggregation op\n"; } return false; }