1/* 2 * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 * 9 */ 10 11#include <sm/gen.h> |
12SM_RCSID("@(#)$Id: sfsasl.c,v 8.91.2.2 2002/09/12 21:07:50 ca Exp $") |
13#include <stdlib.h> 14#include <sendmail.h> 15#include <errno.h> 16#if SASL 17# include "sfsasl.h" 18 19/* Structure used by the "sasl" file type */ 20struct sasl_obj --- 151 unchanged lines hidden (view full) --- 172sasl_read(fp, buf, size) 173 SM_FILE_T *fp; 174 char *buf; 175 size_t size; 176{ 177 int result; 178 ssize_t len; 179# if SASL >= 20000 |
180 static const char *outbuf = NULL; |
181# else /* SASL >= 20000 */ 182 static char *outbuf = NULL; 183# endif /* SASL >= 20000 */ 184 static unsigned int outlen = 0; 185 static unsigned int offset = 0; 186 struct sasl_obj *so = (struct sasl_obj *) fp->f_cookie; 187 188 /* 189 ** sasl_decode() may require more data than a single read() returns. 190 ** Hence we have to put a loop around the decoding. 191 ** This also requires that we may have to split up the returned 192 ** data since it might be larger than the allowed size. 193 ** Therefore we use a static pointer and return portions of it 194 ** if necessary. 195 */ 196 |
197# if SASL >= 20000 198 while (outlen == 0) 199# else /* SASL >= 20000 */ |
200 while (outbuf == NULL && outlen == 0) |
201# endif /* SASL >= 20000 */ |
202 { 203 len = sm_io_read(so->fp, SM_TIME_DEFAULT, buf, size); 204 if (len <= 0) 205 return len; 206 result = sasl_decode(so->conn, buf, 207 (unsigned int) len, &outbuf, &outlen); 208 if (result != SASL_OK) 209 { --- 534 unchanged lines hidden --- |