1 /* Copyright (C) 2001-2019 Artifex Software, Inc. 2 All Rights Reserved. 3 4 This software is provided AS-IS with no warranty, either express or 5 implied. 6 7 This software is distributed under license and may not be copied, 8 modified or distributed except as expressly authorized under the terms 9 of the license contained in the file LICENSE in this distribution. 10 11 Refer to licensing information at http://www.artifex.com or contact 12 Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, 13 CA 94945, U.S.A., +1(415)492-9861, for further information. 14 */ 15 16 17 /* Unique id definitions for Ghostscript */ 18 19 #ifndef gsuid_INCLUDED 20 # define gsuid_INCLUDED 21 22 #include "std.h" 23 24 /* A unique id (uid) may be either a UniqueID or an XUID. */ 25 /* (XUIDs are a Level 2 feature.) */ 26 typedef struct gs_uid_s gs_uid; 27 struct gs_uid_s { 28 /* id >= 0 is a UniqueID, xvalues is 0. */ 29 /* id < 0 is an XUID, size of xvalues is -id. */ 30 long id; 31 long *xvalues; 32 }; 33 34 /* 35 * A UniqueID of no_UniqueID is an indication that there is no uid. 36 * Since we sometimes use gs_ids as UniqueIDs, we want to choose as large 37 * a (positive) value as possible for no_UniqueID. 38 */ 39 #define no_UniqueID max_long 40 #define uid_is_valid(puid)\ 41 ((puid)->id != no_UniqueID) 42 #define uid_set_invalid(puid)\ 43 ((puid)->id = no_UniqueID, (puid)->xvalues = 0) 44 #define uid_is_UniqueID(puid)\ 45 (((puid)->id & ~0xffffff) == 0) 46 #define uid_is_XUID(puid)\ 47 ((puid)->id < 0) 48 49 /* Initialize a uid. */ 50 #define uid_set_UniqueID(puid, idv)\ 51 ((puid)->id = idv, (puid)->xvalues = 0) 52 #define uid_set_XUID(puid, pvalues, siz)\ 53 ((puid)->id = -(long)(siz), (puid)->xvalues = pvalues) 54 55 /* Get the size and the data of an XUID. */ 56 #define uid_XUID_size(puid) ((uint)(-(puid)->id)) 57 #define uid_XUID_values(puid) ((puid)->xvalues) 58 59 /* Compare two uids for equality. */ 60 /* This could be a macro, but the Zortech compiler compiles it wrong. */ 61 bool uid_equal(const gs_uid *, const gs_uid *); /* in gsutil.c */ 62 63 /* Copy the XUID data for a uid, if needed, updating the uid in place. */ 64 int uid_copy(gs_uid *puid, gs_memory_t *mem, client_name_t cname); 65 66 /* Free the XUID array of a uid if necessary. */ 67 #define uid_free(puid, mem, cname)\ 68 gs_free_object(mem, (puid)->xvalues, cname) 69 70 #endif /* gsuid_INCLUDED */ 71