File: authsaslclient.c

package info (click to toggle)
courier-authlib 0.58-4%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 16,212 kB
  • ctags: 1,896
  • sloc: ansic: 21,550; sh: 14,071; makefile: 866; perl: 842; cpp: 284
file content (59 lines) | stat: -rw-r--r-- 1,266 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* $Id: authsaslclient.c,v 1.4 2004/10/23 17:31:22 mrsam Exp $ */

/*
** Copyright 2000 Double Precision, Inc.  See COPYING for
** distribution information.
*/

#include	"courier_auth_config.h"
#include	"courierauthsasl.h"
#include	"authsaslclient.h"
#include	<stdlib.h>
#include	<stdio.h>
#include	<ctype.h>
#include	<string.h>
#include	<errno.h>

/* Use the SASL_LIST macro to build authsaslclientlist */

#define	SASL(a,b,c) {a, c},

struct authsaslclientlist_info authsaslclientlist[] = {

SASL_LIST

	{ 0, 0}};

int auth_sasl_client(const struct authsaslclientinfo *info)
{
char *methodbuf;
int	i;

	if (!info->sasl_funcs
	    ||!info->conv_func
	    ||!info->start_conv_func
	    || !info->plain_conv_func)	return (AUTHSASL_NOMETHODS);

	if ((methodbuf=malloc(strlen(info->sasl_funcs)+1)) == 0)
	{
		perror("malloc");
		return (AUTHSASL_NOMETHODS);
	}

	for (i=0; authsaslclientlist[i].name; i++)
	{
	char	*p;

		strcpy(methodbuf, info->sasl_funcs);
		for (p=methodbuf; *p; p++)
			*p=toupper((int)(unsigned char)*p);
		for (p=methodbuf; (p=strtok(p, " \t\r\n")) != 0; p=0)
			if (strcmp(p, authsaslclientlist[i].name) == 0)
			{
				free(methodbuf);
				return ( (*authsaslclientlist[i].func)(info));
			}
	}
	free(methodbuf);
	return (AUTHSASL_NOMETHODS);
}