1 /* xstart.c start session
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_session_start (Gsasl_ctx
*ctx
,
27 Gsasl_session_ctx
**xctx
,
33 *xctx
= (Gsasl_session_ctx
*) malloc(sizeof(**xctx
));
35 return GSASL_MALLOC_ERROR
;
37 memset(*xctx
, 0, sizeof(**xctx
));
39 for (i
= 0; i
< (clientp
? ctx
->n_client_mechs
: ctx
->n_server_mechs
); i
++)
41 if (mech
&& ((clientp
&& strcmp(mech
, ctx
->client_mechs
[i
].name
) == 0) ||
42 (!clientp
&& strcmp(mech
, ctx
->server_mechs
[i
].name
) == 0)))
45 (*xctx
)->mech
= &ctx
->client_mechs
[i
];
47 (*xctx
)->mech
= &ctx
->server_mechs
[i
];
52 if ((*xctx
)->mech
== NULL
)
56 return GSASL_UNKNOWN_MECHANISM
;
60 (*xctx
)->mech_data
= NULL
;
62 res
= (*xctx
)->mech
->client
.start(*xctx
, &(*xctx
)->mech_data
);
64 res
= (*xctx
)->mech
->server
.start(*xctx
, &(*xctx
)->mech_data
);
78 * @ctx: libgsasl handle.
79 * @mech: name of SASL mechanism.
80 * @xctx: pointer to client handle.
82 * This functions initiates a client SASL authentication. This
83 * function must be called before any other gsasl_client_*() function
86 * Return value: Returns GSASL_OK if successful, or error code.
89 gsasl_client_start (Gsasl_ctx
*ctx
,
91 Gsasl_session_ctx
**xctx
)
93 return _gsasl_session_start (ctx
, mech
, xctx
, 1);
98 * @ctx: libgsasl handle.
99 * @mech: name of SASL mechanism.
100 * @xctx: pointer to server handle.
102 * This functions initiates a server SASL authentication. This
103 * function must be called before any other gsasl_server_*() function
106 * Return value: Returns GSASL_OK if successful, or error code.
109 gsasl_server_start (Gsasl_ctx
*ctx
,
111 Gsasl_session_ctx
**xctx
)
113 return _gsasl_session_start (ctx
, mech
, xctx
, 0);