1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
/*
* EveryBuddy
*
* Copyright (C) 2003, the Ayttm team
*
* Ayttm is derivative of Everybuddy
* Copyright (C) 1999-2002, Torrey Searle <tsearle@uci.edu>
*
* 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 option) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*Modified By Ivor Cave on 29 Apr 2003 to make it more l337!!! :)
*email ivor@happyfragger.com
*/
#ifdef __MINGW32__
#define __IN_PLUGIN__
#endif
#include "intl.h"
#include <stdlib.h>
#include <string.h>
#include "externs.h"
#include "plugin_api.h"
#include "prefs.h"
#include "conversation.h"
/*******************************************************************************
* Begin Module Code
******************************************************************************/
/* Module defines */
#ifndef USE_POSIX_DLOPEN
#define plugin_info middle_LTX_plugin_info
#define plugin_init middle_LTX_plugin_init
#define plugin_finish middle_LTX_plugin_finish
#define module_version middle_LTX_module_version
#endif
/* Function Prototypes */
static char *plstripHTML(Conversation *conv, const char *in);
static int middle_init(void);
static int middle_finish(void);
static int s_doLeet = 0;
static int s_doExtremeLeet = 0;
static int s_ref_count = 0;
/* Module Exports */
PLUGIN_INFO plugin_info = {
PLUGIN_FILTER,
"L33t-o-matic",
"Turns all incoming and outgoing messages into l33t-speak",
"$Revision: 1.12 $",
"$Date: 2009/09/17 12:04:59 $",
&s_ref_count,
middle_init,
middle_finish,
NULL
};
/* End Module Exports */
unsigned int module_version()
{
return CORE_VERSION;
}
static int middle_init(void)
{
input_list *il = calloc(1, sizeof(input_list));
plugin_info.prefs = il;
il->widget.checkbox.value = &s_doLeet;
il->name = "s_doLeet";
il->label = strdup(_("Enable L33t-speak conversion"));
il->type = EB_INPUT_CHECKBOX;
il->next = calloc(1, sizeof(input_list));
il = il->next;
il->widget.checkbox.value = &s_doExtremeLeet;
il->name = "s_doExtremeLeet";
il->label = strdup(_("Enable 3x7r3m3 L33t-speak [implies previous]"));
il->type = EB_INPUT_CHECKBOX;
eb_debug(DBG_MOD, "L33tSp33k initialised\n");
outgoing_message_filters_local =
l_list_prepend(outgoing_message_filters_local, &plstripHTML);
outgoing_message_filters_remote =
l_list_prepend(outgoing_message_filters_remote, &plstripHTML);
incoming_message_filters =
l_list_append(incoming_message_filters, &plstripHTML);
return (0);
}
static int middle_finish(void)
{
eb_debug(DBG_MOD, "L33tSp33k shutting down\n");
outgoing_message_filters_local =
l_list_remove(outgoing_message_filters_local, &plstripHTML);
outgoing_message_filters_remote =
l_list_remove(outgoing_message_filters_remote, &plstripHTML);
incoming_message_filters =
l_list_remove(incoming_message_filters, &plstripHTML);
while (plugin_info.prefs) {
input_list *il = plugin_info.prefs->next;
free(plugin_info.prefs);
plugin_info.prefs = il;
}
return (0);
}
/*******************************************************************************
* End Module Code
******************************************************************************/
static char *plstripHTML(Conversation *conv, const char *in)
{
int pos = 0;
int post = 0;
char *s = g_strdup(in);
char *t = NULL;
if (!s_doLeet && !s_doExtremeLeet)
return (s);
t = g_new0(char, 3*strlen(s));
while (s[pos] != '\0') {
switch (s[pos]) {
case 'a':
case 'A':
t[post] = '4';
break;
case 'c':
case 'C':
t[post] = '(';
break;
case 'e':
case 'E':
t[post] = '3';
break;
case 'l':
case 'L':
t[post] = '1';
break;
case 's':
case 'S':
t[post] = '5';
break;
case 't':
case 'T':
t[post] = '7';
break;
default:
t[post] = s[pos];
break;
}
if (s_doExtremeLeet) {
switch (s[pos]) {
case 'd':
case 'D':
t[post++] = '|';
t[post] = ')';
break;
case 'h':
case 'H':
t[post++] = '|';
t[post++] = '-';
t[post] = '|';
break;
case 'k':
case 'K':
t[post++] = '|';
t[post] = '<';
break;
case 'm':
case 'M':
t[post++] = '/';
t[post++] = 'v';
t[post] = '\\';
break;
case 'n':
case 'N':
t[post++] = '|';
t[post++] = '\\';
t[post] = '|';
break;
case 'o':
case 'O':
t[post++] = '(';
t[post] = ')';
break;
case 'v':
case 'V':
t[post++] = '\\';
t[post] = '/';
break;
case 'w':
case 'W':
t[post++] = '\\';
t[post++] = '^';
t[post] = '/';
break;
default:
break;
}
}
pos++;
post++;
}
t[post] = '\0';
g_free(s);
return (t);
}
|