#define BUFSIZE	512
#define EOF	-1
#define NULL	0
#define NL	'\n'
#define FEOF	0400
#define EOS	'\0'
#define TTYKILL   1
#define TTYNOECHO 0

#define putchar(c)      putc(c,valof_stdout())
#define getchar()       getc(valof_stdin())
/* these macros are faster but requires recompiling if anything changes
   they also do not support unstructured i/o nor the 1 char putback
 */
#define m_putc(c,s)       if (((c)==NL) || (--((s)->j_count)<0)) \
			_flushb(s,c); else *((s)->j_ptr)++ = c;
#define m_getc(s)         (--(s)->j_count >= 0 ? *(s)->j_ptr++&0377 : \
			 _fillb(s))
#define x_putc(c,s)       if ((--((s)->j_count)<0)) \
			_flushb(s,c); else *((s)->j_ptr)++ = c;

#define feof(s)		((s)->j_status&FEOF)
#define VMSerr(i)       (((i)&1) == 0)

typedef struct jab {
	char	*j_ptr;
	char    *jab_lh[5];
	short   j_peek;
	char    j_class;                /* u or r */
	char    j_dirty;
	short   j_chan;                 /* vms channel */
	short	j_status;
	short	j_count;
	char    j_access;               /* w or r */
	char	j_mode;
	int     j_seek;                 /* seek address for class u */
	int     j_fab;                  /* these are also in the list */
	int     j_rab;
	int     j_userio;               /* user get and put routines */
	int     j_uflags;               /* user flags for user io */
	int     j_spare;
	char	j_buf[BUFSIZE];
} jab,FILE;

/* extern FILE     *stdin,*stdout,*stderr; */
FILE	*fopen();
#define abs(x)		((x) < 0 ? -(x) : (x))
#define isalpha(c)	(islower(c) || isupper(c))
#define isdigit(c)	('0' <= (c) && (c) <= '9')
#define islower(c)	('a' <= (c) && (c) <= 'z')
#define isupper(c)	('A' <= (c) && (c) <= 'Z')
#define iswhite(c)	((c) <= ' ' || 0177 <= (c)) /* ASCII ONLY */
#define max(x, y)	(((x) < (y)) ? (y) : (x))
#define min(x, y)	(((x) < (y)) ? (x) : (y))
#define tolower(c)	(isupper(c) ? ((c) + ('a' - 'A')) : (c))
#define toupper(c)	(islower(c) ? ((c) - ('a' - 'A')) : (c))
