home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GSUID.H < prev    next >
Text File  |  1992-09-07  |  2KB  |  57 lines

  1. /* Copyright (C) 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gsuid.h */
  21. /* Unique id definitions for Ghostscript */
  22.  
  23. /* A unique id (uid) may be either a UniqueID or an XUID. */
  24. /* (XUIDs are a Level 2 feature.) */
  25. typedef struct gs_uid_s {
  26.     union {
  27.         long id;    /* UniqueID, size == 0 */
  28.         long *xvalues;    /* XUID, size != 0 */
  29.     } u;
  30.     ushort size;
  31. } gs_uid;
  32.  
  33. /* A UniqueID of -1 is an indication that there is no uid. */
  34. #define uid_is_valid(puid)\
  35.   !((puid)->size == 0 && (puid)->u.id == -1)
  36. #define uid_set_invalid(puid)\
  37.   ((puid)->size = 0, (puid)->u.id = -1)
  38.       
  39. /* Initialize a uid. */
  40. #define uid_set_UniqueID(puid, idv)\
  41.   ((puid)->size = 0, (puid)->u.id = idv)
  42. #define uid_set_XUID(puid, pvalues, siz)\
  43.   ((puid)->size = siz, (puid)->u.xvalues = pvalues)
  44.  
  45. /* Compare two uids for equality. */
  46. #define uid_equal(puid1, puid2)\
  47.   ((puid1)->size == (puid2)->size &&\
  48.    ((puid1)->size ?\
  49.     !memcmp((const char *)(puid1)->u.xvalues,\
  50.         (const char *)(puid2)->u.xvalues, (puid1)->size) :\
  51.     (puid1)->u.id == (puid2)->u.id))
  52.  
  53. /* Free the XUID array of a uid if necessary. */
  54. #define uid_free(puid, proc_free, cname)\
  55.   if ( (puid)->size )\
  56.     (proc_free)((char *)(puid)->u.xvalues, (puid)->size, sizeof(long), cname)
  57.