| 1 | /* supportp.c --- Tell if a specific mechanism is supported. |
| 2 | * Copyright (C) 2002-2012 Simon Josefsson |
| 3 | * |
| 4 | * This file is part of GNU SASL Library. |
| 5 | * |
| 6 | * GNU SASL Library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public License |
| 8 | * as published by the Free Software Foundation; either version 2.1 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * GNU SASL Library 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. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License License along with GNU SASL Library; if not, write to the |
| 18 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include "internal.h" |
| 24 | |
| 25 | static int |
| 26 | _gsasl_support_p (Gsasl_mechanism * mechs, size_t n_mechs, const char *name) |
| 27 | { |
| 28 | size_t i; |
| 29 | |
| 30 | for (i = 0; i < n_mechs; i++) |
| 31 | if (name && strcmp (name, mechs[i].name) == 0) |
| 32 | return 1; |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * gsasl_client_support_p: |
| 39 | * @ctx: libgsasl handle. |
| 40 | * @name: name of SASL mechanism. |
| 41 | * |
| 42 | * Decide whether there is client-side support for a specified |
| 43 | * mechanism. |
| 44 | * |
| 45 | * Return value: Returns 1 if the libgsasl client supports the named |
| 46 | * mechanism, otherwise 0. |
| 47 | **/ |
| 48 | int |
| 49 | gsasl_client_support_p (Gsasl * ctx, const char *name) |
| 50 | { |
| 51 | return _gsasl_support_p (ctx->client_mechs, ctx->n_client_mechs, name); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * gsasl_server_support_p: |
| 56 | * @ctx: libgsasl handle. |
| 57 | * @name: name of SASL mechanism. |
| 58 | * |
| 59 | * Decide whether there is server-side support for a specified |
| 60 | * mechanism. |
| 61 | * |
| 62 | * Return value: Returns 1 if the libgsasl server supports the named |
| 63 | * mechanism, otherwise 0. |
| 64 | **/ |
| 65 | int |
| 66 | gsasl_server_support_p (Gsasl * ctx, const char *name) |
| 67 | { |
| 68 | return _gsasl_support_p (ctx->server_mechs, ctx->n_server_mechs, name); |
| 69 | } |
| 70 | |