/* @(#)lpimisc.h	128.1 1/20/93 19:40:29 */
/************************************************************************\
   Copyright (C) 1990 Lotus Development Corporation.  All rights reserved.
   Name:    lpimisc.h
   Date:    21 Jul 1990
   Description:  Contains the prototypes for CxxxString utility functions
\************************************************************************/

#if !defined(LPIMISC_H)
#define LPIMISC_H


/*--------------------------------------------------------------------------
-  Name:          CFreeString
-
-  Description:   Free a string in memory.  Frees strings of length
-                 strlen()+1, sets the pointer to LNULL on return if
-                 successful.  Uses VMR_1.
-
-  Inputs:        lptr(CONTEXT) LpiContext
-                    pointer to the caller's add-in module globals
-                 lmhdl(lmbcs) theString
-                    handle to string to be freed
-
-  Outputs:       lmhdl(lmbcs)
-                    LNULL if successfully freed, theString if not
--------------------------------------------------------------------------*/
#define CFreeString(arg1, arg2) \
   LPI_MISC(lef_c_free_string) (arg1, arg2)


/*-------------------------------------------------------------------------
  Name:        CCopyString
  Description: Make a copy of a string in memory. This routine is used
               to make copies of the Prompt Title and Default strings
               when creating the strings and when cloning an ADT instance.
               Uses VMR_2, VMR_3
  Inputs:      lptr(CONTEXT)
                  far pointer to the primitive module globals
               lmhdl(char)
                  mptr to the string to copy
  Outputs:     lmhdl(char)
                  mptr to the newly allocated string
                  NULL_MPTR if we ran out of memory
\*-------------------------------------------------------------------------*/
#define CCopyString(arg1, arg2) \
   LPI_MISC(lef_c_copy_string) (arg1, arg2)


/*----------------------------------------------------------------------------
-  Name:          LpiMakeLmhdl
-
-  Description:   Make a copy of a block of memory by allocating a new
-                 appropriately sized block and copying the contents of
-                 the original into it.  Uses VMR_1.
-
-  Inputs:        memtype
-                    type of memory you want to allocate (lmbcs, etc.)
-                 lptr(lmhdl(void))
-                    pointer to output variable for new copy lmhdl
-                 lptr(void)
-                    pointer to source memory block
-                 lushort
-                    size in bytes of block to copy
-
-  Outputs:       lbool
-                    LTRUE if successful, L_FALSE otherwise
----------------------------------------------------------------------------*/
#define LpiMakeLmhdl(arg1, arg2, arg3, arg4) \
   LPI_MISC(lef_make_lmhdl) (LpiContext, arg2, arg3, arg4)


/********************************************************************
**             DATA STRUCTURES
*/

#define MISCTABLE_SKIP 110

#if L_ANSI_C

typedef struct MiscTable_ {
   void         (far *skip[MISCTABLE_SKIP]) (NOPARAMS);
   lmhdl(lmbcs) (far *lef_c_free_string)    (lptr(CONTEXT), lmhdl(lmbcs));
   lmhdl(lmbcs) (far *lef_c_copy_string)    (lptr(CONTEXT), lmhdl(lmbcs));
   lbool        (far *lef_make_lmhdl)       (lptr(CONTEXT),
                                             lptr(lmhdl(void)),
                                             lptr(void),
                                             lushort);
} MiscTableType, *MiscTablePtr;

#else /* !L_ANSI_C */

typedef struct MiscTable_ {
   void         (far *skip[MISCTABLE_SKIP]) ();
   lmhdl(lmbcs) (far *lef_c_free_string)    ();
   lmhdl(lmbcs) (far *lef_c_copy_string)    ();
   lbool        (far *lef_make_lmhdl)       ();
} MiscTableType, *MiscTablePtr;

#endif /* L_ANSI_C */

#undef MISCTABLE_SKIP

#define LPI_MISC(func) (*((MiscTablePtr) LpiContext->Reserved3)->func)

#endif  /* LPIMISC_H */
