$NetBSD: patch-ad,v 1.4 2006/01/08 17:04:58 joerg Exp $ --- mush.h.orig 2006-01-08 16:53:34.000000000 +0000 +++ mush.h @@ -4,89 +4,98 @@ /* POSIX -- a collection of standardized parts from SYSV and BSD */ #if defined(POSIX) || defined(BSD44) -#include -#ifndef NO_STDLIB -#include -#endif -#define SIGRET void +# include +# ifndef NO_STDLIB +# include +# endif +# define SIGRET void #endif + #ifdef SVR4 -#include +# include #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 -#else -# include -#endif - -#ifdef timeout -#undef timeout -#endif -#ifdef overwrite -#undef overwrite -#endif - -#ifdef linux -#include -#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 +# endif /* BSD44 */ +# ifdef NCURSES +# undef NCURSES +# include +# else +# include +# endif + +# ifdef timeout +# undef timeout +# endif +# ifdef overwrite +# undef overwrite +# endif + +# ifdef linux +# include +# endif /* linux */ + +# if !defined(USG) && defined(_USG) +# define USG +# endif /* USG */ +# if !defined(SYSV) && defined(_SYSV) +# define SYSV +# endif /* SYSV */ #else /* CURSES */ -#include -#if defined(POSIX) || defined(SVR4) -#include -#else /* POSIX */ -#if defined(SYSV) && defined(USG) || defined(AIX) -#include -#ifdef DGUX -#include -#endif /* DGUX */ -#endif /* POSIX */ -#endif /* SYSV && USG */ +# include +# if defined(POSIX) || defined(SVR4) +# include +# else /* POSIX */ +# if defined(SYSV) && defined(USG) || defined(AIX) +# include +# ifdef DGUX +# include +# endif /* DGUX */ +# endif /* SYSV && USG || AIX */ +# endif /* POSIX */ #endif /* CURSES */ #ifdef HPUX -#include +# include #endif /* HPUX */ #if defined(SVR4) -#include +# include #endif /* SVR4 */ #include #include #include #include "strings.h" +#ifdef MSGS_DYNAMIC +# if (defined(sun) || defined(__sun__)) && (defined(sparc) || defined(__sparc__)) +# include +# 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 -#ifdef SUN_4_0 -# include -#endif /* SUN_4_0 */ -# include -# include /* for ltchars */ +# include +# ifdef SUN_4_0 +# include +# endif /* SUN_4_0 */ +# include +# include /* for ltchars */ #else -# include -# include -# ifndef SYSV -# include -# include /* for ltchars */ -# else -# include -# ifdef M_UNIX -# ifndef SELECT -# define SELECT -# endif -# include -# endif /* M_UNIX */ -# include -# endif /* SYSV */ +# include +# include +# ifndef SYSV +# include +# include /* for ltchars */ +# else +# include +# ifdef M_UNIX +# ifndef SELECT +# define SELECT +# endif +# include +# endif /* M_UNIX */ +# include +# endif /* SYSV */ #endif /* SUNTOOL */ +#ifdef BSD44 +# define REGCOMP +# include +#endif + #ifdef POSIX_UTIME -#ifdef POSIX -#include -#else /* POSIX */ -#include -#endif /* POSIX */ +# ifdef POSIX +# include +# else /* POSIX */ +# include +# endif /* POSIX */ #endif /* POSIX_UTIME */ + #include #include #ifdef SUNTOOL -# include -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include +# include #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,19 +566,34 @@ 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 */ long m_size; /* number of bytes in msg */ int m_lines; /* number of lines in msg */ + int m_headers; /* number of header lines in msg */ char *m_date_recv;/* Date user received msg (see dates.c for fmt) */ char *m_date_sent;/* Date author sent msg (see dates.c for fmt) */ 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; @@ -597,13 +631,16 @@ extern char **environ; /* user's environment variables */ #endif -extern int errno; /* global system error number */ jmp_buf jmpbuf; /* longjmp to jmpbuf on sigs (not in tool) */ 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 +#endif