summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/tools/mailstream.c
Unidiff
Diffstat (limited to 'kmicromail/libetpan/tools/mailstream.c') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/tools/mailstream.c2
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,91 +1,91 @@
1/* 1/*
2 * libEtPan! -- a mail stuff library 2 * libEtPan! -- a mail stuff library
3 * 3 *
4 * Copyright (C) 2001, 2002 - DINH Viet Hoa 4 * Copyright (C) 2001, 2002 - DINH Viet Hoa
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the libEtPan! project nor the names of its 15 * 3. Neither the name of the libEtPan! project nor the names of its
16 * contributors may be used to endorse or promote products derived 16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission. 17 * from this software without specific prior written permission.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * $Id$ 33 * $Id$
34 */ 34 */
35 35
36#include "mailstream.h" 36#include "mailstream.h"
37#include "maillock.h" 37#include "maillock.h"
38#include <string.h> 38#include <string.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <sys/types.h> 40#include <sys/types.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42 42
43#define DEFAULT_NETWORK_TIMEOUT 300 43
44 44
45#ifdef LIBETPAN_MAILSTREAM_DEBUG 45#ifdef LIBETPAN_MAILSTREAM_DEBUG
46 46
47#define STREAM_DEBUG 47#define STREAM_DEBUG
48 48
49#include <stdio.h> 49#include <stdio.h>
50 50
51#define LOG_FILE "libetpan-stream-debug.log" 51#define LOG_FILE "libetpan-stream-debug.log"
52 52
53int mailstream_debug = 0; 53int mailstream_debug = 0;
54 54
55#define STREAM_LOG_BUF(buf, size) \ 55#define STREAM_LOG_BUF(buf, size) \
56 if (mailstream_debug) { \ 56 if (mailstream_debug) { \
57 FILE * f; \ 57 FILE * f; \
58 mode_t old_mask; \ 58 mode_t old_mask; \
59 \ 59 \
60 old_mask = umask(0077); \ 60 old_mask = umask(0077); \
61 f = fopen(LOG_FILE, "a"); \ 61 f = fopen(LOG_FILE, "a"); \
62 umask(old_mask); \ 62 umask(old_mask); \
63 if (f != NULL) { \ 63 if (f != NULL) { \
64 maillock_write_lock(LOG_FILE, fileno(f)); \ 64 maillock_write_lock(LOG_FILE, fileno(f)); \
65 fwrite((buf), 1, (size), f); \ 65 fwrite((buf), 1, (size), f); \
66 maillock_write_unlock(LOG_FILE, fileno(f)); \ 66 maillock_write_unlock(LOG_FILE, fileno(f)); \
67 fclose(f); \ 67 fclose(f); \
68 } \ 68 } \
69 } 69 }
70 70
71#define STREAM_LOG(str) \ 71#define STREAM_LOG(str) \
72 if (mailstream_debug) { \ 72 if (mailstream_debug) { \
73 FILE * f; \ 73 FILE * f; \
74 mode_t old_mask; \ 74 mode_t old_mask; \
75 \ 75 \
76 old_mask = umask(0077); \ 76 old_mask = umask(0077); \
77 f = fopen(LOG_FILE, "a"); \ 77 f = fopen(LOG_FILE, "a"); \
78 umask(old_mask); \ 78 umask(old_mask); \
79 if (f != NULL) { \ 79 if (f != NULL) { \
80 maillock_write_lock(LOG_FILE, fileno(f)); \ 80 maillock_write_lock(LOG_FILE, fileno(f)); \
81 fputs((str), f); \ 81 fputs((str), f); \
82 maillock_write_unlock(LOG_FILE, fileno(f)); \ 82 maillock_write_unlock(LOG_FILE, fileno(f)); \
83 fclose(f); \ 83 fclose(f); \
84 } \ 84 } \
85 } 85 }
86 86
87#else 87#else
88 88
89#define STREAM_LOG_BUF(buf, size) do { } while (0) 89#define STREAM_LOG_BUF(buf, size) do { } while (0)
90#define STREAM_LOG(buf) do { } while (0) 90#define STREAM_LOG(buf) do { } while (0)
91 91