From 991d3d5401bd9602cf4622b8560ccda2fac29c2e Mon Sep 17 00:00:00 2001 From: TingPing Date: Mon, 19 Nov 2012 20:03:59 -0500 Subject: [PATCH 1/2] Fix checksum plugin when completed dir is set --- plugins/checksum/checksum.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/checksum/checksum.c b/plugins/checksum/checksum.c index e5da9dd5..77359e3f 100644 --- a/plugins/checksum/checksum.c +++ b/plugins/checksum/checksum.c @@ -173,13 +173,22 @@ dccrecv_cb (char *word[], void *userdata) int result; struct stat64 buffer; /* buffer for storing file info */ char sum[65]; /* buffer for checksum */ + char *file; + if (hexchat_get_prefs (ph, "dcc_completed_dir", &file, NULL) == 1 && file[0] != 0) + { + file = g_strconcat (file, G_DIR_SEPARATOR_S, word[1], NULL); + } + else + { + file = word[2]; + } - result = stat64 (word[2], &buffer); + result = stat64 (file, &buffer); if (result == 0) /* stat returns 0 on success */ { if (buffer.st_size <= (unsigned long long) get_limit () * 1048576) { - sha256_file (word[2], sum); /* word[2] is the full filename */ + sha256_file (file, sum); /* file is the full filename even if completed dir set */ /* try to print the checksum in the privmsg tab of the sender */ hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3])); hexchat_printf (ph, "SHA-256 checksum for %s (local): %s\n", word[1], sum); @@ -195,6 +204,7 @@ dccrecv_cb (char *word[], void *userdata) hexchat_printf (ph, "File access error!\n"); } + g_free (file); return HEXCHAT_EAT_NONE; } From 7ac36d4d8d455b62a803e3de80134ec4ae7c1781 Mon Sep 17 00:00:00 2001 From: TingPing Date: Tue, 20 Nov 2012 05:00:39 -0500 Subject: [PATCH 2/2] Use g_strdup --- plugins/checksum/checksum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/checksum/checksum.c b/plugins/checksum/checksum.c index 77359e3f..cedabc21 100644 --- a/plugins/checksum/checksum.c +++ b/plugins/checksum/checksum.c @@ -180,7 +180,7 @@ dccrecv_cb (char *word[], void *userdata) } else { - file = word[2]; + file = g_strdup(word[2]); } result = stat64 (file, &buffer);