author | zautrix <zautrix> | 2004-09-02 08:57:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-02 08:57:01 (UTC) |
commit | 95e13360d1ef2a7caae121ae526a8a3c1ac12005 (patch) (side-by-side diff) | |
tree | c9ca8e5c98a11eb5dd7d2afdc8e69d64cdffad25 | |
parent | f255826bda2f95721aec4d6c9ba372d852fb9d0b (diff) | |
download | kdepimpi-95e13360d1ef2a7caae121ae526a8a3c1ac12005.zip kdepimpi-95e13360d1ef2a7caae121ae526a8a3c1ac12005.tar.gz kdepimpi-95e13360d1ef2a7caae121ae526a8a3c1ac12005.tar.bz2 |
Added debug putput for program hang when reading pop3 mail data
-rw-r--r-- | kmicromail/libetpan/include/libetpan/mailstream.h | 1 | ||||
-rw-r--r-- | kmicromail/libetpan/tools/mailstream.c | 2 | ||||
-rw-r--r-- | kmicromail/libetpan/tools/mailstream.h | 3 | ||||
-rw-r--r-- | kmicromail/libetpan/tools/mailstream_socket.c | 13 |
4 files changed, 14 insertions, 5 deletions
diff --git a/kmicromail/libetpan/include/libetpan/mailstream.h b/kmicromail/libetpan/include/libetpan/mailstream.h index a4e35cd..ffb5062 100644 --- a/kmicromail/libetpan/include/libetpan/mailstream.h +++ b/kmicromail/libetpan/include/libetpan/mailstream.h @@ -1,73 +1,74 @@ /* * 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$ */ #ifndef MAILSTREAM_H +#define DEFAULT_NETWORK_TIMEOUT 30 #define MAILSTREAM_H #include <sys/time.h> #include <libetpan/mailstream_low.h> #include <libetpan/mailstream_helper.h> #include <libetpan/mailstream_socket.h> #include <libetpan/mailstream_ssl.h> #include <libetpan/mailstream_types.h> #ifdef __cplusplus extern "C" { #endif mailstream * mailstream_new(mailstream_low * low, size_t buffer_size); ssize_t mailstream_write(mailstream * s, const void * buf, size_t count); ssize_t mailstream_read(mailstream * s, void * buf, size_t count); int mailstream_close(mailstream * s); int mailstream_flush(mailstream * s); ssize_t mailstream_feed_read_buffer(mailstream * s); mailstream_low * mailstream_get_low(mailstream * s); void mailstream_set_low(mailstream * s, mailstream_low * low); #ifdef LIBETPAN_MAILSTREAM_DEBUG extern int mailstream_debug; #endif #define LIBETPAN_MAILSTREAM_NETWORK_DELAY extern struct timeval mailstream_network_delay; #ifdef __cplusplus } #endif #endif 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,394 +1,394 @@ /* * 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; cur_buf = buf; left = count; while (left > 0) { written = mailstream_low_write(s->low, cur_buf, left); if (written == -1) { if (count == left) return -1; else return count - left; } cur_buf += written; left -= written; } return count; } ssize_t mailstream_write(mailstream * s, const void * buf, size_t count) { int r; if (s == NULL) return -1; if (count + s->write_buffer_len > s->buffer_max_size) { r = mailstream_flush(s); if (r == -1) return -1; if (count > s->buffer_max_size) return write_direct(s, buf, count); } #ifdef STREAM_DEBUG STREAM_LOG(">>>>>>> send >>>>>>\n"); STREAM_LOG_BUF(buf, count); STREAM_LOG("\n"); STREAM_LOG(">>>>>>> end send >>>>>>\n"); #endif return write_to_internal_buffer(s, buf, count); } int mailstream_flush(mailstream * s) { char * cur_buf; size_t left; ssize_t written; if (s == NULL) return -1; cur_buf = s->write_buffer; left = s->write_buffer_len; while (left > 0) { written = mailstream_low_write(s->low, cur_buf, left); if (written == -1) goto move_buffer; cur_buf += written; left -= written; } s->write_buffer_len = 0; return 0; move_buffer: memmove(s->write_buffer, cur_buf, left); s->write_buffer_len = left; return -1; } static ssize_t read_from_internal_buffer(mailstream * s, void * buf, size_t count) { if (count >= s->read_buffer_len) count = s->read_buffer_len; if (count != 0) memcpy(buf, s->read_buffer, count); s->read_buffer_len -= count; if (s->read_buffer_len != 0) memmove(s->read_buffer, s->read_buffer + count, s->read_buffer_len); return count; } static ssize_t read_through_buffer(mailstream * s, void * buf, size_t count) { size_t left; char * cur_buf; ssize_t bytes_read; cur_buf = buf; left = count; while (left > 0) { bytes_read = mailstream_low_read(s->low, cur_buf, left); if (bytes_read == -1) { if (count == left) return -1; else return count - left; } else if (bytes_read == 0) return count - left; cur_buf += bytes_read; left -= bytes_read; } return count; } ssize_t mailstream_read(mailstream * s, void * buf, size_t count) { ssize_t read_bytes; char * cur_buf; size_t left; if (s == NULL) return -1; left = count; cur_buf = buf; read_bytes = read_from_internal_buffer(s, cur_buf, left); cur_buf += read_bytes; left -= read_bytes; if (left == 0) { #ifdef STREAM_DEBUG STREAM_LOG("<<<<<<< read <<<<<<\n"); STREAM_LOG_BUF(buf, read_bytes); STREAM_LOG("\n"); STREAM_LOG("<<<<<<< end read <<<<<<\n"); #endif return read_bytes; } if (left > s->buffer_max_size) { read_bytes = read_through_buffer(s, cur_buf, left); if (read_bytes == -1) { if (count == left) return -1; else { #ifdef STREAM_DEBUG STREAM_LOG("<<<<<<< read <<<<<<\n"); STREAM_LOG_BUF(buf, count - left); STREAM_LOG("\n"); STREAM_LOG("<<<<<<< end read <<<<<<\n"); #endif return count - left; } } cur_buf += read_bytes; left -= read_bytes; #ifdef STREAM_DEBUG STREAM_LOG("<<<<<<< read <<<<<<\n"); STREAM_LOG_BUF(buf, count - left); STREAM_LOG("\n"); STREAM_LOG("<<<<<<< end read <<<<<<\n"); #endif return count - left; } read_bytes = mailstream_low_read(s->low, s->read_buffer, s->buffer_max_size); if (read_bytes == -1) { if (left == count) return -1; else { #ifdef STREAM_DEBUG STREAM_LOG("<<<<<<< read <<<<<<\n"); STREAM_LOG_BUF(buf, count - left); STREAM_LOG("\n"); STREAM_LOG("<<<<<<< end read <<<<<<\n"); #endif return count - left; } } else s->read_buffer_len += read_bytes; read_bytes = read_from_internal_buffer(s, cur_buf, left); cur_buf += read_bytes; left -= read_bytes; #ifdef STREAM_DEBUG STREAM_LOG("<<<<<<< read <<<<<<\n"); STREAM_LOG_BUF(buf, count - left); STREAM_LOG("\n"); STREAM_LOG("<<<<<<< end read <<<<<<\n"); #endif return count - left; } mailstream_low * mailstream_get_low(mailstream * s) { return s->low; } void mailstream_set_low(mailstream * s, mailstream_low * low) { s->low = low; } int mailstream_close(mailstream * s) { mailstream_low_close(s->low); mailstream_low_free(s->low); free(s->read_buffer); free(s->write_buffer); free(s); return 0; } ssize_t mailstream_feed_read_buffer(mailstream * s) { ssize_t read_bytes; if (s == NULL) return -1; if (s->read_buffer_len == 0) { read_bytes = mailstream_low_read(s->low, s->read_buffer, s->buffer_max_size); if (read_bytes == -1) return -1; s->read_buffer_len += read_bytes; } return s->read_buffer_len; } struct timeval mailstream_network_delay = { .tv_sec = DEFAULT_NETWORK_TIMEOUT, .tv_usec = 0 }; diff --git a/kmicromail/libetpan/tools/mailstream.h b/kmicromail/libetpan/tools/mailstream.h index a4e35cd..8a89a72 100644 --- a/kmicromail/libetpan/tools/mailstream.h +++ b/kmicromail/libetpan/tools/mailstream.h @@ -1,73 +1,74 @@ /* * 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$ */ #ifndef MAILSTREAM_H #define MAILSTREAM_H - +//dont forget to change the value in <libetpan/mailstream.h> as well +#define DEFAULT_NETWORK_TIMEOUT 30 #include <sys/time.h> #include <libetpan/mailstream_low.h> #include <libetpan/mailstream_helper.h> #include <libetpan/mailstream_socket.h> #include <libetpan/mailstream_ssl.h> #include <libetpan/mailstream_types.h> #ifdef __cplusplus extern "C" { #endif mailstream * mailstream_new(mailstream_low * low, size_t buffer_size); ssize_t mailstream_write(mailstream * s, const void * buf, size_t count); ssize_t mailstream_read(mailstream * s, void * buf, size_t count); int mailstream_close(mailstream * s); int mailstream_flush(mailstream * s); ssize_t mailstream_feed_read_buffer(mailstream * s); mailstream_low * mailstream_get_low(mailstream * s); void mailstream_set_low(mailstream * s, mailstream_low * low); #ifdef LIBETPAN_MAILSTREAM_DEBUG extern int mailstream_debug; #endif #define LIBETPAN_MAILSTREAM_NETWORK_DELAY extern struct timeval mailstream_network_delay; #ifdef __cplusplus } #endif #endif diff --git a/kmicromail/libetpan/tools/mailstream_socket.c b/kmicromail/libetpan/tools/mailstream_socket.c index 29e50e1..04a6f48 100644 --- a/kmicromail/libetpan/tools/mailstream_socket.c +++ b/kmicromail/libetpan/tools/mailstream_socket.c @@ -1,239 +1,246 @@ /* * 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_socket.h" #include <unistd.h> #include <stdlib.h> #include <fcntl.h> /* these 3 headers MUST be included before <sys/select.h> to insure compatibility with Mac OS X (this is true for 10.2) */ #include <sys/time.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <sys/select.h> /* mailstream_low, socket */ static int mailstream_low_socket_close(mailstream_low * s); static ssize_t mailstream_low_socket_read(mailstream_low * s, void * buf, size_t count); static ssize_t mailstream_low_socket_write(mailstream_low * s, const void * buf, size_t count); static void mailstream_low_socket_free(mailstream_low * s); static int mailstream_low_socket_get_fd(mailstream_low * s); static mailstream_low_driver local_mailstream_socket_driver = { mailstream_read: mailstream_low_socket_read, mailstream_write: mailstream_low_socket_write, mailstream_close: mailstream_low_socket_close, mailstream_free: mailstream_low_socket_free, mailstream_get_fd: mailstream_low_socket_get_fd, }; mailstream_low_driver * mailstream_socket_driver = &local_mailstream_socket_driver; /* file descriptor must be given in (default) blocking-mode */ static struct mailstream_socket_data * socket_data_new(int fd) { struct mailstream_socket_data * socket_data; socket_data = malloc(sizeof(* socket_data)); if (socket_data == NULL) goto err; socket_data->fd = fd; return socket_data; err: return NULL; } static void socket_data_free(struct mailstream_socket_data * socket_data) { free(socket_data); } static void socket_data_close(struct mailstream_socket_data * socket_data) { close(socket_data->fd); socket_data->fd = -1; } mailstream_low * mailstream_low_socket_open(int fd) { mailstream_low * s; struct mailstream_socket_data * socket_data; socket_data = socket_data_new(fd); if (socket_data == NULL) goto err; s = mailstream_low_new(socket_data, mailstream_socket_driver); if (s == NULL) goto free_socket_data; return s; free_socket_data: socket_data_free(socket_data); err: return NULL; } static int mailstream_low_socket_close(mailstream_low * s) { struct mailstream_socket_data * socket_data; socket_data = (struct mailstream_socket_data *) s->data; socket_data_close(socket_data); return 0; } static void mailstream_low_socket_free(mailstream_low * s) { struct mailstream_socket_data * socket_data; socket_data = (struct mailstream_socket_data *) s->data; socket_data_free(socket_data); s->data = NULL; free(s); } static int mailstream_low_socket_get_fd(mailstream_low * s) { struct mailstream_socket_data * socket_data; socket_data = (struct mailstream_socket_data *) s->data; return socket_data->fd; } static ssize_t mailstream_low_socket_read(mailstream_low * s, void * buf, size_t count) { struct mailstream_socket_data * socket_data; socket_data = (struct mailstream_socket_data *) s->data; /* timeout */ { fd_set fds_read; fd_set fds_excp; struct timeval timeout; int r; timeout = mailstream_network_delay; FD_ZERO(&fds_read); FD_SET(socket_data->fd, &fds_read); FD_ZERO(&fds_excp); FD_SET(socket_data->fd, &fds_excp); + // LUTZ for safety I insert here a max val as well + if ( timeout.tv_sec > DEFAULT_NETWORK_TIMEOUT ) + timeout.tv_sec = DEFAULT_NETWORK_TIMEOUT; r = select(socket_data->fd + 1, &fds_read, NULL, &fds_excp, &timeout); - if (r == 0) + if (r < 1 ) return -1; if (FD_ISSET(socket_data->fd, &fds_excp)) return -1; if (!FD_ISSET(socket_data->fd, &fds_read)) return 0; } return recv(socket_data->fd,buf,count,MSG_NOSIGNAL); //return read(socket_data->fd, buf, count); } - +#include <stdio.h> static ssize_t mailstream_low_socket_write(mailstream_low * s, const void * buf, size_t count) { struct mailstream_socket_data * socket_data; socket_data = (struct mailstream_socket_data *) s->data; /* timeout */ { fd_set fds_write; fd_set fds_excp; struct timeval timeout; int r; timeout = mailstream_network_delay; FD_ZERO(&fds_write); FD_SET(socket_data->fd, &fds_write); FD_ZERO(&fds_excp); FD_SET(socket_data->fd, &fds_excp); + // LUTZ next line blocks sometimes + if ( timeout.tv_sec > DEFAULT_NETWORK_TIMEOUT ) + timeout.tv_sec = DEFAULT_NETWORK_TIMEOUT; + fprintf(stderr,"fd %d to secs %d \n", socket_data->fd, timeout.tv_sec ); r = select(socket_data->fd + 1, NULL, &fds_write, &fds_excp, &timeout); - if (r == 0) + if (r < 1) return -1; if (FD_ISSET(socket_data->fd, &fds_excp)) return -1; if (!FD_ISSET(socket_data->fd, &fds_write)) return 0; } return send(socket_data->fd,buf,count,MSG_NOSIGNAL); //return write(socket_data->fd, buf, count); } /* mailstream */ mailstream * mailstream_socket_open(int fd) { mailstream_low * low; mailstream * s; low = mailstream_low_socket_open(fd); if (low == NULL) goto err; s = mailstream_new(low, 8192); if (s == NULL) goto free_low; return s; free_low: mailstream_low_close(low); err: return NULL; } |