00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "internal.h"
00024
00036 const char *
00037 gsasl_client_suggest_mechanism (Gsasl * ctx, const char *mechlist)
00038 {
00039 size_t mechlist_len, target_mech, i;
00040
00041 mechlist_len = mechlist ? strlen (mechlist) : 0;
00042 target_mech = ctx->n_client_mechs;
00043
00044 for (i = 0; i < mechlist_len;)
00045 {
00046 size_t len;
00047
00048 len = strspn (mechlist + i, GSASL_VALID_MECHANISM_CHARACTERS);
00049 if (!len)
00050 ++i;
00051 else
00052 {
00053 size_t j;
00054
00055
00056
00057 for (j = (target_mech < ctx->n_client_mechs ? target_mech + 1 : 0);
00058 j < ctx->n_client_mechs; ++j)
00059 {
00060 if (strncmp (ctx->client_mechs[j].name, mechlist + i, len) == 0)
00061 {
00062 Gsasl_session *sctx;
00063
00064 if (gsasl_client_start (ctx, ctx->client_mechs[j].name,
00065 &sctx) == GSASL_OK)
00066 {
00067 gsasl_finish (sctx);
00068 target_mech = j;
00069 }
00070
00071 break;
00072 }
00073 }
00074 i += len + 1;
00075 }
00076 }
00077
00078 return target_mech < ctx->n_client_mechs ?
00079 ctx->client_mechs[target_mech].name : NULL;
00080 }