コード例 #1
0
ファイル: engine.c プロジェクト: kleopatra999/ibus-hangul
static void
ibus_hangul_engine_destroy (IBusHangulEngine *hangul)
{
    if (hangul->prop_hanja_mode) {
        g_object_unref (hangul->prop_hanja_mode);
        hangul->prop_hanja_mode = NULL;
    }

    if (hangul->prop_list) {
        g_object_unref (hangul->prop_list);
        hangul->prop_list = NULL;
    }

    if (hangul->table) {
        g_object_unref (hangul->table);
        hangul->table = NULL;
    }

    if (hangul->context) {
        hangul_ic_delete (hangul->context);
        hangul->context = NULL;
    }

    IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)hangul);
}
コード例 #2
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
int main()
{
    hangul_init();

    int number_failed;
    Suite* s = libhangul_suite();
    SRunner* sr = srunner_create(s);

    srunner_set_fork_status(sr, CK_NOFORK);
    srunner_run_all(sr, CK_NORMAL);

    number_failed = srunner_ntests_failed(sr);
    srunner_free(sr);

    hangul_ic_delete(global_ic);

    hangul_fini();

    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
コード例 #3
0
ファイル: nimf-libhangul.c プロジェクト: cogniti/nimf
static void
nimf_libhangul_finalize (GObject *object)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  NimfLibhangul *hangul = NIMF_LIBHANGUL (object);

  if (--nimf_libhangul_hanja_table_ref_count == 0)
  {
    hanja_table_delete (nimf_libhangul_hanja_table);
    hanja_table_delete (nimf_libhangul_symbol_table);
  }

  hanja_list_delete (hangul->hanja_list);
  hangul_ic_delete (hangul->context);
  g_free (hangul->preedit_string);
  nimf_preedit_attr_freev (hangul->preedit_attrs);
  g_free (hangul->id);
  g_free (hangul->method);
  nimf_key_freev (hangul->hanja_keys);
  g_object_unref (hangul->settings);

  G_OBJECT_CLASS (nimf_libhangul_parent_class)->finalize (object);
}
コード例 #4
0
QHangulPlatformInputContext::~QHangulPlatformInputContext() {
    if (m_hic != NULL) {
        hangul_ic_delete(m_hic);
    }
}
コード例 #5
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_process_romaja)
{
    HangulInputContext* ic;
    const ucschar* preedit;
    const ucschar* commit;

    // romaja keyboard test
    ic = hangul_ic_new("ro");

    // basic test: han produces 한
    hangul_ic_process(ic, 'h');
    hangul_ic_process(ic, 'a');
    hangul_ic_process(ic, 'n');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == L'한');
    fail_unless(commit[0] == 0);

    hangul_ic_reset(ic);

    // insert ㅇ when a syllable is not started with consonant
    hangul_ic_process(ic, 'a');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == L'아');
    fail_unless(commit[0] == 0);

    // remove correctly when automatically ㅇ was inserted
    hangul_ic_backspace(ic);

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == 0);
    fail_unless(commit[0] == 0);

    // append ㅡ when a syllable is not ended with vowel
    hangul_ic_process(ic, 't');
    hangul_ic_process(ic, 't');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == 0x314c); // ㅌ
    fail_unless(commit[0] == L'트');

    // ng makes trailing ㅇ
    hangul_ic_reset(ic);
    hangul_ic_process(ic, 'g');
    hangul_ic_process(ic, 'a');
    hangul_ic_process(ic, 'n');
    hangul_ic_process(ic, 'g');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == L'강'); // 강
    fail_unless(commit[0] == 0);

    // gangi makes 강이
    hangul_ic_process(ic, 'i');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == L'이');
    fail_unless(commit[0] == L'강');  // 강

    // nanG makes 난ㄱ
    // uppercase makes new syllable
    hangul_ic_process(ic, 'n');
    hangul_ic_process(ic, 'a');
    hangul_ic_process(ic, 'n');
    hangul_ic_process(ic, 'G');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == 0x3131); // ㄱ
    fail_unless(commit[0] == L'난');  // 난

    // special operation for x
    // x generate ㅈ for leading consonant
    hangul_ic_reset(ic);
    hangul_ic_process(ic, 'x');
    hangul_ic_process(ic, 'x');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == 0x3148); // 지
    fail_unless(commit[0] == L'즈');

    hangul_ic_reset(ic);
    hangul_ic_process(ic, 'x');
    hangul_ic_process(ic, 'y');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == L'지'); // 지
    fail_unless(commit[0] == 0x0);

    // x generate ㄱㅅ for trailing consonant
    // and ㅅ will be transferred to next syllable when next input
    // character is vowel.
    hangul_ic_reset(ic);
    hangul_ic_process(ic, 's');
    hangul_ic_process(ic, 'e');
    hangul_ic_process(ic, 'x');
    hangul_ic_process(ic, 'y');

    preedit = hangul_ic_get_preedit_string(ic);
    commit = hangul_ic_get_commit_string(ic);
    fail_unless(preedit[0] == L'시'); // 시
    fail_unless(commit[0] == L'섹');  // 섹
    
    hangul_ic_delete(ic);
}
コード例 #6
0
ファイル: original.cpp プロジェクト: Exceltior/CTF-Solutions
int main() {
    std::string a = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbccccccccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    std::string output;

    ZopfliOptions options;
    ZopfliInitOptions(&options);

    snappy::Compress(a.data(), a.size(), &output);

    if(!checkhash((unsigned char *)output.data(), output.size(), (char *)"0x5a8f06cf6817a74bc75c3c8290196928acb04c189ecdd192a93eb3c3")) {
        std::cout<<"Something wrong\n";
    }

    unsigned char b[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbccccccccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    unsigned char *out = NULL;
    size_t outsize = 0;

    ZopfliCompress(&options, ZOPFLI_FORMAT_GZIP, b, a.size(), &out, &outsize);

    if(!checkhash(out, outsize, (char *)"0x0f66ce213d2d27067ff9ffa8bbde2dd06d7f3e687549fad846169e16")) {
        std::cout<<"Something wrong\n";
    }

    HangulInputContext* ic;
    const char* p = "dekde";
    const ucschar* commit;

    ic = hangul_ic_new("2y");

    while (*p != '\0') {
        hangul_ic_process(ic, *p);
        p++;
    }

    commit = hangul_ic_get_commit_string(ic);

    int len = wcslen((const wchar_t*)commit);

    if(!checkhash((unsigned char*)commit, len * sizeof(const wchar_t), (char *)"0xc9bf9374fbc9f4989afd0af7ac9824a4dcc768b33bfa3bb38e42617b")) {
        std::cout<<"Something wrong\n";
    }
    hangul_ic_delete(ic);

    static JSClass global_class = { "global",
                                    JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS,
                                    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
                                    JS_StrictPropertyStub,
                                    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub,
                                    NULL, JSCLASS_NO_OPTIONAL_MEMBERS
    };
    JSRuntime *rt = JS_NewRuntime(8 * 1024 * 1024);
    JSContext *cx = JS_NewContext(rt, 8192);
    JS_SetOptions(cx, JSOPTION_VAROBJFIX);
    JS_SetErrorReporter(cx, reportError);

    
        JSObject *global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);

        JS_SetGlobalObject(cx, global);

        if (!JS_InitStandardClasses(cx, global)) {
            return 1;
        }
        char source[] = "Math.random()";

        jsval rval;

        cx->rngSeed = 31337;

        JS_EvaluateScript(cx, global, source, strlen(source),
                       "none", 10, &rval);

        double nums[2];
        nums[0] = JSVAL_TO_DOUBLE(rval);
        JS_EvaluateScript(cx, global, source, strlen(source),
                       "none", 10, &rval);
        nums[1] = JSVAL_TO_DOUBLE(rval);

        if(!checkhash((unsigned char*)nums, 2 * sizeof(double), (char *)"0x61b35e8d466f24ee1ea502350ec6f5d1134fe6ec543c17845fa62f8a")) {
            std::cout<<"Something wrong\n";
        }
    
    JS_DestroyContext(cx);
    JS_DestroyRuntime(rt);

    JS_ShutDown();


    mtprngParam mt;

    byte bay[] = "qqqqqqqqqqqqqqqq";
    byte result[100];

    for(int i=0; i< 100; i++) {
        result[i] = 0;
    }

    mtprngSetup(&mt);
    mtprngSeed(&mt, bay, 16);

    mtprngNext(&mt, result, 100);
    if(!checkhash((unsigned char*)&result, 100, (char *)"0x7754dfd27fe6fa00551861ff41e4f48315bd89bef6da652f182ce2d6")) {
        std::cout<<"Something wrong\n";
    }



    ranlib::ChiSquare<double> gen(4);

    gen.seed(31337);
    double f[16];

    for(int i = 0; i<16; i++) {
        f[i] = gen.random();
    }

    if(!checkhash((unsigned char*)&f, 16 * sizeof(double), (char *)"0xd19d0c167fe93b11004c0167c226d2e92c17dfa36ffb243f39824098")) {
        std::cout<<"Something wrong\n";
    }


    Botan::byte pass[] = "aaaabbbb";

    Botan::PBKDF* pbkdf = Botan::get_pbkdf("PBKDF2(SHA-256)");
    Botan::OctetString aes_key = pbkdf->derive_key(32, "pass1337", pass, 8, 31337);


    std::string aa = aes_key.as_string();

    if(!checkhash((unsigned char*)aa.c_str(), aa.size(), (char *)"0x0c33d122ed50848a676539ae48eb84db0dcbf69e9ee857094755f2d7")) {
        std::cout<<"Something wrong\n";
    }

    std::cout<<"Answer is RUCTF_";
    checkhash((unsigned char*)together, pos, (char *)"");

    return 0;
}
コード例 #7
0
ファイル: pyhangul.c プロジェクト: Nanbu21/libhangul
/* PY_HANGULIC dealloc */
static void PY_HANGULIC_dealloc(PY_HANGULIC *self)
{
    hangul_ic_delete(self->hic);
    self->hic = NULL;
    PyMem_Free((char *) self);
}