2 * fontconfig/src/fclist.c
4 * Copyright © 2000 Keith Packard
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the author(s) not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. The authors make no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
28 FcObjectTypeHash (register const char *str, register unsigned int len);
30 static const struct FcObjectTypeInfo *
31 FcObjectTypeLookup (register const char *str, register unsigned int len);
33 #include "fcobjshash.h"
37 /* The 1000 is to leave some room for future added internal objects, such
38 * that caches from newer fontconfig can still be used with older fontconfig
39 * without getting confused. */
40 static fc_atomic_int_t next_id = FC_MAX_BASE_OBJECT + FC_EXT_OBJ_INDEX;
41 struct FcObjectOtherTypeInfo {
42 struct FcObjectOtherTypeInfo *next;
48 _FcObjectLookupOtherTypeByName (const char *str, FcObject *id)
50 struct FcObjectOtherTypeInfo *ots, *ot;
53 ots = fc_atomic_ptr_get (&other_types);
55 for (ot = ots; ot; ot = ot->next)
56 if (0 == strcmp (ot->object.object, str))
61 ot = malloc (sizeof (*ot));
65 ot->object.object = (const char *) FcStrdup (str);
66 ot->object.type = FcTypeUnknown;
67 ot->id = fc_atomic_int_add (next_id, +1);
70 if (!fc_atomic_ptr_cmpexch (&other_types, ots, ot)) {
83 FcObjectLookupBuiltinIdByName (const char *str)
85 const struct FcObjectTypeInfo *o = FcObjectTypeLookup (str, strlen (str));
94 FcObjectLookupIdByName (const char *str)
96 const struct FcObjectTypeInfo *o = FcObjectTypeLookup (str, strlen (str));
101 if (_FcObjectLookupOtherTypeByName (str, &id))
108 FcObjectLookupOtherNameById (FcObject id)
110 struct FcObjectOtherTypeInfo *ot;
112 for (ot = fc_atomic_ptr_get (&other_types); ot; ot = ot->next)
114 return ot->object.object;
120 FcObjectLookupOtherTypeByName (const char *str)
122 return _FcObjectLookupOtherTypeByName (str, NULL);
125 FcPrivate const FcObjectType *
126 FcObjectLookupOtherTypeById (FcObject id)
128 struct FcObjectOtherTypeInfo *ot;
130 for (ot = fc_atomic_ptr_get (&other_types); ot; ot = ot->next)
138 #include "fcaliastail.h"