-
Notifications
You must be signed in to change notification settings - Fork 1
/
MOSS-convpmail.muf
161 lines (142 loc) · 4.35 KB
/
MOSS-convpmail.muf
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
@prog MOSS-mailconvert-pmail
1 99999 d
i
( This is a simple <HA> program to convert page #mail to MOSS mail )
( Programs similar to this one HAVE to be careful on variable use, since it )
( executes a function in newmail, it needs to leave at LEAST 8 local )
( variables untouched, so I'm using $def varname num localvariable to )
( be on the safe side )
$include $lib/strings
( Set this to "page-mail#" for older versions of page )
$def pageprop "_page/"
$def mailprop "_page/mail#"
$def refto 15 localvar
$def converter 16 localvar
( Code borrowed from cmd-page )
: oproploc ( dbref -- dbref' )
dup "_proploc" getpropstr
dup if
dup "#" 1 strncmp not if
1 strcut swap pop
then
atoi dbref
dup ok? if
dup owner 3 pick
dbcmp if swap then
else swap
then pop
else pop
then
;
( encryption stuff )
: transpose (char -- char')
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1234567890_"
over instr dup if
swap pop 1 -
"wG8D kBQzWm4gbRXHOqaZiJPtUTN2pu6M0VjFlK3sdS9oYe5A_7IE1cnLvfyCrhx"
swap strcut 1 strcut pop swap pop
else
pop
then
;
: encrypt-charloop (nullstr string -- string')
dup not if pop exit then
1 strcut swap transpose
rot swap strcat swap
encrypt-charloop
;
: encrypt-loop (nullstr string -- string')
dup not if pop exit then
100 strcut "" rot
encrypt-charloop
rot swap strcat
swap encrypt-loop
;
: encrypt (string -- string')
"" swap encrypt-loop
;
( better encryption. But slower. )
: asc (stringchar -- int)
dup if
" 1234567890-=!@#$%&*()_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:zxcvbnm,./ZXCVBNM<>?\"~\\|^"
swap instr 1 - exit
then pop 0
;
: chr (int -- strchar)
" 1234567890-=!@#$%&*()_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:zxcvbnm,./ZXCVBNM<>?\"~\\|^"
swap strcut 1 strcut pop swap pop
;
: cypher (key chars -- chars')
1 strcut asc swap asc
over 89 > over 89 > or if chr swap chr strcat swap pop exit then
dup 10 / 10 *
4 pick 10 + rot 10 % - 10 %
rot dup 10 / 10 *
5 rotate 10 + rot 10 % - 10 %
4 rotate + chr -3 rotate + chr strcat
;
: crypt2-loop (key strcrypt strnorm -- strcrypt)
dup not if pop swap pop exit then
2 strcut 4 pick rot cypher
rot swap strcat swap
crypt2-loop
;
: crypt2-loop2 (key strcrypt strnorm -- strcrypt)
dup strlen 200 < if crypt2-loop exit then
200 strcut swap 4 pick 4 rotate rot crypt2-loop
swap crypt2-loop2
;
: crypt2 (key string -- string')
swap 9 % 100 + "" rot crypt2-loop2
;
: getday ( -- int)
systime dup 86400 % 86400 + time 60 * + 60 * + - 86400 % - 86400 /
;
( And my own stuff )
: mailparse ( s -- d readat day time s )
( "#dbref day[*readat]@hh:mm:ss ?encryptedmesg" )
" " STRsplit swap
dup "#" 1 strncmp not if
1 strcut swap pop atoi dbref swap
"@" STRsplit swap
dup "*" instr if "*" STRsplit atoi swap else 0 swap then
atoi rot " " STRsplit swap
":" STRsplit swap atoi 60 * swap
":" STRsplit swap atoi rot + 60 * swap
atoi + swap
dup "C" 1 strncmp not if
1 strcut swap pop encrypt
else
dup "D" 1 strncmp not if
1 strcut swap pop refto @ int swap crypt2
then
then
else
"Unhandled mail type: " swap strcat " " strcat swap strcat
refto @ 0 0 0 5 rotate
( "Name (??HH:MM:SS> -- Message" )
then
;
: daytime2systime ( day timesecs -- time )
time 60 * + 60 * + swap - swap getday swap - 86400 * + systime swap -
;
: mailconvert ( d a -- )
converter ! refto !
refto @ oproploc dup mailprop getpropstr atoi 1 begin over while
3 pick mailprop "/" strcat 3 pick intostr strcat getpropstr mailparse
rot rot daytime2systime
refto @ int intostr 5 rotate "Page-mail" 5 rotate 1 6 rotate 7 rotate
dup if 1 else 0 then converter @ execute
3 pick mailprop "/" strcat 3 pick intostr strcat remove_prop
1 + swap 1 - swap
repeat pop pop dup mailprop remove_prop pageprop "forward" strcat
over over getpropstr rot rot remove_prop
refto @ "_prefs/mail/forward" rot setprop
;
.
c
q
@set MOSS-mailconvert-pmail=!d
@set MOSS-mailconvert-pmail=!z
@set MOSS-mailconvert-pmail=!l
@set MOSS-mailconvert-pmail=w