GHashTable樣本

來源:互聯網
上載者:User

HashTable 應用樣本

static const char *
maybe_translate_message (const char *msg)
{
        char              *s;
        const char        *ret;
        static GHashTable *hash = NULL;

        if (hash == NULL) {
                hash = g_hash_table_new (g_str_hash, g_str_equal);
                g_hash_table_insert (hash, "login:", _("Username:"));
                g_hash_table_insert (hash, "Username:", _("Username:"));
                g_hash_table_insert (hash, "username:", _("Username:"));
                g_hash_table_insert (hash, "Password:", _("Password:"));
                g_hash_table_insert (hash, "password:", _("Password:"));
                g_hash_table_insert (hash, "No password supplied", _("No password supplied"));
                g_hash_table_insert (hash, "Password unchanged", _("Password unchanged"));
                g_hash_table_insert (hash, "Can not get username", _("Can not get username"));
                g_hash_table_insert (hash, "Retype new UNIX password:", _("Retype new UNIX password:"));
                g_hash_table_insert (hash, "Enter new UNIX password:", _("Enter new UNIX password:"));
                g_hash_table_insert (hash, "(current) UNIX password:", _("(current) UNIX password:"));
                g_hash_table_insert (hash, "Error while changing NIS password.", _("Error while changing NIS password."));
                g_hash_table_insert (hash, "You must choose a longer password", _("You must choose a longer password"));
                g_hash_table_insert (hash, "Sorry, passwords do not match", _("Sorry, passwords do not match"));
        }

        s = g_strstrip (g_strdup (msg));
        ret = g_hash_table_lookup (hash, s);
        g_free (s);

        if (ret != NULL) {
                return ret;
        } else {
                return msg;
        }
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.