save_error save_manager::read_file(emu_file &file) { // if we have illegal registrations, return an error if (m_illegal_regs > 0) return STATERR_ILLEGAL_REGISTRATIONS; // read the header and turn on compression for the rest of the file file.compress(FCOMPRESS_NONE); file.seek(0, SEEK_SET); UINT8 header[HEADER_SIZE]; if (file.read(header, sizeof(header)) != sizeof(header)) return STATERR_READ_ERROR; file.compress(FCOMPRESS_MEDIUM); // verify the header and report an error if it doesn't match UINT32 sig = signature(); if (validate_header(header, machine().system().name, sig, popmessage, "Error: ") != STATERR_NONE) return STATERR_INVALID_HEADER; // determine whether or not to flip the data when done bool flip = NATIVE_ENDIAN_VALUE_LE_BE((header[9] & SS_MSB_FIRST) != 0, (header[9] & SS_MSB_FIRST) == 0); // read all the data, flipping if necessary for (state_entry *entry = m_entry_list.first(); entry != NULL; entry = entry->next()) { UINT32 totalsize = entry->m_typesize * entry->m_typecount; if (file.read(entry->m_data, totalsize) != totalsize) return STATERR_READ_ERROR; // handle flipping if (flip) entry->flip_data(); } // call the post-load functions for (state_callback *func = m_postload_list.first(); func != NULL; func = func->next()) func->m_func(); return STATERR_NONE; }
void Householder ( ElementalMatrix<F>& APre, ElementalMatrix<F>& phasePre, ElementalMatrix<Base<F>>& signaturePre ) { DEBUG_CSE DEBUG_ONLY(AssertSameGrids( APre, phasePre, signaturePre )) const Int m = APre.Height(); const Int n = APre.Width(); const Int minDim = Min(m,n); DistMatrixReadWriteProxy<F,F,MC,MR> AProx( APre ); DistMatrixWriteProxy<F,F,MD,STAR> phaseProx( phasePre ); DistMatrixWriteProxy<Base<F>,Base<F>,MD,STAR> signatureProx( signaturePre ); auto& A = AProx.Get(); auto& phase = phaseProx.Get(); auto& signature = signatureProx.Get(); phase.Resize( minDim, 1 ); signature.Resize( minDim, 1 ); const Int bsize = Blocksize(); for( Int k=0; k<minDim; k+=bsize ) { const Int nb = Min(bsize,minDim-k); const Range<Int> ind1( k, k+nb ), indB( k, END ), ind2( k+nb, END ); auto AB1 = A( indB, ind1 ); auto AB2 = A( indB, ind2 ); auto phase1 = phase( ind1, ALL ); auto sig1 = signature( ind1, ALL ); PanelHouseholder( AB1, phase1, sig1 ); ApplyQ( LEFT, ADJOINT, AB1, phase1, sig1, AB2 ); } }
inline void BusingerGolub ( AbstractDistMatrix<F>& APre, DistPermutation& Omega, AbstractDistMatrix<F>& Z, const QRCtrl<Base<F>>& ctrl ) { EL_DEBUG_CSE typedef Base<F> Real; DistMatrixReadWriteProxy<F,F,MC,MR> AProx( APre ); auto& A = AProx.Get(); auto ctrlCopy = ctrl; const Int m = A.Height(); const Int n = A.Width(); const Real eps = limits::Epsilon<Real>(); // Demand that we will be able to apply inv(R_L) to R_R by ensuring that // the minimum singular value is sufficiently (relatively) large ctrlCopy.adaptive = true; if( ctrl.boundRank ) { ctrlCopy.tol = Max(ctrl.tol,eps*ctrl.maxRank); } else { ctrlCopy.tol = Max(ctrl.tol,eps*Min(m,n)); } // Perform an adaptive pivoted QR factorization DistMatrix<F,MD,STAR> householderScalars(A.Grid()); DistMatrix<Base<F>,MD,STAR> signature(A.Grid()); QR( A, householderScalars, signature, Omega, ctrlCopy ); const Int numSteps = householderScalars.Height(); auto RL = A( IR(0,numSteps), IR(0,numSteps) ); auto RR = A( IR(0,numSteps), IR(numSteps,n) ); Copy( RR, Z ); Trsm( LEFT, UPPER, NORMAL, NON_UNIT, F(1), RL, Z ); }
void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier &pub, double timeTotal, bool pc=false) { unsigned int len = 16; LC_RNG rng((word32)time(NULL)); AlignedSecByteBlock message(len), signature(pub.SignatureLength()); rng.GenerateBlock(message, len); priv.SignMessage(rng, message, len, signature); clock_t start = clock(); unsigned int i; double timeTaken; for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++) pub.VerifyMessage(message, len, signature, signature.size()); OutputResultOperations(name, "Verification", pc, i, timeTaken); if (!pc && pub.GetMaterial().SupportsPrecomputation()) { pub.AccessMaterial().Precompute(16); BenchMarkVerification(name, priv, pub, timeTotal, true); } }
double getAvail(Parameters& params, std::string currency) { std::ostringstream oss; oss << "api_key=" << params.okCoinApi << "&secret_key=" << params.okCoinSecret; std::string signature(oss.str()); oss.clear(); oss.str(""); oss << "api_key=" << params.okCoinApi; std::string content(oss.str()); json_t* root = authRequest(params, "https://www.okcoin.com/api/v1/userinfo.do", signature, content); double available; if (currency.compare("usd") == 0) { available = atof(json_string_value(json_object_get(json_object_get(json_object_get(json_object_get(root, "info"), "funds"), "free"), "usd"))); } else if (currency.compare("btc") == 0) { available = atof(json_string_value(json_object_get(json_object_get(json_object_get(json_object_get(root, "info"), "funds"), "free"), "btc"))); } else { available = 0.0; } json_decref(root); return available; }
void TestAwsSignatureV2::adornRequest() { QFETCH(QNetworkRequest, request); QFETCH(QString, accessKeyId); QFETCH(QCryptographicHash::Algorithm, algorithm); QFETCH(QString, signatureMethod); const AwsBasicCredentials credentials(accessKeyId, QString()); AwsSignatureV2 signature(algorithm); signature.d_func()->adornRequest(request, credentials); const QUrlQuery query(request.url()); QVERIFY(query.hasQueryItem(QLatin1String("AWSAccessKeyId"))); QVERIFY(query.hasQueryItem(QLatin1String("SignatureMethod"))); QVERIFY(query.hasQueryItem(QLatin1String("SignatureVersion"))); QVERIFY(query.hasQueryItem(QLatin1String("Timestamp"))); QCOMPARE(query.queryItemValue(QLatin1String("AWSAccessKeyId")), accessKeyId); QCOMPARE(query.queryItemValue(QLatin1String("SignatureMethod")), signatureMethod); QCOMPARE(query.queryItemValue(QLatin1String("SignatureVersion")), QString::fromLatin1("2")); }
CodeDB* CodeDB::open(STATE, const char* path) { MutexLockWaiting lock_waiting(state, state->shared().codedb_lock()); CodeDB* codedb = state->memory()->new_object<CodeDB>(state, G(codedb)); codedb->path(state, String::create(state, path)); std::string base_path(path); // Check the CodeDB signature matches the VM. std::string signature_path = base_path + "/signature"; std::ifstream signature(signature_path.c_str()); if(signature) { uint64_t sig; signature >> sig; if(sig != RBX_SIGNATURE) { Exception::raise_runtime_error(state, "the CodeDB signature is not valid for this version"); } signature.close(); } else {
HBufC8* CmsUtils::CreateSignatureL(const TDesC8& aDataToBeSigned, TBool aIsHash, TAlgorithmId aAlgorithm, const CRSAPrivateKey& aKey) { HBufC8* signature(NULL); TPtrC8 hashValue; if (!aIsHash) { // Create hash first CMessageDigest* hash=CreateHashLC(aAlgorithm); hashValue.Set(hash->Hash(aDataToBeSigned)); } else { hashValue.Set(aDataToBeSigned); } //Build the digestInfo Sequence CASN1EncSequence* digestInfoSeq = CASN1EncSequence::NewLC(); //Encode the Algorithm CX509AlgorithmIdentifier* digAlg=CX509AlgorithmIdentifier::NewLC(aAlgorithm, KNullDesC8()); CASN1EncSequence* sigAlg=digAlg->EncodeASN1DERLC(); digestInfoSeq->AddAndPopChildL(sigAlg); CleanupStack::PopAndDestroy(digAlg); //Encode the digest itself CASN1EncOctetString* sigEnc=CASN1EncOctetString::NewLC(hashValue); digestInfoSeq->AddAndPopChildL(sigEnc); //Get the Encoding HBufC8* digestInfo=CreateDEREncodingLC(*digestInfoSeq); signature=CreateSignatureL(digestInfo->Des(), aKey); CleanupStack::PopAndDestroy(2, digestInfoSeq); //digestInfo, digestInfoSeq if (!aIsHash) { CleanupStack::PopAndDestroy(); // hash } return signature; }
size_t SigPolyBasis::regularReducer( ConstMonoRef sig, ConstMonoRef term ) const { size_t reducer = monoLookup().regularReducer(sig, term); #ifdef MATHICGB_SLOW_DEBUG const size_t debugValue = regularReducerSlow(sig, term); if (reducer == static_cast<size_t>(-1)) { MATHICGB_SLOW_ASSERT(debugValue == static_cast<size_t>(-1)); } else { MATHICGB_SLOW_ASSERT(debugValue != static_cast<size_t>(-1)); monomial m = ring().allocMonomial(); MATHICGB_SLOW_ASSERT (ring().monomialIsDivisibleBy(term, leadMono(reducer))); ring().monomialDivide(term, leadMono(reducer), m); ring().monomialMultTo(m, signature(reducer)); MATHICGB_SLOW_ASSERT(monoid().lessThan(m, sig)); ring().freeMonomial(m); } #endif return reducer; }
/* * Check the signature on an object */ bool X509_Object::check_signature(const Public_Key& pub_key) const { try { std::vector<std::string> sig_info = split_on(OIDS::lookup(m_sig_algo.oid), '/'); if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name()) return false; std::string padding = sig_info[1]; Signature_Format format = (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363; PK_Verifier verifier(pub_key, padding, format); return verifier.verify_message(tbs_data(), signature()); } catch(std::exception&) { return false; } }
bool checkSignature(const QString &fileName, QString &line, const char *sig) { static QStringList fileList; int idx = -1; bool found = false; while ((idx = line.indexOf(sig, ++idx)) != -1) { const QByteArray sl(signature(line, idx).toLocal8Bit()); QByteArray nsl(QMetaObject::normalizedSignature(sl.constData())); if (sl != nsl) { found = true; if (printFilename && !fileList.contains(fileName)) { fileList.prepend(fileName); printf("%s\n", fileName.toLocal8Bit().constData()); } if (modify) line.replace(sl, nsl); //qDebug("expected '%s', got '%s'", nsl.data(), sl.data()); } } return found; }
void CryptoAlgorithmRSASSA_PKCS1_v1_5::sign(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const CryptoOperationData& data, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec) { const CryptoAlgorithmRsaSsaParams& rsaSSAParameters = toCryptoAlgorithmRsaSsaParams(parameters); if (!isCryptoKeyRSA(key)) { ec = NOT_SUPPORTED_ERR; return; } const CryptoKeyRSA& rsaKey = toCryptoKeyRSA(key); CCDigestAlgorithm digestAlgorithm; if (!getCommonCryptoDigestAlgorithm(rsaSSAParameters.hash, digestAlgorithm)) { ec = NOT_SUPPORTED_ERR; return; } std::unique_ptr<CryptoDigest> digest = CryptoDigest::create(rsaSSAParameters.hash); if (!digest) { ec = NOT_SUPPORTED_ERR; return; } digest->addBytes(data.first, data.second); Vector<uint8_t> digestData = digest->computeHash(); Vector<uint8_t> signature(512); size_t signatureSize = signature.size(); CCCryptorStatus status = CCRSACryptorSign(rsaKey.platformKey(), ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature.data(), &signatureSize); if (status) { promise->reject(nullptr); return; } signature.resize(signatureSize); promise->fulfill(signature); }
SymTabESP sym_insert_proc(IdentSP idp, ParaListSP plp) { char *proclabel; char *procsign; SymBucketSP p; SymTabESP e; e = NULL; int h = hash(idp->name); procsign = signature(idp, plp); proclabel = Nappend(procsign); if (TOP == NULL) fprintf(tiplist, "SYMTAB BUG:121\n"); for (p = *(TOP->sbp + h); p != NULL; p = p->next) { if ((p->ep != NULL) && (!strcmp(idp->name, p->ep->name)) ) break; } if (p == NULL) { ENTRY(SymTabES, e); e->name = copyString(idp->name); e->label = proclabel; Npush(procsign); e->val = -1; e->lineno = idp->line; e->level = LEVEL; e->posi = -1; e->obj = Proc_Obj_t; e->type = Nop_Type_t; e->stp = TOP; ENTRY(SymBucketS, p); p->ep = e; p->next = NULL; sym_insert(p, TOP); } else { --runlevel; semanticError(DUPSYM, idp->line, FALSE, idp->name); } return e; }
// for now a copy of how we sign in libraries/networking/src/DataServerAccountInfo - // we sha256 the text, read the private key from disk (for now!), and return the signed // sha256. Note later with multiple keys, we may need the key parameter (or something // similar) so I left it alone for now. Also this will probably change when we move // away from RSA keys anyways. Note that since this returns a QString, we better avoid // the horror of code pages and so on (changing the bytes) by just returning a base64 // encoded string representing the signature (suitable for http, etc...) QString Wallet::signWithKey(const QByteArray& text, const QString& key) { EC_KEY* ecPrivateKey = NULL; if ((ecPrivateKey = readPrivateKey(keyFilePath()))) { const auto sig = std::make_unique<unsigned char[]>(ECDSA_size(ecPrivateKey)); unsigned int signatureBytes = 0; qCInfo(commerce) << "Hashing and signing plaintext" << text << "with key at address" << ecPrivateKey; QByteArray hashedPlaintext = QCryptographicHash::hash(text, QCryptographicHash::Sha256); int retrn = ECDSA_sign(0, reinterpret_cast<const unsigned char*>(hashedPlaintext.constData()), hashedPlaintext.size(), sig.get(), &signatureBytes, ecPrivateKey); EC_KEY_free(ecPrivateKey); QByteArray signature(reinterpret_cast<const char*>(sig.get()), signatureBytes); if (retrn != -1) { return signature.toBase64(); } } return QString(); }
QByteArray NvPairingManager::signMessage(QByteArray message) { EVP_MD_CTX *ctx = EVP_MD_CTX_create(); THROW_BAD_ALLOC_IF_NULL(ctx); const EVP_MD *md = EVP_get_digestbyname("SHA256"); THROW_BAD_ALLOC_IF_NULL(md); EVP_DigestInit_ex(ctx, md, NULL); EVP_DigestSignInit(ctx, NULL, md, NULL, m_PrivateKey); EVP_DigestSignUpdate(ctx, reinterpret_cast<unsigned char*>(message.data()), message.length()); size_t signatureLength = 0; EVP_DigestSignFinal(ctx, NULL, &signatureLength); QByteArray signature((int)signatureLength, 0); EVP_DigestSignFinal(ctx, reinterpret_cast<unsigned char*>(signature.data()), &signatureLength); EVP_MD_CTX_destroy(ctx); return signature; }
bool aes_cipher::decrypt(std::string const &cipher,std::string &plain) { load(); size_t digest_size = digest_->digest_size(); size_t block_size = cbc_->block_size(); if(cipher.size() < digest_size + block_size) { return false; } size_t real_size = cipher.size() - digest_size; if(real_size % block_size != 0) { return false; } if(real_size / block_size < 2) { return false; } crypto::hmac signature(std::auto_ptr<crypto::message_digest>(digest_->clone()),mac_key_); signature.append(cipher.c_str(),real_size); std::vector<char> verify(digest_size,0); signature.readout(&verify[0]); if(memcmp(&verify[0],cipher.c_str() + real_size,digest_size)!=0) { memset(&verify[0],0,digest_size); return false; } std::vector<char> full_plain(real_size); cbc_->decrypt(cipher.c_str(),&full_plain[0],real_size); uint32_t size = 0; memcpy(&size,&full_plain[block_size],sizeof(size)); if(size > real_size - block_size - sizeof(size)) { return false; } plain.assign(&full_plain[0] + block_size + sizeof(size),size); return true; }
QString Function::definition() const { if (iline) return QString(); QString result; result += signature(); result += QLatin1String("\n{\n"); QString tmp = body; if (tmp.endsWith(QLatin1Char('\n'))) tmp.chop(1); if (!tmp.startsWith(QLatin1Char('\n'))) tmp.prepend(" "); tmp.replace(QLatin1Char('\n'), QLatin1String("\n ")); result += tmp; result += QLatin1String("\n}\n"); return result; }
int main (int argc, const char* argv[]) { string toSign; FileSource(argv[1], true, new StringSink(toSign)); AutoSeededRandomPool rng; //Read private key CryptoPP::ByteQueue bytes; FileSource file(argv[2], true, new Base64Decoder); file.TransferTo(bytes); bytes.MessageEnd(); RSA::PrivateKey privateKey; privateKey.Load(bytes); //Sign message RSASSA_PKCS1v15_SHA_Signer signer(privateKey); SecByteBlock signature(signer.SignatureLength()); signer.SignMessage( rng, (byte const*) toSign.data(), toSign.size(), signature); //Print string of signature HexEncoder encoder; string signatureString; encoder.Put(signature.data(), signature.size()); encoder.MessageEnd(); word64 signatureSize = encoder.MaxRetrievable(); if (signatureSize) { signatureString.resize(signatureSize); encoder.Get((byte*) signatureString.data(), signatureString.size()); } cout << signatureString << endl; }
#define returnfunc() return 0 #define return_var(var) return var #define declare_argc() #define declare_argv() #define args_initial_ptr() NULL #endif #if !defined(__APPLE__) && !defined(EMSCRIPTEN) #define HAVE_MAIN_LOOP #endif #define MAX_ARGS 32 int main_entry_decide(signature(), args_type() args) { int ret = rarch_main_iterate(); if (ret == -1) { if (g_extern.core_shutdown_initiated && g_settings.load_dummy_on_core_shutdown) { /* Load dummy core instead of exiting RetroArch completely. */ rarch_main_command(RARCH_CMD_PREPARE_DUMMY); g_extern.core_shutdown_initiated = false; return 0; } }
// time critical QByteArray PHPQt::getSignature(const int argc, zval **argv, MocArgument* mocStack) { mocStack[0].argType = xmoc_bool; // the return type mocStack[0].st = SmokeType( PHPQt::smoke(), PHPQt::smoke()->idType("bool") ); QByteArray signature( "(" ); for(int i=0; i<argc; i++) { const uint type = static_cast< int >( argv[i]->type ); mocStack[ i+1 ].st = SmokeType( PHPQt::smoke(), 0 ); switch( type ) { case IS_RESOURCE: // @TODO add resource type break; case IS_ARRAY: // @TODO xmoc_ptr, php_error( E_WARNING, "Array given as signal argument" ); break; case IS_BOOL: mocStack[i+1].argType = xmoc_bool; mocStack[i+1].st = SmokeType( PHPQt::smoke(), PHPQt::smoke()->idType("bool") ); signature.append( "bool" ); break; case IS_LONG: mocStack[i+1].argType = xmoc_int; mocStack[i+1].st = SmokeType( PHPQt::smoke(), PHPQt::smoke()->idType("int") ); signature.append( "int" ); break; case IS_DOUBLE: mocStack[i+1].argType = xmoc_double; mocStack[i+1].st = SmokeType( PHPQt::smoke(), PHPQt::smoke()->idType("double") ); signature.append( "double" ); break; case IS_STRING: mocStack[i+1].argType = xmoc_charstar; mocStack[i+1].st = SmokeType( PHPQt::smoke(), PHPQt::smoke()->idType("char*") ); signature.append( "string" ); break; case IS_OBJECT: if(Z_OBJCE_P( argv[i] ) == qstring_ce) mocStack[i+1].argType = xmoc_QString; else { smokephp_object *o = PHPQt::getSmokePHPObjectFromZval( argv[i] ); mocStack[i+1].st = SmokeType( PHPQt::smoke(), o->classId() ); mocStack[i+1].argType = xmoc_void; } signature.append( "object" ); default: php_error( E_ERROR,"Unknown argument or unsupported argument type %d, type %d, exit\n", i, type ); exit(FAILURE); break; } // switch } signature.append( ")" ); return signature; }
bool WriteMail::buildMail(bool includeSignature) { QMailAccountId accountId(m_accountSelection->itemData(m_accountSelection->currentIndex()).value<QMailAccountId>()); // Ensure the signature of the selected account is used if (accountId.isValid() && includeSignature) { m_composerInterface->setSignature(signature(accountId)); } // Extract the message from the composer QMailMessage newMail = m_composerInterface->message(); // Retain the old mail properties if they're configured newMail.setId(mail.id()); newMail.setParentFolderId(mail.parentFolderId()); newMail.setContentScheme(mail.contentScheme()); newMail.setContentIdentifier(mail.contentIdentifier()); newMail.setServerUid(mail.serverUid()); newMail.setCustomFields(mail.customFields()); newMail.setDate(QMailTimeStamp::currentDateTime()); newMail.setStatus(QMailMessage::Outgoing, true); newMail.setStatus(QMailMessage::ContentAvailable, true); newMail.setStatus(QMailMessage::PartialContentAvailable, true); newMail.setStatus(QMailMessage::Read, true); if (accountId.isValid()) { newMail.setParentAccountId(accountId); newMail.setFrom(QMailAccount(accountId).fromAddress()); } if (!newMail.parentFolderId().isValid()) { newMail.setParentFolderId(QMailFolder::LocalStorageFolderId); } if (m_precursorId.isValid()) { newMail.setInResponseTo(m_precursorId); newMail.setResponseType(m_replyAction); QMailMessage precursor(m_precursorId); // Set the In-Reply-To and References headers in our outgoing message QString references(precursor.headerFieldText("References")); if (references.isEmpty()) { references = precursor.headerFieldText("In-Reply-To"); } QString precursorId(precursor.headerFieldText("Message-ID")); if (!precursorId.isEmpty()) { newMail.setHeaderField("In-Reply-To", precursorId); if (!references.isEmpty()) { references.append(' '); } references.append(precursorId); } if (!references.isEmpty()) { // TODO: Truncate references if they're too long newMail.setHeaderField("References", references); } } mail = newMail; return true; }
// for _ladd, _lmul, _lsub, _ldiv, _lrem void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) { if (x->op() == Bytecodes::_ldiv || x->op() == Bytecodes::_lrem ) { // long division is implemented as a direct call into the runtime LIRItem left(x->x(), this); LIRItem right(x->y(), this); // the check for division by zero destroys the right operand right.set_destroys_register(); BasicTypeList signature(2); signature.append(T_LONG); signature.append(T_LONG); CallingConvention* cc = frame_map()->c_calling_convention(&signature); // check for division by zero (destroys registers of right operand!) CodeEmitInfo* info = state_for(x); const LIR_Opr result_reg = result_register_for(x->type()); left.load_item_force(cc->at(1)); right.load_item(); __ move(right.result(), cc->at(0)); __ cmp(lir_cond_equal, right.result(), LIR_OprFact::longConst(0)); __ branch(lir_cond_equal, T_LONG, new DivByZeroStub(info)); address entry; switch (x->op()) { case Bytecodes::_lrem: entry = CAST_FROM_FN_PTR(address, SharedRuntime::lrem); break; // check if dividend is 0 is done elsewhere case Bytecodes::_ldiv: entry = CAST_FROM_FN_PTR(address, SharedRuntime::ldiv); break; // check if dividend is 0 is done elsewhere case Bytecodes::_lmul: entry = CAST_FROM_FN_PTR(address, SharedRuntime::lmul); break; default: ShouldNotReachHere(); } LIR_Opr result = rlock_result(x); __ call_runtime_leaf(entry, getThreadTemp(), result_reg, cc->args()); __ move(result_reg, result); } else if (x->op() == Bytecodes::_lmul) { // missing test if instr is commutative and if we should swap LIRItem left(x->x(), this); LIRItem right(x->y(), this); // right register is destroyed by the long mul, so it must be // copied to a new register. right.set_destroys_register(); left.load_item(); right.load_item(); LIR_Opr reg = FrameMap::long0_opr; arithmetic_op_long(x->op(), reg, left.result(), right.result(), NULL); LIR_Opr result = rlock_result(x); __ move(reg, result); } else { // missing test if instr is commutative and if we should swap LIRItem left(x->x(), this); LIRItem right(x->y(), this); left.load_item(); // don't load constants to save register right.load_nonconstant(); rlock_result(x); arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL); } }
const QPixmap * Kleo::SignatureKeyListViewItem::pixmap( int col ) const { return listView() && listView()->columnStrategy() ? listView()->columnStrategy()->signaturePixmap( signature(), col ) : 0 ; }
void Function::dump(ostream& os) { Signature::set_fun_name(name(),is_constructor(),is_destructor()); os << *signature(); }
void DoMenu(int Type) { int Strlen, i, x; char *sPrompt, *sPromptBak, *temp; sPrompt = calloc(81, sizeof(char)); sPromptBak = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char)); TimeCheck(); switch(Type) { case 0: /* Display Prompt Line Only */ break; case 1: /* Goto another menu */ strncpy(Menus[MenuLevel], menus.OptionalData, 14); break; case 2: /* Gosub another menu */ if (MenuLevel < 49) { MenuLevel++; strncpy(Menus[MenuLevel], menus.OptionalData, 14); } else Syslog('?', "More than 50 menu levels"); break; case 3: /* Return from gosub */ if (MenuLevel > 0) MenuLevel--; break; case 4: /* Return to top menu */ MenuLevel = 0; break; case 5: /* Display .a?? file with controlcodes */ DisplayFile(menus.OptionalData); break; case 6: /* Show menu prompt */ Strlen = strlen(menus.OptionalData); for (x = 0; x < Strlen; x++) { if (menus.OptionalData[x] == '~') { strcat(sPrompt, sUserTimeleft); } else { snprintf(temp, 81, "%c", menus.OptionalData[x]); strcat(sPrompt, temp); } } strcpy(sPromptBak, sPrompt); strcpy(sPrompt, ""); Strlen = strlen(sPromptBak); for (x = 0; x < Strlen; x++) { if (*(sPromptBak + x) == '@') strcat(sPrompt, sAreaDesc); else if (*(sPromptBak + x) == '^') strcat(sPrompt, sMsgAreaDesc); else if (*(sPromptBak + x) == '#') snprintf(sPrompt, 81, "%s%s", sPrompt, (char *) GetLocalHM()); else { snprintf(temp, 81, "%c", *(sPromptBak + x)); strcat(sPrompt, temp); } } if (le_int(menus.ForeGnd) || le_int(menus.BackGnd)) pout(le_int(menus.ForeGnd), le_int(menus.BackGnd), sPrompt); else pout(WHITE, BLACK, sPrompt); break; case 7: /* Run external program */ if (strlen(menus.DoorName) && !menus.HideDoor) { memset(temp, 0, sizeof(temp)); strcpy(temp, menus.DoorName); ExtDoor(menus.OptionalData, menus.NoDoorsys, menus.Y2Kdoorsys, menus.Comport, menus.NoSuid, menus.NoPrompt, menus.SingleUser, temp); } else { ExtDoor(menus.OptionalData, menus.NoDoorsys, menus.Y2Kdoorsys, menus.Comport, menus.NoSuid, menus.NoPrompt, menus.SingleUser, NULL); } break; case 8: /* Show product information */ cr(); break; case 9: /* display todays callers */ LastCallers(menus.OptionalData); break; case 10: /* display userlist */ UserList(menus.OptionalData); break; case 11: /* display time statistics */ TimeStats(); break; case 12: /* page sysop for chat */ Page_Sysop(menus.OptionalData); break; case 13: /* terminate call */ free(sPrompt); free(sPromptBak); free(temp); Good_Bye(FTNERR_OK); break; case 14: /* make a log entry */ LogEntry(menus.OptionalData); break; case 15: /* print text to screen */ if (exitinfo.Security.level >= le_int(menus.MenuSecurity.level)) { for (i = 0; i < strlen(menus.OptionalData); i++) if (*(menus.OptionalData + i) == '@') *(menus.OptionalData + i) = '\n'; snprintf(temp, 81, "%s\r\n", menus.OptionalData); PUTSTR(temp); } break; case 16: /* who's currently online */ WhosOn(menus.OptionalData); Pause(); break; case 17: /* comment to sysop */ SysopComment((char *)"Comment to Sysop"); break; case 18: /* send on-line message */ SendOnlineMsg(menus.OptionalData); break; case 19: /* display Textfile with more */ MoreFile(menus.OptionalData); break; case 20: /* display a?? file with controlcode and wait for enter */ DisplayFileEnter(menus.OptionalData); break; case 21: /* display menuline only */ break; case 22: /* Chat with any user */ Chat(NULL, NULL); break; case 101: FileArea_List(menus.OptionalData); break; case 102: File_List(); break; case 103: ViewFile(NULL); break; case 104: Download(); break; case 105: File_RawDir(menus.OptionalData); break; case 106: KeywordScan(); break; case 107: FilenameScan(); break; case 108: NewfileScan(TRUE); break; case 109: Upload(); break; case 110: EditTaglist(); break; case 111: /* View file in homedir */ break; case 112: DownloadDirect(menus.OptionalData, TRUE); break; case 113: Copy_Home(); break; case 114: List_Home(); break; case 115: Delete_Home(); break; /* 116 Unpack file in homedir */ /* 117 Pack files in homedir */ case 118: Download_Home(); break; case 119: Upload_Home(); break; case 201: MsgArea_List(menus.OptionalData); break; case 202: Post_Msg(); break; case 203: Read_Msgs(); break; case 204: CheckMail(); break; case 205: QuickScan_Msgs(); break; case 206: Delete_Msg(); break; case 207: MailStatus(); break; case 208: OLR_TagArea(); break; case 209: OLR_UntagArea(); break; case 210: OLR_ViewTags(); break; case 211: OLR_RestrictDate(); break; case 212: OLR_Upload(); break; case 213: OLR_DownBW(); break; case 214: OLR_DownQWK(); break; case 215: OLR_DownASCII(); break; case 216: Read_Email(); break; case 217: Write_Email(); break; case 218: Trash_Email(); break; case 219: Choose_Mailbox(menus.OptionalData); break; case 220: QuickScan_Email(); break; case 221: DisplayRules(); break; case 301: Chg_Protocol(); break; case 302: Chg_Password(); break; case 303: Chg_Location(); break; case 305: Chg_VoicePhone(); break; case 306: Chg_DataPhone(); break; case 307: Chg_News(); break; case 309: Chg_DOB(); break; case 310: Chg_Language(FALSE); break; case 311: Chg_Hotkeys(); break; case 312: Chg_Handle(); break; case 313: Chg_MailCheck(); break; case 314: Chg_Disturb(); break; case 315: Chg_FileCheck(); break; case 316: Chg_FsMsged(); break; case 317: Chg_FsMsgedKeys(); break; case 318: Chg_Address(); break; case 319: signature(); break; case 320: Chg_OLR_ExtInfo(); break; case 321: Chg_Charset(); break; case 322: Chg_Archiver(); break; case 401: Oneliner_Add(); break; case 402: Oneliner_List(); break; case 403: Oneliner_Show(); break; case 404: Oneliner_Delete(); break; case 405: Oneliner_Print(); break; default: Enter(1); pout(WHITE, BLACK, (char *) Language(339)); Enter(2); Syslog('?', "Option: %s -> Unknown Menu Type: %d on %s", menus.MenuKey, Type, Menus[MenuLevel]); Pause(); } free(sPrompt); free(sPromptBak); free(temp); }
SpMVAcceleratorOldCacheDriver(volatile unsigned int * baseAddr) { m_baseAddr = baseAddr; assert(signature() == expSignature());};
// ------------------------------------------------------------------ // ciField::ciField ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with(NULL) { ASSERT_IN_VM; CompilerThread *thread = CompilerThread::current(); assert(ciObjectFactory::is_initialized(), "not a shared field"); assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool"); _cp_index = index; constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants()); // Get the field's name, signature, and type. symbolHandle name (thread, cpool->name_ref_at(index)); _name = ciEnv::current(thread)->get_object(name())->as_symbol(); int nt_index = cpool->name_and_type_ref_index_at(index); int sig_index = cpool->signature_ref_index_at(nt_index); symbolHandle signature (thread, cpool->symbol_at(sig_index)); _signature = ciEnv::current(thread)->get_object(signature())->as_symbol(); BasicType field_type = FieldType::basic_type(signature()); // If the field is a pointer type, get the klass of the // field. if (field_type == T_OBJECT || field_type == T_ARRAY) { bool ignore; // This is not really a class reference; the index always refers to the // field's type signature, as a symbol. Linkage checks do not apply. _type = ciEnv::current(thread)->get_klass_by_index(cpool, sig_index, ignore, klass); } else { _type = ciType::make(field_type); } _name = (ciSymbol*)ciEnv::current(thread)->get_object(name()); // Get the field's declared holder. // // Note: we actually create a ciInstanceKlass for this klass, // even though we may not need to. int holder_index = cpool->klass_ref_index_at(index); bool holder_is_accessible; ciInstanceKlass* declared_holder = ciEnv::current(thread)->get_klass_by_index(cpool, holder_index, holder_is_accessible, klass)->as_instance_klass(); // The declared holder of this field may not have been loaded. // Bail out with partial field information. if (!holder_is_accessible) { // _cp_index and _type have already been set. // The default values for _flags and _constant_value will suffice. // We need values for _holder, _offset, and _is_constant, _holder = declared_holder; _offset = -1; _is_constant = false; return; } instanceKlass* loaded_decl_holder = declared_holder->get_instanceKlass(); // Perform the field lookup. fieldDescriptor field_desc; klassOop canonical_holder = loaded_decl_holder->find_field(name(), signature(), &field_desc); if (canonical_holder == NULL) { // Field lookup failed. Will be detected by will_link. _holder = declared_holder; _offset = -1; _is_constant = false; return; } assert(canonical_holder == field_desc.field_holder(), "just checking"); initialize_from(&field_desc); }
void Structure::dump(const std::string& filename) { pomagma::dump(signature(), filename); }
sds request(T4C* t4c, METHOD method, sds endPoint, Parameters* paramsArgument) { sds result; Parameters* oauthParams = new_parameters(); genOAuthParams(t4c, oauthParams); Parameters* params = new_parameters(); buildParams(params, oauthParams, paramsArgument); sds url = sdscatprintf(sdsempty(), "%s%s", baseUrl, endPoint); sds oauthSignature = signature(t4c->consumerSecret, t4c->accessTokenSecret, method, url, params); sds encodedSignature = url_encode(oauthSignature); add_parameter(oauthParams, sdsnew("oauth_signature"), encodedSignature); add_parameter(params, sdsnew("oauth_signature"), encodedSignature); sds authorizeChild = join_parameters(oauthParams, ","); sds authorize = sdscatprintf(sdsempty(), "Authorization: OAuth %s", authorizeChild); sds path = join_parameters(params, "&"); if (DEBUG) { printf("----------------------------\n"); printf("URL: %s\n", url); printf("endPoint: %s\n", endPoint); printf("path: %s\n", path); printf("authorize: %s\n", authorize); printf("----------------------------\n"); } CURL* curl; curl = curl_easy_init(); sds reqURL; if (method == GET) { reqURL = sdscatprintf(sdsempty(), "%s?%s", url, path); curl_easy_setopt(curl, CURLOPT_URL, reqURL); } else if (method == POST) { curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, path); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sdslen(path)); curl_easy_setopt(curl, CURLOPT_URL, url); } struct curl_slist *headers = NULL; headers = curl_slist_append(headers, authorize); curl_easy_setopt(curl, CURLOPT_HEADER, headers); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_result_stringlize_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&result); curl_easy_perform(curl); curl_easy_cleanup(curl); sdsfree(oauthSignature); sdsfree(encodedSignature); sdsfree(reqURL); sdsfree(url); sdsfree(path); sdsfree(authorize); sdsfree(authorizeChild); free_parameters(oauthParams); return result; }
void LocalRecognitionPipeline<PointT>::loadFeaturesAndCreateFLANN () { std::vector<ModelTPtr> models = source_->getModels(); flann_models_.clear(); std::vector<std::vector<float> > descriptors; for (size_t m_id = 0; m_id < models.size (); m_id++) { ModelTPtr m = models[m_id]; const std::string out_train_path = models_dir_ + "/" + m->class_ + "/" + m->id_ + "/" + descr_name_; const std::string in_train_path = models_dir_ + "/" + m->class_ + "/" + m->id_ + "/views/"; for(size_t v_id=0; v_id< m->view_filenames_.size(); v_id++) { std::string signature_basename (m->view_filenames_[v_id]); boost::replace_last(signature_basename, source_->getViewPrefix(), "/descriptors_"); boost::replace_last(signature_basename, ".pcd", ".desc"); std::ifstream f (out_train_path + signature_basename, std::ifstream::binary); if(!f.is_open()) { std::cerr << "Could not find signature file " << out_train_path << signature_basename << std::endl; continue; } int nrows, ncols; f.read((char*) &nrows, sizeof(nrows)); f.read((char*) &ncols, sizeof(ncols)); std::vector<std::vector<float> > signature (nrows, std::vector<float>(ncols)); for(size_t sig_id=0; sig_id<nrows; sig_id++) f.read((char*) &signature[sig_id][0], sizeof(signature[sig_id][0])*signature[sig_id].size()); f.close(); flann_model descr_model; descr_model.model = m; descr_model.view_id = m->view_filenames_[v_id]; size_t kp_id_offset = 0; if (param_.use_cache_) //load model data (keypoints, pose and normals for each training view) and save them to cache { std::string pose_basename (m->view_filenames_[v_id]); boost::replace_last(pose_basename, source_->getViewPrefix(), "/pose_"); boost::replace_last(pose_basename, ".pcd", ".txt"); Eigen::Matrix4f pose_matrix = io::readMatrixFromFile( in_train_path + pose_basename); std::string keypoint_basename (m->view_filenames_[v_id]); boost::replace_last(keypoint_basename, source_->getViewPrefix(), + "/keypoints_"); typename pcl::PointCloud<PointT>::Ptr keypoints (new pcl::PointCloud<PointT> ()); pcl::io::loadPCDFile (out_train_path + keypoint_basename, *keypoints); std::string kp_normals_basename (m->view_filenames_[v_id]); boost::replace_last(kp_normals_basename, source_->getViewPrefix(), "/keypoint_normals_"); pcl::PointCloud<pcl::Normal>::Ptr kp_normals (new pcl::PointCloud<pcl::Normal> ()); pcl::io::loadPCDFile (out_train_path + kp_normals_basename, *kp_normals); for (size_t kp_id=0; kp_id<keypoints->points.size(); kp_id++) { keypoints->points[ kp_id ].getVector4fMap () = pose_matrix * keypoints->points[ kp_id ].getVector4fMap (); kp_normals->points[ kp_id ].getNormalVector3fMap () = pose_matrix.block<3,3>(0,0) * kp_normals->points[ kp_id ].getNormalVector3fMap (); } if( !m->keypoints_ ) m->keypoints_.reset(new pcl::PointCloud<PointT>()); if ( !m->kp_normals_ ) m->kp_normals_.reset(new pcl::PointCloud<pcl::Normal>()); kp_id_offset = m->keypoints_->points.size(); m->keypoints_->points.insert(m->keypoints_->points.end(), keypoints->points.begin(), keypoints->points.end()); m->kp_normals_->points.insert(m->kp_normals_->points.end(), kp_normals->points.begin(), kp_normals->points.end()); // size_t existing_kp = m->kp_info_.size(); // m->kp_info_.resize(existing_kp + keypoints->points.size()); } for (size_t dd = 0; dd < signature.size (); dd++) { descr_model.keypoint_id = kp_id_offset + dd; descriptors.push_back(signature[dd]); flann_models_.push_back (descr_model); } } } std::cout << "Total number of " << estimator_->getFeatureDescriptorName() << " features within the model database: " << flann_models_.size () << std::endl; flann_data_.reset (new flann::Matrix<float>(new float[descriptors.size () * descriptors[0].size()], descriptors.size (), descriptors[0].size())); for (size_t i = 0; i < flann_data_->rows; i++) { for (size_t j = 0; j < flann_data_->cols; j++) { flann_data_->ptr()[i * flann_data_->cols + j] = descriptors[i][j]; } } if(param_.distance_metric_==2) { flann_index_l2_.reset( new flann::Index<flann::L2<float> > (*flann_data_, flann::KDTreeIndexParams (4))); flann_index_l2_->buildIndex(); } else { flann_index_l1_.reset( new flann::Index<flann::L1<float> > (*flann_data_, flann::KDTreeIndexParams (4))); flann_index_l1_->buildIndex(); } }