Mercurial > emacs
annotate lib-src/movemail.c @ 15581:4d843931581c
(mail-hist-current-header-name): Use buffer-substring-no-properties.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 02 Jul 1996 16:23:34 +0000 |
parents | 328889a58f6d |
children | 32f82ca8b41f |
rev | line source |
---|---|
23 | 1 /* movemail foo bar -- move file foo to file bar, |
2 locking file foo the way /bin/mail respects. | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
3 Copyright (C) 1986, 1992, 1993, 1994, 1996 Free Software Foundation, Inc. |
23 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
38 | 7 GNU Emacs is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | |
5524
f14a0fe979d9
(get_errmsg, pfatal_with_name, pfatal_and_delete): Call strerror instead of
Roland McGrath <roland@gnu.org>
parents:
5446
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
38 | 10 any later version. |
23 | 11 |
38 | 12 GNU Emacs is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
23 | 21 |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
22 /* Important notice: defining MAIL_USE_FLOCK or MAIL_USE_LOCKF *will |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
23 cause loss of mail* if you do it on a system that does not normally |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
24 use flock as its way of interlocking access to inbox files. The |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
25 setting of MAIL_USE_FLOCK and MAIL_USE_LOCKF *must agree* with the |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
26 system's own conventions. It is not a choice that is up to you. |
510
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
27 |
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
28 So, if your system uses lock files rather than flock, then the only way |
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
29 you can get proper operation is to enable movemail to write lockfiles there. |
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
30 This means you must either give that directory access modes |
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
31 that permit everyone to write lockfiles in it, or you must make movemail |
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
32 a setuid or setgid program. */ |
4eaef1578a15
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
447
diff
changeset
|
33 |
23 | 34 /* |
35 * Modified January, 1986 by Michael R. Gretzinger (Project Athena) | |
36 * | |
14649 | 37 * Added POP (Post Office Protocol) service. When compiled -DMAIL_USE_POP |
23 | 38 * movemail will accept input filename arguments of the form |
39 * "po:username". This will cause movemail to open a connection to | |
40 * a pop server running on $MAILHOST (environment variable). Movemail | |
41 * must be setuid to root in order to work with POP. | |
42 * | |
43 * New module: popmail.c | |
44 * Modified routines: | |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
45 * main - added code within #ifdef MAIL_USE_POP; added setuid (getuid ()) |
23 | 46 * after POP code. |
47 * New routines in movemail.c: | |
48 * get_errmsg - return pointer to system error message | |
49 * | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
50 * Modified August, 1993 by Jonathan Kamens (OpenVision Technologies) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
51 * |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
52 * Move all of the POP code into a separate file, "pop.c". |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
53 * Use strerror instead of get_errmsg. |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
54 * |
23 | 55 */ |
56 | |
8449
805f9284065b
Include config.h first thing.
Richard M. Stallman <rms@gnu.org>
parents:
6862
diff
changeset
|
57 #define NO_SHORTNAMES /* Tell config not to load remap.h */ |
805f9284065b
Include config.h first thing.
Richard M. Stallman <rms@gnu.org>
parents:
6862
diff
changeset
|
58 #include <../src/config.h> |
23 | 59 #include <sys/types.h> |
60 #include <sys/stat.h> | |
61 #include <sys/file.h> | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
62 #include <stdio.h> |
23 | 63 #include <errno.h> |
5435 | 64 #include <../src/syswait.h> |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
65 #ifdef MAIL_USE_POP |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
66 #include "pop.h" |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
67 #endif |
23 | 68 |
5446
726a3dc867a6
(malloc): Don't declare it.
Richard M. Stallman <rms@gnu.org>
parents:
5435
diff
changeset
|
69 #ifdef MSDOS |
726a3dc867a6
(malloc): Don't declare it.
Richard M. Stallman <rms@gnu.org>
parents:
5435
diff
changeset
|
70 #undef access |
726a3dc867a6
(malloc): Don't declare it.
Richard M. Stallman <rms@gnu.org>
parents:
5435
diff
changeset
|
71 #endif /* MSDOS */ |
726a3dc867a6
(malloc): Don't declare it.
Richard M. Stallman <rms@gnu.org>
parents:
5435
diff
changeset
|
72 |
15105
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
73 #ifndef DIRECTORY_SEP |
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
74 #define DIRECTORY_SEP '/' |
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
75 #endif |
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
76 #ifndef IS_DIRECTORY_SEP |
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
77 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) |
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
78 #endif |
328889a58f6d
(DIRECTORY_SEP, IS_DIRECTORY_SEP): Definitions copied from lisp.h.
Richard M. Stallman <rms@gnu.org>
parents:
15101
diff
changeset
|
79 |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
80 #ifdef WINDOWSNT |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
81 #undef access |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
82 #undef unlink |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
83 #define fork() 0 |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
84 #define sys_wait(var) (*(var) = 0) |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
85 /* Unfortunately, Samba doesn't seem to properly lock Unix files even |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
86 though the locking call succeeds (and indeed blocks local access from |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
87 other NT programs). If you have direct file access using an NFS |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
88 client or something other than Samba, the locking call might work |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
89 properly - make sure it does before you enable this! */ |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
90 #define DISABLE_DIRECT_ACCESS |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
91 #endif /* WINDOWSNT */ |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
92 |
23 | 93 #ifdef USG |
94 #include <fcntl.h> | |
95 #include <unistd.h> | |
27 | 96 #ifndef F_OK |
97 #define F_OK 0 | |
98 #define X_OK 1 | |
99 #define W_OK 2 | |
100 #define R_OK 4 | |
101 #endif | |
23 | 102 #endif /* USG */ |
103 | |
6862
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6813
diff
changeset
|
104 #ifdef HAVE_UNISTD_H |
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6813
diff
changeset
|
105 #include <unistd.h> |
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6813
diff
changeset
|
106 #endif |
653504b6b5dd
[HAVE_UNISTD_H]: Include unistd.h.
Richard M. Stallman <rms@gnu.org>
parents:
6813
diff
changeset
|
107 |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
108 #if defined (XENIX) || defined (WINDOWSNT) |
23 | 109 #include <sys/locking.h> |
110 #endif | |
111 | |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
112 #ifdef MAIL_USE_LOCKF |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
113 #define MAIL_USE_SYSTEM_LOCK |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
114 #endif |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
115 |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
116 #ifdef MAIL_USE_FLOCK |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
117 #define MAIL_USE_SYSTEM_LOCK |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
118 #endif |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
119 |
25 | 120 #ifdef MAIL_USE_MMDF |
121 extern int lk_open (), lk_close (); | |
122 #endif | |
123 | |
23 | 124 /* Cancel substitutions made by config.h for Emacs. */ |
125 #undef open | |
126 #undef read | |
127 #undef write | |
128 #undef close | |
129 | |
571 | 130 #ifndef errno |
23 | 131 extern int errno; |
571 | 132 #endif |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
133 char *strerror (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
134 |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
135 void fatal (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
136 void error (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
137 void pfatal_with_name (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
138 void pfatal_and_delete (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
139 char *concat (); |
11675
496576df5d46
(xmalloc): Declare it to return long *.
Richard M. Stallman <rms@gnu.org>
parents:
10399
diff
changeset
|
140 long *xmalloc (); |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
141 int popmail (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
142 int pop_retr (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
143 int mbx_write (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
144 int mbx_delimit_begin (); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
145 int mbx_delimit_end (); |
23 | 146 |
147 /* Nonzero means this is name of a lock file to delete on fatal error. */ | |
148 char *delete_lockname; | |
149 | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
150 int |
23 | 151 main (argc, argv) |
152 int argc; | |
153 char **argv; | |
154 { | |
155 char *inname, *outname; | |
156 int indesc, outdesc; | |
157 int nread; | |
5435 | 158 WAITTYPE status; |
23 | 159 |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
160 #ifndef MAIL_USE_SYSTEM_LOCK |
23 | 161 struct stat st; |
162 long now; | |
163 int tem; | |
164 char *lockname, *p; | |
601
3db1540d4b97
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
580
diff
changeset
|
165 char *tempname; |
23 | 166 int desc; |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
167 #endif /* not MAIL_USE_SYSTEM_LOCK */ |
23 | 168 |
169 delete_lockname = 0; | |
170 | |
171 if (argc < 3) | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
172 { |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
173 fprintf (stderr, "Usage: movemail inbox destfile [POP-password]\n"); |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
174 exit(1); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
175 } |
23 | 176 |
177 inname = argv[1]; | |
178 outname = argv[2]; | |
179 | |
25 | 180 #ifdef MAIL_USE_MMDF |
181 mmdf_init (argv[0]); | |
182 #endif | |
183 | |
12793
0464324deda7
(main): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12777
diff
changeset
|
184 if (*outname == 0) |
0464324deda7
(main): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12777
diff
changeset
|
185 fatal ("Destination file name is empty", 0); |
0464324deda7
(main): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12777
diff
changeset
|
186 |
120 | 187 /* Check access to output file. */ |
23 | 188 if (access (outname, F_OK) == 0 && access (outname, W_OK) != 0) |
189 pfatal_with_name (outname); | |
190 | |
14036 | 191 /* Also check that outname's directory is writable to the real uid. */ |
23 | 192 { |
5446
726a3dc867a6
(malloc): Don't declare it.
Richard M. Stallman <rms@gnu.org>
parents:
5435
diff
changeset
|
193 char *buf = (char *) xmalloc (strlen (outname) + 1); |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
194 char *p; |
23 | 195 strcpy (buf, outname); |
196 p = buf + strlen (buf); | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
197 while (p > buf && !IS_DIRECTORY_SEP (p[-1])) |
23 | 198 *--p = 0; |
199 if (p == buf) | |
200 *p++ = '.'; | |
201 if (access (buf, W_OK) != 0) | |
202 pfatal_with_name (buf); | |
203 free (buf); | |
204 } | |
205 | |
206 #ifdef MAIL_USE_POP | |
3309
f00054d40753
* movemail.c [MAIL_USE_POP] (main): Don't use non-portable
Jim Blandy <jimb@redhat.com>
parents:
733
diff
changeset
|
207 if (!strncmp (inname, "po:", 3)) |
23 | 208 { |
12442
981986d7d82f
(main) [MAIL_USE_POP]: When a user specifies a
Richard M. Stallman <rms@gnu.org>
parents:
12389
diff
changeset
|
209 int status; |
23 | 210 |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
211 status = popmail (inname + 3, outname, argc > 3 ? argv[3] : NULL); |
23 | 212 exit (status); |
213 } | |
214 | |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
215 setuid (getuid ()); |
23 | 216 #endif /* MAIL_USE_POP */ |
217 | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
218 #ifndef DISABLE_DIRECT_ACCESS |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
219 |
120 | 220 /* Check access to input file. */ |
221 if (access (inname, R_OK | W_OK) != 0) | |
222 pfatal_with_name (inname); | |
223 | |
25 | 224 #ifndef MAIL_USE_MMDF |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
225 #ifndef MAIL_USE_SYSTEM_LOCK |
12572 | 226 /* Use a lock file named after our first argument with .lock appended: |
23 | 227 If it exists, the mail file is locked. */ |
351
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
228 /* Note: this locking mechanism is *required* by the mailer |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
229 (on systems which use it) to prevent loss of mail. |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
230 |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
231 On systems that use a lock file, extracting the mail without locking |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
232 WILL occasionally cause loss of mail due to timing errors! |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
233 |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
234 So, if creation of the lock file fails |
12572 | 235 due to access permission on the mail spool directory, |
351
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
236 you simply MUST change the permission |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
237 and/or make movemail a setgid program |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
238 so it can create lock files properly. |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
239 |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
240 You might also wish to verify that your system is one |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
241 which uses lock files for this purpose. Some systems use other methods. |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
242 |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
243 If your system uses the `flock' system call for mail locking, |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
244 define MAIL_USE_SYSTEM_LOCK in config.h or the s-*.h file |
351
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
245 and recompile movemail. If the s- file for your system |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
246 should define MAIL_USE_SYSTEM_LOCK but does not, send a bug report |
351
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
247 to bug-gnu-emacs@prep.ai.mit.edu so we can fix it. */ |
5729b1cc3942
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
127
diff
changeset
|
248 |
23 | 249 lockname = concat (inname, ".lock", ""); |
5318
60fa1ee0c98c
(main): When making tempname, cast result of xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
4985
diff
changeset
|
250 tempname = (char *) xmalloc (strlen (inname) + strlen ("EXXXXXX") + 1); |
60fa1ee0c98c
(main): When making tempname, cast result of xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
4985
diff
changeset
|
251 strcpy (tempname, inname); |
23 | 252 p = tempname + strlen (tempname); |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
253 while (p != tempname && !IS_DIRECTORY_SEP (p[-1])) |
23 | 254 p--; |
255 *p = 0; | |
256 strcpy (p, "EXXXXXX"); | |
257 mktemp (tempname); | |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
258 unlink (tempname); |
23 | 259 |
260 while (1) | |
261 { | |
262 /* Create the lock file, but not under the lock file name. */ | |
263 /* Give up if cannot do that. */ | |
5435 | 264 desc = open (tempname, O_WRONLY | O_CREAT | O_EXCL, 0666); |
23 | 265 if (desc < 0) |
12777
96819e0ab508
(main): Mention lock file name in error message.
Richard M. Stallman <rms@gnu.org>
parents:
12572
diff
changeset
|
266 { |
12793
0464324deda7
(main): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12777
diff
changeset
|
267 char *message = (char *) xmalloc (strlen (tempname) + 50); |
0464324deda7
(main): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12777
diff
changeset
|
268 sprintf (message, "%s--see source file lib-src/movemail.c", |
0464324deda7
(main): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
12777
diff
changeset
|
269 tempname); |
12777
96819e0ab508
(main): Mention lock file name in error message.
Richard M. Stallman <rms@gnu.org>
parents:
12572
diff
changeset
|
270 pfatal_with_name (message); |
96819e0ab508
(main): Mention lock file name in error message.
Richard M. Stallman <rms@gnu.org>
parents:
12572
diff
changeset
|
271 } |
23 | 272 close (desc); |
273 | |
274 tem = link (tempname, lockname); | |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
275 unlink (tempname); |
23 | 276 if (tem >= 0) |
277 break; | |
278 sleep (1); | |
279 | |
11746
e93b5c05c949
(main): Increase lock timeout to five minutes.
Richard M. Stallman <rms@gnu.org>
parents:
11675
diff
changeset
|
280 /* If lock file is five minutes old, unlock it. |
e93b5c05c949
(main): Increase lock timeout to five minutes.
Richard M. Stallman <rms@gnu.org>
parents:
11675
diff
changeset
|
281 Five minutes should be good enough to cope with crashes |
e93b5c05c949
(main): Increase lock timeout to five minutes.
Richard M. Stallman <rms@gnu.org>
parents:
11675
diff
changeset
|
282 and wedgitude, and long enough to avoid being fooled |
e93b5c05c949
(main): Increase lock timeout to five minutes.
Richard M. Stallman <rms@gnu.org>
parents:
11675
diff
changeset
|
283 by time differences between machines. */ |
23 | 284 if (stat (lockname, &st) >= 0) |
285 { | |
286 now = time (0); | |
11746
e93b5c05c949
(main): Increase lock timeout to five minutes.
Richard M. Stallman <rms@gnu.org>
parents:
11675
diff
changeset
|
287 if (st.st_ctime < now - 300) |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
288 unlink (lockname); |
23 | 289 } |
290 } | |
291 | |
292 delete_lockname = lockname; | |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
293 #endif /* not MAIL_USE_SYSTEM_LOCK */ |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
294 #endif /* not MAIL_USE_MMDF */ |
23 | 295 |
5435 | 296 if (fork () == 0) |
297 { | |
6813
76f93e487956
(main): Use setuid, not seteuid.
Karl Heuer <kwzh@gnu.org>
parents:
6690
diff
changeset
|
298 setuid (getuid ()); |
5435 | 299 |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
300 #ifndef MAIL_USE_MMDF |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
301 #ifdef MAIL_USE_SYSTEM_LOCK |
5435 | 302 indesc = open (inname, O_RDWR); |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
303 #else /* if not MAIL_USE_SYSTEM_LOCK */ |
5435 | 304 indesc = open (inname, O_RDONLY); |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
305 #endif /* not MAIL_USE_SYSTEM_LOCK */ |
5435 | 306 #else /* MAIL_USE_MMDF */ |
307 indesc = lk_open (inname, O_RDONLY, 0, 0, 10); | |
25 | 308 #endif /* MAIL_USE_MMDF */ |
309 | |
5435 | 310 if (indesc < 0) |
311 pfatal_with_name (inname); | |
23 | 312 |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
313 #if defined (BSD) || defined (XENIX) |
5435 | 314 /* In case movemail is setuid to root, make sure the user can |
315 read the output file. */ | |
316 /* This is desirable for all systems | |
317 but I don't want to assume all have the umask system call */ | |
318 umask (umask (0) & 0333); | |
23 | 319 #endif /* BSD or Xenix */ |
5435 | 320 outdesc = open (outname, O_WRONLY | O_CREAT | O_EXCL, 0666); |
321 if (outdesc < 0) | |
322 pfatal_with_name (outname); | |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
323 #ifdef MAIL_USE_SYSTEM_LOCK |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
324 #ifdef MAIL_USE_LOCKF |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
325 if (lockf (indesc, F_LOCK, 0) < 0) pfatal_with_name (inname); |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
326 #else /* not MAIL_USE_LOCKF */ |
23 | 327 #ifdef XENIX |
5435 | 328 if (locking (indesc, LK_RLCK, 0L) < 0) pfatal_with_name (inname); |
23 | 329 #else |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
330 #ifdef WINDOWSNT |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
331 if (locking (indesc, LK_RLCK, -1L) < 0) pfatal_with_name (inname); |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
332 #else |
5435 | 333 if (flock (indesc, LOCK_EX) < 0) pfatal_with_name (inname); |
23 | 334 #endif |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
335 #endif |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
336 #endif /* not MAIL_USE_LOCKF */ |
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
337 #endif /* MAIL_USE_SYSTEM_LOCK */ |
23 | 338 |
5435 | 339 { |
340 char buf[1024]; | |
604 | 341 |
5435 | 342 while (1) |
604 | 343 { |
5435 | 344 nread = read (indesc, buf, sizeof buf); |
345 if (nread != write (outdesc, buf, nread)) | |
346 { | |
347 int saved_errno = errno; | |
348 unlink (outname); | |
349 errno = saved_errno; | |
350 pfatal_with_name (outname); | |
351 } | |
352 if (nread < sizeof buf) | |
353 break; | |
604 | 354 } |
355 } | |
23 | 356 |
357 #ifdef BSD | |
5435 | 358 if (fsync (outdesc) < 0) |
359 pfatal_and_delete (outname); | |
23 | 360 #endif |
361 | |
5435 | 362 /* Check to make sure no errors before we zap the inbox. */ |
363 if (close (outdesc) != 0) | |
364 pfatal_and_delete (outname); | |
23 | 365 |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
366 #ifdef MAIL_USE_SYSTEM_LOCK |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
367 #if defined (STRIDE) || defined (XENIX) || defined (WINDOWSNT) |
5435 | 368 /* Stride, xenix have file locking, but no ftruncate. This mess will do. */ |
369 close (open (inname, O_CREAT | O_TRUNC | O_RDWR, 0666)); | |
23 | 370 #else |
5435 | 371 ftruncate (indesc, 0L); |
23 | 372 #endif /* STRIDE or XENIX */ |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
373 #endif /* MAIL_USE_SYSTEM_LOCK */ |
25 | 374 |
375 #ifdef MAIL_USE_MMDF | |
5435 | 376 lk_close (indesc, 0, 0, 0); |
25 | 377 #else |
5435 | 378 close (indesc); |
25 | 379 #endif |
23 | 380 |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
381 #ifndef MAIL_USE_SYSTEM_LOCK |
5532
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
382 /* Delete the input file; if we can't, at least get rid of its |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
383 contents. */ |
571 | 384 #ifdef MAIL_UNLINK_SPOOL |
5435 | 385 /* This is generally bad to do, because it destroys the permissions |
386 that were set on the file. Better to just empty the file. */ | |
387 if (unlink (inname) < 0 && errno != ENOENT) | |
571 | 388 #endif /* MAIL_UNLINK_SPOOL */ |
5435 | 389 creat (inname, 0600); |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
390 #endif /* not MAIL_USE_SYSTEM_LOCK */ |
5435 | 391 |
392 exit (0); | |
393 } | |
394 | |
395 wait (&status); | |
396 if (!WIFEXITED (status)) | |
397 exit (1); | |
398 else if (WRETCODE (status) != 0) | |
399 exit (WRETCODE (status)); | |
400 | |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
401 #if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK) |
25 | 402 unlink (lockname); |
6690
a1a42eefcc61
(main): Fix up MAIL_USE_MMDF conditional where
Richard M. Stallman <rms@gnu.org>
parents:
5532
diff
changeset
|
403 #endif /* not MAIL_USE_MMDF and not MAIL_USE_SYSTEM_LOCK */ |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
404 |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
405 #endif /* ! DISABLE_DIRECT_ACCESS */ |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
406 |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
407 return 0; |
23 | 408 } |
409 | |
410 /* Print error message and exit. */ | |
411 | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
412 void |
23 | 413 fatal (s1, s2) |
414 char *s1, *s2; | |
415 { | |
416 if (delete_lockname) | |
417 unlink (delete_lockname); | |
418 error (s1, s2); | |
419 exit (1); | |
420 } | |
421 | |
422 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ | |
423 | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
424 void |
120 | 425 error (s1, s2, s3) |
426 char *s1, *s2, *s3; | |
23 | 427 { |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
428 fprintf (stderr, "movemail: "); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
429 fprintf (stderr, s1, s2, s3); |
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
430 fprintf (stderr, "\n"); |
23 | 431 } |
432 | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
433 void |
23 | 434 pfatal_with_name (name) |
435 char *name; | |
436 { | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
437 char *s = concat ("", strerror (errno), " for %s"); |
23 | 438 fatal (s, name); |
439 } | |
440 | |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
441 void |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
442 pfatal_and_delete (name) |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
443 char *name; |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
444 { |
9490
4e70299f958d
Make functions that return nothing void, not implicitly int.
David J. MacKenzie <djm@gnu.org>
parents:
9157
diff
changeset
|
445 char *s = concat ("", strerror (errno), " for %s"); |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
446 unlink (name); |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
447 fatal (s, name); |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
448 } |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
449 |
23 | 450 /* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */ |
451 | |
452 char * | |
453 concat (s1, s2, s3) | |
454 char *s1, *s2, *s3; | |
455 { | |
456 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); | |
457 char *result = (char *) xmalloc (len1 + len2 + len3 + 1); | |
458 | |
459 strcpy (result, s1); | |
460 strcpy (result + len1, s2); | |
461 strcpy (result + len1 + len2, s3); | |
462 *(result + len1 + len2 + len3) = 0; | |
463 | |
464 return result; | |
465 } | |
466 | |
467 /* Like malloc but get fatal error if memory is exhausted. */ | |
468 | |
11675
496576df5d46
(xmalloc): Declare it to return long *.
Richard M. Stallman <rms@gnu.org>
parents:
10399
diff
changeset
|
469 long * |
23 | 470 xmalloc (size) |
571 | 471 unsigned size; |
23 | 472 { |
11675
496576df5d46
(xmalloc): Declare it to return long *.
Richard M. Stallman <rms@gnu.org>
parents:
10399
diff
changeset
|
473 long *result = (long *) malloc (size); |
23 | 474 if (!result) |
475 fatal ("virtual memory exhausted", 0); | |
476 return result; | |
477 } | |
478 | |
479 /* This is the guts of the interface to the Post Office Protocol. */ | |
480 | |
481 #ifdef MAIL_USE_POP | |
482 | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
483 #ifndef WINDOWSNT |
23 | 484 #include <sys/socket.h> |
485 #include <netinet/in.h> | |
486 #include <netdb.h> | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
487 #else |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
488 #undef _WINSOCKAPI_ |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
489 #include <winsock.h> |
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
490 #endif |
23 | 491 #include <stdio.h> |
634
52d0ff659265
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
604
diff
changeset
|
492 #include <pwd.h> |
23 | 493 |
494 #ifdef USG | |
495 #include <fcntl.h> | |
496 /* Cancel substitutions made by config.h for Emacs. */ | |
497 #undef open | |
498 #undef read | |
499 #undef write | |
500 #undef close | |
501 #endif /* USG */ | |
502 | |
503 #define NOTOK (-1) | |
504 #define OK 0 | |
505 #define DONE 1 | |
506 | |
507 char *progname; | |
508 FILE *sfi; | |
509 FILE *sfo; | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
510 char ibuffer[BUFSIZ]; |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
511 char obuffer[BUFSIZ]; |
23 | 512 char Errmsg[80]; |
513 | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
514 popmail (user, outfile, password) |
120 | 515 char *user; |
516 char *outfile; | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
517 char *password; |
23 | 518 { |
120 | 519 int nmsgs, nbytes; |
520 register int i; | |
521 int mbfi; | |
522 FILE *mbf; | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
523 char *getenv (); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
524 int mbx_write (); |
9630
5410efcb7b6e
PopServer renamed to popserver throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9612
diff
changeset
|
525 popserver server; |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
526 extern char *strerror (); |
23 | 527 |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
528 server = pop_open (0, user, password, POP_NO_GETPASS); |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
529 if (! server) |
120 | 530 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
531 error (pop_error); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
532 return (1); |
23 | 533 } |
534 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
535 if (pop_stat (server, &nmsgs, &nbytes)) |
120 | 536 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
537 error (pop_error); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
538 return (1); |
120 | 539 } |
23 | 540 |
120 | 541 if (!nmsgs) |
542 { | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
543 pop_close (server); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
544 return (0); |
23 | 545 } |
546 | |
120 | 547 mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666); |
548 if (mbfi < 0) | |
549 { | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
550 pop_close (server); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
551 error ("Error in open: %s, %s", strerror (errno), outfile); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
552 return (1); |
120 | 553 } |
554 fchown (mbfi, getuid (), -1); | |
555 | |
15101
f86169152e74
(access, unlink) [WINDOWSNT]: Macros undefined.
Richard M. Stallman <rms@gnu.org>
parents:
14649
diff
changeset
|
556 if ((mbf = fdopen (mbfi, "wb")) == NULL) |
120 | 557 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
558 pop_close (server); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
559 error ("Error in fdopen: %s", strerror (errno)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
560 close (mbfi); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
561 unlink (outfile); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
562 return (1); |
120 | 563 } |
564 | |
565 for (i = 1; i <= nmsgs; i++) | |
566 { | |
567 mbx_delimit_begin (mbf); | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
568 if (pop_retr (server, i, mbx_write, mbf) != OK) |
120 | 569 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
570 error (Errmsg); |
120 | 571 close (mbfi); |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
572 return (1); |
120 | 573 } |
574 mbx_delimit_end (mbf); | |
575 fflush (mbf); | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
576 if (ferror (mbf)) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
577 { |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
578 error ("Error in fflush: %s", strerror (errno)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
579 pop_close (server); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
580 close (mbfi); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
581 return (1); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
582 } |
120 | 583 } |
584 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
585 /* On AFS, a call to write only modifies the file in the local |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
586 * workstation's AFS cache. The changes are not written to the server |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
587 * until a call to fsync or close is made. Users with AFS home |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
588 * directories have lost mail when over quota because these checks were |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
589 * not made in previous versions of movemail. */ |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
590 |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
9490
diff
changeset
|
591 #ifdef BSD |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
592 if (fsync (mbfi) < 0) |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
593 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
594 error ("Error in fsync: %s", strerror (errno)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
595 return (1); |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
596 } |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
9490
diff
changeset
|
597 #endif |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
598 |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
599 if (close (mbfi) == -1) |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
600 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
601 error ("Error in close: %s", strerror (errno)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
602 return (1); |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
603 } |
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
604 |
120 | 605 for (i = 1; i <= nmsgs; i++) |
606 { | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
607 if (pop_delete (server, i)) |
120 | 608 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
609 error (pop_error); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
610 pop_close (server); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
611 return (1); |
23 | 612 } |
613 } | |
614 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
615 if (pop_quit (server)) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
616 { |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
617 error (pop_error); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
618 return (1); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
619 } |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
620 |
447
2e226dcdaf0f
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
351
diff
changeset
|
621 return (0); |
23 | 622 } |
623 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
624 pop_retr (server, msgno, action, arg) |
9630
5410efcb7b6e
PopServer renamed to popserver throughout.
Richard M. Stallman <rms@gnu.org>
parents:
9612
diff
changeset
|
625 popserver server; |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
626 int (*action)(); |
23 | 627 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
628 extern char *strerror (); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
629 char *line; |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
630 int ret; |
23 | 631 |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
632 if (pop_retrieve_first (server, msgno, &line)) |
120 | 633 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
634 strncpy (Errmsg, pop_error, sizeof (Errmsg)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
635 Errmsg[sizeof (Errmsg)-1] = '\0'; |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
636 return (NOTOK); |
23 | 637 } |
638 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
639 while (! (ret = pop_retrieve_next (server, &line))) |
120 | 640 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
641 if (! line) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
642 break; |
23 | 643 |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
644 if ((*action)(line, arg) != OK) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
645 { |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
646 strcpy (Errmsg, strerror (errno)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
647 pop_close (server); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
648 return (NOTOK); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
649 } |
23 | 650 } |
651 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
652 if (ret) |
120 | 653 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
654 strncpy (Errmsg, pop_error, sizeof (Errmsg)); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
655 Errmsg[sizeof (Errmsg)-1] = '\0'; |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
656 return (NOTOK); |
23 | 657 } |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
658 |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
659 return (OK); |
23 | 660 } |
661 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
662 /* Do this as a macro instead of using strcmp to save on execution time. */ |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
663 #define IS_FROM_LINE(a) ((a[0] == 'F') \ |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
664 && (a[1] == 'r') \ |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
665 && (a[2] == 'o') \ |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
666 && (a[3] == 'm') \ |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
667 && (a[4] == ' ')) |
23 | 668 |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
669 int |
120 | 670 mbx_write (line, mbf) |
671 char *line; | |
672 FILE *mbf; | |
23 | 673 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
674 if (IS_FROM_LINE (line)) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
675 { |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
676 if (fputc ('>', mbf) == EOF) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
677 return (NOTOK); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
678 } |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
679 if (fputs (line, mbf) == EOF) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
680 return (NOTOK); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
681 if (fputc (0x0a, mbf) == EOF) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
682 return (NOTOK); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
683 return (OK); |
23 | 684 } |
685 | |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
686 int |
120 | 687 mbx_delimit_begin (mbf) |
688 FILE *mbf; | |
23 | 689 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
690 if (fputs ("\f\n0, unseen,,\n", mbf) == EOF) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
691 return (NOTOK); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
692 return (OK); |
23 | 693 } |
694 | |
120 | 695 mbx_delimit_end (mbf) |
696 FILE *mbf; | |
23 | 697 { |
9157
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
698 if (putc ('\037', mbf) == EOF) |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
699 return (NOTOK); |
29f4cce05fa5
Improve POP code, move most of it into a separate file.
Richard M. Stallman <rms@gnu.org>
parents:
8449
diff
changeset
|
700 return (OK); |
23 | 701 } |
702 | |
703 #endif /* MAIL_USE_POP */ | |
5532
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
704 |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
705 #ifndef HAVE_STRERROR |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
706 char * |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
707 strerror (errnum) |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
708 int errnum; |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
709 { |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
710 extern char *sys_errlist[]; |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
711 extern int sys_nerr; |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
712 |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
713 if (errnum >= 0 && errnum < sys_nerr) |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
714 return sys_errlist[errnum]; |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
715 return (char *) "Unknown error"; |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
716 } |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
717 |
9c86c71e879d
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5524
diff
changeset
|
718 #endif /* ! HAVE_STRERROR */ |