-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathteenymush.pl
executable file
·20936 lines (17843 loc) · 610 KB
/
teenymush.pl
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl
#
# o 8
# 8 8
# o8P .oPYo. .oPYo. odYo. o o ooYoYo. o o .oPYo. 8oPYo.
# 8 8oooo8 8oooo8 8' `8 8 8 8' 8 8 8 8 Yb.. 8 8
# 8 8. 8. 8 8 8 8 8 8 8 8 8 'Yb. 8 8
# 8 `Yooo' `Yooo' 8 8 `YooP8 8 8 8 `YooP' `YooP' 8 8
# 8
# 'oooP'
#
# A TinyMUSH like server written in perl?
# [ impossible but true ]
#
# General Notes:
#
# Reloading Code:
# The code supports re-loading the perl code while the MUSH is running
# for the purposes of debuging or general ease of use. One hurdle is
# certain lines of code should not be re-run or bad things will happen.
# If line is determined that it should not be re-loaded, a "#!#" will
# need to be added to the line to signify to not re-load that line.
#
# See renumber_code() for additional trickery that is required to
# preserve line numbers.
#
use strict;
use IO::Select;
use IO::Socket;
use File::Basename;
use Text::Wrap;
use Digest::SHA qw(sha1 sha1_hex);
use Time::HiRes "ualarm";
use Scalar::Util qw(looks_like_number);
use Time::Local;
use Math::BigInt;
$Text::Wrap::huge = 'overflow';
use POSIX;
use Fcntl qw( SEEK_END SEEK_SET);
use List::Util qw(shuffle);
#
# Certain lines of the code should not be re-loaded or the MUSH or bad
# things will happen. To combat this, the code will assume it should never
# reload any line that contains "#!#". Blank lines will be loaded instead
# to preserve line numbers.
#
my (%command, #!# commands for after player has connected
%fun, #!# functions for players to use
%offline, #!# commands for before player has connected
%connected, #!# connected socket information
%connected_user, #!# users connected
$readable, #!# sockets to wait for input on
$listener, #!# port details
$web, #!# http listen
$ws, #!# websocket server object
$websock, #!# websocket listener
%http, #!# http socket list
%code, #!# loaded perl files w/mod times
$log, #!# database connection for logs
%info, #!# misc info storage
$user, #!# current user details
$enactor, #!# object who initated the action
%c, #!#
%engine, #!# process holder for running
%ansi_rgb, #!# color number to rgb code
%ansi_name, #!# color names to 256 color id
%default, #!# default values for some config options
#----[memory database structures]---------------------------------------#
%help, #!# online-help
@db, #!# whole database
@delta, #!# db changes storage during @dump
%dirty, #!# dirty "bit" to track db changes.
%player, #!# player list for quick lookup
@free, #!# free objects list
%deleted, #!# deleted objects during backup
%flag, #!# flag definition
); #!#
# this should be a variable, but this allows us to reload the data
# without restarting the server.
sub version
{
return "TeenyMUSH 0.91";
}
#
# load_modules
# Some modules are "optional". Load these optional modules or disable
# their use by setting the coresponding @info variable to -1.
#
sub load_modules
{
my %mod = (
'URI::Escape' => 'uri_escape', # liburi-encode-perl
'Net::WebSocket::Server' => 'websocket', # perl -MCPAN -e "install
# Net::WebSocket::Server"
'Net::HTTPS::NB' => 'url_https', # libnet-https-nb-perl
'Net::HTTP::NB' => 'url_http',
'HTML::Entities' => 'entities',
'Digest::MD5' => 'md5',
'File::Copy' => 'copy',
'HTML::Restrict' => 'html_restrict', # libhtml-restrict-perl
'MIME::Base64' => 'mime',
'Compress::Zlib' => 'compress',
'Net::DNS' => 'dns', # libnet-dns-perl
'Cwd' => 'cwd',
'Carp' => 'carp',
'Text::Wrapper' => 'wrap',
'IO::Socket::Timeout' => 'timeout',
);
for my $key (keys %mod) {
if(!defined @info{"@mod{$key}"} || @info{"@mod{$key}"} eq undef) {
@info{"@mod{$key}"} = 1;
eval "use $key; 1;" or @info{"@mod{$key}"} = -1;
if(@info{"@mod{$key}"} == -1 && !@info{shell}) {
printf("WARNING: Missing $key module, @mod{$key} disabled\n");
}
}
}
}
#
# getfile
# Load a file into memory and return the contents of that file.
# Depending upon the extention, files are loaded from different
# folders.
#
sub getfile
{
my ($fn,$code,$filter) = @_;
my($file, $out);
if($fn =~ /^[^\\|\/]+\.(pl|dat|dev|conf)$/i || $fn =~ /tmshell$/) {
open($file,$fn) || return undef; # open pl file
} elsif($fn =~ /^[^\\|\/]+$/i) {
open($file,"files\/$fn") || return undef; # open txt file
} else {
return undef; # don't open file because
} # it doesn't follow conventions
@{$$code{$fn}}{lines} = 0 if(ref($code) eq "HASH");
while(<$file>) { # read all data
s/\r//g;
@{$$code{$fn}}{lines}++ if(ref($code) eq "HASH");
if($filter eq undef || ($_ =~ /ALWAYS_LOAD/ || $_ !~ /$filter/)) {
$out .= $_;
} else {
$out .= "#!#\n"; # preserve line numbers? ALWAYS_LOAD
}
}
close($file);
$out =~ s/\r//g;
$out =~ s/\n/\r\n/g;
return $out; # return data
}
#
# getbinfile
# Load a binary file into memory, such as a jpg for use by
# httpd.
#
sub getbinfile
{
my $fn = shift;
my ($file, $content);
open($file,"files/$fn") || return undef;
binmode($file);
{
local $/;
$content = <$file>;
};
close($file);
return $content;
}
#
# load_defaults
# Default values for common configuration items. This is handled as a
# list of sets to allow reloading while running.
#
sub load_defaults
{
delete @default{keys %default};
@default{max} = 78;
@default{memory_prog_limit} = 122880;
@default{memory_db_limit} = 122880;
@default{dump_interval} = 3600;
@default{master_override} = "no";
@default{money_name_plural} = "Pennies";
@default{money_name_singular} = "Penny";
@default{paycheck} = 50;
@default{starting_room} = 1;
@default{starting_money} = 150;
@default{linkcost} = 1;
@default{digcost} = 10;
@default{createcost} = 10;
@default{function_limit} = 2500;
@default{weblog} = "yes";
@default{conlog} = "yes";
@default{auditlog} = "yes";
@default{httpd_invalid} = 3;
@default{login} = "Welcome to TeenyMUSH\r\n\r\n" .
"Type the below command to " .
"customize this screen after loging ".
"in as God.\r\n\r\n &conf.login #0" .
"= Login screen\r\n\r\n";
@default{badsite} = "Your site has been banned.";
@default{httpd_template} = "<pre>";
@default{mudname} = "TeenyMUSH";
@default{port} = "4096,4201,6250";
@default{starting_quota} = 5;
}
#
# handle command line arguements
#
sub arg
{
my $txt = shift;
for my $i (0 .. $#ARGV) {
return 1 if(@ARGV[$i] eq $txt || @ARGV[$i] eq "--$txt")
}
return 0;
}
#
# process_commandline
# Allow the user to set config attributes when the mush is not running.
# The mush will dump a new db and shutdown when complete.
#
sub process_commandline
{
my $hit = 0;
my $value;
if(conf_true("safemode")) {
set(obj(0),{},0,"conf.safemode");
}
for my $i (0 .. $#ARGV) { # set conf attributes from cmdline
if(@ARGV[$i] eq "--standby" ||
@ARGV[$i] =~ /^--standby=(\d+)$/) {
@info{standby} = nvl($1,1);
} elsif(@info{standby} && @ARGV[$i] =~ /^-{1,2}D([^=]+)=/) {
@info{"conf.$1"} = $';
} elsif(@ARGV[$i] =~ /^-{1,2}d([^=]+)=/) {
@info{"conf.$1"} = $';
} elsif(@info{standby} && @ARGV[$i] =~ /^-{1,2}D([^=]+)$/) {
@info{"conf.$1"} = 1;
} elsif(@ARGV[$i] =~ /^-{1,2}D([^=]+)(=)/ ||
@ARGV[$i] =~ /^-{1,2}D([^=]+)$/) {
if($2 eq "=" && $' eq undef) {
con(" - Deleting conf.%s setting\n",$1);
$value = undef;
} elsif($2 eq "=") {
con(" + Setting conf.%s to %s\n",$1,$');
$value = $';
} else {
con(" + Setting conf.%s to on\n",$1,$');
$value = 1;
}
set(obj(0),{},0,"conf.$1",$value);
$hit = 1 if $1 ne "safemode";
}
}
if($hit) {
printf("\nShutting down as per commandline defines.\n");
if(defined @info{dump_name}) {
do_full_dirty_dump();
} else {
do_full_dump();
}
exit(0);
}
}
#
# run_command
# Run one command and then wait for the queue to empty before
# continueing on. This should only be used when its okay to lag
# the mush.
#
sub run_command
{
mushrun(self => obj(0),
runas => obj(0),
invoker=> obj(0),
source => 1,
cmd => shift
);
while(scalar keys %engine) { # command will remove itself when done
spin();
}
}
#
# main
# The one that rules them all
#
sub main
{
@info{run} = 1;
for my $i (0 .. $#ARGV) { # set conf attributes from cmdline
if(@ARGV[$i] eq "--standby" || @ARGV[$i] =~ /^--standby=(\d+)$/) {
@info{standby} = nvl($1,1);
}
}
printf("%s\n",conf("version")) if !@info{shell};
load_db();
# trap signal HUP and try to reload the code
$SIG{HUP} = sub {
if(module_enabled("md5")) {
my $count = reload_code();
delete @engine{keys %engine};
con("HUP signal caught, reloading: %s\n",$count ? $count : "none");
} else {
con("HUP signal caught, but \@reload not enabled.");
}
};
load_modules();
initialize_functions();
initialize_ansi();
initialize_commands();
initialize_flags();
# not needed for tmshell, should be faster startup too
if(module_enabled("md5") && !@info{shell}) {
@info{source_prev} = get_source_checksums(1);
reload_code();
}
load_defaults();
# create txt directory and silently move help.txt into the right
# location so the user doesn't have to.. and better yet, I don't have
# to document it.
if(!@info{shell}) {
if(!-e "txt") {
mkdir("txt") || die("Unable to create txt directory");
}
if(module_enabled("copy")) {
if(!-e "txt\help.txt" && -e "help.txt") {
move("help.txt","files/help.txt") ||
die("Unable to move help.txt to txt folder");
}
}
}
run_command("@free");
process_commandline();
fun_mush_address(obj(0),{}) if !@info{shell}; # cache public address
if(@info{shell}) {
run_command(join(" ",@ARGV[0 .. $#ARGV]));
} else {
server_start(); #!# start only once
}
}
#
# initalize_ansi
# Define colors numbers to rgb values and color names to color numbers
# for use by ansi. This is handled as a list of sets to allow reloading
# while running.
#
sub initialize_ansi
{
delete @ansi_rgb{keys %ansi_rgb};
delete @ansi_name{keys %ansi_name};
%ansi_rgb = (
0 => "000000", 1 => "800000", 2 => "008000", 3 => "808000",
4 => "000080", 5 => "800080", 6 => "008080", 7 => "c0c0c0",
8 => "808080", 9 => "ff0000", 10 => "00ff00", 11 => "ffff00",
12 => "0000ff", 13 => "ff00ff", 14 => "00ffff", 15 => "ffffff",
16 => "000000", 17 => "00005f", 18 => "000087", 19 => "0000af",
20 => "0000d7", 21 => "0000ff", 22 => "005f00", 23 => "005f5f",
24 => "005f87", 25 => "005faf", 26 => "005fd7", 27 => "005fff",
28 => "008700", 29 => "00875f", 30 => "008787", 31 => "0087af",
32 => "0087d7", 33 => "0087ff", 34 => "00af00", 35 => "00af5f",
36 => "00af87", 37 => "00afaf", 38 => "00afd7", 39 => "00afff",
40 => "00d700", 41 => "00d75f", 42 => "00d787", 43 => "00d7af",
44 => "00d7d7", 45 => "00d7ff", 46 => "00ff00", 47 => "00ff5f",
48 => "00ff87", 49 => "00ffaf", 50 => "00ffd7", 51 => "00ffff",
52 => "5f0000", 53 => "5f005f", 54 => "5f0087", 55 => "5f00af",
56 => "5f00d7", 57 => "5f00ff", 58 => "5f5f00", 59 => "5f5f5f",
60 => "5f5f87", 61 => "5f5faf", 62 => "5f5fd7", 63 => "5f5fff",
64 => "5f8700", 65 => "5f875f", 66 => "5f8787", 67 => "5f87af",
68 => "5f87d7", 69 => "5f87ff", 70 => "5faf00", 71 => "5faf5f",
72 => "5faf87", 73 => "5fafaf", 74 => "5fafd7", 75 => "5fafff",
76 => "5fd700", 77 => "5fd75f", 78 => "5fd787", 79 => "5fd7af",
80 => "5fd7d7", 81 => "5fd7ff", 82 => "5fff00", 83 => "5fff5f",
84 => "5fff87", 85 => "5fffaf", 86 => "5fffd7", 87 => "5fffff",
88 => "870000", 89 => "87005f", 90 => "870087", 91 => "8700af",
92 => "8700d7", 93 => "8700ff", 94 => "875f00", 95 => "875f5f",
96 => "875f87", 97 => "875faf", 98 => "875fd7", 99 => "875fff",
100 => "878700", 101 => "87875f", 102 => "878787", 103 => "8787af",
104 => "8787d7", 105 => "8787ff", 106 => "87af00", 107 => "87af5f",
108 => "87af87", 109 => "87afaf", 110 => "87afd7", 111 => "87afff",
112 => "87d700", 113 => "87d75f", 114 => "87d787", 115 => "87d7af",
116 => "87d7d7", 117 => "87d7ff", 118 => "87ff00", 119 => "87ff5f",
120 => "87ff87", 121 => "87ffaf", 122 => "87ffd7", 123 => "87ffff",
124 => "af0000", 125 => "af005f", 126 => "af0087", 127 => "af00af",
128 => "af00d7", 129 => "af00ff", 130 => "af5f00", 131 => "af5f5f",
132 => "af5f87", 133 => "af5faf", 134 => "af5fd7", 135 => "af5fff",
136 => "af8700", 137 => "af875f", 138 => "af8787", 139 => "af87af",
140 => "af87d7", 141 => "af87ff", 142 => "afaf00", 143 => "afaf5f",
144 => "afaf87", 145 => "afafaf", 146 => "afafd7", 147 => "afafff",
148 => "afd700", 149 => "afd75f", 150 => "afd787", 151 => "afd7af",
152 => "afd7d7", 153 => "afd7ff", 154 => "afff00", 155 => "afff5f",
156 => "afff87", 157 => "afffaf", 158 => "afffd7", 159 => "afffff",
160 => "d70000", 161 => "d7005f", 162 => "d70087", 163 => "d700af",
164 => "d700d7", 165 => "d700ff", 166 => "d75f00", 167 => "d75f5f",
168 => "d75f87", 169 => "d75faf", 170 => "d75fd7", 171 => "d75fff",
172 => "d78700", 173 => "d7875f", 174 => "d78787", 175 => "d787af",
176 => "d787d7", 177 => "d787ff", 178 => "d7af00", 179 => "d7af5f",
180 => "d7af87", 181 => "d7afaf", 182 => "d7afd7", 183 => "d7afff",
184 => "d7d700", 185 => "d7d75f", 186 => "d7d787", 187 => "d7d7af",
188 => "d7d7d7", 189 => "d7d7ff", 190 => "d7ff00", 191 => "d7ff5f",
192 => "d7ff87", 193 => "d7ffaf", 194 => "d7ffd7", 195 => "d7ffff",
196 => "ff0000", 197 => "ff005f", 198 => "ff0087", 199 => "ff00af",
200 => "ff00d7", 201 => "ff00ff", 202 => "ff5f00", 203 => "ff5f5f",
204 => "ff5f87", 205 => "ff5faf", 206 => "ff5fd7", 207 => "ff5fff",
208 => "ff8700", 209 => "ff875f", 210 => "ff8787", 211 => "ff87af",
212 => "ff87d7", 213 => "ff87ff", 214 => "ffaf00", 215 => "ffaf5f",
216 => "ffaf87", 217 => "ffafaf", 218 => "ffafd7", 219 => "ffafff",
220 => "ffd700", 221 => "ffd75f", 222 => "ffd787", 223 => "ffd7af",
224 => "ffd7d7", 225 => "ffd7ff", 226 => "ffff00", 227 => "ffff5f",
228 => "ffff87", 229 => "ffffaf", 230 => "ffffd7", 231 => "ffffff",
232 => "080808", 233 => "121212", 234 => "1c1c1c", 235 => "262626",
236 => "303030", 237 => "3a3a3a", 238 => "444444", 239 => "4e4e4e",
240 => "585858", 241 => "626262", 242 => "6c6c6c", 243 => "767676",
244 => "808080", 245 => "8a8a8a", 246 => "949494", 247 => "9e9e9e",
248 => "a8a8a8", 249 => "b2b2b2", 250 => "bcbcbc", 251 => "c6c6c6",
252 => "d0d0d0", 253 => "dadada", 254 => "e4e4e4", 255 => "eeeeee",
);
%ansi_name = (
aliceblue => 15, antiquewhite => 224, antiquewhite1 => 230,
antiquewhite2 => 224, antiquewhite3 => 181, antiquewhite4 => 8,
aquamarine => 122, aquamarine1 => 122, aquamarine2 => 122,
aquamarine3 => 79, aquamarine4 => 66, azure => 15, azure1 => 15,
azure2 => 255, azure3 => 251, azure4 => 102, beige => 230, bisque => 224,
bisque1 => 224, bisque2 => 223, bisque3 => 181, bisque4 => 101,
black => 0, blanchedalmond => 224, blue => 12, blue1 => 12, blue2 => 12,
blue3 => 20, blue4 => 18, blueviolet => 92, brown => 124, blueviolet => 92,
brown => 124, brown1 => 203, brown2 => 203, brown3 => 167, brown4 => 88,
burlywood => 180, burlywood1 => 222, burlywood2 => 222, burlywood3 => 180,
burlywood4 => 95, cadetblue => 73, cadetblue1 => 123, cadetblue2 => 117,
cadetblue3 => 116, cadetblue4 => 66, chartreuse => 118, chartreuse1 => 118,
chartreuse2 => 118, chartreuse3 => 76, chartreuse4 => 64, chocolate => 166,
chocolate1 => 208, chocolate2 => 208, chocolate3 => 166, chocolate4 => 94,
coral => 209, coral1 => 203, coral2 => 203, coral3 => 167, coral4 => 94,
cornflowerblue => 69, cornsilk => 230, cornsilk1 => 230, cornsilk2 => 254,
cornsilk3 => 187, cornsilk4 => 102, cyan => 14, cyan1 => 14, cyan2 => 14,
cyan3 => 44, cyan4 => 30, darkblue => 18, darkcyan => 30,
darkgoldenrod => 136, darkgoldenrod1 => 214, darkgoldenrod2 => 214,
darkgoldenrod3 => 172, darkgoldenrod4 => 94, darkgray => 248,
darkgreen => 22, darkgrey => 248, darkkhaki => 143, darkmagenta => 90,
darkolivegreen => 239, darkolivegreen1 => 191, darkolivegreen2 => 155,
darkolivegreen3 => 149, darkolivegreen4 => 65, darkorange => 208,
darkorange1 => 208, darkorange2 => 208, darkorange3 => 166,
darkorange4 => 94, darkorchid => 98, darkorchid1 => 135, darkorchid2 => 135,
darkorchid3 => 98, darkorchid4 => 54, darkred => 88, darksalmon => 174,
darkseagreen => 108, darkseagreen1 => 157, darkseagreen2 => 157,
darkseagreen3 => 114, darkseagreen4 => 65, darkslateblue => 60,
darkslategray => 238, darkslategray1 => 123, darkslategray2 => 123,
darkslategray3 => 116, darkslategray4 => 66, darkslategrey => 238,
darkturquoise => 44, darkviolet => 92, debianred => 161, deeppink => 198,
deeppink1 => 198, deeppink2 => 198, deeppink3 => 162, deeppink4 => 89,
deepskyblue => 39, deepskyblue1 => 39, deepskyblue2 => 39,
deepskyblue3 => 32, deepskyblue4 => 24, dimgrey => 242, dodgerblue => 33,
dodgerblue1 => 33, dodgerblue2 => 33, dodgerblue3 => 32, dodgerblue4 => 24,
firebrick => 124, firebrick1 => 203, firebrick2 => 9, firebrick3 => 160,
firebrick4 => 88, floralwhite => 15, forestgreen => 28, gainsboro => 253,
ghostwhite => 15, gold => 220, gold1 => 220, gold2 => 220, gold3 => 178,
gold4 => 3, goldenrod => 178, goldenrod1 => 214, goldenrod2 => 214,
goldenrod3 => 172, goldenrod4 => 94, gray => 7, gray0 => 0, gray1 => 0,
gray2 => 232, gray3 => 232, gray4 => 232, gray5 => 232, gray6 => 233,
gray7 => 233, gray8 => 233, gray9 => 233, gray10 => 234, gray11 => 234,
gray12 => 234, gray13 => 234, gray14 => 235, gray15 => 235, gray16 => 235,
gray17 => 235, gray18 => 236, gray19 => 236, gray20 => 236, gray21 => 237,
gray22 => 237, gray23 => 237, gray24 => 237, gray25 => 238, gray26 => 238,
gray27 => 238, gray28 => 238, gray29 => 239, gray30 => 239, gray31 => 239,
gray32 => 239, gray33 => 240, gray34 => 240, gray35 => 240, gray36 => 59,
gray37 => 59, gray38 => 241, gray39 => 241, gray40 => 241, gray41 => 242,
gray42 => 242, gray43 => 242, gray44 => 242, gray45 => 243, gray46 => 243,
gray47 => 243, gray48 => 243, gray49 => 8, gray50 => 8, gray51 => 8,
gray52 => 102, gray53 => 102, gray54 => 245, gray55 => 245, gray56 => 245,
gray57 => 246, gray58 => 246, gray59 => 246, gray60 => 246, gray61 => 247,
gray62 => 247, gray63 => 247, gray64 => 247, gray65 => 248, gray66 => 248,
gray67 => 248, gray68 => 145, gray69 => 145, gray70 => 249, gray71 => 249,
gray72 => 250, gray73 => 250, gray74 => 250, gray75 => 7, gray76 => 7,
gray77 => 251, gray78 => 251, gray79 => 251, gray80 => 252, gray81 => 252,
gray82 => 252, gray83 => 188, gray84 => 188, gray85 => 253, gray86 => 253,
gray87 => 253, gray88 => 254, gray89 => 254, gray90 => 254, gray91 => 254,
gray92 => 255, gray93 => 255, gray94 => 255, gray95 => 255, gray96 => 255,
gray97 => 15, gray98 => 15, gray99 => 15, gray100 => 15, green => 10,
green1 => 10, green2 => 10, green3 => 40, green4 => 28, greenyellow => 154,
grey => 7, grey0 => 0, grey1 => 0, grey2 => 232, grey3 => 232, grey4 => 232,
grey5 => 232, grey6 => 233, grey7 => 233, grey8 => 233, grey9 => 233,
grey10 => 234, grey11 => 234, grey12 => 234, grey13 => 234, grey14 => 235,
grey15 => 235, grey16 => 235, grey17 => 235, grey18 => 236, grey19 => 236,
grey20 => 236, grey21 => 237, grey22 => 237, grey23 => 237, grey24 => 237,
grey25 => 238, grey26 => 238, grey27 => 238, grey28 => 238, grey29 => 239,
grey30 => 239, grey31 => 239, grey32 => 239, grey33 => 240, grey34 => 240,
grey35 => 240, grey36 => 59, grey37 => 59, grey38 => 241, grey39 => 241,
grey40 => 241, grey41 => 242, grey42 => 242, grey43 => 242, grey44 => 242,
grey45 => 243, grey46 => 243, grey47 => 243, grey48 => 243, grey49 => 8,
grey50 => 8, grey51 => 8, grey52 => 102, grey53 => 102, grey54 => 245,
grey55 => 245, grey56 => 245, grey57 => 246, grey58 => 246, grey59 => 246,
grey60 => 246, grey61 => 247, grey62 => 247, grey63 => 247, grey64 => 247,
grey65 => 248, grey66 => 248, grey67 => 248, grey68 => 145, grey69 => 145,
grey70 => 249, grey71 => 249, grey72 => 250, grey73 => 250, grey74 => 250,
grey75 => 7, grey76 => 7, grey77 => 251, grey78 => 251, grey79 => 251,
grey80 => 252, grey81 => 252, grey82 => 252, grey83 => 188, grey84 => 188,
grey85 => 253, grey86 => 253, grey87 => 253, grey88 => 254, grey89 => 254,
grey90 => 254, grey91 => 254, grey92 => 255, grey93 => 255, grey94 => 255,
grey95 => 255, grey96 => 255, grey97 => 15, grey98 => 15, grey99 => 15,
grey100 => 231, honeydew => 255, honeydew1 => 255, honeydew2 => 194,
honeydew2 => 254, honeydew3 => 251, honeydew4 => 102, hotpink => 205,
hotpink1 => 205, hotpink2 => 205, hotpink3 => 168, hotpink4 => 95,
indianred => 167, indianred1 => 203, indianred2 => 203, indianred3 => 167,
indianred4 => 95, indigo => 54, ivory => 15, ivory1 => 15, ivory2 => 255,
ivory3 => 251, ivory4 => 102, khaki => 222, khaki1 => 228, khaki2 => 222,
khaki3 => 185, khaki4 => 101, lavender => 255, lavenderblush => 15,
lavenderblush1 => 15, lavenderblush2 => 254, lavenderblush3 => 251,
lavenderblush4 => 102, lawngreen => 118, lemonchiffon => 230,
lemonchiffon1 => 230, lemonchiffon2 => 223, lemonchiffon3 => 187,
lemonchiffon4 => 101, lightblue => 152, lightblue1 => 159,
lightblue2 => 153, lightblue3 => 110, lightblue4 => 66, lightcoral => 210,
lightcyan => 195, lightcyan1 => 195, lightcyan2 => 254, lightcyan3 => 152,
lightcyan4 => 102, lightgoldenrod => 222, lightgoldenrod1 => 228,
lightgoldenrod2 => 222, lightgoldenrod3 => 179, lightgoldenrod4 => 101,
lightgoldenrodyellow => 205, lightgray => 252, lightgreen => 120,
lightgrey => 252, lightpink => 217, lightpink1 => 217, lightpink2 => 217,
lightpink3 => 174, lightpink4 => 95, lightsalmon => 216,
lightsalmon1 => 216, lightsalmon2 => 209, lightsalmon3 => 173,
lightsalmon4 => 95, lightseagreen => 37, lightskyblue => 117,
lightskyblue1 => 153, lightskyblue2 => 153, lightskyblue3 => 110,
lightskyblue4 => 66, lightslateblue => 99, lightslategrey => 102,
lightsteelblue => 152, lightsteelblue1 => 189, lightsteelblue2 => 153,
lightsteelblue3 => 146, lightsteelblue4 => 66, lightyellow => 230,
lightyellow1 => 230, lightyellow2 => 254, lightyellow3 => 187,
lightyellow4 => 102, limegreen => 77, linen => 255, magenta => 13,
magenta1 => 13, magenta2 => 13, magenta3 => 164, magenta4 => 90,
maroon => 131, maroon1 => 205, maroon2 => 205, maroon3 => 162,
maroon4 => 89, mediumaquamarine => 79, mediumblue => 20,
mediumorchid => 134, mediumorchid1 => 171, mediumorchid2 => 171,
mediumorchid3 => 134, mediumorchid4 => 96, mediumpurple => 98,
mediumpurple1 => 141, mediumpurple2 => 141, mediumpurple3 => 98,
mediumpurple4 => 60, mediumseagreen => 71, mediumslateblue => 99,
mediumspringgreen => 48, mediumturquoise => 80, mediumvioletred => 162,
midnightblue => 4, mintcream => 15, mistyrose => 224, mistyrose1 => 224,
mistyrose2 => 224, mistyrose3 => 181, mistyrose4 => 8, moccasin => 223,
navajowhite => 223, navajowhite1 => 223, navajowhite2 => 223,
navajowhite3 => 180, navajowhite4 => 101, navy => 4, navyblue => 4,
oldlace => 230, olivedrab => 64, olivedrab1 => 155, olivedrab2 => 155,
olivedrab3 => 113, olivedrab4 => 64, orange => 214, orange1 => 214,
orange2 => 208, orange3 => 172, orange4 => 94, orangered => 202,
orangered1 => 202, orangered2 => 202, orangered3 => 166, orangered4 => 88,
orchid => 170, orchid1 => 213, orchid2 => 212, orchid3 => 170,
orchid4 => 96, palegoldenrod => 223, palegreen => 120, palegreen1 => 120,
palegreen2 => 120, palegreen3 => 114, palegreen4 => 65,
paleturquoise => 159, paleturquoise1 => 159, paleturquoise2 => 159,
paleturquoise3 => 116, paleturquoise4 => 66, palevioletred => 168,
palevioletred1 => 211, palevioletred2 => 211, palevioletred3 => 168,
palevioletred4 => 95, papayawhip => 230, peachpuff => 223,
peachpuff1 => 223, peachpuff2 => 223, peachpuff3 => 180, peachpuff4 => 101,
peru => 173, pink => 218, pink1 => 218, pink2 => 217, pink3 => 175,
pink4 => 95, plum => 182, plum1 => 219, plum2 => 183, plum3 => 176,
plum4 => 96, powderblue => 152, purple => 129, purple1 => 99,
purple2 => 93, purple3 => 92, purple4 => 54, red => 9, red1 => 9, red2=>9,
red3 => 160, red4 => 88, rosybrown => 138, rosybrown1 => 217,
rosybrown2 => 217, rosybrown3 => 174, rosybrown4 => 95, royalblue => 62,
royalblue1 => 69, royalblue2 => 63, royalblue3 => 62, royalblue4 => 24,
saddlebrown => 94, salmon => 209, salmon1 => 209, salmon2 => 209,
salmon3 => 167, salmon4 => 95, sandybrown => 215, seagreen => 29,
seagreen1 => 85, seagreen2 => 84, seagreen3 => 78, seagreen4 => 29,
seashell => 255, seashell1 => 255, seashell2 => 254, seashell3 => 251,
seashell4 => 102, sienna => 130, sienna1 => 209, sienna1 => 209,
sienna2 => 209, sienna3 => 167, sienna4 => 94, skyblue => 116,
skyblue1 => 117, skyblue2 => 111, skyblue3 => 74, skyblue4 => 60,
slateblue => 62, slateblue1 => 99, slateblue2 => 99, slateblue3 => 62,
slateblue4 => 60, slategray => 66, slategray1 => 189, slategray2 => 153,
slategray3 => 146, slategray4 => 66, slategrey => 66, snow => 15,
snow1 => 15, snow2 => 255, snow3 => 251, snow4 => 245, springgreen => 48,
springgreen1 => 48, springgreen2 => 48, springgreen3 => 41,
springgreen4 => 29, steelblue => 67, steelblue1 => 75, steelblue2 => 75,
steelblue3 => 68, steelblue4 => 60, tan => 180, tan1 => 215, tan2 => 209,
tan3 => 173, tan4 => 94, thistle => 182, thistle1 => 225, thistle2 => 254,
thistle3 => 182, thistle4 => 102, tomato => 203, tomato1 => 203,
tomato2 => 203, tomato3 => 167, tomato4 => 94, turquoise => 80,
turquoise1 => 14, turquoise2 => 45, turquoise3 => 44, turquoise4 => 30,
violet => 213, violetred => 162, violetred1 => 204, violetred2 => 204,
violetred3 => 168, violetred4 => 89, wheat => 223, wheat1 => 223,
wheat2 => 223, wheat3 => 180, wheat4 => 101, white => 15, whitesmoke => 255,
xterm0 => 0, xterm1 => 1, xterm2 => 2, xterm3 => 3, xterm4 => 4,
xterm5 => 5, xterm6 => 6, xterm7 => 7, xterm8 => 8, xterm9 => 9,
xterm10 => 10, xterm11 => 11, xterm12 => 12, xterm13 => 13, xterm14 => 14,
xterm15 => 15, xterm16 => 16, xterm17 => 17, xterm18 => 18, xterm19 => 19,
xterm20 => 20, xterm21 => 21, xterm22 => 22, xterm23 => 23, xterm24 => 24,
xterm25 => 25, xterm26 => 26, xterm27 => 27, xterm28 => 28, xterm29 => 29,
xterm30 => 30, xterm31 => 31, xterm32 => 32, xterm33 => 33, xterm34 => 34,
xterm35 => 35, xterm36 => 36, xterm37 => 37, xterm38 => 38, xterm39 => 39,
xterm40 => 40, xterm41 => 41, xterm42 => 42, xterm43 => 43, xterm44 => 44,
xterm45 => 45, xterm46 => 46, xterm47 => 47, xterm48 => 48, xterm49 => 49,
xterm50 => 50, xterm51 => 51, xterm52 => 52, xterm53 => 53, xterm54 => 54,
xterm55 => 55, xterm56 => 56, xterm57 => 57, xterm58 => 58, xterm59 => 59,
xterm60 => 60, xterm61 => 61, xterm62 => 62, xterm63 => 63, xterm64 => 64,
xterm65 => 65, xterm66 => 66, xterm67 => 67, xterm68 => 68, xterm69 => 69,
xterm70 => 70, xterm71 => 71, xterm72 => 72, xterm73 => 73, xterm74 => 74,
xterm75 => 75, xterm76 => 76, xterm77 => 77, xterm78 => 78, xterm79 => 79,
xterm80 => 80, xterm81 => 81, xterm82 => 82, xterm83 => 83, xterm84 => 84,
xterm85 => 85, xterm86 => 86, xterm87 => 87, xterm88 => 88, xterm89 => 89,
xterm90 => 90, xterm91 => 91, xterm92 => 92, xterm93 => 93, xterm94 => 94,
xterm95 => 95, xterm96 => 96, xterm97 => 97, xterm98 => 98, xterm99 => 99,
xterm100 => 100, xterm101 => 101, xterm102 => 102, xterm103 => 103,
xterm104 => 104, xterm105 => 105, xterm106 => 106, xterm107 => 107,
xterm108 => 108, xterm109 => 109, xterm110 => 110, xterm111 => 111,
xterm112 => 112, xterm113 => 113, xterm114 => 114, xterm115 => 115,
xterm116 => 116, xterm117 => 117, xterm118 => 118, xterm119 => 119,
xterm120 => 120, xterm121 => 121, xterm122 => 122, xterm123 => 123,
xterm124 => 124, xterm125 => 125, xterm126 => 126, xterm127 => 127,
xterm128 => 128, xterm129 => 129, xterm130 => 130, xterm131 => 131,
xterm132 => 132, xterm133 => 133, xterm134 => 134, xterm135 => 135,
xterm136 => 136, xterm137 => 137, xterm138 => 138, xterm139 => 139,
xterm140 => 140, xterm141 => 141, xterm142 => 142, xterm143 => 143,
xterm144 => 144, xterm145 => 145, xterm146 => 146, xterm147 => 147,
xterm148 => 148, xterm149 => 149, xterm150 => 150, xterm151 => 151,
xterm152 => 152, xterm153 => 153, xterm154 => 154, xterm155 => 155,
xterm156 => 156, xterm157 => 157, xterm158 => 158, xterm159 => 159,
xterm160 => 160, xterm161 => 161, xterm162 => 162, xterm163 => 163,
xterm164 => 164, xterm165 => 165, xterm166 => 166, xterm167 => 167,
xterm168 => 168, xterm169 => 169, xterm170 => 170, xterm171 => 171,
xterm172 => 172, xterm173 => 173, xterm174 => 174, xterm175 => 175,
xterm176 => 176, xterm177 => 177, xterm178 => 178, xterm179 => 179,
xterm180 => 180, xterm181 => 181, xterm182 => 182, xterm183 => 183,
xterm184 => 184, xterm185 => 185, xterm186 => 186, xterm187 => 187,
xterm188 => 188, xterm189 => 189, xterm190 => 190, xterm191 => 191,
xterm192 => 192, xterm193 => 193, xterm194 => 194, xterm195 => 195,
xterm196 => 196, xterm197 => 197, xterm198 => 198, xterm199 => 199,
xterm200 => 200, xterm201 => 201, xterm202 => 202, xterm203 => 203,
xterm204 => 204, xterm205 => 205, xterm206 => 206, xterm207 => 207,
xterm208 => 208, xterm209 => 209, xterm210 => 210, xterm211 => 211,
xterm212 => 212, xterm213 => 213, xterm214 => 214, xterm215 => 215,
xterm216 => 216, xterm217 => 217, xterm218 => 218, xterm219 => 219,
xterm220 => 220, xterm221 => 221, xterm222 => 222, xterm223 => 223,
xterm224 => 224, xterm225 => 225, xterm226 => 226, xterm227 => 227,
xterm228 => 228, xterm229 => 229, xterm230 => 230, xterm231 => 231,
xterm232 => 232, xterm233 => 233, xterm234 => 234, xterm235 => 235,
xterm236 => 236, xterm237 => 237, xterm238 => 238, xterm239 => 239,
xterm240 => 240, xterm241 => 241, xterm242 => 242, xterm243 => 243,
xterm244 => 244, xterm245 => 245, xterm246 => 246, xterm247 => 247,
xterm248 => 248, xterm249 => 249, xterm250 => 250, xterm251 => 251,
xterm252 => 252, xterm253 => 253, xterm254 => 254, xterm255 => 255,
yellow => 11, yellow1 => 11, yellow2 => 11, yellow3 => 184, yellow4 => 100,
yellowgreen => 113,
);
}
#
# initialize_commands
# Populate the HASH table of commands. This could be defined when %command
# is defined but we'd loose the ability to change the variable on the fly,
# or we'd have to have two lists.
#
sub initialize_commands
{
delete @command{keys %command};
delete @offline{keys %offline};
@offline{connect} = sub { return cmd_connect(@_); };
@offline{who} = sub { return cmd_who(@_); };
@offline{create} = sub { return cmd_pcreate(@_); };
@offline{quit} = sub { return cmd_quit(@_); };
@offline{huh} = sub { return cmd_offline_huh(@_); };
@offline{screenwidth} = sub { return; };
@offline{screenheight} = sub { return; };
@offline{"\@remotehostname"} = sub { return cmd_remotehost(@_); };
# ------------------------------------------------------------------------#
@command{"\@break"} ={ fun => sub { return &cmd_break(@_);} };
@command{"\@search"} ={ fun => sub { return &cmd_search(@_);} };
@command{screenwidth} ={ fun => sub { return 1;} };
@command{screenheight} ={ fun => sub { return 1;} };
@command{"\@wall"} ={ fun => sub { return &cmd_wall(@_);} };
@command{"\@read"} ={ fun => sub { return &cmd_read(@_);} };
@command{"\@function"} ={ fun => sub { return &cmd_function(@_);} };
@command{"\@imc"} ={ fun => sub { return &cmd_imc(@_);} };
@command{"\@perl"} ={ fun => sub { return &cmd_perl(@_); } };
@command{say} ={ fun => sub { return &cmd_say(@_); } };
@command{"\""} ={ fun => sub { return &cmd_say(@_); }, nsp=>1 };
@command{"`"} ={ fun => sub { return &cmd_to(@_); }, nsp=>1 };
@command{"&"} ={ fun => sub { return &cmd_set2(@_); }, nsp=>1 };
@command{"\@reload"} ={ fun => sub { return &cmd_reload_code(@_); } };
@command{pose} ={ fun => sub { return &cmd_pose(@_); } };
@command{":"} ={ fun => sub { return &cmd_pose(@_); }, nsp=>1 };
@command{";"} ={ fun => sub { return &cmd_pose(@_,1); },nsp=>1};
@command{"emote"} ={ fun => sub { return &cmd_pose(@_,1); },nsp=>1};
@command{"\\"} ={ fun => sub { return &cmd_slash(@_,1);},nsp=>1};
@command{who} ={ fun => sub { return &cmd_who(@_); } };
@command{whisper} ={ fun => sub { return &cmd_whisper(@_); } };
@command{w} ={ fun => sub { return &cmd_whisper(@_); } };
@command{doing} ={ fun => sub { return &cmd_DOING(@_); } };
@command{"\@doing"} ={ fun => sub { return &cmd_doing(@_); } };
@command{"\@poll"} ={ fun => sub { return &cmd_doing(@_[0],@_[1],
@_[2],{ header=>1}); } };
@command{help} ={ fun => sub { return &cmd_help(@_); } };
@command{"\@dig"} ={ fun => sub { return &cmd_dig(@_); } };
@command{"\@idesc"} ={ fun => sub { return &cmd_generic_set(@_); } };
@command{"\@parent"} ={ fun => sub { return &cmd_parent(@_); } };
@command{"look"} ={ fun => sub { return &cmd_look(@_); } };
@command{"l"} ={ fun => sub { return &cmd_look(@_); } };
@command{quit} ={ fun => sub { return &cmd_quit(@_); } };
@command{"\@trigger"} ={ fun => sub { return &cmd_trigger(@_); } };
@command{"\@set"} ={ fun => sub { return &cmd_set(@_); } };
@command{"\@cls"} ={ fun => sub { return &cmd_clear(@_); } };
@command{"\@create"} ={ fun => sub { return &cmd_create(@_); } };
@command{"print"} ={ fun => sub { return &cmd_print(@_); } };
@command{"go"} ={ fun => sub { return &cmd_go(@_); } };
@command{"home"} ={ fun => sub { return &cmd_home(@_); } };
@command{"examine"} ={ fun => sub { return &cmd_ex(@_); } };
@command{"brief"} ={ fun => sub { return &cmd_ex($_[0],$_[1],
$_[2],{brief => 1});} };
@command{"\@edit"} ={ fun => sub { return &cmd_edit(@_); } };
@command{"ex"} ={ fun => sub { return &cmd_ex(@_); } };
@command{"e"} ={ fun => sub { return &cmd_ex(@_); } };
@command{"\@last"} ={ fun => sub { return &cmd_last(@_); } };
@command{page} ={ fun => sub { return &cmd_page(@_); } };
@command{p} ={ fun => sub { return &cmd_page(@_); } };
@command{take} ={ fun => sub { return &cmd_take(@_); } };
@command{get} ={ fun => sub { return &cmd_take(@_); } };
@command{drop} ={ fun => sub { return &cmd_drop(@_); } };
@command{"\@force"} ={ fun => sub { return &cmd_force(@_); } };
@command{inventory} ={ fun => sub { return &cmd_inventory(@_); } };
@command{i} ={ fun => sub { return &cmd_inventory(@_); } };
@command{enter} ={ fun => sub { return &cmd_enter(@_); } };
@command{leave} ={ fun => sub { return &cmd_leave(@_); } };
@command{"\@name"} ={ fun => sub { return &cmd_name(@_); } };
@command{"\@moniker"} ={ fun => sub { return &cmd_name(@_); } };
@command{"\@describe"} ={ fun => sub { return &cmd_generic_set(@_); } };
@command{"\@pemit"} ={ fun => sub { return &cmd_pemit(@_); } };
@command{"\@emit"} ={ fun => sub { return &cmd_emit(@_); } };
@command{"think"} ={ fun => sub { return &cmd_think(@_); } };
@command{"version"} ={ fun => sub { return &cmd_version(@_); } };
@command{"\@version"} ={ fun => sub { return &cmd_version(@_); } };
@command{"\@link"} ={ fun => sub { return &cmd_link(@_); } };
@command{"\@teleport"} ={ fun => sub { return &cmd_teleport(@_); } };
@command{"\@tel"} ={ fun => sub { return &cmd_teleport(@_); } };
@command{"\@open"} ={ fun => sub { return &cmd_open(@_); } };
@command{"\@uptime"} ={ fun => sub { return &cmd_uptime(@_); } };
@command{"\@destroy"} ={ fun => sub { return &cmd_destroy(@_); } };
@command{"\@cpattr"} ={ fun => sub { return &cmd_cpattr(@_); } };
@command{"\@wipe"} ={ fun => sub { return &cmd_wipe(@_); } };
@command{"\@toad"} ={ fun => sub { return &cmd_toad(@_); } };
@command{"\@sleep"} ={ fun => sub { return &cmd_sleep(@_); } };
@command{"\@wait"} ={ fun => sub { return &cmd_wait(@_); } };
@command{"\@sweep"} ={ fun => sub { return &cmd_sweep(@_); } };
@command{"\@list"} ={ fun => sub { return &cmd_list(@_); } };
@command{"\@mail"} ={ fun => sub { return &cmd_mail(@_); } };
@command{"score"} ={ fun => sub { return &cmd_score(@_); } };
@command{"\@telnet"} ={ fun => sub { return &cmd_telnet(@_); } };
@command{"\@close"} ={ fun => sub { return &cmd_close(@_); } };
@command{"\@reset"} ={ fun => sub { return &cmd_reset(@_); } };
@command{"\@send"} ={ fun => sub { return &cmd_send(@_); } };
@command{"\@password"} ={ fun => sub { return &cmd_password(@_); } };
@command{"\@newpassword"}={ fun => sub { return &cmd_newpassword(@_); } };
@command{"\@switch"} ={ fun => sub { return &cmd_switch(@_); } };
@command{"\@select"} ={ fun => sub { return &cmd_switch(@_); } };
@command{"\@ps"} ={ fun => sub { return &cmd_ps(@_); } };
@command{"\@kill"} ={ fun => sub { return &cmd_killpid(@_); } };
@command{"\@var"} ={ fun => sub { return &cmd_var(@_); } };
@command{"\@dolist"} ={ fun => sub { return &cmd_dolist(@_); } };
@command{"\@notify"} ={ fun => sub { return &cmd_notify(@_); } };
@command{"\@drain"} ={ fun => sub { return &cmd_drain(@_); } };
@command{"\@while"} ={ fun => sub { return &cmd_while(@_); } };
@command{"\@crash"} ={ fun => sub { return &cmd_crash(@_); } };
@command{"\@\@"} ={ fun => sub { return;} };
@command{"\@lock"} ={ fun => sub { return &cmd_lock(@_);} };
@command{"\@boot"} ={ fun => sub { return &cmd_boot(@_);} };
@command{"\@halt"} ={ fun => sub { return &cmd_halt(@_);} };
@command{"\@sex"} ={ fun => sub { return &cmd_generic_set(@_);} };
@command{"\@apay"} ={ fun => sub { return &cmd_generic_set(@_);} };
@command{"\@opay"} ={ fun => sub { return &cmd_generic_set(@_);} };
@command{"\@pay"} ={ fun => sub { return &cmd_generic_set(@_);} };
@command{"give"} ={ fun => sub { return &cmd_give(@_);} };
@command{"\@squish"} ={ fun => sub { return &cmd_squish(@_);} };
@command{"\@websocket"} ={ fun => sub { return &cmd_websocket(@_); } };
@command{"\@find"} ={ fun => sub { return &cmd_find(@_); } };
@command{"\@bad"} ={ fun => sub { return &cmd_bad(@_); } };
@command{"\@dump"} ={ fun => sub { return &cmd_dump(@_); } };
@command{"\@dirty_dump"} ={ fun => sub { return &cmd_dirty_dump(@_); } };
@command{"\@import"} ={ fun => sub { return &cmd_import(@_); } };
@command{"\@stats"} ={ fun => sub { return &cmd_stats(@_); } };
@command{"\@cost"} ={ fun => sub { return &cmd_generic_set(@_); } };
@command{"\@quota"} ={ fun => sub { return &cmd_quota(@_); } };
@command{"\@player"} ={ fun => sub { return &cmd_player(@_); } };
@command{"\@big"} ={ fun => sub { return &cmd_big(@_); } };
@command{"huh"} ={ fun => sub { return &cmd_huh(@_); } };
@command{"\@capture"} ={ fun => sub { return &cmd_capture(@_); } };
@command{"\@\@"} ={ fun => sub { return 1; } };
@command{"\@shutdown"} ={ fun => sub { return &cmd_shutdown(@_); } };
@command{"train"} ={ fun => sub { return &cmd_train(@_); } };
@command{"teach"} ={ fun => sub { return &cmd_train(@_); } };
@command{"\@restore"} ={ fun => sub { return &cmd_restore(@_); } };
@command{"\@ping"} ={ fun => sub { return &cmd_ping(@_); } };
@command{"\@ban"} ={ fun => sub { return &cmd_ban(@_); } };
@command{"\@missing"} ={ fun => sub { return &cmd_missing(@_); } };
@command{"\@motd"} ={ fun => sub { return &cmd_motd(@_); } };
@command{"\@chown"} ={ fun => sub { return &cmd_chown(@_); } };
@command{"\@nohelp"} ={ fun => sub { return &cmd_nohelp(@_); } };
@command{"\@debug"} ={ fun => sub { return &cmd_debug(@_); } };
@command{"\@free"} ={ fun => sub { return &cmd_free(@_); } };
# ------------------------------------------------------------------------#
# Generate Partial Commands #
# Instead of looping through all the commands every time, we'll just #
# populate the table with all possibilities. #
# ------------------------------------------------------------------------#
for my $key (sort {length($a) <=> length($b)} keys %command) {
for my $i (0 .. length($key)) {
if(!defined @{@command{$key}}{full}) {
@{@command{$key}}{full} = $key;
}
if(!defined @command{substr($key,0,$i)}) {
@command{substr($key,0,$i)} = @command{$key};
}
}
}
delete @command{q}; # no alias for QUIT
delete @command{qu};
delete @command{qui};
delete @command{va};
delete @command{var};
}
# ------------------------------------------------------------------------#
#
# get_mail_idx
# Build an index of attributes for email messages.
#
sub get_mail_idx
{
my $self = shift;
return sort { substr($a,9) <=> substr($b,9) } # build index
grep(/^obj_mail_/i,lattr($self));
}
sub get_mail
{
my ($self,$num) = @_;
return undef if($num !~ /^\s*(\d+)\s*$/ || $num <= 0); # invalid number
my @list = get_mail_idx($self);
return undef if(!defined @list[$num-1]); # invalid email number
my $attr = get($self,@list[$num-1]) ||
return undef;
if($attr =~ /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,/) {
return { sent => $1,
from => $2,
new => $3,
msg => $',
attr => @list[$num-1],
num => trim($num)
};
} else {
return undef;
}
}
sub restore_process_line
{
my ($obj, $atr,$state,$list,$line) = @_;
$line =~ s/\r|\n//g;
$$state{chars} += length($_);
if($$state{obj} eq undef && $line =~ # header
/^server: ([^,]+), dbversion=([^,]+), exported=([^,]+), type=/) {
$$state{ver} = $2;
} elsif($line =~ /^\*\* Dump Completed (.*) \*\*$/) {
$$state{complete} = 1; # dump complete
} elsif($$state{obj} eq undef && $line =~ /^obj\[(\d+)]\s*{\s*$/) {
$$state{obj} = $1; # start of object
} elsif($$state{obj} ne undef &&
$line =~ /^\s*([^ \/:]+):(\d+):(\d+):([^:]*):M:/) {
if($$state{obj} eq $obj && $atr eq $1) {
if(!defined $$list{single_line(db_unsafe($'))}) {
$$list{single_line(db_unsafe($'))} = $3;
} elsif($$list{single_line(db_unsafe($'))} < $3) {
$$list{single_line(db_unsafe($'))} = $3;
}
}
} elsif($$state{obj} ne undef &&
$line =~ /^\s*([^ \/:]+):(\d+):(\d+):([^:]*):A:/) {
if($$state{obj} eq $obj && $atr eq $1) {
if(!defined $$list{single_line(db_unsafe($'))}) {
$$list{single_line(db_unsafe($'))} = $3;
} elsif($$list{single_line(db_unsafe($'))} < $3) {
$$list{single_line(db_unsafe($'))} = $3;
}
}
} elsif($$state{obj} ne undef &&
$line =~ /^\s*([^ \/:]+):(\d+):(\d+):([^:]*):L:/) {
# not restoring lists?
} elsif($$state{obj} ne undef &&
$line =~ /^\s*([^ \/:]+):(\d+):(\d+):([^:]*):H:/) {
# not restoring hash lists?
} elsif($$state{obj} ne undef && $line =~ /^\s*}\s*$/) { # end of object
delete @$state{obj};
delete @$state{type};
delete @$state{loc};
} else {
# con("Unable to parse[$$state{obj}]: '%s'\n",$line);
# printf("Unable to parse[$$state{obj}]: '%s'\n",$line);
# printf("%s\n",code("long"));
}
}
#
# cmd_break
# Stop the running mushcode/program now.
#
sub cmd_break
{
my ($self,$prog,$txt) = (obj(shift),shift,shift);
# 1 means stop, anything else means do nothing.
printf("break: called\n");
if(evaluate($self,$prog,$txt) =~ /^\s*1\s*$/) {
printf("break: stopping\n");
for my $i (0 .. $#{$$prog{stack}}) { # mark each command done
$$prog{stack}->[$i]->{done} = 1;
}
}
}
sub cmd_remotehost
{
my ($self,$prog,$txt,$switch) = (obj(shift),shift,shift,shift);
if($$prog{user}->{ip} eq "192.168.1.8") {
if($txt =~ /\s*=\s*(\d+)\s*$/) {
$$self{ip} = $`;
@connected{$$self{sock}}->{start} = $1;
} else {
$$self{ip} = $txt;
}
$$self{hostname} = server_hostname($$self{sock});
@connected{$$self{sock}}->{ip} = $$self{ip};
@connected{$$self{sock}}->{hostname} = server_hostname($$self{sock});
@{@connected{$$self{sock}}}{ip} = $$self{ip};
my $name = gethostbyaddr(inet_aton($$self{ip}),AF_INET);
if($name =~ /^\s*$/ || $name =~ /in-addr\.arpa$/) {
@{@connected{$$self{sock}}}{hostname} = $$self{ip};
} else {
@{@connected{$$self{sock}}}{hostname} = $name;
}
}
}
sub cmd_debug
{
my ($self,$prog,$txt,$switch) = (obj(shift),shift,shift,shift);
if(hasflag($self,"DEBUG")) {
if(!managed_var_set($prog,"debug",1)) {
echo(self => $self,
prog => $prog,
source => [ managed_var_set_error() ]
);
}
echo(self => $self,