-
-
-#if 0
-static int
-putline (char *s, FILE *iop)
-{
-#ifdef CYRUS_SASL
- char outbuf[BUFSIZ], *buf;
- int result;
- unsigned int buflen;
-
- if (sasl_complete == 0 || sasl_ssf == 0) {
-#endif /* CYRUS_SASL */
-#ifdef TLS_SUPPORT
- if (tls_active) {
- int ret;
-
- BIO_printf(io, "%s\r\n");
- ret = BIO_flush(io);
-
- if (ret != 1) {
- strncpy(response, "lost connection", sizeof(response));
- return NOTOK;
- else {
- return OK;
- }
- } else
-#endif /* TLS_SUPPORT */
- fprintf (iop, "%s\r\n", s);
-#ifdef CYRUS_SASL
- } else {
- /*
- * Build an output buffer, encrypt it using sasl_encode, and
- * squirt out the results.
- */
- strncpy(outbuf, s, sizeof(outbuf) - 3);
- outbuf[sizeof(outbuf) - 3] = '\0'; /* Just in case */
- strcat(outbuf, "\r\n");
-
- result = sasl_encode(conn, outbuf, strlen(outbuf),
- (const char **) &buf, &buflen);
-
- if (result != SASL_OK) {
- snprintf(response, sizeof(response), "SASL encoding error: %s",
- sasl_errdetail(conn));
- return NOTOK;
- }
-
- if (fwrite(buf, buflen, 1, iop) < 1) {
- advise ("putline", "fwrite");
- }
- }
-#endif /* CYRUS_SASL */
-
- fflush (iop);
- if (ferror (iop)) {
- strncpy (response, "lost connection", sizeof(response));
- return NOTOK;
- }
-
- return OK;
-}
-#endif
-
-#if 0
-#ifdef CYRUS_SASL
-/*
- * Okay, our little fgetc replacement. Hopefully this is a little more
- * efficient than the last one.
- */
-static int
-sasl_fgetc(FILE *f)
-{
- static unsigned char *buffer = NULL, *ptr;
- static unsigned int size = 0;
- static int cnt = 0;
- unsigned int retbufsize = 0;
- int cc, result;
- char *retbuf, tmpbuf[SASL_BUFFER_SIZE];
-
- /*
- * If we have some leftover data, return that
- */
-
- if (cnt) {
- cnt--;
- return (int) *ptr++;
- }
-
- /*
- * Otherwise, fill our buffer until we have some data to return.
- */
-
- while (retbufsize == 0) {
-
-#ifdef TLS_SUPPORT
- if (tls_active) {
-#endif
-
- cc = read(fileno(f), tmpbuf, sizeof(tmpbuf));
-
- if (cc == 0)
- return EOF;
-
- if (cc < 0) {
- snprintf(response, sizeof(response), "Error during read from "
- "network: %s", strerror(errno));
- return -2;
- }
-
- /*
- * We're not allowed to call sasl_decode until sasl_complete is
- * true, so we do these gyrations ...
- */
-
- if (!sasl_complete) {
-
- retbuf = tmpbuf;
- retbufsize = cc;
-
- } else {
-
- result = sasl_decode(conn, tmpbuf, cc,
- (const char **) &retbuf, &retbufsize);
-
- if (result != SASL_OK) {
- snprintf(response, sizeof(response), "Error during SASL "
- "decoding: %s", sasl_errdetail(conn));
- return -2;
- }
- }
- }
-
- if (retbufsize > size) {
- buffer = mh_xrealloc(buffer, retbufsize);
- size = retbufsize;
- }
-
- memcpy(buffer, retbuf, retbufsize);
- ptr = buffer + 1;
- cnt = retbufsize - 1;
-
- return (int) buffer[0];
-}
-#endif /* CYRUS_SASL */
-#endif