1 /* listmech.c list active client and server mechanisms
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
25 _gsasl_listmech (Gsasl_ctx
*ctx
,
26 _Gsasl_mechanism
*mechs
,
32 Gsasl_session_ctx
*xctx
;
38 *outlen
= n_mechs
* GSASL_MAX_MECHANISM_SIZE
;
42 if (outlen
== NULL
|| *outlen
== 0)
43 return GSASL_TOO_SMALL_BUFFER
;
46 for (i
= 0; i
< n_mechs
; i
++)
49 gsasl_client_start (ctx
, mechs
[i
].name
, &xctx
) == GSASL_OK
) ||
51 gsasl_server_start (ctx
, mechs
[i
].name
, &xctx
) == GSASL_OK
))
54 gsasl_client_finish (xctx
);
56 gsasl_server_finish (xctx
);
58 if (strlen(out
) + strlen(mechs
[i
].name
) + strlen(" ") >= *outlen
)
59 return GSASL_TOO_SMALL_BUFFER
;
61 strcat(out
, mechs
[i
].name
);
70 * gsasl_client_listmech:
71 * @ctx: libgsasl handle.
72 * @out: output character array.
73 * @outlen: input maximum size of output character array, on output
74 * contains actual length of output array.
76 * Write SASL names, separated by space, of mechanisms supported by
77 * the libgsasl client to the output array. To find out how large the
78 * output array must be, call this function with out=NULL.
80 * Return value: Returns GSASL_OK if successful, or error code.
83 gsasl_client_listmech (Gsasl_ctx
*ctx
, char *out
, size_t *outlen
)
85 return _gsasl_listmech (ctx
, ctx
->client_mechs
, ctx
->n_client_mechs
,
90 * gsasl_server_listmech:
91 * @ctx: libgsasl handle.
92 * @out: output character array.
93 * @outlen: input maximum size of output character array, on output
94 * contains actual length of output array.
96 * Write SASL names, separated by space, of mechanisms supported by
97 * the libgsasl server to the output array. To find out how large the
98 * output array must be, call this function with out=NULL.
100 * Return value: Returns GSASL_OK if successful, or error code.
103 gsasl_server_listmech (Gsasl_ctx
*ctx
, char *out
, size_t *outlen
)
105 return _gsasl_listmech (ctx
, ctx
->server_mechs
, ctx
->n_server_mechs
,