--- a/libpurple/cipher.c Thu Apr 03 16:02:37 2014 +0200
+++ b/libpurple/cipher.c Thu Apr 03 17:30:00 2014 +0200
@@ -51,6 +51,46 @@
+purple_cipher_get_name(PurpleCipher *cipher) + PurpleCipherClass *klass; + if (!PURPLE_IS_CIPHER(cipher)) + return "(error: not a cipher)"; + klass = PURPLE_CIPHER_GET_CLASS(cipher); + return "(error: unknown cipher class)"; + name = g_type_name(G_TYPE_FROM_CLASS(klass)); + return "(error: unknown cipher name)"; +purple_hash_get_name(PurpleHash *hash) + PurpleHashClass *klass; + if (!PURPLE_IS_HASH(hash)) + return "(error: not a hash)"; + klass = PURPLE_HASH_GET_CLASS(hash); + return "(error: unknown hash class)"; + name = g_type_name(G_TYPE_FROM_CLASS(klass)); + return "(error: unknown hash name)"; purple_cipher_reset(PurpleCipher *cipher) {
PurpleCipherClass *klass = NULL;
@@ -59,12 +99,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->reset)
+ if (klass && klass->reset)
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the reset method", + purple_cipher_get_name(cipher)); @@ -75,12 +116,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->reset_state)
+ if (klass && klass->reset_state) klass->reset_state(cipher);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- "reset_state method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the reset_state method", + purple_cipher_get_name(cipher)); @@ -93,12 +135,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->set_iv)
+ if (klass && klass->set_iv) klass->set_iv(cipher, iv, len);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the set_iv method", + purple_cipher_get_name(cipher)); @@ -111,12 +154,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->append)
+ if (klass && klass->append) klass->append(cipher, data, len);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the append method", + purple_cipher_get_name(cipher)); @@ -128,12 +172,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->digest)
+ if (klass && klass->digest) return klass->digest(cipher, digest, len);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the digest method", + purple_cipher_get_name(cipher)); @@ -175,12 +220,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->get_digest_size)
+ if (klass && klass->get_digest_size) return klass->get_digest_size(cipher);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- "get_digest_size method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the get_digest_size method", + purple_cipher_get_name(cipher)); @@ -198,12 +244,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->encrypt)
+ if (klass && klass->encrypt) return klass->encrypt(cipher, input, in_len, output, out_size);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the encrypt method", + purple_cipher_get_name(cipher)); @@ -220,12 +267,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->decrypt)
+ if (klass && klass->decrypt) return klass->decrypt(cipher, input, in_len, output, out_size);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the decrypt method", + purple_cipher_get_name(cipher)); @@ -238,12 +286,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->set_salt)
+ if (klass && klass->set_salt) klass->set_salt(cipher, salt, len);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the set_salt method", + purple_cipher_get_name(cipher)); @@ -254,12 +303,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->set_key)
+ if (klass && klass->set_key) klass->set_key(cipher, key, len);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the set_key method", + purple_cipher_get_name(cipher)); @@ -270,12 +320,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->get_key_size)
+ if (klass && klass->get_key_size) return klass->get_key_size(cipher);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- "get_key_size method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the get_key_size method", + purple_cipher_get_name(cipher)); @@ -290,12 +341,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->set_batch_mode)
+ if (klass && klass->set_batch_mode) klass->set_batch_mode(cipher, mode);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- "set_batch_mode method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the set_batch_mode method", + purple_cipher_get_name(cipher)); @@ -307,12 +359,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->get_batch_mode)
+ if (klass && klass->get_batch_mode) return klass->get_batch_mode(cipher);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- "get_batch_mode method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the get_batch_mode method", + purple_cipher_get_name(cipher)); @@ -326,12 +379,13 @@
klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if(klass && klass->get_block_size)
+ if (klass && klass->get_block_size) return klass->get_block_size(cipher);
- purple_debug_warning("cipher", "the %s cipher does not implement the "
- "get_block_size method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(cipher)));
+ purple_debug_warning("cipher", "the %s cipher does not " + "implement the get_block_size method", + purple_cipher_get_name(cipher)); @@ -373,12 +427,12 @@
klass = PURPLE_HASH_GET_CLASS(hash);
- if(klass && klass->reset)
+ if (klass && klass->reset)
- purple_debug_warning("hash", "the %s hash does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(hash)));
+ purple_debug_warning("hash", "the %s hash does not implement " + "the reset method", purple_hash_get_name(hash)); @@ -389,12 +443,12 @@
klass = PURPLE_HASH_GET_CLASS(hash);
- if(klass && klass->reset_state)
+ if (klass && klass->reset_state) klass->reset_state(hash);
- purple_debug_warning("hash", "the %s hash does not implement the "
- "reset_state method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(hash)));
+ purple_debug_warning("hash", "the %s hash does not implement " + "the reset_state method", purple_hash_get_name(hash)); @@ -407,12 +461,12 @@
klass = PURPLE_HASH_GET_CLASS(hash);
- if(klass && klass->append)
+ if (klass && klass->append) klass->append(hash, data, len);
- purple_debug_warning("hash", "the %s hash does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(hash)));
+ purple_debug_warning("hash", "the %s hash does not implement " + "the append method", purple_hash_get_name(hash)); @@ -424,12 +478,12 @@
klass = PURPLE_HASH_GET_CLASS(hash);
- if(klass && klass->digest)
+ if (klass && klass->digest) return klass->digest(hash, digest, len);
- purple_debug_warning("hash", "the %s hash does not implement the "
- g_type_name(G_TYPE_FROM_INSTANCE(hash)));
+ purple_debug_warning("hash", "the %s hash does not implement " + "the digest method", purple_hash_get_name(hash)); @@ -471,12 +525,12 @@
klass = PURPLE_HASH_GET_CLASS(hash);
- if(klass && klass->get_digest_size)
+ if (klass && klass->get_digest_size) return klass->get_digest_size(hash);
- purple_debug_warning("hash", "the %s hash does not implement the "
- "get_digest_size method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(hash)));
+ purple_debug_warning("hash", "the %s hash does not implement " + "the get_digest_size method", purple_hash_get_name(hash)); @@ -490,12 +544,12 @@
klass = PURPLE_HASH_GET_CLASS(hash);
- if(klass && klass->get_block_size)
+ if (klass && klass->get_block_size) return klass->get_block_size(hash);
- purple_debug_warning("hash", "the %s hash does not implement the "
- "get_block_size method\n",
- g_type_name(G_TYPE_FROM_INSTANCE(hash)));
+ purple_debug_warning("hash", "the %s hash does not implement " + "the get_block_size method", purple_hash_get_name(hash));