callback.c

Go to the documentation of this file.
00001 /* callback.c --- Callback handling.
00002  * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008  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 
00049 #ifndef GSASL_NO_OBSOLETE
00050 /* Declared in obsolete.c. */
00051 int _gsasl_obsolete_callback (Gsasl * ctx, Gsasl_session * sctx,
00052                               Gsasl_property prop);
00053 #endif
00054 
00080 int
00081 gsasl_callback (Gsasl * ctx, Gsasl_session * sctx, Gsasl_property prop)
00082 {
00083   if (ctx == NULL && sctx == NULL)
00084     return GSASL_NO_CALLBACK;
00085 
00086   if (ctx == NULL)
00087     ctx = sctx->ctx;
00088 
00089   if (ctx->cb)
00090     return ctx->cb (ctx, sctx, prop);
00091 
00092 #ifndef GSASL_NO_OBSOLETE
00093   return _gsasl_obsolete_callback (ctx, sctx, prop);
00094 #endif
00095 
00096   return GSASL_NO_CALLBACK;
00097 }
00098 
00113 void
00114 gsasl_callback_hook_set (Gsasl * ctx, void *hook)
00115 {
00116   ctx->application_hook = hook;
00117 }
00118 
00133 void *
00134 gsasl_callback_hook_get (Gsasl * ctx)
00135 {
00136   return ctx->application_hook;
00137 }
00138 
00153 void
00154 gsasl_session_hook_set (Gsasl_session * sctx, void *hook)
00155 {
00156   sctx->application_hook = hook;
00157 }
00158 
00173 void *
00174 gsasl_session_hook_get (Gsasl_session * sctx)
00175 {
00176   return sctx->application_hook;
00177 }

Generated on Tue Oct 21 18:28:18 2008 for gsasl by  doxygen 1.5.6