File: debian-changes

package info (click to toggle)
tf 1%3A4.0s1-21.1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 1,920 kB
  • sloc: ansic: 15,663; sh: 44; makefile: 38
file content (971 lines) | stat: -rw-r--r-- 30,811 bytes parent folder | download | duplicates (3)
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
This patch contains the differences between the upstream tarball and
the sources actually used for building the package.

Option single-debian-patch is used as the changes are tracked in git.

--- tf-4.0s1.orig/src/history.c
+++ tf-4.0s1/src/history.c
@@ -38,18 +38,6 @@
 #define LOCALSIZE      100	/* local history size */
 #define INPUTSIZE      100	/* command history buffer size */
 
-typedef struct History {	/* circular list of Alines, and logfile */
-    struct Aline **alines;
-    int size;			/* actual number of lines currently saved */
-    int maxsize;		/* maximum number of lines that can be saved */
-    int first;			/* position of first line in circular array */
-    int last;			/* position of last line in circular array */
-    int index;			/* current recall position */
-    int total;			/* total number of lines ever saved */
-    TFILE *logfile;
-    CONST char *logname;
-} History;
-
 #define empty(hist) (!(hist)->alines || !(hist)->size)
 
 static void     FDECL(alloc_history,(History *hist, int maxsize));
--- tf-4.0s1.orig/src/history.h
+++ tf-4.0s1/src/history.h
@@ -31,6 +31,18 @@ extern void   NDECL(free_histories);
 #define record_global(aline)  recordline(globalhist, (aline))
 #define record_local(aline)   recordline(localhist, (aline))
 
+typedef struct History {	/* circular list of Alines, and logfile */
+    struct Aline **alines;
+    int size;			/* actual number of lines currently saved */
+    int maxsize;		/* maximum number of lines that can be saved */
+    int first;			/* position of first line in circular array */
+    int last;			/* position of last line in circular array */
+    int index;			/* current recall position */
+    int total;			/* total number of lines ever saved */
+    TFILE *logfile;
+    CONST char *logname;
+} History;
+
 extern struct History globalhist[], localhist[];
 extern int log_count, norecord, nolog;
 
--- /dev/null
+++ tf-4.0s1/src/mccp.c
@@ -0,0 +1,426 @@
+/*
+ * Client decompression module for the mud client compression protocol.
+ * See http://homepages.ihug.co.nz/~icecube/compress/ for more details.
+ *
+ * mccpDecompress.c - module code. Link this with your client code.
+ *
+ * Oliver Jowett <icecube$ihug.co.nz>. Demangle address as needed.
+ *
+ * This code is placed in the public domain.
+ *
+ */
+
+/* Modified: 20000530 */
+
+/* See mccp.h for API information */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "config.h"
+#ifdef MUDCOMPRESS
+
+#include <zlib.h>
+
+#include "mccp.h"
+
+/* Telnet values we're interested in */
+
+#define IAC             255
+#define DONT            254
+#define DO              253
+#define WONT            252
+#define WILL            251
+#define SB              250
+#define SE              240
+
+#define TELOPT_COMPRESS 85
+#define TELOPT_COMPRESS2 86
+
+/* We say DO COMPRESS2 to WILL COMPRESS2, then DONT COMPRESS to WILL COMPRESS
+ * -or-
+ * We say DO COMPRESS to WILL COMPRESS if it arrives before any COMPRESS2.
+ *
+ * Later the server sends IAC SB COMPRESS IAC SE (v2) or IAC SB COMPRESS WILL
+ * SE (v1), and immediately following
+ * that, begins compressing
+ *
+ * Compression ends on a Z_STREAM_END, no other marker is used
+ */
+
+static char will_v1[] = { IAC, WILL, TELOPT_COMPRESS, 0 };
+static char do_v1[] =   { IAC, DO,   TELOPT_COMPRESS, 0 };
+static char dont_v1[] = { IAC, DONT, TELOPT_COMPRESS, 0 };
+static char on_v1[] =   { IAC, SB, TELOPT_COMPRESS, WILL, SE, 0 };
+
+static char will_v2[] = { IAC, WILL, TELOPT_COMPRESS2, 0 };
+static char do_v2[] =   { IAC, DO,   TELOPT_COMPRESS2, 0 };
+static char on_v2[] =   { IAC, SB, TELOPT_COMPRESS2, IAC, SE, 0 };
+
+/* "Opaque" state object */
+
+struct mc_state_s {
+    z_stream *stream;      /* stream we're using */
+
+    unsigned char *inbuf;  /* input buffer (data from mud) */
+    unsigned int insize;   /* .. and how much is used */
+    unsigned int inalloc;  /* .. and how much is allocated */
+
+    unsigned char *outbuf; /* output buffer (data to user) */
+    unsigned int outsize;  /* .. and how much is used */
+    unsigned int outalloc; /* .. and how much is allocated */
+
+    int error;
+    int resp_v1;  /* waiting to send IAC DO/DONT COMPRESS */
+    int resp_v2;  /* waiting to send IAC DO COMPRESS2 */
+    int got_v2;   /* responded to a IAC WILL COMPRESS2 already */
+
+    unsigned long comp;
+    unsigned long uncomp;
+};
+
+/* Initialise a new state object */
+mc_state *mudcompress_new(void)
+{
+    mc_state *state;
+
+    state = malloc(sizeof(*state));
+    state->stream   = NULL;   /* Not decompressing */
+    state->inalloc  = 2048;
+    state->outalloc = 2048;
+    state->inbuf    = malloc(state->inalloc);
+    state->outbuf   = malloc(state->outalloc);
+    state->insize   = 0;
+    state->outsize  = 0;
+    state->error    = 0;
+    state->comp     = 0;
+    state->uncomp   = 0;
+    state->resp_v1  = 0;
+    state->resp_v2  = 0;
+    state->got_v2   = 0;
+
+    return state;
+}
+
+/* Clean up a state object */
+void mudcompress_delete(mc_state *state)
+{
+    if (state->stream) {
+        inflateEnd(state->stream);
+        free(state->stream);
+    }
+
+    free(state->inbuf);
+    free(state->outbuf);
+    free(state);
+}
+
+/* zlib helpers */
+
+static void *zlib_alloc(void *opaque, unsigned int items, unsigned int size)
+{
+    return calloc(items, size);
+}
+
+static void zlib_free(void *opaque, void *address)
+{
+    free(address);
+}
+
+static void grow_inbuf(mc_state *state, int needed)
+{
+    int old = state->inalloc;
+
+    while (state->inalloc < state->insize + needed)
+        state->inalloc *= 2;
+
+    if (old != state->inalloc)
+        state->inbuf = realloc(state->inbuf, state->inalloc);
+}
+
+static void grow_outbuf(mc_state *state, int needed)
+{
+    int old = state->outalloc;
+
+    while (state->outalloc < state->outsize + needed)
+        state->outalloc *= 2;
+
+    if (old != state->outalloc)
+        state->outbuf = realloc(state->outbuf, state->outalloc);
+}
+
+static void decompress_inbuf(mc_state *state)
+{
+    int status;
+
+    /* We are now decompressing from inbuf to outbuf */
+
+    if (!state->insize)
+        return; /* nothing to decompress? */
+
+    state->stream->next_in = state->inbuf;
+    state->stream->next_out = state->outbuf + state->outsize;
+    state->stream->avail_in = state->insize;
+    state->stream->avail_out = state->outalloc - state->outsize;
+
+    status = inflate(state->stream, Z_PARTIAL_FLUSH);
+
+    if (status == Z_OK || status == Z_STREAM_END) {
+        /* Successful decompression */
+
+        /* Remove used data from inbuf */
+        state->comp += state->insize - state->stream->avail_in;
+        state->uncomp += state->stream->next_out - state->outbuf;
+
+        memmove(state->inbuf, state->stream->next_in, state->stream->avail_in);
+        state->insize = state->stream->avail_in;
+
+        /* Update outbuf pointers */
+        state->outsize = state->stream->next_out - state->outbuf;
+
+        /* Done */
+
+        if (status == Z_STREAM_END) {
+            /* Turn off compression too */
+
+            grow_outbuf(state, state->insize);
+
+            memcpy(state->outbuf + state->outsize, state->inbuf, state->insize);
+            state->outsize += state->insize;
+            state->insize = 0;
+
+            inflateEnd(state->stream);
+            free(state->stream);
+            state->stream = NULL;
+        }
+
+        return;
+    }
+
+    if (status == Z_BUF_ERROR) {
+        /* Full buffers? Maybe we need more output space.. */
+
+        if (state->outsize * 2 > state->outalloc) {
+            grow_outbuf(state, state->outalloc);
+            decompress_inbuf(state);
+        }
+
+        return;
+    }
+
+    /* Error */
+    state->error = 1;
+}
+
+/* We received some data */
+void mudcompress_receive(mc_state *state, const char *data, unsigned len)
+{
+    int i;
+
+    if (state->error)
+        return;
+
+    if (!state->stream) {
+        int residual = -1;
+        int clen;
+
+        /* Just copy to outbuf. Also copy any residual inbuf */
+
+        grow_outbuf(state, len + state->insize);
+        memcpy(state->outbuf + state->outsize, data, len);
+        state->outsize += len;
+        memcpy(state->outbuf + state->outsize, state->inbuf, state->insize);
+        state->outsize += state->insize;
+        state->insize = 0;
+
+        /* Check for Magic Marker. ugh this is messy */
+        for (i=0; i < state->outsize; i++) {
+            if (state->outbuf[i] == IAC) {
+                if (i + 1 < state->outsize && state->outbuf[i+1] == IAC) {
+                    /* IAC IAC - ignore */
+                    i++;
+                    continue;
+                }
+
+                clen = (i + strlen(will_v1) < state->outsize) ? strlen(will_v1) : state->outsize - i;
+
+                if (!memcmp(&state->outbuf[i], will_v1, clen)) {
+                    if (clen != strlen(will_v1)) {
+                        /* Partial match. Save it. */
+                        residual = i;
+                        break;
+                    }
+
+                    /* If we got WILL COMPRESS2 then refuse COMPRESS, otherwise
+                     * accept it
+                     */
+
+                    if (state->got_v2)
+                        state->resp_v1 = -1;
+                    else
+                        state->resp_v1 = 1;
+
+                    memmove(&state->outbuf[i],
+                            &state->outbuf[i + strlen(will_v1)],
+                            state->outsize - strlen(will_v1));
+                    state->outsize -= strlen(will_v1);
+                    i--;
+                    continue;
+                }
+
+                if (!memcmp(&state->outbuf[i], will_v2, clen)) {
+                    if (clen != strlen(will_v2)) {
+                        /* Partial match. Save it. */
+                        residual = i;
+                        break;
+                    }
+
+                    state->resp_v2 = 1;
+                    state->got_v2 = 1;
+
+                    memmove(&state->outbuf[i],
+                            &state->outbuf[i + strlen(will_v2)],
+                            state->outsize - strlen(will_v2));
+                    state->outsize -= strlen(will_v2);
+                    i--;
+                    continue;
+                }
+
+                clen = (i + strlen(on_v1) < state->outsize) ? strlen(on_v1) : state->outsize - i;
+
+                if ((!memcmp(&state->outbuf[i], on_v1, clen) && !state->got_v2) ||
+                    (!memcmp(&state->outbuf[i], on_v2, clen) && state->got_v2)) {
+                    if (clen != strlen(on_v1)) {
+                        /* Partial match. Save it. */
+                        residual = i;
+                        break;
+                    }
+
+                    /* Switch to compression */
+                    /* copy any compressible bits to our inbuf */
+
+                    grow_inbuf(state, state->outsize - i - strlen(on_v1));
+
+                    memcpy(state->inbuf,
+                           state->outbuf + i + strlen(on_v1),
+                           state->outsize - i - strlen(on_v1));
+
+                    state->insize = state->outsize - i - strlen(on_v1);
+
+                    /* clean up our output buffer */
+                    state->outsize = i;
+
+                    /* init stream */
+                    state->stream = malloc(sizeof(z_stream));
+                    state->stream->zalloc = zlib_alloc;
+                    state->stream->zfree = zlib_free;
+                    state->stream->opaque = NULL;
+
+                    if (inflateInit(state->stream) != Z_OK) {
+                        state->error = 1;
+                        free(state->stream);
+                        state->stream = NULL;
+                        return;
+                    }
+
+                    /* Continue with decompression */
+                    break;
+                }
+            }
+        }
+
+        if (!state->stream) { /* didn't start decompressing? */
+            /* We might have some residual, copy to inbuf for later checking */
+
+            if (residual != -1) {
+                grow_inbuf(state, state->outsize - residual);
+                memcpy(state->inbuf + state->insize, state->outbuf + residual, state->outsize - residual);
+                state->outsize = residual;
+            }
+
+            return;
+        }
+    } else {
+        /* New data to decompress. Copy to inbuf */
+        grow_inbuf(state, len);
+        memcpy(state->inbuf + state->insize, data, len);
+        state->insize += len;
+    }
+
+    decompress_inbuf(state);
+}
+
+/* How much data is available? */
+int mudcompress_pending(mc_state *state)
+{
+    return state->error ? 0 : state->outsize;
+}
+
+/* Was there an error? */
+int mudcompress_error(mc_state *state)
+{
+    return state->error;
+}
+
+/* Get some data */
+int mudcompress_get(mc_state *state, char *buf, int size)
+{
+    int copied;
+
+    if (state->error || !state->outsize)
+        return 0;
+
+    if (size > state->outsize)
+        copied = state->outsize;
+    else
+        copied = size;
+
+    memcpy(buf, state->outbuf, copied);
+    state->outsize -= copied;
+    if (state->outsize)
+        memmove(state->outbuf, state->outbuf + copied, state->outsize);
+
+    /* Do some more decompression */
+    decompress_inbuf(state);
+
+    return copied;
+}
+
+void mudcompress_stats(mc_state *state, unsigned long *comp, unsigned long *uncomp)
+{
+    *comp = state->comp;
+    *uncomp = state->uncomp;
+}
+
+const char *mudcompress_response(mc_state *state)
+{
+    if (state->resp_v1 == 1) {
+        state->resp_v1 = 0;
+        return do_v1;
+    }
+
+    if (state->resp_v1 == -1) {
+        state->resp_v1 = 0;
+        return dont_v1;
+    }
+
+    if (state->resp_v2) {
+        state->resp_v2 = 0;
+        return do_v2;
+    }
+
+    return NULL;
+}
+
+int mudcompress_compressing(mc_state *state)
+{
+    return (state->stream != NULL);
+}
+
+int mudcompress_v2(mc_state *state)
+{
+    return (state->stream != NULL && state->got_v2);
+}
+
+#endif	/* MUDCOMPRESS */
--- /dev/null
+++ tf-4.0s1/src/mccp.h
@@ -0,0 +1,141 @@
+/*
+ * Client decompression module for the mud client compression protocol.
+ * See http://homepages.ihug.co.nz/~icecube/compress/ for more details.
+ *
+ * mccpDecompress.h - header definitions. #include this in your client code.
+ *
+ * Oliver Jowett <icecube$ihug.co.nz>. Demangle address as needed.
+ *
+ * This code is placed in the public domain.
+ *
+ */
+
+/* Modified: 981203 */
+
+/*
+ *
+ * mc_state is an opaque type representing the current compression state of
+ * a connection. You should include a (mc_state *) in the information you
+ * store for a server connection.
+ *
+ * Initialization / cleanup:
+ *
+ *   When a connection is initiated, call mudcompress_new, and store the
+ *   resulting pointer in your server connection information. This pointer is
+ *   used as a handle for all other functions. This does NOT begin compression
+ *   - it just initialises various internal structures.
+ *
+ *   When a connection is terminated, call mudcompress_delete with the handle
+ *   to delete all memory allocated by the decompressor for the connection.
+ *
+ * Reading / writing:
+ *
+ *   Reading from the server connection must go through the decompressor at
+ *   all times. The decompressor handles both negotiation and decompression
+ *   transparently - it receives input directly from the server, then provides
+ *   the main client code with decompressed data, hiding all protocol details.
+ *
+ *   When data is received from the mud server, call mudcompress_receive,
+ *   passing it the handle for the connection, a pointer to the data read,
+ *   and the length of data read. It is VITAL that ALL data read is passed
+ *   to the decompressor - including data with embedded NULs!
+ *
+ *   After mudcompress_receive has been called, call mudcompress_pending() to
+ *   see if any decompressed data is available. It returns the number of
+ *   bytes pending.
+ *
+ *   If there is pending data waiting, call mudcompress_get to retrieve it.
+ *   This fills up to "size" bytes in the provided buffer "buf", and returns
+ *   the number of bytes copied. Your client can now process this data as if
+ *   it had been directly read from the server.
+ *
+ *   Be sure to check mudcompress_pending again after calling mudcompress_get!
+ *   Removing some data from the decompress buffer may have allowed the
+ *   decompressor to decompress some more data - in which case, you want to
+ *   process it immediately, rather than waiting for another read from the
+ *   mud server.
+ *
+ *   Regularly call mudcompress_response. If non-NULL, you need to write the
+ *   returned string to the mud server. This is needed when the decompressor
+ *   is negotiating compression with the server. When called,
+ *   mudcompress_response clears any pending string, so be sure to save its
+ *   return value!
+ *
+ * Status information:
+ *
+ *   mudcompress_error returns non-0 if there has been a (fatal) decompression
+ *   error. In this case, all you can do is tell the user that something went
+ *   wrong and close the connection.
+ *
+ *   mudcompress_stats fills in the two (unsigned long *) values passed, with
+ *   the number of compressed bytes read, and the number of bytes that they
+ *   decompressed to.
+ *
+ *   mudcompress_compressing returns non-0 if the connection is currently
+ *   using compression.
+ *
+ */
+
+#ifndef MUDCOMPRESS_H
+#define MUDCOMPRESS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*  Opaque handle for a decompressor. Details defined in Compress.c - you
+     *  should never need to see them externally.
+     */
+    struct mc_state_s;
+    typedef struct mc_state_s mc_state;
+
+    /*  Create a new decompressor. Return a handle to it.
+     */
+    mc_state *mudcompress_new(void);
+
+    /*  Deallocate a decompressor and associated data. 'state' is invalid
+     *  afterthis call.
+     */
+    void mudcompress_delete(mc_state *state);
+
+    /*  Perform decompression and negotiation on some received data.
+     *  'data' is a pointer to the received data, 'len' is its length.
+     */
+    void mudcompress_receive(mc_state *state, const char *data, unsigned len);
+
+    /*  Return the number of pending decompressed bytes that can currently
+     *  be read by mudcompress_get
+     */
+    int mudcompress_pending(mc_state *state);
+
+    /*  Return true (non-0) if this decompressor encountered a fatal error.
+     */
+    int mudcompress_error(mc_state *state);
+
+    /*  Read decompressed data from the decompressor into 'buf', up to a
+     *  maximum of 'size' bytes. Returns the number of bytes actually copied.
+     */
+    int mudcompress_get(mc_state *state, char *buf, int size);
+
+    /*  Set *comp to the number of compressed bytes read, and *uncomp to the
+     *  number of bytes they expanded to, for this decompressor.
+     */
+    void mudcompress_stats(mc_state *state, unsigned long *comp, unsigned long *uncomp);
+
+    /*  Check for a negotiation response. If this returns NULL, no output is
+     *  needed. If it returns non-NULL, it points to a NUL-terminated string
+     *  that should be sent to the mud server. Calling this function clears
+     *  the pending string (so be sure to save the result).
+     */
+    const char *mudcompress_response(mc_state *state);
+
+    /*  Return true (non-0) if this decompressor has successfully negotiated
+     *  compression and is currently performing decompression.
+     */
+    int mudcompress_compressing(mc_state *state);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- tf-4.0s1.orig/src/rules.mak
+++ tf-4.0s1/src/rules.mak
@@ -50,6 +50,7 @@ main.$O: main.c config.h port.h dstring.
 	variable.h tty.h $(BUILDERS)
 makehelp.$O: makehelp.c config.h port.h $(BUILDERS)
 malloc.$O: malloc.c config.h port.h signals.h malloc.h $(BUILDERS)
+mccp.$O: mccp.c mccp.h
 output.$O: output.c config.h port.h dstring.h $(TF_H) util.h tfio.h socket.h \
 	output.h macro.h search.h tty.h variable.h expr.h $(BUILDERS)
 process.$O: process.c config.h port.h dstring.h $(TF_H) util.h tfio.h \
@@ -59,7 +60,7 @@ signals.$O: signals.c config.h port.h ds
 	process.h tty.h output.h signals.h variable.h $(BUILDERS)
 socket.$O: socket.c config.h port.h dstring.h $(TF_H) util.h tfio.h tfselect.h \
 	history.h world.h socket.h output.h process.h macro.h keyboard.h \
-	commands.h command.h signals.h search.h $(BUILDERS)
+	commands.h command.h signals.h search.h mccp.h $(BUILDERS)
 tfio.$O: tfio.c config.h port.h dstring.h $(TF_H) util.h tfio.h tfselect.h \
 	output.h macro.h history.h search.h signals.h variable.h $(BUILDERS)
 tty.$O: tty.c config.h port.h $(TF_H) dstring.h util.h tty.h output.h macro.h \
--- tf-4.0s1.orig/src/socket.c
+++ tf-4.0s1/src/socket.c
@@ -67,6 +67,10 @@ struct sockaddr_in {
 #include "search.h"
 #include "variable.h"	/* set_var_by_*() */
 
+#ifdef MUDCOMPRESS
+#  include "mccp.h"
+#endif
+
 #ifdef _POSIX_VERSION
 # include <sys/wait.h>
 #endif
@@ -206,6 +210,9 @@ typedef struct Sock {		/* an open connec
     TIME_T time[2];		/* time of last receive/send */
     char state;			/* state of parser finite state automaton */
     long pid;			/* pid of name resolution process */
+#ifdef MUDCOMPRESS
+    mc_state *mccp;		/* mud compression struct */
+#endif
 } Sock;
 
 
@@ -806,6 +813,9 @@ int opensock(world, autologin, quietlogi
         tsock = *(tsock ? &tsock->next : &hsock) = xsock;
         xsock->activity = 0;
         Stringinit(xsock->buffer);
+#ifdef MUDCOMPRESS
+	xsock->mccp = mudcompress_new();
+#endif
         xsock->prompt = NULL;
         init_queue(xsock->queue = (Queue *)XMALLOC(sizeof(Queue)));
         xsock->next = NULL;
@@ -1297,6 +1307,9 @@ static void nukesock(sock)
 #endif /* NONBLOCKING_GETHOST */
     }
     Stringfree(sock->buffer);
+#ifdef MUDCOMPRESS
+    mudcompress_delete(sock->mccp);
+#endif
     if (sock->prompt) free_aline(sock->prompt);
     while(sock->queue->head)
         free_aline((Aline*)unlist(sock->queue->head, sock->queue));
@@ -1728,8 +1741,25 @@ static int handle_socket_input()
     }
 
     do {  /* while (n > 0 && !interrupted() && (received += count) < SPAM) */
-        do count = recv(xsock->fd, buffer, sizeof(buffer), 0);
-            while (count < 0 && errno == EINTR);
+#ifdef MUDCOMPRESS
+	if (!mudcompress_pending(xsock->mccp))
+	{
+	    do count = recv(xsock->fd, buffer, sizeof(buffer), 0);
+                while (count < 0 && errno == EINTR);
+
+	    if (count > 0) {
+		mudcompress_receive(xsock->mccp, buffer, count);
+		if (mudcompress_error(xsock->mccp)) {
+		    count = -1;
+		    errno = EIO;
+		}
+	    }
+	}
+#else
+	do count = recv(xsock->fd, buffer, sizeof(buffer), 0);
+	    while (count < 0 && errno == EINTR);
+#endif
+
         if (count <= 0) {
             int err = errno;
 #ifdef SUNOS_5_4
@@ -1761,6 +1791,25 @@ static int handle_socket_input()
             return received;
         }
 
+	received += count;
+	
+#ifdef MUDCOMPRESS
+	{
+	    const char *resp;
+	    
+	    count = 0;
+	    while (count < sizeof(buffer)
+		   && mudcompress_pending(xsock->mccp)) {
+		count += mudcompress_get(xsock->mccp, buffer + count,
+					 sizeof(buffer) - count);
+	    }
+	    
+	    resp = mudcompress_response(xsock->mccp);
+	    if (resp)
+		transmit(resp,strlen(resp));
+	} 
+#endif
+	
         for (place = buffer; place - buffer < count; place++) {
 
             /* We always accept 8-bit data, even though RFCs 854 and 1123
@@ -1958,7 +2007,6 @@ static int handle_socket_input()
         }
 
         /* See if anything arrived while we were parsing */
-
         FD_ZERO(&readfds);
         FD_SET(xsock->fd, &readfds);
         tv.tv_sec = tv.tv_usec = 0;
@@ -1976,7 +2024,13 @@ static int handle_socket_input()
             if (errno != EINTR) die("handle_socket_input: select", errno);
         }
 
-    } while (n > 0 && !interrupted() && (received += count) < SPAM);
+#ifdef MUDCOMPRESS
+	if (mudcompress_pending(xsock->mccp)) {
+	    n = 1;
+	}
+#endif
+
+    } while (n > 0 && !interrupted() && received < SPAM);
 
     /* If lpflag is on and we got a partial line from the fg world,
      * assume the line is a prompt.
--- tf-4.0s1.orig/src/socket.h
+++ tf-4.0s1/src/socket.h
@@ -13,7 +13,7 @@
 #define SOCK_RECV	0
 #define SOCK_SEND	1
 
-struct World   *world_decl;	/* declares struct World */
+struct World;	/* declares struct World */
 
 extern Aline *incoming_text;
 extern int quit_flag;
--- tf-4.0s1.orig/src/tf.1.catman
+++ tf-4.0s1/src/tf.1.catman
@@ -152,6 +152,8 @@ TF(1)
 
        Recall previously received text.
 
+       Support for the Mud Client Compression Protocol version 1 and 2.
+
 
 CCOONNFFIIGGUURRAATTIIOONN FFIILLEESS
        _T_F will attempt to read  two  files  when  starting.   The
--- tf-4.0s1.orig/src/tf.1.nroffman
+++ tf-4.0s1/src/tf.1.nroffman
@@ -112,6 +112,8 @@ Separate LP and Diku style prompts from
 Page output using a --More-- prompt.
 .sp
 Recall previously received text.
+.sp
+Support for Mud Client Compression Protocol versions 1 and 2.
 
 .SH "CONFIGURATION FILES"
 .PP
--- tf-4.0s1.orig/src/util.c
+++ tf-4.0s1/src/util.c
@@ -887,7 +887,7 @@ int ch_mailfile()
     CONST char *end;
 
     path = (TFMAILPATH && *TFMAILPATH) ? TFMAILPATH : MAIL;
-    while (*(name = stringarg(&path, &end))) {
+    while (path && *(name = stringarg(&path, &end))) {
         for (oldp = &maillist; *oldp; oldp = &(*oldp)->next) {
             if (strncmp(name, (*oldp)->name, end-name) == 0 &&
                 !(*oldp)->name[end-name])
--- tf-4.0s1.orig/src/vars.mak
+++ tf-4.0s1/src/vars.mak
@@ -15,14 +15,14 @@
 # Predefined variables:
 #   O - object file suffix (e.g., "o" or "obj")
 
-TFVER=40s1
+TFVER=40s1-mccp
 
 SOURCE = command.c dstring.c expand.c help.c history.c keyboard.c \
   macro.c main.c malloc.c output.c process.c search.c signals.c \
   socket.c tfio.c tty.c util.c variable.c world.c
 
 OBJS = command.$O dstring.$O expand.$O expr.$O help.$O history.$O keyboard.$O \
-  macro.$O main.$O malloc.$O output.$O process.$O search.$O signals.$O \
+  macro.$O main.$O malloc.$O mccp.$O output.$O process.$O search.$O signals.$O \
   socket.$O tfio.$O tty.$O util.$O variable.$O world.$O \
   regexp.$O $(OTHER_OBJS)
 
--- tf-4.0s1.orig/tf-lib/spell.tf
+++ tf-4.0s1/tf-lib/spell.tf
@@ -7,7 +7,7 @@
 
 /def -i spell_line = \
     /setenv ARGS=$(/recall -i 1)%; \
-    /let _errs=$(/quote -S -decho !echo $$ARGS | spell)%; \
+    /let _errs=$(/quote -S -decho !echo $$ARGS | ispell -l)%; \
     /if ( _errs !~ "" ) \
         /echo MISSPELLINGS: %_errs%; \
     /else \
--- tf-4.0s1.orig/unix/Config
+++ tf-4.0s1/unix/Config
@@ -33,8 +33,8 @@
 #   even if an old version is currently in use.  You can remove
 #   the old version manually later when it is no longer in use.
 
-# TF="/usr/local/bin/tf-${TFVER}"
-# LIBDIR="/usr/local/lib/tf-${TFVER}-lib"
+TF="/usr/games/tf"
+LIBDIR="/usr/share/games/tf"
 # SYMLINK="/usr/local/bin/tf"
 
 
@@ -44,8 +44,8 @@
 # uses nroff format; set MANTYPE=cat if your man uses pre-formatted
 # vt100 "catman" pages.  Default is "cat".
 
-# MANTYPE="nroff"
-# MANPAGE="/usr/local/man/man1/tf.1"
+MANTYPE="nroff"
+MANPAGE="/usr/man/man6/tf.6"
 
 
 ### Flags.
@@ -110,7 +110,7 @@ FLAGS=''
 # by removing the leading "#".
 
 # CC=cc
-# CCFLAGS="-g"
+CCFLAGS="-O2 -g -Wall"
 
 
 ### Stripping.
--- tf-4.0s1.orig/unix/tfconfig
+++ tf-4.0s1/unix/tfconfig
@@ -66,8 +66,12 @@ X=''
 if [ -z "$USER" ]; then USER=$LOGNAME; fi
 export USER
 
-UNAME=`{ uname -s && uname -v && uname -r || uname -a; } 2>/dev/null`
-echo "#define UNAME     " \"$UNAME\" >&4
+UNAME=`{ uname -smo; } 2>/dev/null`
+if test -n "$SOURCE_DATE_EPOCH"; then
+    echo "#define UNAME     \"\"" >&4
+else
+    echo "#define UNAME     " \"$UNAME\" >&4
+fi
 case "$UNAME" in
 "SunOS 5.4")
     echo "#define SUNOS_5_4" >&4
@@ -168,18 +172,18 @@ fi
 # The cd;pwd is needed to normalize the directory name in case of links, etc.
 
 DIR1=`echo $TF      | sed 's;/[^/]*$;;'`
-DIR1=`cd $DIR1 && pwd`
+#DIR1=`cd $DIR1 && pwd`
 DIR2=`echo $LIBDIR  | sed 's;/[^/]*$;;'`
-DIR2=`cd $DIR2 && pwd`
+#DIR2=`cd $DIR2 && pwd`
 DIR3=`echo $SYMLINK | sed 's;/[^/]*$;;'`
-DIR3=`cd $DIR3 && pwd`
+#DIR3=`cd $DIR3 && pwd`
 
-if [ -z "$DIR1" ] || [ -z "$DIR2" ] || [ -z "$DIR3" ]; then
+if [ -z "$DIR1" ] || [ -z "$DIR2" ]; then
     echo "Error in directory."
     exit 1;
 fi
 
-DIR1=`cd $DIR1 && pwd || { echo "Error in directory $DIR1."; false; }`
+#DIR1=`cd $DIR1 && pwd || { echo "Error in directory $DIR1."; false; }`
 
 BUILDTREE=`cd .. && pwd`
 if echo "${DIR1}/" | egrep "^${BUILDTREE}/" >/dev/null 2>&1 ||
@@ -482,6 +486,14 @@ else
     echo "I can't find <pwd.h>.  Filename '~user' expansion won't be supported."
 fi
 
+### Find zlib.h
+if echo '#include <zlib.h>' >test.c; ${CPP} test.c >/dev/null 2>&1; then
+    echo "#define MUDCOMPRESS" >&4
+    echo "Found <zlib.h>."
+else
+    echo "I can't find <zlib.h>.  The Mud Client Compression Protocol will not be supported."
+fi
+
 ### Figure out how to do varadic args.
 if [ "$STD_C" = "1" ] || [ "$GNU_C" = "1" ]; then
     if echo '#include <stdarg.h>' >test.c; ${CPP} test.c >/dev/null 2>&1; then
@@ -758,6 +770,12 @@ else
     echo "/* warning: tfconfig couldn't find connect() */" >&4
 fi
 
+### Test for zlib for mud compression
+if eval "${LIBTEST} -lz ${LIBS} >/dev/null 2>&1" && test -f ${AOUT}; then
+    echo "Will link with -lz."
+    LIBS="-lz $LIBS"
+fi
+
 ### Test for SOCKS firewall proxy server.
 if [ -n "$SOCKS" ]; then
     # SOCKS uses res_init(), so we need -lresolv if there is one.
--- tf-4.0s1.orig/unix/unix.mak
+++ tf-4.0s1/unix/unix.mak
@@ -14,7 +14,7 @@
 # unix section of src/Makefile.
 #
 
-CFLAGS     = $(FLAGS)
+#CFLAGS     = $(FLAGS)
 SHELL      = /bin/sh
 BUILDERS   = Makefile
 
@@ -52,13 +52,13 @@ _failmsg:
 
 regexp.o: $(BUILDERS) config.h
 	cd ./regexp; \
-	    $(MAKE) CC='$(CC)' CFLAGS='-O' O=o regexp.o >err 2>&1 || \
+	    $(MAKE) CC='$(CC)' CFLAGS='$(CFLAGS)' O=o regexp.o >err 2>&1 || \
 	    { cat err; rm err; exit 1; }
 	rm regexp/err
 	mv regexp/regexp.o .
 
 TF tf$(X):     $(OBJS) $(BUILDERS)
-	$(CC) $(CFLAGS) -o tf$(X) $(OBJS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o tf$(X) $(OBJS) $(LIBS)
 #	@# Some stupid linkers return ok status even if they fail.
 	@test -f tf$(X)
 #	@# ULTRIX's sh errors here if strip isn't found, despite "true".
@@ -114,7 +114,7 @@ LIBRARY $(LIBDIR): ../tf-lib/tf-help ../
 	rm -f worldqueue.tf;   ln -s  world-q.tf   worldqueue.tf;
 
 makehelp: makehelp.c
-	$(CC) $(CFLAGS) -o makehelp makehelp.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o makehelp makehelp.c
 
 __always__: