summaryrefslogtreecommitdiffstats
path: root/src/lib/gssapi/mechglue/get_mechanism.c
blob: ef600fd8da8715fcba5f2b913256b681cb7cc6ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ident  "@(#)get_mechanism.c 1.10     95/08/04 SMI"
/*
 *  given the mechs_array and a mechanism OID, return the 
 *  pointer to the mechanism, or NULL if that mechanism is
 *  not supported.  If the requested OID is NULL, then return
 *  the first mechanism.
 *
 * Copyright (c) 1995, by Sun Microsystems, Inc.
 * All rights reserved.
 */

#include "mglueP.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <string.h>

extern gss_mechanism *mechs_array;

gss_mechanism get_mechanism (gss_OID type)
{
    int	i;

    if (type == GSS_C_NULL_OID)
	return (mechs_array[0]);

    for (i=0; mechs_array[i]->mech_type.length != 0; i++) {
	if ((mechs_array[i]->mech_type.length == type->length) &&
	    (memcmp (mechs_array[i]->mech_type.elements, type->elements,
		     type->length) == 0)) {

	    return (mechs_array[i]);
	}
    }
    return NULL;
}