| 1 | /* $Id: authsaslclientlogin.c,v 1.2 2004/10/21 00:10:49 mrsam Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | ** Copyright 2000 Double Precision, Inc. See COPYING for |
| 5 | ** distribution information. |
| 6 | */ |
| 7 | |
| 8 | #include "courier_auth_config.h" |
| 9 | #include "courierauthsasl.h" |
| 10 | #include "authsaslclient.h" |
| 11 | #include <stdlib.h> |
| 12 | #include <stdio.h> |
| 13 | #include <ctype.h> |
| 14 | #include <string.h> |
| 15 | #include <errno.h> |
| 16 | |
| 17 | int authsaslclient_login(const struct authsaslclientinfo *info) |
| 18 | { |
| 19 | const char *p; |
| 20 | char *q; |
| 21 | int i; |
| 22 | |
| 23 | p=(*info->start_conv_func)("LOGIN", NULL, info->conv_func_arg); |
| 24 | if (!p) return (AUTHSASL_CANCELLED); |
| 25 | |
| 26 | q=authsasl_tobase64( info->userid ? info->userid:"", -1); |
| 27 | |
| 28 | if (!q) |
| 29 | { |
| 30 | perror("malloc"); |
| 31 | return (AUTHSASL_ERROR); |
| 32 | } |
| 33 | p=(*info->conv_func)(q, info->conv_func_arg); |
| 34 | free(q); |
| 35 | if (!p) return (AUTHSASL_CANCELLED); |
| 36 | |
| 37 | q=authsasl_tobase64( info->password ? info->password:"", -1); |
| 38 | |
| 39 | if (!q) |
| 40 | { |
| 41 | perror("malloc"); |
| 42 | return (AUTHSASL_ERROR); |
| 43 | } |
| 44 | i=(*info->final_conv_func)(q, info->conv_func_arg); |
| 45 | free(q); |
| 46 | return (i); |
| 47 | } |