gsasl  1.8.0
callback.c
Go to the documentation of this file.
00001 /* callback.c --- Callback handling.
00002  * Copyright (C) 2002-2012 Simon Josefsson
00003  *
00004  * This file is part of GNU SASL Library.
00005  *
00006  * GNU SASL Library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation; either version 2.1 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * GNU SASL Library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License License along with GNU SASL Library; if not, write to the
00018  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "internal.h"
00024 
00043 void
00044 gsasl_callback_set (Gsasl * ctx, Gsasl_callback_function cb)
00045 {
00046   ctx->cb = cb;
00047 }
00048 
00074 int
00075 gsasl_callback (Gsasl * ctx, Gsasl_session * sctx, Gsasl_property prop)
00076 {
00077   if (ctx == NULL && sctx == NULL)
00078     return GSASL_NO_CALLBACK;
00079 
00080   if (ctx == NULL)
00081     ctx = sctx->ctx;
00082 
00083   if (ctx->cb)
00084     return ctx->cb (ctx, sctx, prop);
00085 
00086 #ifndef GSASL_NO_OBSOLETE
00087   return _gsasl_obsolete_callback (ctx, sctx, prop);
00088 #endif
00089 
00090   return GSASL_NO_CALLBACK;
00091 }
00092 
00107 void
00108 gsasl_callback_hook_set (Gsasl * ctx, void *hook)
00109 {
00110   ctx->application_hook = hook;
00111 }
00112 
00127 void *
00128 gsasl_callback_hook_get (Gsasl * ctx)
00129 {
00130   return ctx->application_hook;
00131 }
00132 
00147 void
00148 gsasl_session_hook_set (Gsasl_session * sctx, void *hook)
00149 {
00150   sctx->application_hook = hook;
00151 }
00152 
00167 void *
00168 gsasl_session_hook_get (Gsasl_session * sctx)
00169 {
00170   return sctx->application_hook;
00171 }