gsasl  2.2.2
callback.c
Go to the documentation of this file.
1 /* callback.c --- Callback handling.
2  * Copyright (C) 2002-2025 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 along with GNU SASL Library; if not, see
18  * <https://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #include <config.h>
23 #include "internal.h"
24 
43 void
45 {
46  ctx->cb = cb;
47 }
48 
69 int
71 {
72  if (ctx == NULL && sctx == NULL)
73  return GSASL_NO_CALLBACK;
74 
75  if (ctx == NULL)
76  ctx = sctx->ctx;
77 
78  if (ctx->cb)
79  return ctx->cb (ctx, sctx, prop);
80 
81  return GSASL_NO_CALLBACK;
82 }
83 
98 void
99 gsasl_callback_hook_set (Gsasl *ctx, void *hook)
100 {
101  ctx->application_hook = hook;
102 }
103 
118 void *
120 {
121  return ctx->application_hook;
122 }
123 
138 void
140 {
141  sctx->application_hook = hook;
142 }
143 
158 void *
160 {
161  return sctx->application_hook;
162 }
void gsasl_callback_set(Gsasl *ctx, Gsasl_callback_function cb)
Definition: callback.c:44
void gsasl_session_hook_set(Gsasl_session *sctx, void *hook)
Definition: callback.c:139
void * gsasl_callback_hook_get(Gsasl *ctx)
Definition: callback.c:119
void * gsasl_session_hook_get(Gsasl_session *sctx)
Definition: callback.c:159
int gsasl_callback(Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop)
Definition: callback.c:70
void gsasl_callback_hook_set(Gsasl *ctx, void *hook)
Definition: callback.c:99
int(* Gsasl_callback_function)(Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop)
Definition: gsasl.h:285
@ GSASL_NO_CALLBACK
Definition: gsasl.h:141
Gsasl_property
Definition: gsasl.h:221
void * application_hook
Definition: internal.h:53
Gsasl * ctx
Definition: internal.h:49
Definition: internal.h:36
void * application_hook
Definition: internal.h:43
Gsasl_callback_function cb
Definition: internal.h:42