summaryrefslogtreecommitdiff
path: root/mail/mush/patches/patch-ad
blob: 6f2ff9be7ccd89a23c413418bcf56cadfa5da855 (plain)
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
$NetBSD: patch-ad,v 1.3 2005/05/29 05:33:42 minskim Exp $

--- mush.h.orig	2005-05-29 00:29:17.730213120 -0500
+++ mush.h
@@ -4,89 +4,98 @@
 
 /* POSIX -- a collection of standardized parts from SYSV and BSD */
 #if defined(POSIX) || defined(BSD44)
-#include <unistd.h>
-#ifndef	NO_STDLIB
-#include <stdlib.h>
-#endif
-#define SIGRET void
+# include <unistd.h>
+# ifndef	NO_STDLIB
+#  include <stdlib.h>
+# endif
+# define SIGRET void
 #endif
+
 #ifdef SVR4
-#include <libgen.h>
+# include <libgen.h>
 #endif
 
 /* STDC -- i.e. ANSI C, a collection of standardized modifications to
  * the C language, often accompanied by [partial] POSIX compliance
  */
 #ifdef __STDC__
-#ifndef VPRINTF
-#define VPRINTF
-#endif
+# ifndef VPRINTF
+#  define VPRINTF
+# endif
 #endif
 
 #ifdef CURSES
 
-#ifndef POSIX
-#ifdef USG
-#    define _USG
-#    undef USG
-#endif /* USG */
-#ifdef SYSV
-#    define _SYSV
-#    undef SYSV
-#endif /* SYSV */
-#endif /* POSIX */
-
-#ifdef NCURSES
-# undef NCURSES
-# include <ncurses.h>
-#else
-# include <curses.h>
-#endif
-
-#ifdef timeout
-#undef timeout
-#endif
-#ifdef overwrite
-#undef overwrite
-#endif
-
-#ifdef linux
-#include <termios.h>
-#endif /* linux */
-
-#if !defined(USG) && defined(_USG)
-#    define USG
-#endif /* USG */
-#if !defined(SYSV) && defined(_SYSV)
-#    define SYSV
-#endif /* SYSV */
+# ifndef POSIX
+#  ifdef USG
+#   define _USG
+#   undef USG
+#  endif /* USG */
+#  ifdef SYSV
+#   define _SYSV
+#   undef SYSV
+#  endif /* SYSV */
+# endif /* POSIX */
+
+# ifdef BSD44
+#  include <termios.h>
+# endif /* BSD44 */
+# ifdef NCURSES
+#  undef NCURSES
+#  include <ncurses.h>
+# else
+#  include <curses.h>
+# endif
+
+# ifdef timeout
+#  undef timeout
+# endif
+# ifdef overwrite
+#  undef overwrite
+# endif
+
+# ifdef linux
+#  include <termios.h>
+# endif /* linux */
+
+# if !defined(USG) && defined(_USG)
+#  define USG
+# endif /* USG */
+# if !defined(SYSV) && defined(_SYSV)
+#  define SYSV
+# endif /* SYSV */
 
 #else /* CURSES */
-#include <stdio.h>
-#if defined(POSIX) || defined(SVR4)
-#include <termios.h>
-#else /* POSIX */
-#if defined(SYSV) && defined(USG) || defined(AIX)
-#include <termio.h>
-#ifdef DGUX
-#include <ioctl.h>
-#endif /* DGUX */
-#endif /* POSIX */
-#endif /* SYSV && USG */
+# include <stdio.h>
+# if defined(POSIX) || defined(SVR4)
+#  include <termios.h>
+# else /* POSIX */
+#  if defined(SYSV) && defined(USG) || defined(AIX)
+#   include <termio.h>
+#   ifdef DGUX
+#    include <ioctl.h>
+#   endif /* DGUX */
+#  endif /* SYSV && USG || AIX */
+# endif /* POSIX */
 #endif /* CURSES */
 
 #ifdef HPUX
-#include <termio.h>
+# include <termio.h>
 #endif /* HPUX */
 
 #if defined(SVR4)
-#include <sys/ttold.h>
+# include <sys/ttold.h>
 #endif /* SVR4 */
 
 #include <ctype.h>
 #include <errno.h>
 #include <setjmp.h>
 #include "strings.h"
+#ifdef MSGS_DYNAMIC
+# if (defined(sun) || defined(__sun__)) && (defined(sparc) || defined(__sparc__))
+#  include <alloca.h>
+# endif
+#endif
 
 #ifndef __STDC__
 extern char
@@ -100,79 +109,85 @@ extern void
     xfree();		/* free malloc'ed pointers */
 
 #ifdef BSD
-#define fputs Fputs	/* See comments in print.c */
+# define fputs Fputs	/* See comments in print.c */
 #endif /* BSD */
 
 #if (defined(BSD) || defined(GETWD)) && !defined(__STDC__)
 extern char *getwd();
-#define GetCwd(buf,len)	getwd(buf)
+# define GetCwd(buf,len)	getwd(buf)
 #else
-#ifndef __STDC__
+# ifndef __STDC__
 extern char *getcwd();
-#endif
-#define GetCwd(buf,len) getcwd(buf,len)
+# endif
+# define GetCwd(buf,len) getcwd(buf,len)
 #endif /* BSD || GETWD */
 
 #ifdef SUNTOOL
-#    include <suntool/sunview.h>
-#ifdef SUN_4_0
-#    include <suntool/alert.h>
-#endif /* SUN_4_0 */
-#    include <suntool/textsw.h>
-#    include <sys/ioctl.h>   /* for ltchars */
+# include <suntool/sunview.h>
+# ifdef SUN_4_0
+#  include <suntool/alert.h>
+# endif /* SUN_4_0 */
+# include <suntool/textsw.h>
+# include <sys/ioctl.h>   /* for ltchars */
 #else
-#    include <sys/types.h>
-#    include <signal.h>
-#    ifndef SYSV
-#	include <sys/time.h>
-#	include <sys/ioctl.h>   /* for ltchars */
-#    else
-#	include <time.h>
-#	ifdef M_UNIX
-#	    ifndef SELECT
-#		define SELECT
-#	    endif
-#	    include <sys/select.h>
-#	endif /* M_UNIX */
-#	include <fcntl.h>
-#    endif /* SYSV */
+# include <sys/types.h>
+# include <signal.h>
+# ifndef SYSV
+#  include <sys/time.h>
+#  include <sys/ioctl.h>   /* for ltchars */
+# else
+#  include <time.h>
+#  ifdef M_UNIX
+#   ifndef SELECT
+#    define SELECT
+#   endif
+#   include <sys/select.h>
+#  endif /* M_UNIX */
+#  include <fcntl.h>
+# endif /* SYSV */
 #endif /* SUNTOOL */
 
+#ifdef BSD44
+# define REGCOMP
+# include <regex.h>
+#endif
+
 #ifdef POSIX_UTIME
-#ifdef POSIX
-#include <utime.h>
-#else  /* POSIX */
-#include <sys/utime.h>
-#endif /* POSIX */
+# ifdef POSIX
+#  include <utime.h>
+# else  /* POSIX */
+#  include <sys/utime.h>
+# endif /* POSIX */
 #endif /* POSIX_UTIME */
+
 #include <sys/stat.h>
 #include <sys/file.h>
 
 #ifdef SUNTOOL
-#    include <suntool/panel.h>
-#    include <suntool/canvas.h>
-#    include <suntool/tty.h>
-#    include <suntool/menu.h>
-#    include <suntool/icon.h>
-#    include <suntool/scrollbar.h>
-#    include <suntool/icon_load.h>
+# include <suntool/panel.h>
+# include <suntool/canvas.h>
+# include <suntool/tty.h>
+# include <suntool/menu.h>
+# include <suntool/icon.h>
+# include <suntool/scrollbar.h>
+# include <suntool/icon_load.h>
 #endif /* SUNTOOL */
 
 /* if no maximum number of files can be found, we'll use getdtablesize() */
 #ifdef _NFILE
-#    define MAXFILES _NFILE
+# define MAXFILES _NFILE
 #else
-#ifdef NOFILE
-#    define MAXFILES NOFILE
-#endif /* NOFILE */
+# ifdef NOFILE
+#  define MAXFILES NOFILE
+# endif /* NOFILE */
 #endif /* _NFILE */
 
 #ifndef MAXPATHLEN
-#define MAXPATHLEN BUFSIZ
+# define MAXPATHLEN BUFSIZ
 #endif /* MAXPATHLEN */
 
 #ifdef CTRL
-#undef CTRL
+# undef CTRL
 #endif /* CTRL */
 #define CTRL(c)		((c) & 037)
 
@@ -180,20 +195,24 @@ extern char *getcwd();
 
 #define NO_STRING	""
 #ifdef  NULL
-#undef  NULL
+# undef  NULL
 #endif /* NULL */
+#ifdef __STDC__
+#define NULL		(void *)0
+#else
 #define NULL		(char *)0
+#endif
 #define NULL_FILE	(FILE *)0
 #define DUBL_NULL	(char **)0
 #define TRPL_NULL	(char ***)0
 #ifdef putchar
-#undef putchar
+# undef putchar
 #endif /* putchar */
 #define putchar(c)	(void) (fputc(c, stdout), fflush(stdout))
 #ifdef SUNTOOL
 extern int bell();
 #else /* SUNTOOL */
-#define bell()		(void) (fputc('\007', stderr), fflush(stderr))
+# define bell()		(void) (fputc('\007', stderr), fflush(stderr))
 #endif /* SUNTOOL */
 
 /* For error recovery purposes, send keyboard generated signals to a special
@@ -211,121 +230,121 @@ extern int bell();
 
 /* Don't flush input when setting echo or cbreak modes (allow typeahead) */
 #ifdef TIOCSETN
-#ifdef stty
-#undef stty
-#endif /* stty */
-#define stty(fd, sgttybuf)	ioctl(fd, TIOCSETN, sgttybuf)
+# ifdef stty
+#  undef stty
+# endif /* stty */
+# define stty(fd, sgttybuf)	ioctl(fd, TIOCSETN, sgttybuf)
 #endif /* TIOCSETN */
 
 /* for system-V machines that run termio */
 #if defined(SYSV) && defined(USG) || defined(AIX) || defined(POSIX) || defined(BSD44)
-#ifdef crmode
-#undef crmode
-#undef nocrmode
-#endif /* nocrmode */
+# ifdef crmode
+#  undef crmode
+#  undef nocrmode
+# endif /* nocrmode */
 
 unsigned char vmin, vtime;
 
-#ifdef __linux__
-# undef TCGETA
-# undef TCSETAW
-# define TCGETA TCGETS
-# define TCSETAW TCSETSW
-#endif
-#ifdef BSD44
-# undef TCGETA
-# undef TCSETAW
-# define TCGETA TIOCGETA
-# define TCSETAW TIOCSETAW
-#endif
-
-#ifdef POSIX
-#define sg_erase  c_cc[VERASE]
-#define sg_flags  c_lflag
-#define sg_kill   c_cc[VKILL]
-#define gtty(fd, SGTTYbuf)	tcgetattr(fd, SGTTYbuf)
-#undef stty
-#define stty(fd, SGTTYbuf)	tcsetattr(fd, TCSADRAIN, SGTTYbuf)
-#else /* !POSIX */
-#define sg_erase  c_cc[2]
-#define sg_flags  c_lflag
-#define sg_kill   c_cc[3]
-#define sg_ospeed c_cflag
-#define gtty(fd, SGTTYbuf)	ioctl(fd, TCGETA, SGTTYbuf)
-#undef stty
-#define stty(fd, SGTTYbuf)	ioctl(fd, TCSETAW, SGTTYbuf)
-#endif /* POSIX */
-
-#define echon()    (_tty.sg_flags |= (ECHO|ECHOE),    stty(0, &_tty))
-#define echoff()   (_tty.sg_flags &= ~ECHO,   stty(0, &_tty))
-#define cbrkon()   \
+# ifdef __linux__
+#  undef TCGETA
+#  undef TCSETAW
+#  define TCGETA TCGETS
+#  define TCSETAW TCSETSW
+# endif
+# ifdef BSD44
+#  undef TCGETA
+#  undef TCSETAW
+#  define TCGETA TIOCGETA
+#  define TCSETAW TIOCSETAW
+# endif
+
+# ifdef POSIX
+#  define sg_erase  c_cc[VERASE]
+#  define sg_flags  c_lflag
+#  define sg_kill   c_cc[VKILL]
+#  define gtty(fd, SGTTYbuf)	tcgetattr(fd, SGTTYbuf)
+#  undef stty
+#  define stty(fd, SGTTYbuf)	tcsetattr(fd, TCSADRAIN, SGTTYbuf)
+# else /* !POSIX */
+#  define sg_erase  c_cc[2]
+#  define sg_flags  c_lflag
+#  define sg_kill   c_cc[3]
+#  define sg_ospeed c_cflag
+#  define gtty(fd, SGTTYbuf)	ioctl(fd, TCGETA, SGTTYbuf)
+#  undef stty
+#  define stty(fd, SGTTYbuf)	ioctl(fd, TCSETAW, SGTTYbuf)
+# endif /* POSIX */
+
+# define echon()    (_tty.sg_flags |= (ECHO|ECHOE),    stty(0, &_tty))
+# define echoff()   (_tty.sg_flags &= ~ECHO,   stty(0, &_tty))
+# define cbrkon()   \
 	(_tty.sg_flags &= ~ICANON, _tty.c_cc[VMIN] = 1, stty(0, &_tty))
-#define cbrkoff()  \
+# define cbrkoff()  \
 	(_tty.sg_flags |= ICANON,_tty.c_cc[VMIN] = vmin,_tty.c_iflag |= ICRNL, \
 		_tty.c_cc[VTIME] = vtime, stty(0, &_tty))
 
-#ifdef __linux__
-# undef savetty
-# undef cbreak
-# undef nocbreak
-#endif
+# ifdef __linux__
+#  undef savetty
+#  undef cbreak
+#  undef nocbreak
+# endif
 
-#ifndef savetty
-# define savetty()  \
+# ifndef savetty
+#  define savetty()  \
 	(void) gtty(0, &_tty), vtime = _tty.c_cc[VTIME], vmin = _tty.c_cc[VMIN]
-#endif
-#ifndef cbreak
-# define cbreak()   cbrkon()
-#endif
-#ifndef nocbreak
-# define nocbreak() cbrkoff()
-#endif
+# endif
+# ifndef cbreak
+#  define cbreak()   cbrkon()
+# endif
+# ifndef nocbreak
+#  define nocbreak() cbrkoff()
+# endif
 
 /* If curses isn't defined, declare our 'tty' and macros for echo/cbreak */
-#ifndef CURSES
-#ifdef POSIX
+# ifndef CURSES
+#  ifdef POSIX
 typedef struct termios SGTTY;
-#else
+#  else
 typedef struct termio SGTTY;
-#endif
-#define echom()    echon()
-#define noechom()  echoff()
-#define crmode()   cbrkon()
-#define nocrmode() cbrkoff()
+#  endif
+#  define echom()    echon()
+#  define noechom()  echoff()
+#  define crmode()   cbrkon()
+#  define nocrmode() cbrkoff()
 
 /* These two moved from above; is that right?? Were they misplaced? */
 /* are these even needed?  I don't think any code (except below) uses them. */
-#define cbreak()   cbrkon()
-#define nocbreak() cbrkoff()
+#  define cbreak()   cbrkon()
+#  define nocbreak() cbrkoff()
 
-#else /* CURSES */
-#ifdef DEFINE_CURSES_SGTTY
+# else /* CURSES */
+#  if defined(DEFINE_CURSES_SGTTY) || defined(BSD44)
 typedef struct termios SGTTY;
-#endif
+#  endif
 /* If curses is defined, use the echo/cbreak commands in library only
  * if curses is running.  If curses isn't running, use macros above.
  */
-#define echom()    ((iscurses) ? echo(): echon())
-#define noechom()  ((iscurses) ? noecho(): echoff())
-#define crmode()   ((iscurses) ? cbreak() : cbrkon())
-#define nocrmode() ((iscurses) ? nocbreak() : cbrkoff())
-#endif /* CURSES */
+#  define echom()    ((iscurses) ? echo(): echon())
+#  define noechom()  ((iscurses) ? noecho(): echoff())
+#  define crmode()   ((iscurses) ? cbreak() : cbrkon())
+#  define nocrmode() ((iscurses) ? nocbreak() : cbrkoff())
+# endif /* CURSES */
 #endif /* SYSV && USG || AIX || POSIX || BSD44 */
 
 #if !defined(USG) && !defined(AIX) && !defined(POSIX) && !defined(BSD44)
-#ifndef CURSES
+# ifndef CURSES
 /* if curses is not defined, simulate the same tty based macros */
 typedef struct sgttyb SGTTY;
 /* Do real ioctl calls to set the tty modes */
-#define crmode()   (_tty.sg_flags |= CBREAK,  stty(0, &_tty))
-#define nocrmode() (_tty.sg_flags &= ~CBREAK, stty(0, &_tty))
-#define echom()    (_tty.sg_flags |= ECHO,    stty(0, &_tty))
-#define noechom()  (_tty.sg_flags &= ~ECHO,   stty(0, &_tty))
-#define savetty()  (void) gtty(0, &_tty)
-#else /* CURSES */
-#define echom()    echo()
-#define noechom()  noecho()
-#endif /* ~CURSES */
+#  define crmode()   (_tty.sg_flags |= CBREAK,  stty(0, &_tty))
+#  define nocrmode() (_tty.sg_flags &= ~CBREAK, stty(0, &_tty))
+#  define echom()    (_tty.sg_flags |= ECHO,    stty(0, &_tty))
+#  define noechom()  (_tty.sg_flags &= ~ECHO,   stty(0, &_tty))
+#  define savetty()  (void) gtty(0, &_tty)
+# else /* CURSES */
+#  define echom()    echo()
+#  define noechom()  noecho()
+# endif /* ~CURSES */
 #endif /* ~USG */
 
 /* With all that out of the way, we can now declare our tty type */
@@ -351,78 +370,78 @@ extern char
 #define Debug		if (debug == 0) {;} else (void) wprint
 
 #ifdef SYSV
-#ifndef L_SET
-#define L_SET	0
-#endif /* L_SET */
-#ifndef F_OK
-#define F_OK	000
-#define R_OK	004
-#define W_OK	002
-#define E_OK	001
-#endif /* F_OK */
-#ifdef u_long
-#undef u_long
-#endif /* u_long */
-#define u_long	unsigned long
-#ifndef HPUX
-#define vfork   fork
-#endif /* HPUX */
-#ifndef SIGCHLD
-#define SIGCHLD SIGCLD
-#endif /* SIGCHLD */
+# ifndef L_SET
+#  define L_SET	0
+# endif /* L_SET */
+# ifndef F_OK
+#  define F_OK	000
+#  define R_OK	004
+#  define W_OK	002
+#  define E_OK	001
+# endif /* F_OK */
+# ifdef u_long
+#  undef u_long
+# endif /* u_long */
+# define u_long	unsigned long
+# ifndef HPUX
+#  define vfork   fork
+# endif /* HPUX */
+# ifndef SIGCHLD
+#  define SIGCHLD SIGCLD
+# endif /* SIGCHLD */
 #endif /* SYSV */
 
 #if !defined(SUNTOOL) && !defined(CURSES)
 
-#define TRUE		  1
-#define FALSE		  0
-#define print		  (void) printf
-#define wprint		  (void) printf
-#define print_more	  (void) printf
+# define TRUE		  1
+# define FALSE		  0
+# define print		  (void) printf
+# define wprint		  (void) printf
+# define print_more	  (void) printf
 
 #endif /* !SUNTOOL && !CURSES */
 
 #ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#define min(a,b) (((a) < (b)) ? (a) : (b))
+# define max(a,b) (((a) > (b)) ? (a) : (b))
+# define min(a,b) (((a) < (b)) ? (a) : (b))
 #endif /* max */
 
 #if defined(CURSES) && (!defined(SUNTOOL))
-#define wprint	(void) printf
+# define wprint	(void) printf
 #endif /* CURSES && (!SUNTOOL) */
 
 #ifdef SUNTOOL
 /* stdout may be closed */
-#define printf wprint
+# define printf wprint
 #else /* !SUNTOOL */
-#define ok_box print
+# define ok_box print
 #endif /* SUNTOOL */
 
 #if defined(CURSES) || defined(SUNTOOL)
-#define print_more	  turnon(glob_flags, CONT_PRNT), print
-#ifdef __STDC__
+# define print_more	  turnon(glob_flags, CONT_PRNT), print
+# ifdef __STDC__
 void print(char *fmt,...);	/* compliance with ansi header for varargs */
-#else /* __STDC__ */
+# else /* __STDC__ */
 void print();	/* printf to window or curses or tty accordingly */
-#endif /* __STDC__ */
+# endif /* __STDC__ */
 #endif /* CURSES || SUNTOOL */
 
 #define ArraySize(o)	  (sizeof(o) / sizeof(*o))
 
 #ifdef SUNTOOL
 
-#define NO_ITEM		(Panel_item)0
-#define NO_EVENT	(struct inputevent *)0
-#define TIME_OUT	60	/* sleep 60 secs between mailchecks */
-#define PIX_XOR		PIX_SRC ^ PIX_DST
-#define ID		event_id(event)
-#define l_width()	mush_font->pf_defaultsize.x /* width of letter */
-#define l_height()	mush_font->pf_defaultsize.y /* height of letter */
-#define Clrtoeol(w,x,y)	((void) pw_text(w, x, y, PIX_SRC, mush_font, blank))
-
+# define NO_ITEM		(Panel_item)0
+# define NO_EVENT	(struct inputevent *)0
+# define TIME_OUT	60	/* sleep 60 secs between mailchecks */
+# define PIX_XOR		PIX_SRC ^ PIX_DST
+# define ID		event_id(event)
+# define l_width()	mush_font->pf_defaultsize.x /* width of letter */
+# define l_height()	mush_font->pf_defaultsize.y /* height of letter */
+# define Clrtoeol(w,x,y)	((void) pw_text(w, x, y, PIX_SRC, mush_font, blank))
+ 
 /* Miscellaneous old-SunView cleanup */
 #ifndef TTY_ARGV_DO_NOT_FORK
-#define TTY_ARGV_DO_NOT_FORK (-1)
+# define TTY_ARGV_DO_NOT_FORK (-1)
 #endif
 
 #endif /* SUNTOOL */
@@ -547,8 +566,13 @@ u_long   glob_flags;	/* global boolean f
 /* It is possible to reset MAX_PRIORITY to as high as 9 */
 #define MAX_PRIORITY	5
 
-#define	MAXMSGS_BITS	((MAXMSGS+7)/8)	/* number of bits for bitmap */
-
+#ifndef MSGS_DYNAMIC
+# define	MAXMSGS_BITS	MAXMSGS/sizeof(char)	/* number of bits for bitmap */
+#else
+# define MSGS_BITS(a)	(((a)+7)/8)
+# define MSGS_INCR	500
+#endif
+  
 struct msg {
     u_long m_flags;
     long   m_offset;	/* offset in tempfile of msg */
@@ -559,7 +583,16 @@ struct msg {
     char   *m_to;	/* Cached To: field */
     char   *m_subject;	/* Cached Subject: field */
     char   *m_from;	/* Cached Reply-To: or From: field */
-} msg[MAXMSGS];
+    char   *m_addr;	/* Cached Reply-To: or From: field */
+    char   *m_name;	/* Cached Reply-To: or From: field */
+    char   m_author;	/* if any of the 3 preceding ones has been inited */
+    u_long m_spare;	/* spare field */
+}
+#ifdef MSGS_DYNAMIC
+    *msg;
+#else
+    msg[MAXMSGS];
+#endif
 
 struct options {
     char *option;
@@ -603,7 +636,11 @@ jmp_buf jmpbuf;		/* longjmp to jmpbuf on
 char
     debug,		/* debug causes various print statements in code */
     tempfile[MAXPATHLEN],	/* path to filename of temporary file */
+#ifdef MSGS_DYNAMIC
+    *msg_list,		/* boolean storage */
+#else
     msg_list[MAXMSGS_BITS],	/* MAXMSGS bits of boolean storage */
+#endif
     **alternates,	/* alternates list --see alts() */
     *cmd_help,		/* filename of location for "command -?" commands. */
     *login,		/* login name of user */
@@ -658,6 +695,9 @@ char
 int
     last_msg_cnt,	/* when checking for new mail, save the last msg_cnt */
     msg_cnt,		/* total number of messages */
+#ifdef MSGS_DYNAMIC
+    msg_max,		/* current maximum allocation limit */
+#endif
     crt,		/* min number of lines msg contains to invoke pager */
     current_msg,	/* the current message we're dealing with */
     exec_pid,		/* pid of a command that has been "exec"ed */
@@ -666,7 +706,7 @@ int
 #if defined(SUNTOOL) || defined(lint)
     istool,		/* argv[0] == "xxxxtool", ranges from 0 to 2 */
 #else /* !SUNTOOL */
-#define istool 0
+# define istool 0
 #endif /* SUNTOOL */
     n_array[128],	/* array of message numbers in the header window */
     screen,		/* number of headers window can handle */
@@ -725,7 +765,7 @@ int
 char * quoteit();
 
 #ifndef SIGRET
-#define SIGRET int
+# define SIGRET int
 #endif /* SIGRET */
 SIGRET
     rm_edfile(),	/* remove letter-compose file on interrupts */
@@ -737,8 +777,8 @@ SIGRET
 
 long
     spool_size,		/* size of spool mail regardless of current folder */
-    last_size,		/* the last size of the mailfile since last check */
-    time();		/* satisfy lint */
+    last_size;		/* the last size of the mailfile since last check */
+/*    time();		 satisfy lint */
 
 void
     error(), getmail(), mail_status(), sign_letter(),
@@ -754,9 +794,9 @@ void
 #ifdef TIOCGLTC
 struct ltchars ltchars;			/* tty character settings */
 #endif /* TIOCGLTC */
-#if defined(BSD) && !defined(AIX) /* (TIOCGETC) */
+#if defined(BSD) && !defined(AIX) && defined(TIOCGETC)
 struct tchars  tchars;			/* more tty character settings */
-#endif /* BSD && !AIX (TIOCGETC) */
+#endif /* BSD && !AIX && TIOCGETC */
 
 #ifdef CURSES
 
@@ -775,16 +815,16 @@ void
     mac_flush();	/* Abandon macro processing (on error) */
 
 #if defined(SUNTOOL) || defined(POP3_SUPPORT)
-#ifdef POP3_SUPPORT
-#define MIN_TIME_OUT	(15 * 60)	/* 15 min. checks */
+# ifdef POP3_SUPPORT
+#  define MIN_TIME_OUT	(15 * 60)	/* 15 min. checks */
 extern void popchkmail();
 extern void popgetmail();
-#ifdef MAIL_FROM_POPHOST
+#  ifdef MAIL_FROM_POPHOST
 extern char *pophostname();
-#endif /* MAIL_FROM_POPHOST */
-#else
-#define MIN_TIME_OUT	30		/* 30 sec. checks */
-#endif /* POP3_SUPPORT */
+#  endif /* MAIL_FROM_POPHOST */
+# else
+#  define MIN_TIME_OUT	30		/* 30 sec. checks */
+# endif /* POP3_SUPPORT */
 
 int
     time_out;		/* time out interval to wait for new mail */
@@ -838,3 +878,7 @@ typedef enum {
     MUSH_SCROLL_PASS_EVENT
 } Scroll_action;
 #endif /* SUNTOOL */
+
+#ifdef __linux__
+#include <time.h>
+#endif