1 #ifndef	courierauthsaslclient_h
2 #define	courierauthsaslclient_h
3 
4 /*
5 ** Copyright 2000-2004 Double Precision, Inc.  See COPYING for
6 ** distribution information.
7 */
8 
9 #include	"courierauthsasl.h"
10 #include	<sys/types.h>
11 
12 #ifdef	__cplusplus
13 extern "C" {
14 #endif
15 
16 
17 /*
18 	These family of functions are used to implement the SASL client
19 	interface on top of authlib.
20 */
21 
22 
23 /*
24 **  The authsaslclientinfo structure is initialized by the sasl client.
25 **  It's the sole argument to authsaslclient().
26 */
27 
28 struct authsaslclientinfo {
29 
30 	const char *userid;		/* Usually required */
31 	const char *password;		/* Usually required */
32 
33 	const char *sasl_funcs;		/* A list of SASL methods supported
34 					** by the server, space-separated.
35 					*/
36 
37 	const char *(*start_conv_func)(const char *, const char *, void *);
38 			/*
39 			** Start SASL conversation.  First argument is the
40 			** SASL method name.  The second argument is the
41 			** initial message to send to the SASL server, base64-
42 			** encoded, or NULL if there is no initial message.
43 			*/
44 
45 	const char *(*conv_func)(const char *, void *);
46 			/* The conversation function.  It receives a base64
47 			** string to send to the server, and returns a
48 			** base64 response (or NULL of there was an error).
49 			*/
50 
51 	int (*final_conv_func)(const char *, void *);
52 			/*
53 			** The "final" base64 message to send to the server.
54 			*/
55 
56 	int (*plain_conv_func)(const char *, const char *, void *);
57 			/*
58 			** plain_conv_func is used when the SASL method is
59 			** a simple method involving a single message, like
60 			** PLAIN.  plain_conv_func is basically a merge between
61 			** start_conv_func and final_conv_func, a one-shot
62 			** deal.
63 			*/
64 
65 	void *conv_func_arg;	/* Callback argument to conv_func */
66 	} ;
67 
68 int auth_sasl_client(const struct authsaslclientinfo *);
69 	/* Returns 0 for success, non zero for failure */
70 
71 /* Additional error codes */
72 
73 #define	AUTHSASL_NOMETHODS	-3
74 #define	AUTHSASL_CANCELLED	-4
75 
76 #ifdef	__cplusplus
77 }
78 #endif
79 
80 #endif
81