コード例 #1
0
DictViewInstance::WordList *DictViewInstance::WordSuggestion(FarStringW &word)
{
  WordList *wl = new WordList();
  _current_color = -1;
  _current_word = word;
  DecisionTable::action_inst_t act_inst = logic.Execute();
  Action *action = static_cast<Action *>(act_inst->client_context);
  far_assert(action);
  FarString suggestion_order = action->suggestions;
  if (suggestion_order.IsEmpty()) 
    for (int i = 0; i<DictCount(); i++)
      suggestion_order += GetDict(i)->dict + ';';
  if (suggestion_order.IsEmpty())
    return wl;
  FarStringTokenizer dicts(suggestion_order, ';');
  for (int i = 0; i < DictCount() && dicts.HasNext(); i++) 
  {
    const FarString &dict(dicts.NextToken());
    for (int j = 0; j < DictCount(); j++)
      if (GetDict(j)->dict == dict) {
        far_assert(spell_factory);
        SpellInstance *dict_inst = spell_factory->GetDictInstance(dict);
        far_assert(dict_inst);
        wl->Add(dict_inst->Suggest(word));
      }
  }
  return wl;
}
コード例 #2
0
ファイル: test.c プロジェクト: SRI-CSL/ENCODERS
int runABETest(Charm_t *pGroup)
{
	Charm_t *pClass = NULL;

    pClass = InitScheme("abenc_bsw07", "CPabe_BSW07", pGroup);
    if(pClass == NULL) return -1;

    Charm_t *pKeys = CallMethod(pClass, "setup", "");
    debug("setup ok.\n");

	Charm_t *pkDict = GetIndex(pKeys, 0);
	Charm_t *mskDict = GetIndex(pKeys, 1);

	Charm_t *pValue = GetDict(pkDict, "g");
	Charm_t *pValue1 = GetDict(mskDict, "beta");

	char *attrList = "[ONE, TWO]";

	debug("calling keygen...\n");
	char *policy = "((THREE or ONE) and (THREE or TWO))";
	printf("attribute: '%s'\n", attrList);
	printf("enc policy: '%s'\n", policy);
	Charm_t *skDict = CallMethod(pClass, "keygen", "%O%O%A", pkDict, mskDict, attrList);

	Charm_t *pValue2 = GetDict(skDict, "D");

	Charm_t *msg = CallMethod(pGroup, "random", "%I", GT);
	Charm_t *ctDict = CallMethod(pClass, "encrypt", "%O%O%s", pkDict, msg, policy);
	Charm_t *pValue3 = GetDict(ctDict, "C_tilde");

	Charm_t *pValue4 = CallMethod(pClass, "decrypt", "%O%O%O", pkDict, skDict, ctDict);

	PrintObject(pValue);
	PrintObject(pValue1);
	PrintObject(pValue2);
	printf("ct :=> \n");
	PrintObject(pValue3);
	printf("msg :=> \n");
	PrintObject(msg);
	printf("rec msg :=> \n");
	PrintObject(pValue4);

	Free(pValue);
	Free(pValue1);
	Free(pValue2);
	Free(pValue3);
	Free(pValue4);
	Free(skDict);
	Free(pkDict);
	Free(mskDict);
	Free(pKeys);
	Free(pClass);
    return 0;
}
コード例 #3
0
bp::object PyHandle::ExecFile(const char* file)
{
	char pf[255];

	Q_snprintf(pf, 255, "%s\\%s", GEPython()->GetRootPath(), file);

	char fullPath[255];
	filesystem->RelativePathToFullPath( pf, "MOD", fullPath, 255);

	return bp::exec_file(fullPath, GetDict(), GetDict());
}
コード例 #4
0
bool CPDF_Stream::WriteTo(IFX_ArchiveStream* archive,
                          const CPDF_Encryptor* encryptor) const {
  const bool is_metadata = IsMetaDataStreamDictionary(GetDict());
  CPDF_FlateEncoder encoder(this, !is_metadata);

  std::vector<uint8_t> encrypted_data;
  pdfium::span<const uint8_t> data = encoder.GetSpan();

  if (encryptor && !is_metadata) {
    encrypted_data = encryptor->Encrypt(data);
    data = encrypted_data;
  }

  size_t size = data.size();
  if (static_cast<size_t>(encoder.GetDict()->GetIntegerFor("Length")) != size) {
    encoder.CloneDict();
    encoder.GetClonedDict()->SetNewFor<CPDF_Number>("Length",
                                                    static_cast<int>(size));
  }

  if (!encoder.GetDict()->WriteTo(archive, encryptor))
    return false;

  if (!archive->WriteString("stream\r\n"))
    return false;

  if (size && !archive->WriteBlock(data.data(), size))
    return false;

  if (!archive->WriteString("\r\nendstream"))
    return false;

  return true;
}
コード例 #5
0
ファイル: cpdf_stream.cpp プロジェクト: gradescope/pdfium
CPDF_Object* CPDF_Stream::CloneNonCyclic(
    bool bDirect,
    std::set<const CPDF_Object*>* pVisited) const {
  pVisited->insert(this);
  CPDF_StreamAcc acc;
  acc.LoadAllData(this, TRUE);
  uint32_t streamSize = acc.GetSize();
  CPDF_Dictionary* pDict = GetDict();
  if (pDict && !pdfium::ContainsKey(*pVisited, pDict)) {
    pDict = ToDictionary(
        static_cast<CPDF_Object*>(pDict)->CloneNonCyclic(bDirect, pVisited));
  }

  return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
}
コード例 #6
0
std::unique_ptr<CPDF_Object> CPDF_Stream::CloneNonCyclic(
    bool bDirect,
    std::set<const CPDF_Object*>* pVisited) const {
  pVisited->insert(this);
  auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(this);
  pAcc->LoadAllDataRaw();

  uint32_t streamSize = pAcc->GetSize();
  const CPDF_Dictionary* pDict = GetDict();
  std::unique_ptr<CPDF_Dictionary> pNewDict;
  if (pDict && !pdfium::ContainsKey(*pVisited, pDict)) {
    pNewDict =
        ToDictionary(static_cast<const CPDF_Object*>(pDict)->CloneNonCyclic(
            bDirect, pVisited));
  }
  return pdfium::MakeUnique<CPDF_Stream>(pAcc->DetachData(), streamSize,
                                         std::move(pNewDict));
}
コード例 #7
0
ファイル: test.c プロジェクト: SRI-CSL/ENCODERS
int runHybridABETest(Charm_t *pGroup)
{
	Charm_t *pABEClass = NULL, *pClass = NULL;

    pABEClass = InitScheme("charm.schemes.abenc.abenc_bsw07", "CPabe_BSW07", pGroup);
    if(pABEClass == NULL) return -1;

    debug("cpabe initialized.\n");

    pClass = InitAdapter("charm.adapters.abenc_adapt_hybrid", "HybridABEnc", pABEClass, pGroup);
    if(pClass == NULL) return -1;

    debug("hyb_abe initialized.\n");

    Charm_t *pKeys = CallMethod(pClass, "setup", "");
    debug("setup ok.\n");

	Charm_t *pkDict = GetIndex(pKeys, 0);
	Charm_t *mskDict = GetIndex(pKeys, 1);

	Charm_t *pValue = GetDict(pkDict, "g");
	Charm_t *pValue1 = GetDict(mskDict, "beta");

	char *attrList = "[ONE, TWO]";

	debug("calling keygen...\n");
	char *policy = "((THREE or ONE) and (THREE or TWO))";
	printf("attribute: '%s'\n", attrList);
	printf("enc policy: '%s'\n", policy);
	Charm_t *skDict = CallMethod(pClass, "keygen", "%O%O%A", pkDict, mskDict, attrList);

	Charm_t *pValue2 = objectToBytes(skDict, pGroup);
    debug("keygen ok.\n");

	//Charm_t *pValue2 = GetDict(skDict, "D");

	char *msg = "this is a test message.";
	Charm_t *ctDict = CallMethod(pClass, "encrypt", "%O%b%s", pkDict, msg, policy);
    debug("encrypt ok.\n");

	Charm_t *rec_msg = CallMethod(pClass, "decrypt", "%O%O%O", pkDict, skDict, ctDict);
    debug("decrypt ok.\n");

    printf("g => ");
	PrintObject(pValue);
	printf("beta => ");
	PrintObject(pValue1);
	printf("sk serialized => \n");
	PrintObject(pValue2);
	//	printf("ct :=> \n");
	//	PrintObject(pValue3);
	printf("original msg :=> '%s'\n", msg);
	//	PrintObject(msg);
	printf("rec msg :=> \n");
	PrintObject(rec_msg);

	Free(pValue);
	Free(pValue1);
	Free(pValue2);
//	Free(pValue3);
	Free(rec_msg);
	Free(skDict);
	Free(pkDict);
	Free(mskDict);
	Free(pKeys);
	Free(pClass);
    Free(pABEClass);
	return 0;
}
コード例 #8
0
bp::object PyHandle::Exec(const char* buff)
{
	return bp::exec(buff, GetDict(), GetDict());
}