home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / server / PEX / include / pexUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-15  |  2.6 KB  |  79 lines

  1. /* $XConsortium: pexUtils.h,v 5.1 91/02/16 09:57:36 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ******************************************************************/
  26.  
  27. #ifndef PEXUTILS_H
  28. #define PEXUTILS_H
  29.  
  30. #include "ddpex.h"
  31.  
  32. /* declarations for the utilities in pexUtils.c */
  33. extern listofObj  *puCreateList();
  34. extern void    puDeleteList();
  35. extern short    puInList();
  36. extern short    puAddToList();
  37. extern short    puRemoveFromList();
  38. extern short    puCopyList();
  39. extern short    puMergeLists();
  40. extern int    puBuffRealloc();
  41. extern void    puInitList();
  42. extern int    puCountList();
  43.  
  44. /* useful macros to use with lists */
  45. #define PU_TRUE    1
  46. #define PU_FALSE 0
  47.  
  48. #define    PU_BAD_LIST    -1    /* error returned by list utilities */
  49.  
  50. #define PU_EMPTY_LIST( plist )  \
  51.     (plist)->numObj = 0
  52.  
  53. #define PU_REMOVE_LAST_OBJ( plist )     \
  54.     if ( (plist)->numObj > 0 )      (plist)->numObj--
  55.  
  56. /* useful macros to use with ddBuffer */
  57. #define PU_BUF_HDR_SIZE(pBuffer) \
  58.     (int) (((char *) pBuffer->pBuf) - ((char *) pBuffer->pHead))
  59.  
  60. #define PU_BUF_TOO_SMALL(pBuffer,minSize) \
  61.     ((minSize) > ((pBuffer->bufSize) - PU_BUF_HDR_SIZE(pBuffer) + 1))
  62.  
  63. #define PU_CHECK_BUFFER_SIZE( pBuffer, size )                 \
  64.     if ( PU_BUF_TOO_SMALL((pBuffer), (size)) )                \
  65.     if (puBuffRealloc((pBuffer), (ddULONG)(size)) != Success )    \
  66.     {                                \
  67.         (pBuffer)->dataSize = 0;                    \
  68.         return( BadAlloc );                        \
  69.         }
  70.  
  71. /*
  72.     useful macro for ensuring that lists of shorts allocate full longwords
  73.  */
  74. #define MAKE_EVEN(_n)  \
  75.     ( (_n)%2 ? (_n)+1 : (_n) )
  76.  
  77.  
  78. #endif    /* PEXUTILS_H */
  79.