gsasl
2.2.1
lib
src
register.c
Go to the documentation of this file.
1
/* register.c --- Initialize and register SASL plugin in global context.
2
* Copyright (C) 2002-2024 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 <config.h>
24
#include "
internal.h
"
25
38
int
39
gsasl_register
(
Gsasl
*ctx,
const
Gsasl_mechanism
*mech)
40
{
41
Gsasl_mechanism
*tmp;
42
43
#ifdef USE_CLIENT
44
if
(mech->
client
.
init
== NULL || mech->
client
.
init
(ctx) ==
GSASL_OK
)
45
{
46
tmp = realloc (ctx->
client_mechs
,
47
sizeof (*ctx->
client_mechs
) * (ctx->
n_client_mechs
+ 1));
48
if
(tmp == NULL)
49
return
GSASL_MALLOC_ERROR
;
50
51
memcpy (&tmp[ctx->
n_client_mechs
], mech, sizeof (*mech));
52
53
ctx->
client_mechs
= tmp;
54
ctx->
n_client_mechs
++;
55
}
56
#endif
57
58
#ifdef USE_SERVER
59
if
(mech->
server
.
init
== NULL || mech->
server
.
init
(ctx) ==
GSASL_OK
)
60
{
61
tmp = realloc (ctx->
server_mechs
,
62
sizeof (*ctx->
server_mechs
) * (ctx->
n_server_mechs
+ 1));
63
if
(tmp == NULL)
64
return
GSASL_MALLOC_ERROR
;
65
66
memcpy (&tmp[ctx->
n_server_mechs
], mech, sizeof (*mech));
67
68
ctx->
server_mechs
= tmp;
69
ctx->
n_server_mechs
++;
70
}
71
#endif
72
73
return
GSASL_OK
;
74
}
GSASL_OK
@ GSASL_OK
Definition:
gsasl.h:129
GSASL_MALLOC_ERROR
@ GSASL_MALLOC_ERROR
Definition:
gsasl.h:133
internal.h
gsasl_register
int gsasl_register(Gsasl *ctx, const Gsasl_mechanism *mech)
Definition:
register.c:39
Gsasl_mechanism_functions::init
Gsasl_init_function init
Definition:
gsasl-mech.h:153
Gsasl_mechanism
Definition:
gsasl-mech.h:172
Gsasl_mechanism::server
struct Gsasl_mechanism_functions server
Definition:
gsasl-mech.h:176
Gsasl_mechanism::client
struct Gsasl_mechanism_functions client
Definition:
gsasl-mech.h:175
Gsasl
Definition:
internal.h:37
Gsasl::n_client_mechs
size_t n_client_mechs
Definition:
internal.h:38
Gsasl::server_mechs
Gsasl_mechanism * server_mechs
Definition:
internal.h:41
Gsasl::client_mechs
Gsasl_mechanism * client_mechs
Definition:
internal.h:39
Gsasl::n_server_mechs
size_t n_server_mechs
Definition:
internal.h:40
Generated by
1.9.1