Diffstat (limited to 'kmicromail/libetpan/tools/mailstream.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libetpan/tools/mailstream.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kmicromail/libetpan/tools/mailstream.c b/kmicromail/libetpan/tools/mailstream.c index 0f55e67..6d1a8cc 100644 --- a/kmicromail/libetpan/tools/mailstream.c +++ b/kmicromail/libetpan/tools/mailstream.c @@ -1,139 +1,139 @@ /* * libEtPan! -- a mail stuff library * * Copyright (C) 2001, 2002 - DINH Viet Hoa * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the libEtPan! project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * $Id$ */ #include "mailstream.h" #include "maillock.h" #include <string.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> -#define DEFAULT_NETWORK_TIMEOUT 300 + #ifdef LIBETPAN_MAILSTREAM_DEBUG #define STREAM_DEBUG #include <stdio.h> #define LOG_FILE "libetpan-stream-debug.log" int mailstream_debug = 0; #define STREAM_LOG_BUF(buf, size) \ if (mailstream_debug) { \ FILE * f; \ mode_t old_mask; \ \ old_mask = umask(0077); \ f = fopen(LOG_FILE, "a"); \ umask(old_mask); \ if (f != NULL) { \ maillock_write_lock(LOG_FILE, fileno(f)); \ fwrite((buf), 1, (size), f); \ maillock_write_unlock(LOG_FILE, fileno(f)); \ fclose(f); \ } \ } #define STREAM_LOG(str) \ if (mailstream_debug) { \ FILE * f; \ mode_t old_mask; \ \ old_mask = umask(0077); \ f = fopen(LOG_FILE, "a"); \ umask(old_mask); \ if (f != NULL) { \ maillock_write_lock(LOG_FILE, fileno(f)); \ fputs((str), f); \ maillock_write_unlock(LOG_FILE, fileno(f)); \ fclose(f); \ } \ } #else #define STREAM_LOG_BUF(buf, size) do { } while (0) #define STREAM_LOG(buf) do { } while (0) #endif mailstream * mailstream_new(mailstream_low * low, size_t buffer_size) { mailstream * s; s = malloc(sizeof(* s)); if (s == NULL) goto err; s->read_buffer = malloc(buffer_size); if (s->read_buffer == NULL) goto free_s; s->read_buffer_len = 0; s->write_buffer = malloc(buffer_size); if (s->write_buffer == NULL) goto free_read_buffer; s->write_buffer_len = 0; s->buffer_max_size = buffer_size; s->low = low; return s; free_read_buffer: free(s->read_buffer); free_s: free(s); err: return NULL; } static size_t write_to_internal_buffer(mailstream * s, const void * buf, size_t count) { memcpy(s->write_buffer + s->write_buffer_len, buf, count); s->write_buffer_len += count; return count; } static size_t write_direct(mailstream * s, const void * buf, size_t count) { size_t left; const char * cur_buf; ssize_t written; |