/* @(#)lpixport.h	128.1 1/20/93 19:40:32 */
/****************************************************************************
 (c) Copyright 1991 by Lotus Development Corporation.
 All rights reserved.

 Name:         lpixport.h
 Description:  1-2-3 for Sun Toolkit Library export module macros

 Change History:
-----------------------------------------------------------------------------
 Date      Rev.  Pgmr  Change
-----------------------------------------------------------------------------
 01-May-91 0001  jdm   Initial version.
****************************************************************************/

#if !defined(LPIXPORT_H)
#define LPIXPORT_H

#if ! defined STATIC_MODULE
#define STATIC_CAT
#endif

#define GlobalVersionNumber  7

/******************* INCLUDE ALL THE LOTUS SUPPLIED FILES ******************/
#include "ltsdefs.h"
#include "lpisys.h"

/* #define of LPI_ENVIRONMENT must follow lpisys.h and precede lpiprim.h */
#define LPI_ENVIRONMENT LPI_123R3PC

#include "lpiprim.h"
#include "lpimemm.t"
#include "lpimemm.h"
#include "lpixport.t"
#include "lpickstk.h" /* #includes lpierror.h */
#include "lpienum.h"
#include "lpimisc.h"


/******************* DEFINE "NOGLOBALDATA" HERE IF NEEDED ******************/
/* #define NOGLOBALDATA */


/******************* OTHER #DEFINES HERE IF NEEDED *************************/
#define VMR_0 0
#define VMR_1 1
#define VMR_2 2
#define VMR_3 3


/******************* GLOBAL TYPEDEFS ***************************************/
typedef lptr(struct LpiCellType_)      LpiCellType;
typedef lptr(struct LpiRangeType_)     LpiRangeType;
typedef lptr(struct LpiSheetType_)     LpiSheetType;
typedef lptr(struct LpiWorkfileType_)  LpiWorkfileType;
typedef lptr(struct LpiWorkspaceType_) LpiWorkspaceType;
typedef lptr(struct LpiPromptType_)    LpiPromptType;
typedef lptr(struct LpiMenuType_)      LpiMenuType;
typedef lptr(struct LpiKeyboardType_)  LpiKeyboardType;


/******************* DEFINE OR DECLARE MATH TABLE POINTER ******************/
/* In order to use the lpi infix math, you must #define LPI_MAIN_MODULE in */
/* at least one C module which includes this file.  Usually this should be */
/* done in the same module that contains that bind/unbind routines.        */
#if defined(LPI_MAIN_MODULE)  
#if ! defined STATIC_CAT  
lptr(MathTableType) lpimathtable = LNULL;
#else
extern lptr(MathTableType) lpimathtable;
#endif /* ! defined STATIC_CAT */ 
#else
extern lptr(MathTableType) lpimathtable;
#endif

/******************* INCORPORATE .PLX FILES ********************************/
#if defined(USE_CELL)
#include "cell.plx"
#endif

#if defined(USE_RANGE)
#include "range.plx"
#endif

#if defined(USE_SHEET)
#include "sheet.plx"
#endif

#if defined(USE_WORKFILE)
#include "workfile.plx"
#endif

#if defined(USE_WKSPACE)
#include "wkspace.plx"
#endif

#if defined(USE_INPUT)
#include "input.plx"
#endif

#if defined(USE_ATSTAT)
#include "atstat.plx"
#endif

#if defined(USE_ATFIN)
#include "atfin.plx"
#endif

#if defined(USE_ATDATE)
#include "atdate.plx"
#endif

#if defined(USE_ATDBASE)
#include "atdbase.plx"
#endif

#if defined(USE_ATSTR)
#include "atstr.plx"
#endif

#if defined(USE_ATSPCL)
#include "atspcl.plx"
#endif

#if defined(USE_ATLOGIC)
#include "atlogic.plx"
#endif

#if defined(USE_UTILITY)
#include "utility.plx"
#endif

#if defined(USE_MACRO)
#include "macro.plx"
#endif

#if defined(USE_REGISTER)
#include "register.plx"
#endif

#if defined(USE_ALERT)
#include "alert.plx"
#endif


#if defined(NOGLOBALDATA) /* if global data is not allowed */

/******************* DEFINE SETUP MACROS FOR NOGLOBALDATA ******************/
/* The following structure has its contents conditionally defined,
 * depending on which libraries the user has requested.  The USE_XXX macros
 * (defined above) include the .plx files with the needed definitions and
 * define the XXX_PLX symbols, which then determine the contents  of this
 * structure.
 */

typedef struct {
/* CELL */
#if defined(CELL_PLX)
   lptr(cl_exports)     cl_table;
   lptr(CONTEXT)        cl_global;
#endif

/* RANGE */
#if defined(RANGE_PLX)
   lptr(rng_exports)    rng_table;
   lptr(CONTEXT)        rng_global;
#endif

/* SHEET */
#if defined(SHEET_PLX)
   lptr(sh_exports)     sh_table;
   lptr(CONTEXT)        sh_global;
#endif

/* WORKFILE */
#if defined(WORKFILE_PLX)
   lptr(wf_exports)     wf_table;
   lptr(CONTEXT)        wf_global;
#endif

/* WORKSPACE */
#if defined(WKSPACE_PLX)
   lptr(ws_exports)     ws_table;
   lptr(CONTEXT)        ws_global;
#endif

/* INPUT */
#if defined(INPUT_PLX)
   lptr(in_exports)     in_table;
   lptr(CONTEXT)        in_global;
#endif

/* ATSTAT */
#if defined(ATSTAT_PLX)
   lptr(atst_exports)   atst_table;
   lptr(CONTEXT)        atst_global;
#endif

/* ATFIN */
#if defined(ATFIN_PLX)
   lptr(atfin_exports)  atfin_table;
   lptr(CONTEXT)        atfin_global;
#endif

/* ATDATE */
#if defined(ATDATE_PLX)
   lptr(atd_exports)    atd_table;
   lptr(CONTEXT)        atd_global;
#endif

/* ATDBASE */
#if defined(ATDBASE_PLX)
   lptr(atdb_exports)   atdb_table;
   lptr(CONTEXT)        atdb_global;
#endif

/* ATSTR */
#if defined(ATSTR_PLX)
   lptr(atstr_exports)  atstr_table;
   lptr(CONTEXT)        atstr_global;
#endif

/* ATSPCL */
#if defined(ATSPCL_PLX)
   lptr(atspcl_exports) atspc_table;
   lptr(CONTEXT)        atspc_global;
#endif

/* ATLOGIC */
#if defined(ATLOGIC_PLX)
   lptr(atlog_exports)  atlog_table;
   lptr(CONTEXT)        atlog_global;
#endif

/* UTILITY */
#if defined(UTILITY_PLX)
   lptr(util_exports)   util_table;
   lptr(CONTEXT)        util_global;
#endif

/* MACRO */
#if defined(MACRO_PLX)
   lptr(mac_exports)    mac_table;
   lptr(CONTEXT)        mac_global;
#endif

/* REGISTER */
#if defined(REGISTER_PLX)
   lptr(reg_exports)    reg_table;
   lptr(CONTEXT)        reg_global;
#endif

/* ALERT */
#if defined(ALERT_PLX)
   lptr(alert_exports)  alert_table;
   lptr(CONTEXT)        alert_global;
#endif

   LpiADTUTIL  utility_vector;
   lmhdl(void) instance_data;
   lptr(void)  user_data;
} lpiglobaldatatype;

#define LPI_CALL_DATA ((lpiglobaldatatype *)LpiContext->LibData)

/* Allocate memory in LpiContext->LibData for the function table and,
   as part of doing the setup, make the mathtable accessable to us all.
*/
#define LPI_SETUP_LOAD    {LpiContext->LibData = \
                             (*LpiContext->Environment->alloc) \
                             ((lulong) sizeof(lpiglobaldatatype)); \
                          if (LpiContext->LibData == LNULL) \
                             return(LPI_FAILURE); \
                          lpimathtable = LpiContext->Reserved2;}

#define LPI_UNLOAD        (*LpiContext->Environment->dealloc) \
                             (LpiContext->LibData, \
                             (lulong) sizeof(lpiglobaldatatype))

#define LPI_LOAD_CELL     LpiSetupAltCall(ll3cell_name,\
                                          &(LPI_CALL_DATA->cl_table),\
                                          &(LPI_CALL_DATA->cl_global))

#define LPI_LOAD_RANGE    LpiSetupAltCall(ll3range_name,\
                                          &(LPI_CALL_DATA->rng_table),\
                                          &(LPI_CALL_DATA->rng_global))

#define LPI_LOAD_SHEET    LpiSetupAltCall(ll3sheet_name,\
                                          &(LPI_CALL_DATA->sh_table),\
                                          &(LPI_CALL_DATA->sh_global))

#define LPI_LOAD_WORKFILE LpiSetupAltCall(ll3wfile_name,\
                                          &(LPI_CALL_DATA->wf_table),\
                                          &(LPI_CALL_DATA->wf_global))

#define LPI_LOAD_WKSPACE  LpiSetupAltCall(ll3wkspace_name,\
                                          &(LPI_CALL_DATA->ws_table),\
                                          &(LPI_CALL_DATA->ws_global))

#define LPI_LOAD_INPUT    LpiSetupAltCall(ll3input_name,\
                                          &(LPI_CALL_DATA->in_table),\
                                          &(LPI_CALL_DATA->in_global))

#define LPI_LOAD_ATSTAT   LpiSetupAltCall(ll3atstat_name,\
                                          &(LPI_CALL_DATA->atst_table),\
                                          &(LPI_CALL_DATA->atst_global))

#define LPI_LOAD_ATFIN    LpiSetupAltCall(ll3atfin_name,\
                                          &(LPI_CALL_DATA->atfin_table),\
                                          &(LPI_CALL_DATA->atfin_global))

#define LPI_LOAD_ATDATE   LpiSetupAltCall(ll3atdate_name,\
                                          &(LPI_CALL_DATA->atd_table),\
                                          &(LPI_CALL_DATA->atd_global))

#define LPI_LOAD_ATDBASE  LpiSetupAltCall(ll3atdbase_name,\
                                          &(LPI_CALL_DATA->atdb_table),\
                                          &(LPI_CALL_DATA->atdb_global))

#define LPI_LOAD_ATSTR    LpiSetupAltCall(ll3atstr_name,\
                                          &(LPI_CALL_DATA->atstr_table),\
                                          &(LPI_CALL_DATA->atstr_global))

#define LPI_LOAD_ATSPCL   LpiSetupAltCall(ll3atspcl_name,\
                                          &(LPI_CALL_DATA->atspc_table),\
                                          &(LPI_CALL_DATA->atspc_global))

#define LPI_LOAD_ATLOGIC  LpiSetupAltCall(ll3atlogic_name,\
                                          &(LPI_CALL_DATA->atlog_table),\
                                          &(LPI_CALL_DATA->atlog_global))

#define LPI_LOAD_UTILITY  LpiSetupAltCall(ll3utility_name,\
                                          &(LPI_CALL_DATA->util_table),\
                                          &(LPI_CALL_DATA->util_global))

#define LPI_LOAD_MACRO    LpiSetupAltCall(ll3macro_name,\
                                          &(LPI_CALL_DATA->mac_table),\
                                          &(LPI_CALL_DATA->mac_global))

#define LPI_LOAD_REGISTER LpiSetupAltCall(ll3register_name,\
                                          &(LPI_CALL_DATA->reg_table),\
                                          &(LPI_CALL_DATA->reg_global))

#define LPI_LOAD_ALERT    LpiSetupAltCall(lpialert_name,\
                                          &(LPI_CALL_DATA->alert_table),\
                                          &(LPI_CALL_DATA->alert_global))

#else /* !defined(NOGLOBALDATA) -- for use with global data */

/******************* DEFINE SETUP MACROS FOR GLOBAL DATA OK ****************/
#if defined(CELL_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(cl_exports)            lts_cl_table = LNULL;
    lptr(CONTEXT)               lts_cl_global = LNULL;
#else
    extern lptr(cl_exports)     lts_cl_table;
    extern lptr(CONTEXT)        lts_cl_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(cl_exports)     lts_cl_table;
    extern lptr(CONTEXT)        lts_cl_global;
#endif
#endif

/** RANGE */
#if defined(RANGE_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(rng_exports)           lts_rng_table = LNULL;
    lptr(CONTEXT)               lts_rng_global = LNULL;
#else
    extern lptr(rng_exports)    lts_rng_table;
    extern lptr(CONTEXT)        lts_rng_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(rng_exports)    lts_rng_table;
    extern lptr(CONTEXT)        lts_rng_global;
#endif
#endif

/** SHEET */
#if defined(SHEET_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(sh_exports)            lts_sh_table = LNULL;
    lptr(CONTEXT)               lts_sh_global = LNULL;
#else
    extern lptr(sh_exports)     lts_sh_table;
    extern lptr(CONTEXT)        lts_sh_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(sh_exports)     lts_sh_table;
    extern lptr(CONTEXT)        lts_sh_global;
#endif
#endif

/** WORKFILE */
#if defined(WORKFILE_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(wf_exports)            lts_wf_table = LNULL;
    lptr(CONTEXT)               lts_wf_global = LNULL;
#else
    extern lptr(wf_exports)     lts_wf_table;
    extern lptr(CONTEXT)        lts_wf_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(wf_exports)     lts_wf_table;
    extern lptr(CONTEXT)        lts_wf_global;
#endif
#endif

/** WORKSPACE */
#if defined(WKSPACE_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(ws_exports)            lts_ws_table = LNULL;
    lptr(CONTEXT)               lts_ws_global = LNULL;
#else
    extern lptr(ws_exports)     lts_ws_table;
    extern lptr(CONTEXT)        lts_ws_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(ws_exports)     lts_ws_table;
    extern lptr(CONTEXT)        lts_ws_global;
#endif
#endif

/** INPUT */
#if defined(INPUT_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(in_exports)            lts_in_table = LNULL;
    lptr(CONTEXT)               lts_in_global = LNULL;
#else
    extern lptr(in_exports)     lts_in_table;
    extern lptr(CONTEXT)        lts_in_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(in_exports)     lts_in_table;
    extern lptr(CONTEXT)        lts_in_global;
#endif
#endif

/** ATSTAT */
#if defined(ATSTAT_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atst_exports)          lts_atst_table = LNULL;
    lptr(CONTEXT)               lts_atst_global = LNULL;
#else
    extern lptr(atst_exports)   lts_atst_table;
    extern lptr(CONTEXT)        lts_atst_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atst_exports)   lts_atst_table;
    extern lptr(CONTEXT)        lts_atst_global;
#endif
#endif

/** ATFIN */
#if defined(ATFIN_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atfin_exports)         lts_atfin_table = LNULL;
    lptr(CONTEXT)               lts_atfin_global = LNULL;
#else
    extern lptr(atfin_exports)  lts_atfin_table;
    extern lptr(CONTEXT)        lts_atfin_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atfin_exports)  lts_atfin_table;
    extern lptr(CONTEXT)        lts_atfin_global;
#endif
#endif

/** ATDATE */
#if defined(ATDATE_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atd_exports)           lts_atd_table = LNULL;
    lptr(CONTEXT)               lts_atd_global = LNULL;
#else
    extern lptr(atd_exports)    lts_atd_table;
    extern lptr(CONTEXT)        lts_atd_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atd_exports)    lts_atd_table;
    extern lptr(CONTEXT)        lts_atd_global;
#endif
#endif

/** ATDBASE */
#if defined(ATDBASE_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atdb_exports)          lts_atdb_table = LNULL;
    lptr(CONTEXT)               lts_atdb_global = LNULL;
#else
    extern lptr(atdb_exports)   lts_atdb_table;
    extern lptr(CONTEXT)        lts_atdb_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atdb_exports)   lts_atdb_table;
    extern lptr(CONTEXT)        lts_atdb_global;
#endif
#endif

/** ATSTR */
#if defined(ATSTR_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atstr_exports)         lts_atstr_table = LNULL;
    lptr(CONTEXT)               lts_atstr_global = LNULL;
#else
    extern lptr(atstr_exports)  lts_atstr_table;
    extern lptr(CONTEXT)        lts_atstr_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atstr_exports)  lts_atstr_table;
    extern lptr(CONTEXT)        lts_atstr_global;
#endif
#endif

/** ATSPCL */
#if defined(ATSPCL_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atspcl_exports)        lts_atspc_table = LNULL;
    lptr(CONTEXT)               lts_atspc_global = LNULL;
#else
    extern lptr(atspcl_exports) lts_atspc_table;
    extern lptr(CONTEXT)        lts_atspc_global ;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atspcl_exports) lts_atspc_table;
    extern lptr(CONTEXT)        lts_atspc_global ;
#endif
#endif

/** ATLOGIC */
#if defined(ATLOGIC_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(atlog_exports)         lts_atlog_table = LNULL;
    lptr(CONTEXT)               lts_atlog_global = LNULL;
#else
    extern lptr(atlog_exports)  lts_atlog_table;
    extern lptr(CONTEXT)        lts_atlog_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(atlog_exports)  lts_atlog_table;
    extern lptr(CONTEXT)        lts_atlog_global;
#endif
#endif

/** UTILITY */
#if defined(UTILITY_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(util_exports)          lts_ut_table = LNULL;
    lptr(CONTEXT)               lts_ut_global = LNULL;
#else
    extern lptr(util_exports)   lts_ut_table;
    extern lptr(CONTEXT)        lts_ut_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(util_exports)   lts_ut_table;
    extern lptr(CONTEXT)        lts_ut_global;
#endif
#endif

/** MACRO */
#if defined(MACRO_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(mac_exports)           lts_mac_table = LNULL;
    lptr(CONTEXT)               lts_mac_global = LNULL;
#else
    extern lptr(mac_exports)    lts_mac_table;
    extern lptr(CONTEXT)        lts_mac_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(mac_exports)    lts_mac_table;
    extern lptr(CONTEXT)        lts_mac_global;
#endif
#endif

/** REGISTER */
#if defined(REGISTER_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(reg_exports)           lts_reg_table = LNULL;
    lptr(CONTEXT)               lts_reg_global = LNULL;
#else
    extern lptr(reg_exports)    lts_reg_table;
    extern lptr(CONTEXT)        lts_reg_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(reg_exports)    lts_reg_table;
    extern lptr(CONTEXT)        lts_reg_global;
#endif
#endif

/** ALERT */
#if defined(ALERT_PLX)
#if defined(LPI_MAIN_MODULE)
#if ! defined STATIC_CAT  
    lptr(alert_exports)         lts_alert_table = LNULL;
    lptr(CONTEXT)               lts_alert_global = LNULL;
#else
    extern lptr(alert_exports)  lts_alert_table;
    extern lptr(CONTEXT)        lts_alert_global;
#endif /* ! defined STATIC_CAT */ 
#else
    extern lptr(alert_exports)  lts_alert_table;
    extern lptr(CONTEXT)        lts_alert_global;
#endif
#endif

/* as part of doing the setup, make the mathtable accessable to us all */
#define LPI_SETUP_LOAD    lpimathtable = LpiContext->Reserved2;

#define LPI_UNLOAD        LpiContext;

#define LPI_LOAD_CELL     LpiSetupAltCall(ll3cell_name,\
                                          &lts_cl_table,\
                                          &lts_cl_global)

#define LPI_LOAD_RANGE    LpiSetupAltCall(ll3range_name,\
                                          &lts_rng_table,\
                                          &lts_rng_global)

#define LPI_LOAD_SHEET    LpiSetupAltCall(ll3sheet_name,\
                                          &lts_sh_table,\
                                          &lts_sh_global)

#define LPI_LOAD_WORKFILE LpiSetupAltCall(ll3wfile_name,\
                                          &lts_wf_table,\
                                          &lts_wf_global)

#define LPI_LOAD_WKSPACE  LpiSetupAltCall(ll3wkspace_name,\
                                          &lts_ws_table,\
                                          &lts_ws_global)

#define LPI_LOAD_INPUT    LpiSetupAltCall(ll3input_name,\
                                          &lts_in_table,\
                                          &lts_in_global)

#define LPI_LOAD_ATSTAT   LpiSetupAltCall(ll3atstat_name,\
                                          &lts_atst_table,\
                                          &lts_atst_global)

#define LPI_LOAD_ATFIN    LpiSetupAltCall(ll3atfin_name,\
                                          &lts_atfin_table,\
                                          &lts_atfin_global)

#define LPI_LOAD_ATDATE   LpiSetupAltCall(ll3atdate_name,\
                                          &lts_atd_table,\
                                          &lts_atd_global)

#define LPI_LOAD_ATDBASE  LpiSetupAltCall(ll3atdbase_name,\
                                          &lts_atdb_table,\
                                          &lts_atdb_global)

#define LPI_LOAD_ATSTR    LpiSetupAltCall(ll3atstr_name,\
                                          &lts_atstr_table,\
                                          &lts_atstr_global)

#define LPI_LOAD_ATSPCL   LpiSetupAltCall(ll3atspcl_name,\
                                          &lts_atspc_table,\
                                          &lts_atspc_global)

#define LPI_LOAD_ATLOGIC  LpiSetupAltCall(ll3atlogic_name,\
                                          &lts_atlog_table,\
                                          &lts_atlog_global)

#define LPI_LOAD_UTILITY  LpiSetupAltCall(ll3utility_name,\
                                          &lts_ut_table,\
                                          &lts_ut_global)

#define LPI_LOAD_MACRO    LpiSetupAltCall(ll3macro_name,\
                                          &lts_mac_table,\
                                          &lts_mac_global)

#define LPI_LOAD_REGISTER LpiSetupAltCall(ll3register_name,\
                                          &lts_reg_table,\
                                          &lts_reg_global)

#define LPI_LOAD_ALERT    LpiSetupAltCall(lpialert_name,\
                                          &lts_alert_table,\
                                          &lts_alert_global)
#endif /* defined(NOGLOBALDATA) */
#endif /* !defined(LPIXPORT_H) */
