/* @(#)ex_ltsdefs.h	128.1 1/20/93 19:42:33 */
/************************************************************************\
   Copyright (C) 1990 Lotus Development Corporation.  All rights reserved.
   Name:    ltsdefs.h (External Version)
   Date:    07 Feb 1989
   Description: Lotus basic data types and other standard
                definitions used for machine independent C coding.
\************************************************************************/

#if !defined(LTSDEFS_H)
#define LTSDEFS_H


/*********************************************************************/
/*
**       Section 1
*/
/*
**       Platform (hardware and operating system) Defines
   The following defines list the hardware/operating system
   groupings that Lotus is now or may in the future be interested in.
   The hardware and operating system are lumped into a single define.
*/

/* DOS defines */
#define LSYS_BEGIN_DOS_DEFINES           0
#define LSYS_IBMPC_DOS_NATIVE            1  /* PCs using MS/DOS */
#define LSYS_IBMPC_DOS                   2
#define LSYS_IBMPC_DOS_16M               2  /* PC MS/DOS & 16M */
#define LSYS_IBMPC_DOS_DPMI              3  /* PC MS/DOS DPMI */
#define LSYS_IBMPC_DOS_WIN               4  /* PC MS/DOS & WINDOWS */
#define LSYS_END_DOS_DEFINES            24

/* OS2 defines */
#define LSYS_BEGIN_OS2_DEFINES          25
#define LSYS_IBMPC_OS2                  26  /* PCs using os/2 */
#define LSYS_IBMPC_OS2PM                27  /* PCs using os/2PM */
#define LSYS_END_OS2_DEFINES            49

/* UNIX defines */
#define LSYS_BEGIN_UNIX_DEFINES        100
#define LSYS_BEGIN_UNIX_SYSV_DEFINES   101
#define LSYS_IBMPC_XENIX               102  /* PC running XENIX*/
#define LSYS_IBMRT_AIX                 104  /* RT running AIX */
#define LSYS_MACII_AUX                 201  /* Macintosh II/Unix */
#define LSYS_BEGIN_UNIX_SYSV3_DEFINES  300
#define LSYS_ATT6386                   301  /* AT&T 6300 running Unix */
#define LSYS_386_UNIXV3                302  /* 386/ix and SCO Unix. */
#define LSYS_END_UNIX_SYSV3_DEFINES    399
#define LSYS_END_UNIX_SYSV_DEFINES     399
#define LSYS_BEGIN_UNIX_BSD_DEFINES    400
#define LSYS_IBMRT_ACIS                401  /* RT running ACIS of UNIX */
#define LSYS_VAXULTRIX                 501  /* VAX/ULTRIX */
#define LSYS_BEGIN_UNIX_SUN_DEFINES    600
#define LSYS_SUN360                    601  /* SUN 360 running Unix */
#define LSYS_SUN386                    602  /* SUN 386i running Unix */
#define LSYS_SUN3                      603  /* SUN 3 running Unix */
#define LSYS_SUN4                      604  /* SUN 4 running Unix*/
#define LSYS_END_UNIX_SUN_DEFINES      699
#define LSYS_NEXT_MACH                 701  /* NeXT running Mach */
#define LSYS_END_UNIX_BSD_DEFINES      999
#define LSYS_END_UNIX_DEFINES          999

/* VM defines */
#define LSYS_BEGIN_CMS_DEFINES        1000
#define LSYS_VMCMS                    1001  /* VM/CMS */
#define LSYS_END_CMS_DEFINES          1024

/* MVS defines */
#define LSYS_BEGIN_TSO_DEFINES        1025
#define LSYS_MVSTSO                   1026  /* MVS/TSO */
#define LSYS_END_TSO_DEFINES          1049
#define LSYS_BEGIN_CICS_DEFINES       1050
#define LSYS_MVSCICS                  1051  /* MVS/CICS */
#define LSYS_END_CICS_DEFINES         1099

/* VMS defines */
#define LSYS_BEGIN_VMS_DEFINES        1200
#define LSYS_VAXVMS                   1201  /* VAX/VMS */
#define LSYS_END_VMS_DEFINES          1299

/* Macintosh Finder defines */
#define LSYS_BEGIN_FINDER_DEFINES     1300
#define LSYS_MACIIFIND                1301  /* Macintosh II/Finder */
#define LSYS_END_FINDER_DEFINES       1399
#define LSYS_LRP                      1601  /* Lotus reserved */


/*********************************************************************/
/*
**       Platform dependent control information
   LTSCNTRL.H contains the hardware/operating system/compiler
   dependent control information.  These switches allow this
   file to be platform independent and hence common to/with the
   source and products that Lotus creates or provides for all
   its products and sub-products on all the systems Lotus is
   interested in.
*/

#include "ltscntrl.h"


/********************************************************************/
/*
**       Standard Lotus Defines
*/

/*********************************************************************/
/*
**       Section 2
*/
/*
**       General Use defines
   The following are generally useful defines that Lotus wishes
   to use standard names and values for.
*/

#define LTRUE    1
#define LFALSE   0
#define LNULL    0L


/*********************************************************************/
/*
**       Section 3
*/
/*
**       PC compiler keywords
   The following terms mean something to compilers on PCs and
   nothing to compilers on the other systems.  Therefore on some
   systems they are defined to be nothing to get those compilers
   to ignore them.
*/

#if !L_USING_PC_C_TERMS
#define cdecl
#define far
#define fortran
#define huge
#define near
#define _cdecl
#define _far
#define _fortran
#define _huge
#define _near
#else /* L_USING_PC_C_TERMS */
#if !L_ANSI_FORM_EXTD_KEYWDS
#define _cdecl     cdecl
#define _far       far
#define _fortran   fortran
#define _huge      huge
#define _near      near
#endif /* !L_ANSI_FORM_ETXD_KEYWDS */
#endif /* !L_USING_PC_C_TERMS */

#if !L_USING_LOADDS_KEYWORD
#define _loadds
#endif /* !L_USING_LOADDS_KEYWORD */

#if L_USING_PASCAL_CALLS
#if L_ANSI_FORM_EXTD_KEYWDS
#define L_PASCAL    _pascal
#else /* !L_ANSI_FORM_EXTD_KEYWDS */
#define L_PASCAL     pascal
#endif /* L_ANSI_FORM_EXTD_KEYWDS */
#else /* !L_USING_PASCAL_CALLS */
#define L_PASCAL
#endif /* L_USING_PASCAL_CALLS */


/********************************************************************/
/*
**       Section 4
*/
/*
**       Atomic data types
   Definitions of basic (atomic) data types. The implementation
   of these types is machine-independent (via conditional
   compilation).
*/

#if !L_USING_EXPLICIT_SIGNED_DATA
/* Some systems/compilers can't handle the term
   'signed' in a data variable declaration or a
   typedef statement.  It is therefore defined
   to be nothing.
*/
#define signed
#endif /* !L_USING_EXPLICIT_SIGNED_DATA */

/* The integer data types */
typedef   signed char      lsbyte;     /*   signed 8-bit integer */
typedef unsigned char      lubyte;     /* unsigned 8-bit integer */
typedef   signed short int lsshort;    /*   signed 16-bit integer */
typedef   signed short int lpshort;    /* positive 16-bit integer */
                                       /*    (0 <= value <= 32767) */
typedef unsigned short int lushort;    /* unsigned 16-bit integer */
typedef   signed long  int lslong;     /*   signed 32-bit integer */
typedef unsigned long  int lulong;     /* unsigned 32-bit integer */
                                       /* Note: not all systems can
                                          properly handle an unsigned
                                          32-bit integer value.  Use
                                          with care */

/*
   Normal Lotus usage avoids the use of variable size data (int),
   however, the C language forces the use of this type of variable
   in a few places (notably as the switch value and as parameters
   to vendor supplied runtime functions).  In these cases, the
   following two defines should be used to indicate that the
   developer really needs to use the 'int' data type.
   These defines could also be used as loop counters, so that the
   platform's compiler can generate the best code in that situation.
*/

#define lsint       signed int
#define luint     unsigned int

/*
   The floating point data types which represent 32-bit,
   64-bit, and 80-bit reals.  Some compilers support 80-bit reals
   as a datatype while others use a structure for representation.
*/

typedef float        lfloat4;          /*          32-bit real */
typedef double       lfloat8;          /*          64-bit real */

#if L_USING_SIMPLE_10BYTE_REALS
typedef unsigned char lfloat10[10];    /* PC IEEE 10 byte real */
#else /* !L_USING_SIMPLE_10BYTE_REALS */
typedef struct {
   lushort mant[4]; /* 8 byte mantissa */
   lushort exp;     /* 2 byte exponent */
} lfloat10;         /* PC IEEE 10 byte real */
#endif /* L_USING_SIMPLE_10BYTE_REALS */

/* Various other atomic data types */
#define lbitfld   unsigned
                 /* Designates the data type for bit field data.  Not
                    all compilers will accept datatypes like
                    'signed short' for a structure element whose
                    size is specified in bits.  Use of this define
                    will not help the problem of different compilers
                    allocating the bit fields from different ends of
                    allocated space.  Use of bitfields is not
                    especially portable.
                    */
typedef   signed short int lbool;
                 /* A Boolean value (see LTRUE and LFALSE above).
                    It is a 'signed short' for efficiency. */
typedef unsigned long  int lmbchr;     /* a single LMBCS character */
typedef unsigned char      lmbcs;
                 /* Used with lptr to construct a pointer to a set
                    of LMBCS characters.  Do not try to extract a
                    single character in the typical C manner.
                    Instead use the provided functions. */
typedef void _far         *lhdl;       /* handle to memory */


/********************************************************************/
/*
**       Section 5
*/
/*
**             Argument handling macros
   The following macros provide easy methods for dealing with complex
   argument types and function declarations.
*/

#define lptr(dt)           dt _far *   /* real memory pointer */
#define lretarg(dt)        dt _far *   /* real ptr to a returned arg */
                 /* In the above two macros, the 'dt' argument should
                    be a valid data type like 'lslong' */


/********************************************************************/
/*
**       Section 6
*/
/*
**             Function definition macros
   The following defines are used to declare functions, those that are
   potentially in another language, and global functions in C.
   The 'f' suffix denotes function definition and the 'p' suffix denotes
   function pointer.
*/

#if L_USING_PASCAL_IN_FRONT
#define lexportf(dt)        L_PASCAL dt
#define lexportp(dt,fn)     dt (* fn)
#else /* !L_USING_PASCAL_IN_FRONT */
#define lexportf(dt)        dt L_PASCAL _loadds _far
#if L_PUT_PASCAL_IN_FPTR_PARENS
#define lexportp(dt,fn)     dt (L_PASCAL _loadds _far * fn)
#else /* !L_PUT_PASCAL_IN_FPTR_PARENS */
#define lexportp(dt,fn)     dt L_PASCAL (_loadds _far * fn)
#endif /* L_PUT_PASCAL_IN_FPTR_PARENS */
#endif /* L_USING_PASCAL_IN_FRONT */
                 /* In the above macros, the 'dt' argument should
                    be a valid data type like 'lslong', since it
                    is the function return data type. The 'fn'
                    argument is the function name.  */

/*
   Set the use of parameter passing and data model for local functions.
*/
#if L_USING_PASCAL_PARMS
#define L_PARMS     L_PASCAL
#else /* !L_USING_PASCAL_PARMS */
#define L_PARMS     cdecl
#endif /* L_USING_PASCAL_PARMS */

#if L_USING_LARGE_MODEL
#define L_MODEL     _far
#else /* !L_USING_LARGE_MODEL */
#define L_MODEL    _near
#endif /* L_USING_LARGE_MODEL */

#if L_USING_PASCAL_IN_FRONT
#define llocalf(dt)         L_PASCAL dt
#define llocalp(dt,fn)      dt (* fn)
#else /* !L_USING_PASCAL_IN_FRONT */
#define llocalf(dt)         dt L_PARMS L_MODEL
#if L_PUT_PASCAL_IN_FPTR_PARENS
#define llocalp(dt,fn)      dt (L_PARMS L_MODEL * fn)
#else /* !L_PUT_PASCAL_IN_FPTR_PARENS */
#define llocalp(dt,fn)      dt L_PARMS (L_MODEL * fn)
#endif /* L_PUT_PASCAL_IN_FPTR_PARENS */
#endif /* L_USING_PASCAL_IN_FRONT */
                 /* In the above macros, the 'dt' argument should
                    be a valid data type like 'lslong', since it
                    is the function return data type. The 'fn'
                    argument is the function name.  */

/*
     This section handles the compiler and platform specific forms
     of function related declarations.  The macros are of the format:
        lXXXYYY(dt, fn, args)
     where:
      XXX is one of the three function types:
         exp - exported function which is called between load modules.
         loc - local function which is called between source files in
               the same load module.
         sta - static function which is called within a source file.
      YYY is one of the three function related declarations to be set:
         fnc - specifies the function definition.
         pro - specifies the function prototype.
         ptr - specifies the pointer to the function.
      dt is the return datatype for the function.
      fn is the function name.
      args is the list of function parameters with their datatypes.
*/

/***** static function handling *****/
#define lstafnc(dt, fn, args)   static dt _near fn args
#define lstapro(dt, fn, args)   static dt _near fn args
#define lstaptr(dt, fn, args)   static dt (_near * fn) args

#if L_USING_PASCAL_IN_FRONT

#if L_ANSI_C

/***** exported function handling *****/
#define lexpfnc(dt, fn, args)   L_PASCAL dt fn args
#define lexppro(dt, fn, args)   L_PASCAL dt fn args
#define lexpptr(dt, fn, args)   dt (* fn) args

/***** local function handling *****/
#define llocfnc(dt, fn, args)   L_PASCAL dt fn args
#define llocpro(dt, fn, args)   L_PASCAL dt fn args
#define llocptr(dt, fn, args)   dt (* fn) args

#else /* !L_ANSI_C */

/***** exported function handling *****/
#define lexpfnc(dt, fn, args)   L_PASCAL dt fn args
#define lexppro(dt, fn, args)   L_PASCAL dt fn ()
#define lexpptr(dt, fn, args)   dt (* fn) ()

/***** local function handling *****/
#define llocfnc(dt, fn, args)   L_PASCAL dt fn args
#define llocpro(dt, fn, args)   L_PASCAL dt fn ()
#define llocptr(dt, fn, args)   dt (* fn) () 

#endif /* L_ANSI_C */

#else /* !L_USING_PASCAL_IN_FRONT */

#if L_ANSI_C

/***** exported function handling *****/
#define lexpfnc(dt, fn, args)   dt L_PASCAL _loadds _far fn args
#define lexppro(dt, fn, args)   dt L_PASCAL _loadds _far fn args
#if L_PUT_PASCAL_IN_FPTR_PARENS
#define lexpptr(dt, fn, args)   dt (L_PASCAL _loadds _far * fn) args
#else /* !L_PUT_PASCAL_IN_FPTR_PARENS */
#define lexpptr(dt, fn, args)   dt L_PASCAL (_loadds _far * fn) args
#endif /* L_PUT_PASCAL_IN_FPTR_PARENS */

/***** local function handling *****/
#define llocfnc(dt, fn, args)   dt L_PASCAL L_MODEL fn args
#define llocpro(dt, fn, args)   dt L_PASCAL L_MODEL fn args
#if L_PUT_PASCAL_IN_FPTR_PARENS
#define llocptr(dt, fn, args)   dt (L_PASCAL L_MODEL * fn) args
#else /* !L_PUT_PASCAL_IN_FPTR_PARENS */
#define llocptr(dt, fn, args)   dt L_PASCAL (L_MODEL * fn) args
#endif /* L_PUT_PASCAL_IN_FPTR_PARENS */

#else /* !L_ANSI_C */

/***** exported function handling *****/
#define lexpfnc(dt, fn, args)   dt L_PASCAL _loadds _far fn args
#define lexppro(dt, fn, args)   dt L_PASCAL _loadds _far fn ()
#if L_PUT_PASCAL_IN_FPTR_PARENS
#define lexpptr(dt, fn, args)   dt (L_PASCAL _loadds _far * fn) ()
#else /* !L_PUT_PASCAL_IN_FPTR_PARENS */
#define lexpptr(dt, fn, args)   dt L_PASCAL (_loadds _far * fn) ()
#endif /* L_PUT_PASCAL_IN_FPTR_PARENS */

/***** local function handling *****/
#define llocfnc(dt, fn, args)   dt L_PASCAL L_MODEL fn args
#define llocpro(dt, fn, args)   dt L_PASCAL L_MODEL fn ()
#if L_PUT_PASCAL_IN_FPTR_PARENS
#define llocptr(dt, fn, args)   dt (L_PASCAL L_MODEL * fn) ()
#else /* !L_PUT_PASCAL_IN_FPTR_PARENS */
#define llocptr(dt, fn, args)   dt L_PASCAL (L_MODEL * fn) ()
#endif /* L_PUT_PASCAL_IN_FPTR_PARENS */

#endif /* L_ANSI_C */

#endif /* L_USING_PASCAL_IN_FRONT */


/*
     This section handles the compiler and platform specific forms
     of data storage model declarations for global data.  The macros
     are of the format:
        lXXXZZZ(dt)
     where:
      XXX is one of the three data model types:
         exp - exported data which is referenced between load modules.
         loc - local data which is referenced between source files in
               the same load module (in the local data segment).
         sta - static data which is referenced within a source file.
      ZZZ is one of the two data declarations:
         dat - the reference to global data.
         pub - the definition of public global data (not static data).
      dt is the datatype for the global data.
*/

#if L_USING_DATA_NOSHARE
#define lstadat(dt)     static dt
#define lexpdat(dt)     extern noshare dt
#define lexppub(dt)     noshare dt
#define llocdat(dt)     extern noshare dt
#define llocpub(dt)     noshare dt
#else /* !L_USING_DATA_NOSHARE */
#define lstadat(dt)     static dt _near
#define lexpdat(dt)     extern dt L_PASCAL _far
#define lexppub(dt)     dt L_PASCAL _far
#define llocdat(dt)     extern dt _cdecl _near
#define llocpub(dt)     dt _cdecl _near
#endif /* L_USING_DATA_NOSHARE */

/********************************************************************/
/*
   The following is set to control the storage packing of a
   structure.  Some compilers on platforms which align data according
   to data type use a keyword to override the hardware alignment.
*/

#if L_USING_PACKED_KEYWORD
#define LPACKED         _Packed
#else /* !L_USING_PACKED_KEYWORD */
#define LPACKED
#endif /* L_USING_PACKED_KEYWORD */


/********************************************************************/
/*
**       Section 7
*/
/*
**             mapped memory handle
   The following defines provide a method for declaring variables
   that are memory handles that need to be mapped, as opposed to
   real pointers.  The defines allow for the programmer to document
   the data type of the memory.
*/

#define lmhdl(dt)       lptr(void)     /* memory handle to map */


/********************************************************************/
/*
**       Section 8
*/
/*
**             Constant data
   The following defines allow us to control whether a symbol is
   declared as having a constant value.  Some systems cannot declare
   data of this type, yet on other systems, doing so can make a
   tremendous difference in performance.
*/

#if L_USING_CONSTANT_DATA
#define LCONSTANT          const       /* constant data is     in use */
#else /* !L_USING_CONSTANT_DATA */
#define LCONSTANT                      /* constant data is not in use */
#endif /* L_USING_CONSTANT_DATA */


/********************************************************************/
/*
**       Section 9
*/
/*
**             Register usage
   The following defines allow us to control whether a data variable
   is allocated in a register.  It is dependent on whether the system
   in question can put a variable of a given size in a register
   efficiently.
*/
#if L_USING_REGISTER_SHORTS
#define LREGSHORT          register    /* shorts can go into registers */
#else /* !L_USING_REGISTER_SHORTS */
#define LREGSHORT
#endif /* L_USING_REGISTER_SHORTS */

#if L_USING_REGISTER_LONGS
#define LREGLONG           register    /* longs  can go into registers */
#else /* !L_USING_REGISTER_LONGS */
#define LREGLONG
#endif /* L_USING_REGISTER_LONGS */

#if L_USING_REGISTER_NEAR_PTRS
#define LREGNEARPTR        register    /* near * can go into registers */
#else /* !L_USING_REGISTER_NEAR_PTRS */
#define LREGNEARPTR
#endif /* L_USING_REGISTER_NEAR_PTRS */


/********************************************************************/
/*
**       Section 10
*/
/*
**             Main Function Exit Codes
   The various machines assume that a 'good' exit code from a C
   MAIN function is a particular value and that a 'bad' exit code
   is NOT that value.  Unfortunately, the 'good' and 'bad' values
   are not the same on all machines.
*/

#if L_USING_GOOD_EXITCODE_IS_0
#define LEXIT_GOOD         0           /* good exit/return code */
#define LEXIT_BAD          1           /* bad  exit/return code */
#else /* !L_USING_GOOD_EXITCODE_IS_0 */
#define LEXIT_GOOD         1           /* good exit/return code */
#define LEXIT_BAD          0           /* bad  exit/return code */
#endif /* L_USING_GOOD_EXITCODE_IS_0 */


/********************************************************************/
/*
**       Section 11
*/
/*
**             Function Return Data Types
   With the new ANSI C standards came the ability to prototype
   function return values to say that the function returns nothing.
   Not all compilers can handle a function return type of 'void'.
*/

#if L_USING_VOID_FUNCTIONS
#define LNORETVAL         void        /* Compiler can   handle void */
#else /* !L_USING_VOID_FUNCTIONS */
#define LNORETVAL         lsshort     /* Compiler can't handle void */
#endif /* L_USING_VOID_FUNCTIONS */


/********************************************************************/
/*
**             END OF FILE
*/
#endif /* if !defined(LTSDEFS_H) */
