1 #define ENCODE_VERSION "0.001"
2
3 /*
4 *
5 * Written by Colten Edwards. (C) August 97
6 * Based on script by suicide for evolver script.
7 */
8 #include "irc.h"
9 #include "struct.h"
10 #include "ircaux.h"
11 #include "vars.h"
12 #include "misc.h"
13 #include "output.h"
14 #include "module.h"
15 #define INIT_MODULE
16 #include "modval.h"
17
18 #define cparse convert_output_format
19 char encode_version[] = "Encode 0.001";
20 unsigned char *encode_string = NULL;
21
BUILT_IN_FUNCTION(func_encode)22 BUILT_IN_FUNCTION(func_encode)
23 {
24 char *new;
25 if (!input)
26 return m_strdup(empty_string);
27 new = m_strdup(input);
28 my_encrypt(new, strlen(new), encode_string);
29 return new;
30 }
31
BUILT_IN_FUNCTION(func_decode)32 BUILT_IN_FUNCTION(func_decode)
33 {
34 char *new;
35 if (!input)
36 return m_strdup(empty_string);
37 new = m_strdup(input);
38 my_decrypt(new, strlen(new), encode_string);
39 return new;
40 }
41
Encode_Version(IrcCommandDll ** intp)42 char *Encode_Version(IrcCommandDll **intp)
43 {
44 return ENCODE_VERSION;
45 }
46
47
Encrypt_Init(IrcCommandDll ** intp,Function_ptr * global_table)48 int Encrypt_Init(IrcCommandDll **intp, Function_ptr *global_table)
49 {
50 int i, j;
51 char buffer[BIG_BUFFER_SIZE+1];
52 initialize_module("encrypt");
53
54 add_module_proc(ALIAS_PROC, "encrypt", "MENCODE", NULL, 0, 0, func_encode, NULL);
55 add_module_proc(ALIAS_PROC, "encrypt", "MDECODE", NULL, 0, 0, func_decode, NULL);
56 encode_string = (char *)new_malloc(512);
57 for (i = 1, j = 255; i <= 255; i++, j--)
58 {
59 switch (i)
60 {
61 case 27:
62 case 127:
63 case 255:
64 encode_string[i-1] = i;
65 break;
66 default:
67 encode_string[i-1] = j;
68 break;
69 }
70 }
71 sprintf(buffer, "$0+%s by panasync - $2 $3", encode_version);
72 fset_string_var(FORMAT_VERSION_FSET, buffer);
73 put_it("%s", convert_output_format("$G $0 v$1 by panasync. Based on suicide's Abot script.", "%s %s", encode_version, ENCODE_VERSION));
74 return 0;
75 }
76
77