2 * g_mechname.c --- registry of mechanism-specific name types
4 * This file contains a registry of mechanism-specific name types. It
5 * is used to determine which name types not should be lazy evaluated,
6 * but rather evaluated on the spot.
18 #define g_OID_equal(o1,o2) \
19 (((o1)->length == (o2)->length) && \
20 (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0))
22 static gss_mech_spec_name name_list = NULL;
25 * generic searching helper function.
27 static gss_mech_spec_name search_mech_spec(name_type)
32 for (p = name_list; p; p = p->next) {
33 if (g_OID_equal(name_type, p->name_type))
40 * Given a name_type, if it is specific to a mechanism, return the
41 * mechanism OID. Otherwise, return NULL.
43 gss_OID gss_find_mechanism_from_name_type(name_type)
48 p = search_mech_spec(name_type);
55 * This function adds a (name_type, mechanism) pair to the
56 * mechanism-specific name type registry. If an entry for the
57 * name_type already exists, then zero out the mechanism entry.
58 * Otherwise, enter the pair into the registry.
61 gss_add_mech_name_type(minor_status, name_type, mech)
62 OM_uint32 *minor_status;
66 OM_uint32 major_status, tmp;
69 p = search_mech_spec(name_type);
72 * We found an entry for this name type; mark it as not being
73 * a mechanism-specific name type.
76 if (!g_OID_equal(mech, p->mech)) {
77 generic_gss_release_oid(minor_status, &p->mech);
81 return GSS_S_COMPLETE;
83 p = malloc(sizeof(gss_mech_spec_name_desc));
85 *minor_status = ENOMEM;
86 goto allocation_failure;
91 major_status = generic_gss_copy_oid(minor_status, name_type,
94 goto allocation_failure;
95 major_status = generic_gss_copy_oid(minor_status, mech,
98 goto allocation_failure;
104 return GSS_S_COMPLETE;
109 generic_gss_release_oid(&tmp, &p->mech);
111 generic_gss_release_oid(&tmp, &p->name_type);
114 return GSS_S_FAILURE;