/* @(#)lpickstk.h	128.1 1/20/93 18:13:53 */
/************************************************************************\

   Copyright (C) 1990 Lotus Development Corporation.  All rights reserved.

   Name:    lpickstk.h
   Author:  R. Suitor
   Date:    07 Feb 1990

   Description:  Definitions and template for stack checking routines

    Change History:
-------------------------------------------------------------------------
    Date    Chg#  Pgmr  SPR#   Change
-------------------------------------------------------------------------
 21-Feb-91  0011  spl    none  Defined CheckStackStatus for C_PROGRAMMABILITY

 06-Feb-91  0010  jdm    none  Made changes for non-ANSI C compilers.
 !
 27-Nov-90  0009  jrc  121493  Remove VCS stuff from C interface headers
  
 16-nov-90  0008  dgr  121577  Change is_godiva to is_r30 per leaf review
 
 25-sep-90  0007  dgr    none  Per Mehmet, conditional inclusion of lpierror.h
 
 24-sep-90  0006  dgr    none  Change outofmemory_trap to LPI_S_STACK_OVERFLOW
 
 24-sep-90  0005  dgr    none  Change outofmemory_trap to stackoverflow
 
 06-mar-90  0004  dgr    none  Add is_godiva version checking code
 
 06-mar-90  0003  dgr    none  Add is_godiva version checking code
 
 07-Feb-90  0002  rfs    none  added void to arg of StackStatus
 
 07-Feb-90  0001  rfs    none  StackStatus can't be near right now
 
 07-Feb-90  0000  rfs    none  Initial revision
-------------------------------------------------------------------------

Instructions:

In Microsoft C, stack checking may be turned on or off with the pragma:

#pragma check_stack (on[or off])

Default is on, unless /Gs (or flags containing it, such as Ox) are used
on the compile command line.

Primitive routines that use significant stack should check the stack.
Such a routine should have CheckStackStatus; as its first executable line.
This means that there should be no initialization in the declaration
statements.

All such routines should be designed to return a status; if such a status
== StackOverflow that means there was not enough stack for the routine to
run and it didn't.  Clearly the calling routine must be designed to take
appropriate action.  Immediately passing the status back is always
sufficient; it may not always be necessary.

\************************************************************************/

#if !defined(LPICKSTK_H)
#define LPICKSTK_H

#if !defined(LPIERROR_H)
#include "lpierror.h"
#endif

#if ANYIBMPC || C_PROGRAMMABILITY

#if L_ANSI_C
extern int cdecl StackStatus(void);
#else /* !L_ANSI_C */
extern int cdecl StackStatus();
#endif /* L_ANSI_C */

#define StackOverflow    (LPI_S_STACK_OVERFLOW) /* stack overflow trap */
#define CheckStackStatus if(StackStatus())return(StackOverflow)

#else /* !ANYIBMPC && !C_PROGRAMMABILITY */

#define CheckStackStatus

#endif /* ANYIBMPC */

/* the following is for 1-2-3 version checking */
#if L_ANSI_C
lptr(lubyte) get_123_ver(lptr(CONTEXT));
#else /* !L_ANSI_C */
lptr(lubyte) get_123_ver();
#endif /* L_ANSI_C */

/*
- Macro:       is_r30
-
- Description: Return true if the core product is 1-2-3 version 3.00.00.
-              (strcmp returns 0 if strings are identical.)
-
*/

#define is_r30() (!strcmp(get_123_ver(LpiContext), "3.00.00"))

#endif  /* LPICKSTK_H */
