#================= GENERAL SYMBOL DEFINITIONS =================

# General definitions for software tools
# Should be put on a file named 'symbols'
# Used by all the tools; read automatically by preprocessor


#   Many of these symbols may change for your particular machine.
#   The values provided are intended as guidelines, and may
#   well serve you adequately, but don't hesitate to change them if
#   necessary.

# In particular, the following might have to change for your system:
#         TERMINAL_IN
#         TERMINAL_OUT
#         MAXLINE
#         FILENAMESIZE
#         DRIVER    and    DRETURN
#         MAXOFILES
#         character

#   Also, watch out for the following definitions, which
#   may conflict with the Fortran operators on your system:
#       AND         OR        NOT


#  Many of the definitions will be used in character variables.
#  They must be defined to be something other than a valid ascii
#  character--such as a number > 255 or a negative number.
#  If you have defined "character" to be "integer", then you may
#  use either a very large number or a small negative number.
#  If you have defined "character" to be something like an 8-bit
#  signed field, you'll need to use negative numbers.
#  Use of a standard integer (whatever is the default size on your
#  machine) is STRONGLY recommended, despite the apparent waste of
#  storage.

#  the following constants affect conditional pre-processing

define(PDP_RSX,)		# define CPU and Operating System
#define(LARGE_ADDRESS_SPACE,)	# this is defined if the user has at least
				# 18 address bits for use
#define(TREE_STRUCT_FILE_SYS,)	# defined if the file system is tree structured
#define(SORTED_DIRECTORIES,)	# defined if the directories are inherently
				# sorted


# ASCII control character definitions:

define(NUL,8%00)
define(SOH,8%01)
define(STX,8%02)
define(ETX,8%03)
define(EOT,8%04)
define(ENQ,8%05)
define(ACK,8%06)
define(BEL,8%07)
define(BS,8%10)
define(HT,8%11)
define(LF,8%12)
define(VT,8%13)
define(FF,8%14)
define(CR,8%15)
define(SO,8%16)
define(SI,8%17)
define(DLE,8%20)
define(DC1,8%21)
define(DC2,8%22)
define(DC3,8%23)
define(DC4,8%24)
define(NAK,8%25)
define(SYN,8%26)
define(ETB,8%27)
define(CAN,8%30)
define(EM,8%31)
define(SUB,8%32)
define(ESC,8%33)
define(FS,8%34)
define(GS,8%35)
define(RS,8%36)
define(US,8%37)
define(SP,8%40)
define(DEL,8%177)


# Synonyms for important non-printing ASCII characters:

define(BACKSPACE,8%10)
define(BELL,8%07)
define(BLANK,8%40)
define(NEWLINE,8%12)
define(RUBOUT,8%177)
define(TAB,8%11)


# Printable ASCII characters:

define(AND,'&')
define(ESCAPE,'@@')      #escape character for ch, find, tr, ed, and sh
define(NOT,'!')  # used in pattern matching; choose ~, ^, or !
define(OR,'|')


# Ratfor language extensions:

define(abs,iabs)
define(ABS,abs)
define(andif,if)
define(ARB,100)
define(character,logical*1)  # define character data type
define(CHARACTER,character)
define(ext_func,)
define(ext_subr,#)
define(DS_DECL,integer $1($2);character c$1(arith($2,*,CHAR_PER_INT));
equivalence (c$1(1),$1(1));common /cdsmem/ $1)
define(cvt_to_cptr,(CHAR_PER_INT*($1-1)+1))	# convert pointer to char ptr
define(PB_DECL,integer pbp, pbsize; character pbbuf($1);
common /cpback/ pbp, pbsize, pbbuf)
define(elif,else if)
define(filedes,integer)    # file descriptor/designator data type
define(FILEDES,filedes)
define(IS_DIGIT,('0'<=$1&$1<='9'))   # valid only for ASCII!
define(IS_LETTER,(IS_UPPER($1)|IS_LOWER($1)))
define(IS_LOWER,('a'<=$1&$1<='z'))
define(IS_UPPER,('A'<=$1&$1<='Z'))
define(long_real,double precision)
define(linepointer,integer*4)
define(NULLPOINTER,0)
define(LINEPTRSIZE,MAXCHARS)
define(max,max0)
define(MAX,max0)
define(min,min0)
define(MIN,min0)
define(pointer,integer)
define(POINTER,integer)



# Input/output modes:

define(APPEND,4)
define(PRINT,5)		# print file access
define(READ,1)
define(READWRITE,3)
define(WRITE,2)

define(B_APPEND,arith(0,-,APPEND))
define(B_READ,arith(0,-,READ))
define(B_READWRITE,arith(0,-,READWRITE))
define(B_WRITE,arith(0,-,WRITE))

# Standard input/output ports:

define(ERROUT,3)           # standard error file
define(STDERR,ERROUT)
define(STDIN,1)            # standard input file
define(STDOUT,2)           # standard output file


# TERMINAL_IN and TERMINAL_OUT are the names of the I/O channels
# from and to the user's terminal, respectively.  It's highly likely
# there is no such thing on your system; in this case, simply invent
# a name that is not likely to conflict with any file name.
# For example, the VAX/VMS version of the tools uses "TT", the RSX/11M
# version uses "TI:", the DEC 10 version uses "tty:", and the Prime
# version uses "/dev/tty".
# Note that you must make the 'open' primitive recognize this name
# and provide access to the terminal accordingly.

define(TTY_NAME,"TI:")
define(TERMINAL_IN,TTY_NAME)
define(TERMINAL_OUT,TTY_NAME)
define(TERMINAL_EOF,SUB)


# Manifest constants included for readability and modifiability:

define(ALPHA,-9)
define(ASCII,12)             # flag for ascii character file
define(BEGINNING_OF_FILE,-2) # flag to seek for positioning at
                             # the beginning of a file
define(BINARY,60)            # flag for indicating binary file
define(DIGIT,2)
define(END_OF_FILE,-1)       # flag to seek for positioning at
                             # end of file
define(EOF,-1)
define(EOS,0)
define(ERR,-3)
define(TMO,-4)
define(HUGE,30000)           # some arbitrarily large number
define(LAMBDA,0)             # end of list marker
define(LETTER,1)
define(LOCAL,6)              # flag for local-type character file
define(NO,0)
define(NOERR,0)              # flag for successful completion
define(OK,0)                # success flag
define(PATH,5)		   # type == PATH
define(USERSIZE,40)	# size of username returned by userid
define(YES,1)


# Size limiting definitions for important objects:

define(FILENAMESIZE,36)    # max characters in file name
                           # (including EOS)
define(MAXARG,128)         # max size of command line argument
define(MAXARGS,25)	   # some tools require this for max no of args
define(MAXCHARS,20)        # max nbr of chars when converting
                           # from integers to characters
                           # (used by putint, outnum, etc.)
define(MAXCARD,400)        # number of usable characters in line buffer
define(MAXLINE,402)        # declared size of line buffers; must be 1 more
                           # than MAXCARD
define(MAXNAME,FILENAMESIZE)  # max size of file name
define(MAXOFILES,7)        # max nbr opened files allowed at a time
define(MAXPAT,132)         # max size of encoded patterns
                           # (used in string matching)
define(NCHARS,33)          # number of special characters


# Machine-dependent parameters:

define(BITS_PER_CHAR,8)
define(BITS_PER_WORD,16)
define(CHARS_PER_WORD,2)
define(CHAR_PER_INT,2)
define(CHAR_PER_LPTR,4)
define(MAX_INTEGER,32767)
define(MIN_INTEGER,-32768)
define(MAX_REAL_EXP,38)
define(MIN_REAL_EXP,-38)
define(REAL_PRECISION,6)


# DRIVER is defined as those things you need to do to start a Software
# Tools program running.  The following is a common approach, but you
# may have to change it (for example, by adding a "program" card).
# Many machines will require no special driver procedure other than
# the call to 'initst'.

define(DRIVER,subroutine main # $1)

# DRETURN is used to finish up a Software Tools program:

define(DRETURN,return)   # (returning from subroutine defined in DRIVER)


# Definitions for 'spawn' primitive (if implemented):

define(WAIT,'w')              # wait for subprocess to complete
define(NOWAIT,'n')            # control returns as soon as
                               # subprocess starts
define(BACKGR,'b')            # spawning a background process
define(PIDSIZE,7)
define(ARGBUFSIZE,256)
define(CHILD_ABORTED,-10)


# rawmode io definitions

define(COOKED,0)		# processed characters
define(RAW,1)			# raw characters
define(RARE,RAW)		# the same on RSX

# definitions for obtaining directory strings

define(HOMEDIRECTORY,0)
define(BINDIRECTORY,1)
define(USRDIRECTORY,2)
define(TMPDIRECTORY,3)
define(LPRDIRECTORY,4)
define(MSGDIRECTORY,5)
define(MAILDIRECTORY,5)
define(MANDIRECTORY,6)
define(SRCDIRECTORY,7)
define(INCDIRECTORY,8)
define(LIBDIRECTORY,9)

# definitions needed for directory operations

define(TCOLWIDTH,11)		# width of date string returned by gdraux
define(MAXDIRECTS,5)		# max number of path fields in file spec

# definitions needed for double integer manipulations

define(initdi,{$1(1) = 0; $1(2) = 0})
define(incrdi,{$1(2) = $1(2) + 1; if($1(2) >= 10000)
{$1(1) = $1(1) + 1; $1(2) = 0}})
define(decrdi,{$1(2) = $1(2) - 1; if($1(2) < 0)
{$1(1) = $1(1) - 1; $1(2) = 9999}})
define(adddi,{$2(1) = $2(1) + $1(1); $2(2) = $2(2) + $1(2);
if ($2(2) >= 10000){$2(1) = $2(1) + 1; $2(2) = $2(2) - 10000}})
define(subdi,{$2(1) = $2(1) - $1(1); $2(2) = $2(2) - $1(2);
if ($2(2) < 0){$2(1) = $2(1) - 1; $2(2) = $2(2) + 10000}})

# It may be necessary to add special definitions; for example
# names of important directories, substitute routine names for
# Software Tools primitives that conflict with local subprograms,
# etc.

define(putc,putch($1,STDOUT))
define(getc,ifelse($1,,getch,getch($1,STDIN)))
define(assign,ifelse($1,,assngi,assngi($1,$3,$2)))
define(mklocl,fxlate($1,LOCAL,$2))
define(putdec,putint($1,$2,STDOUT))
define(spawn,sspawn)
define(index,indexc)	# avoid collision with f77 built-in
define(markl,note($2,$1))
define(mkuniq,scratf)
define(IS_SUC,1)
define(FREEUNIT,arith(MAXOFILES,+,1))
define(STD_PATH,"@e~/@e~usr/@e~bin/@e@n")
define(BOTH_SUFFIX,".sh@e.tsk@e@n")
define(IMAGE_SUFFIX,".tsk@e@n")
define(NO_SUFFIX,"@e@n")
define(IAS,)				# this definition needed for `ld'
