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