[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/src
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/src |
Date: |
Thu, 30 Sep 2004 17:34:51 +0200 |
Update of /home/cvs/gsasl/lib/src
In directory dopio:/tmp/cvs-serv26035/lib/src
Modified Files:
callback.c gsasl.h.in internal.h property.c
Log Message:
Simplify callbacks, now there is only one application callback (the global).
--- /home/cvs/gsasl/lib/src/callback.c 2004/09/30 13:50:28 1.10
+++ /home/cvs/gsasl/lib/src/callback.c 2004/09/30 15:34:51 1.11
@@ -23,80 +23,40 @@
/**
* gsasl_callback_set:
- * @sctx: session handle.
- * @cb: pointer to function implemented by application.
- *
- * Store the pointer to the application provided callback in the
- * session specific handle. The callback will be used, via
- * gsasl_callback(), by mechanisms to discover various parameters
- * (such as username and passwords). The callback function will be
- * called with a Gsasl_property value indicating the requested
- * behaviour. For example, for GSASL_CLIENT_ANONYMOUS, the function
- * is expected to invoke gsasl_property_set(SCTX,
- * GSASL_CLIENT_ANONYMOUS, "token") where "token" is the anonymous
- * token the application wishes the SASL mechanism to use. See the
- * manual for the meaning of all parameters.
- *
- * It is valid, but may be confusing at first, to set different
- * callbacks using gsasl_callback_set() and
- * gsasl_callback_set_global(). Normally the session specific
- * callback (i.e., the one set by gsasl_callback_set()) will be used
- * by mechanisms, with a fall back to the global callback if a session
- * specific callback has not been set. You can use this to set a
- * general global callback handler that apply to most sessions, but
- * for some specific sessions you can override the callback with a
- * different function.
- **/
-void
-gsasl_callback_set (Gsasl_session * sctx, Gsasl_callback_function cb)
-{
- sctx->cb = cb;
-}
-
-/**
- * gsasl_callback_set_global:
* @ctx: handle received from gsasl_init().
* @cb: pointer to function implemented by application.
*
* Store the pointer to the application provided callback in the
- * library handle. The callback will be used, via gsasl_callback()
- * and gsasl_callback_global(), by mechanisms to discover various
- * parameters (such as username and passwords). The callback function
- * will be called with a Gsasl_property value indicating the requested
- * behaviour. For example, for GSASL_CLIENT_ANONYMOUS, the function
- * is expected to invoke gsasl_property_set_global(CTX,
- * GSASL_CLIENT_ANONYMOUS, "token") where "token" is the anonymous
- * token the application wishes the SASL mechanism to use. See the
- * manual for the meaning of all parameters.
- *
- * It is valid, but may be confusing at first, to set different
- * callbacks using gsasl_callback_set() and
- * gsasl_callback_set_global(). Normally the session specific
- * callback (i.e., the one set by gsasl_callback_set()) will be used
- * by mechanisms, with a fall back to the global callback if a session
- * specific callback has not been set. You can use this to set a
- * general global callback handler that apply to most sessions, but
- * for some specific sessions you can override the callback with a
- * different function.
+ * library handle. The callback will be used, via gsasl_callback(),
+ * by mechanisms to discover various parameters (such as username and
+ * passwords). The callback function will be called with a
+ * Gsasl_property value indicating the requested behaviour. For
+ * example, for GSASL_CLIENT_ANONYMOUS, the function is expected to
+ * invoke gsasl_property_set_global(CTX, GSASL_CLIENT_ANONYMOUS,
+ * "token") where "token" is the anonymous token the application
+ * wishes the SASL mechanism to use. See the manual for the meaning
+ * of all parameters.
**/
void
-gsasl_callback_set_global (Gsasl * ctx, Gsasl_callback_function cb)
+gsasl_callback_set (Gsasl * ctx, Gsasl_callback_function cb)
{
ctx->cb = cb;
}
/**
* gsasl_callback:
+ * @ctx: handle received from gsasl_init(), may be NULL to derive it
+ * from @sctx.
* @sctx: session handle.
* @prop: enumerated value of Gsasl_property type.
*
- * Invoke the session specific application callback, with a fall back
- * to the global callback. The @prop value indicate what the callback
- * is expected to do. For example, for GSASL_CLIENT_ANONYMOUS, the
- * function is expected to invoke gsasl_property_set(SCTX,
- * GSASL_CLIENT_ANONYMOUS, "token") where "token" is the anonymous
- * token the application wishes the SASL mechanism to use. See the
- * manual for the meaning of all parameters.
+ * Invoke the application callback. The @prop value indicate what the
+ * callback is expected to do. For example, for
+ * GSASL_CLIENT_ANONYMOUS, the function is expected to invoke
+ * gsasl_property_set(SCTX, GSASL_CLIENT_ANONYMOUS, "token") where
+ * "token" is the anonymous token the application wishes the SASL
+ * mechanism to use. See the manual for the meaning of all
+ * parameters.
*
* Note that if no callback has been set by the application, but the
* obsolete callback interface has been used, this function will
@@ -107,13 +67,16 @@
* GSASL_NO_CALLBACK if no application was known.
**/
int
-gsasl_callback (Gsasl_session * sctx, Gsasl_property prop)
+gsasl_callback (Gsasl * ctx, Gsasl_session * sctx, Gsasl_property prop)
{
- if (sctx->cb)
- return sctx->cb (sctx->ctx, sctx, prop);
+ if (ctx == NULL && sctx == NULL)
+ return GSASL_NO_CALLBACK;
- if (sctx->ctx->cb)
- return sctx->ctx->cb (sctx->ctx, sctx, prop);
+ if (ctx == NULL)
+ ctx = sctx->ctx;
+
+ if (ctx->cb)
+ return ctx->cb (ctx, sctx, prop);
{
/* Call obsolete callbacks. Remove this when the obsolete
@@ -167,31 +130,6 @@
}
/**
- * gsasl_callback_global:
- * @ctx: handle received from gsasl_init().
- * @prop: enumerated value of Gsasl_property type.
- *
- * Invoke the handle global application callback. The @prop value
- * indicate what the callback is expected to do. For example, for
- * GSASL_CLIENT_ANONYMOUS, the function is expected to invoke
- * gsasl_property_set(SCTX, GSASL_CLIENT_ANONYMOUS, "token") where
- * "token" is the anonymous token the application wishes the SASL
- * mechanism to use. See the manual for the meaning of all
- * parameters.
- *
- * Return value: Returns whatever the application callback return, or
- * GSASL_NO_CALLBACK if no application was known.
- **/
-int
-gsasl_callback_global (Gsasl * ctx, Gsasl_property prop)
-{
- if (ctx->cb)
- return ctx->cb (ctx, NULL, prop);
-
- return GSASL_NO_CALLBACK;
-}
-
-/**
* gsasl_application_data_set:
* @ctx: libgsasl handle.
* @appdata: opaque pointer to application specific data.
--- /home/cvs/gsasl/lib/src/gsasl.h.in 2004/09/30 14:44:15 1.31
+++ /home/cvs/gsasl/lib/src/gsasl.h.in 2004/09/30 15:34:51 1.32
@@ -183,12 +183,9 @@
extern void *gsasl_application_data_get (Gsasl * ctx);
extern void gsasl_appinfo_set (Gsasl_session * sctx, void *appdata);
extern void *gsasl_appinfo_get (Gsasl_session * sctx);
- extern void gsasl_callback_set (Gsasl_session * sctx,
- Gsasl_callback_function cb);
- extern void gsasl_callback_set_global (Gsasl * ctx,
- Gsasl_callback_function cb);
- extern int gsasl_callback (Gsasl_session * sctx, Gsasl_property prop);
- extern int gsasl_callback_global (Gsasl * ctx, Gsasl_property prop);
+ extern void gsasl_callback_set (Gsasl * ctx, Gsasl_callback_function cb);
+ extern int gsasl_callback (Gsasl * ctx, Gsasl_session * sctx,
+ Gsasl_property prop);
/* Property handling: property.c */
extern void gsasl_property_set (Gsasl_session * sctx, Gsasl_property prop,
--- /home/cvs/gsasl/lib/src/internal.h 2004/09/24 00:38:10 1.16
+++ /home/cvs/gsasl/lib/src/internal.h 2004/09/30 15:34:51 1.17
@@ -43,7 +43,7 @@
size_t n_server_mechs;
Gsasl_mechanism *server_mechs;
void *application_data;
- /* Global callback. */
+ /* Callback. */
Gsasl_callback_function cb;
/* Global properties. */
char *anonymous_token;
@@ -87,9 +87,6 @@
Gsasl_mechanism *mech;
void *application_data;
void *mech_data;
- /* Session specific callback. If NULL, use global callback in
- * ctx->cb. */
- Gsasl_callback_function cb;
/* Session specific properties. If NULL, use corresponding global
* property. */
char *anonymous_token;
--- /home/cvs/gsasl/lib/src/property.c 2004/09/30 13:51:41 1.9
+++ /home/cvs/gsasl/lib/src/property.c 2004/09/30 15:34:51 1.10
@@ -266,7 +266,7 @@
if (!p)
{
- gsasl_callback (sctx, prop);
+ gsasl_callback (NULL, sctx, prop);
p = gsasl_property_fast (sctx, prop);
}
@@ -387,7 +387,7 @@
if (!p)
{
- gsasl_callback_global (ctx, prop);
+ gsasl_callback (ctx, NULL, prop);
p = gsasl_property_fast_global (ctx, prop);
}
- CVS gsasl/lib/src, (continued)
- CVS gsasl/lib/src, gsasl-commit, 2004/09/24
- CVS gsasl/lib/src, gsasl-commit, 2004/09/24
- CVS gsasl/lib/src, gsasl-commit, 2004/09/24
- CVS gsasl/lib/src, gsasl-commit, 2004/09/24
- CVS gsasl/lib/src, gsasl-commit, 2004/09/24
- CVS gsasl/lib/src, gsasl-commit, 2004/09/26
- CVS gsasl/lib/src, gsasl-commit, 2004/09/30
- CVS gsasl/lib/src, gsasl-commit, 2004/09/30
- CVS gsasl/lib/src, gsasl-commit, 2004/09/30
- CVS gsasl/lib/src, gsasl-commit, 2004/09/30
- CVS gsasl/lib/src,
gsasl-commit <=
- CVS gsasl/lib/src, gsasl-commit, 2004/09/30
- CVS gsasl/lib/src, gsasl-commit, 2004/09/30