/*
 * Icon configuration.
 */

/*
 * System-specific definitions are in define.h
 */
#include "..\h\define.h"

#include <stdio.h>

/*
 *  A number of symbols are defined here.  Some are specific to individual
 *  to operating systems.  Examples are:
 *
 *	MSDOS		MS-DOS for PCs
 *	UNIX		any UNIX system
 *	VMS		VMS for the VAX
 *
 *  These are defined to be 1 or 0 depending on which operating system
 *  the installation is being done under.  They are all defined and only
 *  one is defined to be 1.  (They are used in the form #if VAX || MSDOS.)
 *
 *  There also are definitions of symbols for specific computers and
 *  versions of operating systems.  These include:
 *
 *	SUN		code specific to the Sun Workstation
 *	MICROSOFT	code specific to the Microsoft C compiler for MS-DOS
 *
 *  Other definitions may occur for different configurations. These include:
 *
 *	DeBug		debugging code
 *	MemMon		memory monitoring output
 *
 *  Other definitions perform configurations that are common to several
 *  systems. An example is:
 *
 *	Double		align reals at double-word boundaries
 *
 */

/*
 * The following definitions insure that all the symbols for operating
 * systems that are not relevant are defined to be 0 -- so that they
 * can be used in logical expressions in #if directives.
 */

#ifndef PORT
#define PORT 0
#endif					/* PORT */

#ifndef AMIGA
#define AMIGA 0
#endif					/* AMIGA */

#ifndef ATARI_ST
#define ATARI_ST 0
#endif					/* ATARI_ST */

#ifndef HIGHC_386
#define HIGHC_386 0
#endif					/* HIGHC_386 */

#ifndef MACINTOSH
#define MACINTOSH 0
#endif					/* MACINTOSH */

#ifndef MSDOS
#define MSDOS 0
#endif					/* MSDOS */

#ifndef MVS
#define MVS 0
#endif					/* MVS */

#ifndef OS2
#define OS2 0
#endif					/* OS2 */

#ifndef UNIX
#define UNIX 0
#endif					/* UNIX */

#ifndef VM
#define VM 0
#endif					/* VM */

#ifndef VMS
#define VMS 0
#endif					/* VMS */


/*
 * The following definitions serve to cast common conditionals is
 *  a positive way, while allowing defaults for the cases that
 *  occur most frequently.  That is, if co-expressions are not supported,
 *  NoCoexpr is defined in define.h, but if they are supported, no
 *  definition is needed in define.h; nonetheless subsequent conditionals
 *  can be cast as #ifdef Coexpr.
 */

#ifndef NoCoexpr
#undef Coexpr
#define Coexpr
#endif					/* NoCoexpr */

#ifndef NoEnvVars
#undef EnvVars
#define EnvVars
#endif					/* NoEnvVars */

#ifndef NoTraceBack
#undef TraceBack
#define TraceBack
#endif					/* NoTraceBack */

#ifndef NoStrInvoke
#undef StrInvoke
#define StrInvoke
#endif					/* NoStrInvoke */

#ifndef NoMathFncs
#undef MathFncs
#define MathFncs
#endif					/* NoMathFncs */

#ifndef NoLargeInts
#undef LargeInts
#define LargeInts
#endif					/* NoLargeInts */

#ifndef NoMemMon
#ifdef EnvVars
#undef MemMon
#define MemMon
#endif					/* EnvVars */
#endif					/* NoMemMon */

#ifndef NoExternalFunctions
#undef ExternalFunctions
#define ExternalFunctions
#endif					/* NoExternalFunctions */

/*
 * EBCDIC == 0 corresponds to ASCII.  EBCDIC == 1 corresponds to EBCDIC
 *  collating sequence, while EBCDIC == 2 provides the ASCII collating
 *  sequence for EBCDIC systems.
 */
#ifndef EBCDIC
#define EBCDIC 0
#endif					/* EBCDIC */

/*
 * Other defaults.
 */

#ifdef DeBug
#undef DeBugTrans
#undef DeBugLinker
#undef DeBugIconx
#define DeBugTrans
#define DeBugLinker
#define DeBugIconx
#endif					/* DeBug */

#ifdef ExecImages
#undef IconCalling
#endif					/* ExecImages */

#ifndef AllocType
#define AllocType unsigned int
#endif					/* AllocType */

typedef AllocType msize;

#ifndef ErrorExit
#define ErrorExit 1
#endif					/* ErrorExit */

#ifndef NormalExit
#define NormalExit 0
#endif					/* NormalExit */

#ifndef Hz
#define Hz 60
#endif					/* Hz */

#ifndef MaxHdr
#define MaxHdr 4096
#endif					/* MaxHdr */

#ifndef StackAlign
#define StackAlign 2
#endif					/* StackAlign */

#ifndef SysTime
#define SysTime <time.h>
#endif					/* SysTime */

#ifndef WordBits
#define WordBits 32
#endif					/* WordBits */

#ifndef IntBits
#define IntBits WordBits
#endif					/* IntBits */

#ifndef SourceSuffix
#define SourceSuffix ".icn"
#endif					/* SourceSuffix */

#ifndef IcodeSuffix
#define IcodeSuffix ""
#endif					/* IcodeSuffix */

#ifndef IcodeASuffix
#define IcodeASuffix ""
#endif					/* IcodeASuffix */

#ifndef U1Suffix
#define U1Suffix ".u1"
#endif					/* U1Suffix */

#ifndef U2Suffix
#define U2Suffix ".u2"
#endif					/* U2Suffix */

#ifndef USuffix
#define USuffix ".u"
#endif					/* USuffix */

/*
 * Representations of directories. LocalDir is the "current working directory".
 *  SourceDir is where the source file is. 
 */

#define LocalDir ""
#define SourceDir (char *)NULL

#ifndef TargetDir
#define TargetDir LocalDir
#endif					/* TargetDir */

#ifndef Options
#if UNIX
#define Options "ce:mo:stuxLS:"
#else					/* UNIX */
#define Options "ce:o:stuxLS:"
#endif					/* UNIX */
#endif					/* Options */

#ifndef Usage
#if UNIX
#define Usage "[-cmstu] [-e efile] [-o ofile] [-Sxnnnn]"
#else					/* UNIX */
#if MVS || VM
#define Usage "<-cstu> <-e efile> <-o ofile> <-Sxnnnn>"
#else					/* MVS || VM */
#define Usage "[-cstu] [-e efile] [-o ofile] [-Sxnnnn]"
#endif					/* MVS || VM */
#endif					/* UNIX */
#endif					/* Usage */

#ifndef Pipes
#if UNIX || VMS
#define Pipes
#endif					/* UNIX || VMS */
#endif					/* Pipes */

#ifndef SystemFnc
#if AMIGA || ATARI_ST || MSDOS || MVS || OS2 || UNIX || VM || VMS
#define SystemFnc
#endif					/* AMIGA || ATARI_ST || ... */
#endif					/* SystemFnc */

/*
 * Default sizing and such.
 */

/*
 * Set up typedefs and related definitions depending on whether or not
 * ints and pointers are the same size.
 */

#if IntBits == 16
typedef long int word;
typedef unsigned long int uword;
#else					/* IntBits == 16 */
typedef int word;
typedef unsigned int uword;
#endif					/* IntBits == 16 */

#define WordSize sizeof(word)

#ifndef ByteBits
#define ByteBits 8
#endif					/* ByteBits */

/*
 * Define the size of the units in MemMon (allocation history) files.
 */
#ifndef MMUnits
#define MMUnits WordSize
#endif					/* MMUnits */

/*
 * Change the name of gcvt() if we're supplying our own version,
 * to avoid complaints under VMS and others with shared libraries.
 */

#ifdef IconGcvt
#define gcvt icon_gcvt
#endif					/* IconGcvt */


/*
 *  The following definitions depend on whether or not the ANSI C standard
 *  is supported.
 */

#ifdef Standard
#undef StandardC
#undef StandardPP
#undef StandardLib
#define StandardC
#define StandardPP
#define StandardLib
#endif					/* Standard */

#ifdef StandardPP
#define Cat(x,y) x##y
#define Lit(x) #x
#else					/* StandardPP */
#define Ident(x) x
#define Cat(x,y) Ident(x)y
#define Lit(x) "x"
#endif					/* StandardPP */

#ifdef StandardC
#undef Prototypes
#define Prototypes
#ifndef PointerDef
typedef void *pointer;
#endif					/* PointerDef */
#undef VoidType
#define VoidType
#define Bell '\a'
#else					/* StandardC */
#ifndef PointerDef
typedef char *pointer;
#endif					/* PointerDef */
#if EBCDIC
#define Bell '\x2F'
#else					/* EBCDIC */
#define Bell '\007'
#endif					/* EBCDIC */
#endif					/* StandardC */

#ifdef StandardLib
#undef SysMem
#define SysMem
#endif					/* StandardLib */

#if IntBits != WordBits
#undef SysMem
#endif					/* Intbits != WordBits */

#ifdef SysMem
#undef memcopy
#undef memfill
#define memcopy memcpy
#define memfill memset
#endif					/* SysMem */

/*
 * Provide definition to use void if it's supported (mainly avoids error
 *  messages with some C compilers.  Note: typedef does not work, so care
 *  is needed not to use compound declarations.
 */

#ifdef VoidType
#define novalue void
#define noargs void
#else					/* VoidType */
#define novalue int
#define noargs
#endif					/* VoidType */

/*
 * Customize output if not pre-defined.
 */

#ifndef TraceOut
#define TraceOut(s) fprintf(stderr,s)
#endif					/* TraceOut */

#if EBCDIC
#define BackSlash "\xe0"
#else					/* EBCDIC */
#define BackSlash "\\"
#endif					/* EBCDIC */

#if UNIX
#define WriteBinary "w"
#define ReadBinary "r"
#define WriteText "w"
#define ReadText "r"
#endif					/* UNIX */

#ifndef WriteBinary
#define WriteBinary "wb"
#endif					/* WriteBinary */

#ifndef ReadBinary
#define ReadBinary "rb"
#endif					/* ReadBinary */

#ifndef WriteText
#define WriteText "w"
#endif					/* WriteText */

#ifndef ReadText
#define ReadText "r"
#endif					/* ReadText */

/*
 * Typedefs to make some things easier.
 */

typedef int (*fptr)();
typedef struct descrip *dptr;

/*
 * "hidden" is used to declare static functions;  "hidden" normally == "static",
 *  except with compilers that can't handle "static" in prototypes.
 */

#ifndef hidden
#define hidden static
#endif					/* hidden */

/*
 * The "Params" macro allows a single declaration to be used with both old- and
 *  new-style compilers.
 */

#ifdef Prototypes
#define Params(a) a
#else					/* Prototypes */
#define Params(a) ()
#endif					/* Prototypes */

/*
 * cal_time holds a calendar time.
 */
struct cal_time {
   int year;		/* yyyy */
   int month_no;	/* month number: 1-12 */
   char *month_nm;	/* month name: "January", "February", ... */
   int mday;		/* day of the month */
   char *wday;		/* "Sunday", "Monday", ... */
   int hour;		/* hour by 24 hr clock */
   int minute;
   int second;
   };

/*
 * Function prototypes.
 */

#include "..\h\proto.h"

/*
 * More definitions depending on whether or not ints and pointers
 * are the same size.  These must follow the include of proto.h to
 * avoid redefinition problems with some compilers.
 */

#if IntBits == 16
#define sbrk lsbrk
#define qsort llqsort
#define strlen lstrlen
#endif					/* WordBits != IntBits */

/*
 * The following code is operating-system dependent [@config.01].
 *  Any configuration stuff that has to be done at this point.
 */

#if PORT
   /* Probably nothing is needed. */
Deliberate Syntax Error
#endif					/* PORT */

#if AMIGA || ATARI_ST || MACINTOSH || MSDOS || MVS || VM || VMS
   /* Nothing is needed */
#endif					/* AMIGA || MACINTOSH ...*/

#if HIGHC_386
/*
 * MetaWare's HighC 386 macro putc doesn't handle putc('\n') correctly -
 * sometimes a CR is not written out before the LF.  So, redefine
 * macro putc to actually issue an fputc.
 */
#undef putc
#define putc(c,f) fputc(c,f)
#endif					/* HIGHC_386 */

#if MACINTOSH
#if LSC
/*
 * LightSpeed C requires that #define tokens appear after prototypes
 */
#define index strchr
#define malloc mlalloc
#define rindex strrchr
#define unlink remove
#endif					/* LSC */
#endif					/* MACINTOSH */

#if UNIX

#undef WriteBinary
#define WriteBinary "w"

#undef ReadBinary
#define ReadBinary "r"

#ifndef NoHardWiredPaths
#define HardWiredPaths
#endif					/* NoHardWiredPaths */

#ifndef NoHeader
#undef Header
#define Header
#endif					/* NoHeader */

#endif					/* UNIX */

/*
 * End of operating-system specific code.
 */


#ifndef DiffPtrs
#define DiffPtrs(p1,p2) (word)((p1)-(p2))
#endif					/* Diffptrs */

#ifndef AllocReg
#define AllocReg(n) malloc((msize)n)
#endif					/* AllocReg */
