summaryrefslogtreecommitdiffstats
path: root/src/modules/lamerizer
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
commita6d58bb6052ac8cb01805a48c4ad2f129126116f (patch)
treedd867a099fcbb263a8009a9fb22695b87855dad6 /src/modules/lamerizer
downloadkvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.tar.gz
kvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.zip
Added KDE3 version of kvirc
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/modules/lamerizer')
-rw-r--r--src/modules/lamerizer/Makefile.am27
-rw-r--r--src/modules/lamerizer/lamerizer1
-rw-r--r--src/modules/lamerizer/libkvilamerizer.cpp279
-rw-r--r--src/modules/lamerizer/libkvilamerizer.h47
4 files changed, 354 insertions, 0 deletions
diff --git a/src/modules/lamerizer/Makefile.am b/src/modules/lamerizer/Makefile.am
new file mode 100644
index 00000000..ce798e5c
--- /dev/null
+++ b/src/modules/lamerizer/Makefile.am
@@ -0,0 +1,27 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <stefanek@tin.it>
+###############################################################################
+
+AM_CPPFLAGS = -I$(SS_TOPSRCDIR)/src/kvilib/include/ -I$(SS_TOPSRCDIR)/src/kvirc/include/ \
+$(SS_INCDIRS) $(SS_CPPFLAGS) -DGLOBAL_KVIRC_DIR=\"$(globalkvircdir)\"
+
+pluglib_LTLIBRARIES = libkvilamerizer.la
+
+libkvilamerizer_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS)
+
+libkvilamerizer_la_SOURCES = libkvilamerizer.cpp
+libkvilamerizer_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la
+
+noinst_HEADERS= libkvilamerizer.h
+
+tmpdir = $(pluglibdir)/caps/crypt/
+
+tmp_DATA= lamerizer
+
+EXTRA_DIST = $(tmp_DATA)
+
+
+%.moc: %.h
+ $(SS_QT_MOC) $< -o $@
+
+libkvilamerizer.cpp: libkvilamerizer.moc
diff --git a/src/modules/lamerizer/lamerizer b/src/modules/lamerizer/lamerizer
new file mode 100644
index 00000000..9788f702
--- /dev/null
+++ b/src/modules/lamerizer/lamerizer
@@ -0,0 +1 @@
+timestamp
diff --git a/src/modules/lamerizer/libkvilamerizer.cpp b/src/modules/lamerizer/libkvilamerizer.cpp
new file mode 100644
index 00000000..adb7a194
--- /dev/null
+++ b/src/modules/lamerizer/libkvilamerizer.cpp
@@ -0,0 +1,279 @@
+//=============================================================================
+//
+// File : libkvilamerizer.cpp
+// Creation date : Sat Jan 20 2002 17:06:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002-2005 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "libkvilamerizer.h"
+
+#include "kvi_module.h"
+#include "kvi_debug.h"
+#include "kvi_locale.h"
+
+
+
+/*
+ @doc: lamerizer
+ @type:
+ module
+ @short:
+ The Lamerizer text transformation engine
+ @title:
+ The lamerizer module
+ @body:
+ This is an example of what you should NOT do with a text transformation
+ engine. Do NOT use it! :D
+*/
+
+
+
+#ifdef COMPILE_CRYPT_SUPPORT
+
+ #include "kvi_memmove.h"
+ #include "kvi_malloc.h"
+
+ #include "kvi_pointerlist.h"
+
+ static KviPointerList<KviCryptEngine> * g_pEngineList = 0;
+
+ KviLamerizerEngine::KviLamerizerEngine(bool bLight)
+ : KviCryptEngine()
+ {
+ m_bLight = bLight;
+ g_pEngineList->append(this);
+ }
+
+ KviLamerizerEngine::~KviLamerizerEngine()
+ {
+ g_pEngineList->removeRef(this);
+ }
+
+ bool KviLamerizerEngine::init(const char *,int,const char *,int)
+ {
+ return true;
+ }
+
+ static char subst_table[256] =
+ {
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 007
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 015
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 023
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 031
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 039 : '
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 047 : /
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 055 : 7
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 063 : ?
+ 0 , '4' , '8' , 'C' , 'D' , '3' , 'F' , 'G' , // 071 : G
+ 'H' , '|' , 'J' , 'K' , 'L' , 'm' , 'N' , 'O' , // 079 : O
+ 'P' , 'q' , 'R' , '5' , '7' , 'U' , 'V' , 'W' , // 087 : W
+ 'x' , 'Y' , '2' , 0 , 0 , 0 , 0 , 0 , // 095 : _
+ 0 , '4' , 'b' , 'c' , 'd' , '3' , 'f' , '9' , // 103 : g
+ 'h' , '|' , 'j' , 'k' , '1' , 'm' , 'n' , '0' ,
+ 'p' , 'q' , 'r' , '5' , '7' , 'u' , 'v' , 'w' , // 119 : w
+ 'x' , 'y' , '2' , 0 , 0 , 0 , 0 , 0 , // 127 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 135 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 143 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 151 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 159 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 167 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 175 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 183 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 191 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 199 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 215 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 223 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 231 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 239 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 247 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
+ };
+
+ static char subst_table_light[256] =
+ {
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 007
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 015
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 023
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 031
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 039 : '
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 047 : /
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 055 : 7
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 063 : ?
+ 0 , '4' , 'B' , 'C' , 'D' , '3' , 'F' , 'G' , // 071 : G
+ 'H' , '|' , 'J' , 'K' , 'L' , 'm' , 'N' , 'O' , // 079 : O
+ 'P' , 'q' , 'R' , '5' , '7' , 'U' , 'V' , 'W' , // 087 : W
+ 'x' , 'Y' , 'Z' , 0 , 0 , 0 , 0 , 0 , // 095 : _
+ 0 , '4' , 'b' , 'c' , 'd' , '3' , 'f' , 'G' , // 103 : g
+ 'h' , '|' , 'j' , 'k' , '1' , 'm' , 'n' , '0' ,
+ 'p' , 'q' , 'r' , '5' , '7' , 'u' , 'v' , 'w' , // 119 : w
+ 'x' , 'y' , 'z' , 0 , 0 , 0 , 0 , 0 , // 127 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 135 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 143 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 151 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 159 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 167 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 175 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 183 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 191 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 199 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 215 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 223 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 231 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 239 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // 247 :
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
+ };
+
+
+ KviCryptEngine::EncryptResult KviLamerizerEngine::encrypt(const char * plainText,KviStr &outBuffer)
+ {
+ outBuffer = plainText;
+ unsigned char * aux = (unsigned char *)outBuffer.ptr();
+ if(m_bLight)
+ {
+ while(*aux)
+ {
+ if(subst_table_light[*aux])
+ {
+ *aux = subst_table_light[*aux];
+ }
+ aux++;
+ }
+ } else {
+ while(*aux)
+ {
+ if(subst_table[*aux])
+ {
+ *aux = subst_table[*aux];
+ }
+ aux++;
+ }
+ }
+
+ if(!m_bLight)
+ {
+ outBuffer.replaceAll("F","Ph");
+ outBuffer.replaceAll("V","\\/");
+ }
+
+ return KviCryptEngine::Encoded;
+ }
+
+ KviCryptEngine::DecryptResult KviLamerizerEngine::decrypt(const char * inBuffer,KviStr &plainText)
+ {
+ plainText = inBuffer;
+ return KviCryptEngine::DecryptOkWasPlainText;
+ }
+
+ static KviCryptEngine * allocLamerizerEngine()
+ {
+ return new KviLamerizerEngine(false);
+ }
+
+ static KviCryptEngine * allocLightLamerizerEngine()
+ {
+ return new KviLamerizerEngine(true);
+ }
+
+ static void deallocLamerizerEngine(KviCryptEngine * e)
+ {
+ delete e;
+ }
+
+#endif
+
+
+// =======================================
+// module routines
+// =======================================
+static bool lamerizer_module_init(KviModule * m)
+{
+#ifdef COMPILE_CRYPT_SUPPORT
+ g_pEngineList = new KviPointerList<KviCryptEngine>;
+ g_pEngineList->setAutoDelete(false);
+
+ // FIXME: Maybe convert this repeated code to a function eh ?
+
+ KviCryptEngineDescription * d = new KviCryptEngineDescription;
+ d->szName = "Lamerizer";
+ d->szAuthor = "Szymon Stefanek and Jan Wagner";
+ d->szDescription = __tr2qs("A really lame text transformation engine :D");
+ d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT;
+ d->allocFunc = allocLamerizerEngine;
+ d->deallocFunc = deallocLamerizerEngine;
+ m->registerCryptEngine(d);
+
+
+ d = new KviCryptEngineDescription;
+ d->szName = "LamerizerLight";
+ d->szAuthor = "Szymon Stefanek and Jan Wagner";
+ d->szDescription = __tr2qs("A really lame text transformation engine: Light Version.");
+ d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT;
+ d->allocFunc = allocLightLamerizerEngine;
+ d->deallocFunc = deallocLamerizerEngine;
+ m->registerCryptEngine(d);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+static bool lamerizer_module_cleanup(KviModule *m)
+{
+#ifdef COMPILE_CRYPT_SUPPORT
+ while(g_pEngineList->first())delete g_pEngineList->first();
+ delete g_pEngineList;
+ g_pEngineList = 0;
+ m->unregisterCryptEngines();
+ return true;
+#else
+ return false;
+#endif
+}
+
+static bool lamerizer_module_can_unload(KviModule *)
+{
+#ifdef COMPILE_CRYPT_SUPPORT
+ return g_pEngineList->isEmpty();
+#else
+ return true;
+#endif
+}
+
+// =======================================
+// plugin definition structure
+// =======================================
+KVIRC_MODULE(
+ "Lamerizer crypt engine",
+ "1.0.1",
+ "Szymon Stefanek <pragma at kvirc dot net> \n Jan Wagner <istari@kvirc.net>" ,
+ "Exports the lamerizer text transformation engine",
+ lamerizer_module_init ,
+ lamerizer_module_can_unload,
+ 0,
+ lamerizer_module_cleanup
+)
+
+#ifdef COMPILE_CRYPT_SUPPORT
+ #include "libkvilamerizer.moc"
+#endif
diff --git a/src/modules/lamerizer/libkvilamerizer.h b/src/modules/lamerizer/libkvilamerizer.h
new file mode 100644
index 00000000..e0b78bd7
--- /dev/null
+++ b/src/modules/lamerizer/libkvilamerizer.h
@@ -0,0 +1,47 @@
+#ifndef _LIBKVILAMERIZER_H_
+#define _LIBKVILAMERIZER_H_
+//
+// File : libkvilamerizer.h
+// Creation date : Sat Now 4 2000 15:41:41 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2000 Till Bush (buti@geocities.com)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "kvi_settings.h"
+
+#ifdef COMPILE_CRYPT_SUPPORT
+
+ #include "kvi_crypt.h"
+
+ class KviLamerizerEngine : public KviCryptEngine
+ {
+ Q_OBJECT
+ public:
+ KviLamerizerEngine(bool bLight);
+ ~KviLamerizerEngine();
+ protected:
+ bool m_bLight;
+ public:
+ virtual bool init(const char *encKey,int encKeyLen,const char *decKey,int decKeyLen);
+ virtual KviCryptEngine::EncryptResult encrypt(const char * plainText,KviStr &outBuffer);
+ virtual KviCryptEngine::DecryptResult decrypt(const char * inBuffer,KviStr &plainText);
+ };
+
+#endif // COMPILE_CRYPT_SUPPORT
+
+#endif // _LIBKVILAMERIZER_H_