QString JournalMessage::presentation() { QString subj = getSubject(); QString res; if (!subj.isEmpty()) res = i18n("<p>Subject: %1</p>") .arg(subj); res += Message::presentation(); return res; }
StateResult ActionPutInto::doPreBeginWorkNVI(GameState& gameState, Systems::Manager& systems, json& arguments) { std::string message; auto subject = getSubject(); auto object = getObject(); auto container = getTargetThing(); auto& narrator = systems.narrator(); // Verify that the Action has an object. if (object == EntityId::Void) { return StateResult::Failure(); } // Check that the entity and container aren't the same entity. if (object == container) { if (gameState.components().globals.player() == subject) { message = narrator.makeTr("YOU_TRY_TO_STORE_THE_FOO_INSIDE_ITSELF_HUMOROUS", arguments); } else { message = narrator.makeTr("YOU_TRY_TO_STORE_THE_FOO_INSIDE_ITSELF_INVALID", arguments); CLOG(WARNING, "Action") << "NPC tried to store a container in itself!?"; } return StateResult::Failure(); } // Check that the container actually IS a container. if (COMPONENTS.inventory.valueOrDefault(container).maxSize() == 0) { printMessageTry(systems, arguments); putMsg(narrator.makeTr("THE_TARGET_IS_NOT_A_CONTAINER", arguments)); return StateResult::Failure(); } // Check that the entity's location isn't already the container. if (COMPONENTS.position[object].parent() == container) { printMessageTry(systems, arguments); putMsg(narrator.makeTr("THE_FOO_IS_ALREADY_IN_THE_TARGET", arguments)); return StateResult::Failure(); } // Check that the container is within reach. if (!systems.geometry()->firstCanReachSecond(subject, container)) { printMessageTry(systems, arguments); putMsg(narrator.makeTr("THE_TARGET_IS_OUT_OF_REACH", arguments)); return StateResult::Failure(); } return StateResult::Success(); }
void pki_x509super::opensslConf(QString fname) { QString extensions; extList el = getV3ext(); x509name n = getSubject(); el.genGenericConf(&extensions); QString name = n.taggedValues(); QString final = oid_sect(); final += QString("[ req ]\n"
ReasonBool ActionWield::subjectIsCapable(GameState const& gameState) const { auto subject = getSubject(); bool isSapient = COMPONENTS.sapience.existsFor(subject); bool canGrasp = COMPONENTS.bodyparts.existsFor(subject) && COMPONENTS.bodyparts[subject].hasPrehensileBodyPart(); if (!isSapient) return { false, "YOU_ARE_NOT_SAPIENT" }; ///< @todo Add translation key if (!canGrasp) return { false, "YOU_HAVE_NO_GRASPING_BODYPARTS" }; ///< @todo Add translation key return { true, "" }; }
void data_printInput() { unsigned int i, j; printf("%u\n%u\n%u\n", num_cabinets, num_documents, num_subjects); for(i = 0; i < num_documents; i++) { printf("%u ", i); for(j=0; j < num_subjects; j++) printf("%.1f ", getSubject(j, getDocument(i))); printf("\n"); } }
StateResult ActionWield::doFinishWorkNVI(GameState& gameState, Systems::Manager& systems, json& arguments) { auto subject = getSubject(); auto object = getObject(); auto& components = gameState.components(); auto& narrator = systems.narrator(); std::string bodypart_desc = narrator.getBodypartDescription(subject, m_bodyLocation); COMPONENTS.bodyparts[subject].wieldEntity(object, m_bodyLocation); arguments["your_bodypart"] = narrator.getPossessiveString(subject, bodypart_desc); putMsg(narrator.makeTr("YOU_ARE_NOW_WIELDING_THE_FOO", arguments)); return StateResult::Success(); }
QSqlError pki_x509super::insertSqlData() { QSqlError e = lookupKey(); if (e.isValid()) return e; XSqlQuery q; SQL_PREPARE(q, "INSERT INTO x509super (item, subj_hash, pkey, key_hash) " "VALUES (?, ?, ?, ?)"); q.bindValue(0, sqlItemId); q.bindValue(1, (uint)getSubject().hashNum()); q.bindValue(2, privkey ? privkey->getSqlItemId() : QVariant()); q.bindValue(3, pubHash()); q.exec(); return q.lastError(); }
StateResult ActionWield::doBeginWorkNVI(GameState& gameState, Systems::Manager& systems, json& arguments) { /// @todo Wielding should take time -- should not be instantaneously done here. auto& lua = gameState.lua(); auto subject = getSubject(); auto object = getObject(); printMessageBegin(systems, arguments); // If we HAVE a new item, try to wield it. if (lua.doSubjectActionObject(subject, *this, object)) { /// @todo Figure out action time. return StateResult::Success(); } return StateResult::Failure(); }
void Search::saveSettings(QSettings *config) { config->setValue("mailbox", mailbox() ); config->setValue("name", name() ); config->setValue("from", getFrom() ); config->setValue("to", getTo() ); config->setValue("subject", getSubject() ); config->setValue("body", getBody() ); config->setValue("status", status() ); if ( !getBeforeDate().isNull() ) { config->setValue("datebefore", getBeforeDate().toString() ); } else { config->setValue("datebefore", "" ); } if ( !getAfterDate().isNull() ) { config->setValue("dateafter", getAfterDate().toString() ); } else { config->setValue("dateafter", "" ); } }
void update() { int v = getSubject()->getValue(); cout << v << " mult " << _value << " is " << v * _value << endl; }
void update() { int v = getSubject()->getValue(); cout << _value << " div " << v << " is " << _value / v << endl; }
bool bdoc::X509Cert::verifySignature(int digestMethod, int digestSize, std::vector<unsigned char> digest, std::vector<unsigned char> signature) { int result = 0; EVP_PKEY* key = getPublicKey(); switch (EVP_PKEY_type(key->type)) { case EVP_PKEY_RSA: { if (digest.size() > static_cast<size_t>(digestSize)) { // The digest already has an ASN.1 DigestInfo header. break; } X509_SIG *sig = X509_SIG_new(); // Prefer set0 to set_md, so we don't have to initialize the // digest lookup table with OpenSSL_add_all_digests. None of // our supported digests have parameters anyway. X509_ALGOR_set0(sig->algor, OBJ_nid2obj(digestMethod), V_ASN1_NULL, NULL); ASN1_OCTET_STRING_set(sig->digest, &digest[0], digest.size()); unsigned char *asn1 = NULL; size_t asn1_len = i2d_X509_SIG(sig, &asn1); digest = std::vector<unsigned char>(asn1, asn1 + asn1_len); X509_SIG_free(sig); break; } case EVP_PKEY_EC: { ECDSA_SIG *sig = ECDSA_SIG_new(); // signature is just r and s concatenated, so split them. size_t n_len = signature.size() >> 1; BN_bin2bn(&signature[0], n_len, sig->r); BN_bin2bn(&signature[n_len], n_len, sig->s); unsigned char *asn1 = NULL; size_t asn1_len = i2d_ECDSA_SIG(sig, &asn1); signature = std::vector<unsigned char>(asn1, asn1 + asn1_len); ECDSA_SIG_free(sig); break; } default: THROW_STACK_EXCEPTION("Certificate '%s' has an unsupported " "public key type, can not verify signature.", getSubject().c_str()); } EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(key, NULL); if (!ctx) { EVP_PKEY_free(key); THROW_STACK_EXCEPTION("Creating signature verification " "context failed: %s", ERR_reason_error_string(ERR_get_error())); } if (EVP_PKEY_verify_init(ctx) <= 0) { EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(key); THROW_STACK_EXCEPTION("Initializing signature " "verification context failed: %s", ERR_reason_error_string(ERR_get_error())); } result = EVP_PKEY_verify(ctx, &signature[0], signature.size(), &digest[0], digest.size()); if (result < 0) { EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(key); THROW_STACK_EXCEPTION("Error during signature verification: %s", ERR_reason_error_string(ERR_get_error())); } EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(key); return (result == 1); }
void Gallows::displayInfo() { // display relevant info std::cout << "Your word is from the subject " << getSubject() << " and has " << getCharacters() << " characters. You have " << lives << " lives remaining." << std::endl; }