Initial release, version 0.0.0.
[gsasl.git] / lib / supportp.c
blobd34664df31f3dc2957d1f6aaf1b422ffecca938a
1 /* supportp.c tell if a specific mechanism is support by the client or server
2 * Copyright (C) 2002 Simon Josefsson
4 * This file is part of libgsasl.
6 * Libgsasl is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libgsasl is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with libgsasl; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "internal.h"
24 static int
25 _gsasl_support_p (_Gsasl_mechanism *mechs, size_t n_mechs, const char *name)
27 int i;
29 for (i = 0; i < n_mechs; i++)
30 if (name && strcmp(name, mechs[i].name) == 0)
31 return 1;
33 return 0;
36 /**
37 * gsasl_client_support_p:
38 * @ctx: libgsasl handle.
39 * @name: name of SASL mechanism.
41 * Return value: Returns 1 if the libgsasl client supports the named
42 * mechanism, otherwise 0.
43 **/
44 int
45 gsasl_client_support_p (Gsasl_ctx *ctx, const char *name)
47 return _gsasl_support_p (ctx->client_mechs, ctx->n_client_mechs, name);
50 /**
51 * gsasl_server_support_p:
52 * @ctx: libgsasl handle.
53 * @name: name of SASL mechanism.
55 * Return value: Returns 1 if the libgsasl server supports the named
56 * mechanism, otherwise 0.
57 **/
58 int
59 gsasl_server_support_p (Gsasl_ctx *ctx, const char *name)
61 return _gsasl_support_p (ctx->server_mechs, ctx->n_server_mechs, name);