/********** gpm.h *****************************************************/

#include <errno.h>
#include <stdio.h>

#include <malloc.h>

/* These were kludges for Solaris */
/* int fprintf(FILE *,char *,...); */
/* void fflush(FILE *); */
/* int atoi(char *s); */

/*
** gpm concept by C. Strachey
** gpm implementation by Wim Jansen
**
** gpm rework by Adriaan de Groot
** 920320 : Added -S (stack size) flag
**        : Added multiple input file support
**        : Allow only one -o or -s flag per invokation
**        : Expanded default stack size
**        : Made stack alloced instead of static
**        : Make -- file refer to /dev/tty
** 920323 : Added Usage() function
**        : Added -h (help)
**        : Added -d (dryrun)
**        : Added EscapeSymbol
** 920324 : Added -A (authors)
** 920325 : Did many name changes.
**        : Modified NextCh()
**        : Started adding -D(level)
** 920326 : Changed VERBOSE compilation flag.
**        : Added -v flag if verbosity is settable.
** 940303 : Changed files around. This was to make additional
**	    changes easier. gpm.h becomes gpmdefs.h. New files
**	    gpm.h, gpmmonitor.c, gpmmonitor.h, gpmbuiltin.c,
**	    gpmbuiltin.h are made.
** 940314 : Massive amounts of code beautification, as well as
**	    adding all the debugging macros. "Type" checking in
**	    BAR and BIN and DEC macros.
**		
**
** Compilation Flags:
**
** For all varieties of gpm:
**
** -DESCAPE     Allow an escape char (so you can insert QuoteClose
**              in the output stream.
** -DVERBOSE=x  This controls whether the -v option is accepted,
**              and what the default verbosity is. See gpm.doc.
** -DLINENUMBER Show line number on error.
** -DFILENAME   Show file name on error.
** -DCAREFUL	Won't overwrite existing files.
** -DQUOTEM=x	Put [ ] around macro names in error messages.
**		See gpm.doc.
** -DDEBUG_MACROS	Add extra macros like ERR, MSG, DUMP and EXIT.
**
** For gpm.c:
**
** -DESCAPE,-DLINENUMBER,-DFILENAME should be the same as for gpmmain.c
**
** For gpmdb.c:
**
** -DESCAPE,-DLINENUMBER,-DFILENAME should be the same as for gpmmain.c
*/

/* ----- Set up default values for compilation flags if needed ----- */

#ifndef VERBOSE
#define VERBOSE                 0
#endif
#ifndef QUOTEM
#define QUOTEM			0
#endif

/* ----- Set up flag values in compilation flags ----- */

#if VERBOSE & 1
#define VERBOSEDEFAULT
#endif
#if VERBOSE & (1<<1)
#define VERBOSESET		1
#endif

#if QUOTEM & 1
#define QUOTEMDEF
#endif
#if QUOTEM & (1<<1)
#define QUOTEMSET		1
#endif

/* ----- Other values ----- */

#define F OpenPtr               /* Two horrible hacks ! */
#define P ClosedPtr
#define H OutputPtr
#define q QuoteLevel
#define A CurrentChar

#define MinStackSize            10000
#define DefStackSize            30000

#ifdef ESCAPE
#define SpecialCount            9
#define CHARSETSIZE             256
#else
#define SpecialCount            8
#endif

#define SpecialMarker           -9
#define SpecialMark             512

#define InputStream             0
#define OutputStream            0

#define Marker          (Special[0])
#define ApplyOpen       (Special[1])
#define ItemSep         (Special[2])
#define QuoteOpen       (Special[3])
#define ArgStart        (Special[4])
#define QuoteClose      (Special[5])
#define ApplyClose      (Special[6])
#define SkipSymbol      (Special[7])
#define EscapeSymbol    (Special[8])

#define Num(x)  ((x) - '0')
#define Char(x) ((x) + '0')

#define StackItem int


#define EXIT_EXIT	7		/* {EXIT} macro. */
#define EXIT_11		6		/* Monitor 11 */
#define EXIT_INTERNAL	5		/* Internal bug. */

