From 81ed389e71cda96c1bd5935dd5f9cb98327870ce Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Fri, 25 Nov 2011 10:24:33 +0100 Subject: [PATCH] get in sync with fishlim upstream --- plugins/fishlim/Makefile | 6 +++--- plugins/fishlim/README | 2 +- plugins/fishlim/fish.c | 28 ++++++++++++++-------------- plugins/fishlim/keystore.c | 2 +- plugins/fishlim/keystore.h | 2 +- plugins/fishlim/plugin_xchat.c | 24 ++++++++++++++---------- plugins/fishlim/plugin_xchat.h | 30 ++++++++++++++++++++++++++++++ plugins/fishlim/test.c | 8 ++++++++ 8 files changed, 72 insertions(+), 30 deletions(-) diff --git a/plugins/fishlim/Makefile b/plugins/fishlim/Makefile index 7a5081e4..a1832c84 100644 --- a/plugins/fishlim/Makefile +++ b/plugins/fishlim/Makefile @@ -4,17 +4,17 @@ OURCFLAGS = -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic `pkg-config - OURLINKFLAGS = `pkg-config --libs glib-2.0 libcrypto` $(CFLAGS) $(LDFLAGS) BASE_OBJECTS = irc.o fish.o keystore.o misc.o -PLUGIN_OBJECTS = $(BASE_OBJECTS) xchat_plugin.o +PLUGIN_OBJECTS = $(BASE_OBJECTS) plugin_xchat.o TEST_OBJECTS = $(BASE_OBJECTS) test.o all: fishlim.so test fish.o: fish.h keystore.h misc.h irc.o: irc.h -keystore.o: keystore.h irc.h fish.h misc.h +keystore.o: keystore.h irc.h fish.h misc.h plugin_xchat.h misc.o: misc.h test.o: fish.h -xchat_plugin.o: fish.h irc.h keystore.h +plugin_xchat.o: fish.h irc.h keystore.h plugin_xchat.h .c.o: $(CC) $(OURCFLAGS) -c $< -o $@ diff --git a/plugins/fishlim/README b/plugins/fishlim/README index 9c5cd5fc..4f315b44 100644 --- a/plugins/fishlim/README +++ b/plugins/fishlim/README @@ -2,7 +2,7 @@ FiSHLiM - http://fishlim.slbdata.se/ + http://fishlim.kodafritt.se/ FiSHLiM is an XChat plugin for FiSH IRC encryption. It's my attempt at making diff --git a/plugins/fishlim/fish.c b/plugins/fishlim/fish.c index 0d92ecc9..cb977d7f 100644 --- a/plugins/fishlim/fish.c +++ b/plugins/fishlim/fish.c @@ -58,14 +58,14 @@ static const signed char fish_unbase64[256] = { char *fish_encrypt(const char *key, size_t keylen, const char *message) { BF_KEY bfkey; - size_t messagelen; - size_t i; - int j; - char *encrypted; - char *end; - unsigned char bit; - unsigned char word; - unsigned char d; + size_t messagelen; + size_t i; + int j; + char *encrypted; + char *end; + unsigned char bit; + unsigned char word; + unsigned char d; BF_set_key(&bfkey, keylen, (const unsigned char*)key); messagelen = strlen(message); @@ -111,12 +111,12 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) { char *fish_decrypt(const char *key, size_t keylen, const char *data) { BF_KEY bfkey; - size_t i; - char *decrypted; - char *end; - unsigned char bit; - unsigned char word; - unsigned char d; + size_t i; + char *decrypted; + char *end; + unsigned char bit; + unsigned char word; + unsigned char d; BF_set_key(&bfkey, keylen, (const unsigned char*)key); decrypted = malloc(strlen(data)+1); diff --git a/plugins/fishlim/keystore.c b/plugins/fishlim/keystore.c index ff30faa7..ce029a2e 100644 --- a/plugins/fishlim/keystore.c +++ b/plugins/fishlim/keystore.c @@ -29,7 +29,7 @@ #include "fish.h" #include "misc.h" #include "keystore.h" -#include "xchat_plugin.h" +#include "plugin_xchat.h" static char *keystore_password = NULL; diff --git a/plugins/fishlim/keystore.h b/plugins/fishlim/keystore.h index e6c527c7..b0c1c69c 100644 --- a/plugins/fishlim/keystore.h +++ b/plugins/fishlim/keystore.h @@ -33,7 +33,7 @@ #include char *keystore_get_key(const char *nick); -int keystore_store_key(const char *nick, const char *key); +bool keystore_store_key(const char *nick, const char *key); bool keystore_delete_nick(const char *nick); void keystore_secure_free(void *ptr, size_t size); diff --git a/plugins/fishlim/plugin_xchat.c b/plugins/fishlim/plugin_xchat.c index dd410548..ba0e1280 100644 --- a/plugins/fishlim/plugin_xchat.c +++ b/plugins/fishlim/plugin_xchat.c @@ -27,7 +27,11 @@ #include // #pragma GCC visibility push(default) +#ifdef _MSC_VER #include "xchat-plugin.h" +#else +#include +#endif #define XCHAT_MAX_WORDS 32 // #pragma GCC visibility pop @@ -40,7 +44,7 @@ static const char plugin_name[] = "FiSHLiM"; static const char plugin_desc[] = "Encryption plugin for the FiSH protocol. Less is More!"; -static const char plugin_version[] = "0.0.13"; +static const char plugin_version[] = "0.0.14"; static const char usage_setkey[] = "Usage: SETKEY [] , sets the key for a channel or nick"; static const char usage_delkey[] = "Usage: DELKEY , deletes the key for a channel or nick"; @@ -112,7 +116,7 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) { const char *recipient; const char *encrypted; const char *peice; - char *sender_nick; + char *sender_nick; char *decrypted; char *message; size_t w; @@ -127,7 +131,6 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) { if (!strcmp(command, "332")) w++; // Look for encrypted data - ew; for (ew = w+1; ew < XCHAT_MAX_WORDS-1; ew++) { const char *s = (ew == w+1 ? word[ew]+1 : word[ew]); if (strcmp(s, "+OK") == 0) goto has_encrypted_data; @@ -242,7 +245,7 @@ static int handle_delkey(char *word[], char *word_eol[], void *userdata) { * Returns the plugin name version information. */ void xchat_plugin_get_info(const char **name, const char **desc, - const char **version, void **reserved) { + const char **version, void **reserved) { *name = plugin_name; *desc = plugin_desc; *version = plugin_version; @@ -252,10 +255,10 @@ void xchat_plugin_get_info(const char **name, const char **desc, * Plugin entry point. */ int xchat_plugin_init(xchat_plugin *plugin_handle, - const char **name, - const char **desc, - const char **version, - char *arg) { + const char **name, + const char **desc, + const char **version, + char *arg) { ph = plugin_handle; /* Send our info to XChat */ @@ -275,12 +278,13 @@ int xchat_plugin_init(xchat_plugin *plugin_handle, xchat_hook_server(ph, "TOPIC", XCHAT_PRI_NORM, handle_incoming, NULL); xchat_hook_server(ph, "332", XCHAT_PRI_NORM, handle_incoming, NULL); - xchat_printf (ph, "%s plugin loaded\n", plugin_name); + xchat_printf(ph, "%s plugin loaded\n", plugin_name); /* Return success */ return 1; } int xchat_plugin_deinit(void) { - xchat_printf (ph, "%s plugin unloaded\n", plugin_name); + xchat_printf(ph, "%s plugin unloaded\n", plugin_name); return 1; } + diff --git a/plugins/fishlim/plugin_xchat.h b/plugins/fishlim/plugin_xchat.h index 40e21816..0243e81f 100644 --- a/plugins/fishlim/plugin_xchat.h +++ b/plugins/fishlim/plugin_xchat.h @@ -1 +1,31 @@ +/* + + Copyright (c) 2010 Samuel Lidén Borell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +#ifndef XCHAT_PLUGIN_H +#define XCHAT_PLUGIN_H + gchar *get_config_filename(); + +#endif + diff --git a/plugins/fishlim/test.c b/plugins/fishlim/test.c index 2032496a..3511bbb1 100644 --- a/plugins/fishlim/test.c +++ b/plugins/fishlim/test.c @@ -22,10 +22,18 @@ */ +#include #include #include #include "fish.h" +// We can't use the XChat plugin API from here... +gchar *get_config_filename() { + const gchar *homedir = g_get_home_dir(); + return g_build_filename(homedir, ".xchat2", "blow.ini", NULL); +} + + static int decrypt(int nick_count, char *nicks[]) { char encrypted[8192]; while (fgets(encrypted, sizeof(encrypted), stdin)) {