/soc/2013/ankitkv/gobjectification: 7db2a0940b39: Some fixes to ...

Ankit Vani a at nevitus.org
Fri Sep 20 12:41:34 EDT 2013


Changeset: 7db2a0940b39bab549436059e5292d0757d92f2f
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-20 22:10 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7db2a0940b39

Description:

Some fixes to caesarcipher

diffstat:

 libpurple/plugins/caesarcipher.c |  10 ++++++----
 libpurple/plugins/caesarcipher.h |   4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diffs (65 lines):

diff --git a/libpurple/plugins/caesarcipher.c b/libpurple/plugins/caesarcipher.c
--- a/libpurple/plugins/caesarcipher.c
+++ b/libpurple/plugins/caesarcipher.c
@@ -53,6 +53,8 @@ caesar_shift(const guchar input[], size_
 		else if (input[i] >= 'A' && input[i] <= 'Z')
 			output[i] = (((input[i] - 'A') + offset) % 26) + 'A';
 	}
+
+	output[i] = '\0';
 }
 
 static void
@@ -69,7 +71,7 @@ caesar_cipher_encrypt(PurpleCipher *ciph
 {
 	CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
 
-	g_return_val_if_fail(out_size >= in_len, -1);
+	g_return_val_if_fail(out_size > in_len, -1);
 
 	caesar_shift(input, in_len, output, priv->offset);
 
@@ -82,7 +84,7 @@ caesar_cipher_decrypt(PurpleCipher *ciph
 {
 	CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
 
-	g_return_val_if_fail(out_size >= in_len, -1);
+	g_return_val_if_fail(out_size > in_len, -1);
 
 	caesar_shift(input, in_len, output, -priv->offset);
 
@@ -92,7 +94,7 @@ caesar_cipher_decrypt(PurpleCipher *ciph
 static void
 caesar_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len)
 {
-	caesar_cipher_set_offset(cipher, GPOINTER_TO_INT(key));
+	caesar_cipher_set_offset(cipher, len);
 }
 
 static const gchar*
@@ -160,7 +162,7 @@ caesar_cipher_class_init(PurpleCipherCla
  */
 PURPLE_DEFINE_TYPE(CaesarCipher, caesar_cipher, PURPLE_TYPE_CIPHER);
 
-PurpleCipher *
+G_MODULE_EXPORT PurpleCipher *
 caesar_cipher_new(void)
 {
 	return g_object_new(CAESAR_TYPE_CIPHER, NULL);
diff --git a/libpurple/plugins/caesarcipher.h b/libpurple/plugins/caesarcipher.h
--- a/libpurple/plugins/caesarcipher.h
+++ b/libpurple/plugins/caesarcipher.h
@@ -58,11 +58,11 @@ struct _CaesarCipherClass
 /*
  * Returns the GType for the CaesarCipher object.
  */
-GType caesar_cipher_get_type(void);
+G_MODULE_EXPORT GType caesar_cipher_get_type(void);
 
 /*
  * Creates a new CaesarCipher instance and returns it.
  */
-PurpleCipher *caesar_cipher_new(void);
+G_MODULE_EXPORT PurpleCipher *caesar_cipher_new(void);
 
 #endif /* _CAESAR_CIPHER_H_ */



More information about the Commits mailing list