1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ POP3 (RFCs 1939, 2595) client.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2014 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
9 * Gunnar Ritter. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Gunnar Ritter
22 * and his contributors.
23 * 4. Neither the name of Gunnar Ritter nor the names of his contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY GUNNAR RITTER AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL GUNNAR RITTER OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 #ifndef HAVE_AMALGAMATION
52 #define POP3_ANSWER(RV,ACTIONSTOP) \
53 do if (((RV) = pop3_answer(mp)) == STOP) {\
57 #define POP3_OUT(RV,X,Y,ACTIONSTOP) \
59 if (((RV) = pop3_finish(mp)) == STOP) {\
62 if (options & OPT_VERBVERB)\
63 fprintf(stderr, ">>> %s", X);\
65 if (((RV) = swrite(&mp->mb_sock, X)) == STOP) {\
70 static char *_pop3_buf
;
71 static size_t _pop3_bufsize
;
72 static sigjmp_buf _pop3_jmp
;
73 static sighandler_type _pop3_savealrm
;
74 static int _pop3_keepalive
;
75 static int volatile _pop3_lock
;
77 /* Perform entire login handshake */
78 static enum okay
_pop3_login(struct mailbox
*mp
, struct sockconn
*scp
);
80 /* APOP: get greeting credential or NULL */
82 static char * _pop3_lookup_apop_timestamp(char const *bp
);
85 static bool_t
_pop3_use_starttls(struct sockconn
const *scp
);
87 /* APOP: shall we use it? */
88 static bool_t
_pop3_no_apop(struct sockconn
const *scp
);
90 /* Several authentication methods */
92 static enum okay
_pop3_auth_apop(struct mailbox
*mp
,
93 struct sockconn
const *scp
, char const *ts
);
95 static enum okay
_pop3_auth_plain(struct mailbox
*mp
,
96 struct sockconn
const *scp
);
98 static void pop3_timer_off(void);
99 static enum okay
pop3_answer(struct mailbox
*mp
);
100 static enum okay
pop3_finish(struct mailbox
*mp
);
101 static void pop3catch(int s
);
102 static void _pop3_maincatch(int s
);
103 static enum okay
pop3_noop1(struct mailbox
*mp
);
104 static void pop3alarm(int s
);
105 static enum okay
pop3_stat(struct mailbox
*mp
, off_t
*size
, int *cnt
);
106 static enum okay
pop3_list(struct mailbox
*mp
, int n
, size_t *size
);
107 static void pop3_init(struct mailbox
*mp
, int n
);
108 static void pop3_dates(struct mailbox
*mp
);
109 static void pop3_setptr(struct mailbox
*mp
);
110 static enum okay
pop3_get(struct mailbox
*mp
, struct message
*m
,
112 static enum okay
pop3_exit(struct mailbox
*mp
);
113 static enum okay
pop3_delete(struct mailbox
*mp
, int n
);
114 static enum okay
pop3_update(struct mailbox
*mp
);
117 _pop3_login(struct mailbox
*mp
, struct sockconn
*scp
)
125 /* Get the greeting, check wether APOP is advertised */
126 POP3_ANSWER(rv
, goto jleave
);
128 ts
= _pop3_lookup_apop_timestamp(_pop3_buf
);
131 /* If not yet secured, can we upgrade to TLS? */
133 if (!scp
->sc_url
.url_needs_tls
&& _pop3_use_starttls(scp
)) {
134 POP3_OUT(rv
, "STLS" NL
, MB_COMD
, goto jleave
);
135 POP3_ANSWER(rv
, goto jleave
);
136 if ((rv
= ssl_open(scp
->sc_url
.url_host
.s
, &scp
->sc_sock
,
137 scp
->sc_url
.url_u_h_p
.s
)) != OKAY
)
141 if (_pop3_use_starttls(scp
->sc_url
.url_u_h_p
.s
)) {
142 fprintf(stderr
, "No SSL support compiled in.\n");
148 /* Use the APOP single roundtrip? */
149 if (!_pop3_no_apop(scp
)) {
152 if ((rv
= _pop3_auth_apop(mp
, scp
, ts
)) != OKAY
)
153 fprintf(stderr
, _("POP3 `APOP' authentication failed, "
154 "maybe try setting *pop3-no-apop*\n"));
158 if (options
& OPT_VERB
)
159 fprintf(stderr
, _("No POP3 `APOP' support "
160 "available, sending password in clear text\n"));
163 rv
= _pop3_auth_plain(mp
, scp
);
171 _pop3_lookup_apop_timestamp(char const *bp
)
174 * A POP3 server which implements the APOP command will include
175 * a timestamp in its banner greeting. The syntax of the timestamp
176 * corresponds to the `msg-id' in [RFC822]
178 * msg-id = "<" addr-spec ">"
179 * addr-spec = local-part "@" domain */
186 if ((cp
= strchr(bp
, '<')) == NULL
)
189 /* xxx What about malformed APOP timestamp (<@>) here? */
190 for (ep
= cp
; *ep
!= '\0'; ++ep
) {
195 else if (*ep
== '>') {
204 tl
= PTR2SIZE(++ep
- cp
);
215 _pop3_use_starttls(struct sockconn
const *scp
)
220 if (!(rv
= ok_blook(pop3_use_starttls
)))
221 if (!ok_blook(v15_compat
) ||
222 !(rv
= vok_blook(savecat("pop3-use-starttls-",
223 scp
->sc_url
.url_h_p
.s
))))
224 rv
= vok_blook(savecat("pop3-use-starttls-", scp
->sc_url
.url_u_h_p
.s
));
230 _pop3_no_apop(struct sockconn
const *scp
)
235 if (!(rv
= ok_blook(pop3_no_apop
)))
236 if (!ok_blook(v15_compat
) ||
237 !(rv
= vok_blook(savecat("pop3-no-apop-", scp
->sc_url
.url_h_p
.s
))))
238 rv
= vok_blook(savecat("pop3-no-apop-", scp
->sc_url
.url_u_h_p
.s
));
245 _pop3_auth_apop(struct mailbox
*mp
, struct sockconn
const *scp
, char const *ts
)
247 unsigned char digest
[16];
248 char hex
[MD5TOHEX_SIZE
], *cp
;
255 md5_update(&ctx
, (uc_it
*)UNCONST(ts
), strlen(ts
));
256 md5_update(&ctx
, (uc_it
*)scp
->sc_cred
.cc_pass
.s
,
257 scp
->sc_cred
.cc_pass
.l
);
258 md5_final(digest
, &ctx
);
259 md5tohex(hex
, digest
);
261 i
= scp
->sc_cred
.cc_user
.l
;
262 cp
= ac_alloc(5 + i
+ 1 + MD5TOHEX_SIZE
+ sizeof(NL
)-1 +1);
264 memcpy(cp
, "APOP ", 5);
265 memcpy(cp
+ 5, scp
->sc_cred
.cc_user
.s
, i
);
268 memcpy(cp
+ i
, hex
, MD5TOHEX_SIZE
);
270 memcpy(cp
+ i
, NL
, sizeof(NL
));
271 POP3_OUT(rv
, cp
, MB_COMD
, goto jleave
);
272 POP3_ANSWER(rv
, goto jleave
);
280 #endif /* HAVE_MD5 */
283 _pop3_auth_plain(struct mailbox
*mp
, struct sockconn
const *scp
)
289 /* The USER/PASS plain text version */
290 cp
= ac_alloc(MAX(scp
->sc_cred
.cc_user
.l
, scp
->sc_cred
.cc_pass
.l
) + 5 +
293 memcpy(cp
, "USER ", 5);
294 memcpy(cp
+ 5, scp
->sc_cred
.cc_user
.s
, scp
->sc_cred
.cc_user
.l
);
295 memcpy(cp
+ 5 + scp
->sc_cred
.cc_user
.l
, NL
, sizeof(NL
));
296 POP3_OUT(rv
, cp
, MB_COMD
, goto jleave
);
297 POP3_ANSWER(rv
, goto jleave
);
299 memcpy(cp
, "PASS ", 5);
300 memcpy(cp
+ 5, scp
->sc_cred
.cc_pass
.s
, scp
->sc_cred
.cc_pass
.l
);
301 memcpy(cp
+ 5 + scp
->sc_cred
.cc_pass
.l
, NL
, sizeof(NL
));
302 POP3_OUT(rv
, cp
, MB_COMD
, goto jleave
);
303 POP3_ANSWER(rv
, goto jleave
);
316 if (_pop3_keepalive
> 0) {
318 safe_signal(SIGALRM
, _pop3_savealrm
);
324 pop3_answer(struct mailbox
*mp
)
331 if ((sz
= sgetline(&_pop3_buf
, &_pop3_bufsize
, NULL
, &mp
->mb_sock
)) > 0) {
332 if ((mp
->mb_active
& (MB_COMD
| MB_MULT
)) == MB_MULT
)
334 if (options
& OPT_VERBVERB
)
335 fputs(_pop3_buf
, stderr
);
336 switch (*_pop3_buf
) {
339 mp
->mb_active
&= ~MB_COMD
;
343 mp
->mb_active
= MB_NONE
;
344 fprintf(stderr
, _("POP3 error: %s"), _pop3_buf
);
347 /* If the answer starts neither with '+' nor with '-', it must be part
348 * of a multiline response. Get lines until a single dot appears */
350 while (_pop3_buf
[0] != '.' || _pop3_buf
[1] != NL
[0] ||
351 _pop3_buf
[2] != NL
[1] || _pop3_buf
[3] != '\0') {
352 sz
= sgetline(&_pop3_buf
, &_pop3_bufsize
, NULL
, &mp
->mb_sock
);
356 mp
->mb_active
&= ~MB_MULT
;
357 if (mp
->mb_active
!= MB_NONE
)
363 mp
->mb_active
= MB_NONE
;
370 pop3_finish(struct mailbox
*mp
)
373 while (mp
->mb_sock
.s_fd
> 0 && mp
->mb_active
!= MB_NONE
)
382 NYD_X
; /* Signal handler */
385 fprintf(stderr
, _("Interrupt\n"));
386 siglongjmp(_pop3_jmp
, 1);
389 fprintf(stderr
, "Received SIGPIPE during POP3 operation\n");
395 _pop3_maincatch(int s
)
397 NYD_X
; /* Signal handler */
400 if (interrupts
++ == 0)
401 fprintf(stderr
, _("Interrupt\n"));
407 pop3_noop1(struct mailbox
*mp
)
412 POP3_OUT(rv
, "NOOP" NL
, MB_COMD
, goto jleave
);
413 POP3_ANSWER(rv
, goto jleave
);
422 sighandler_type
volatile saveint
, savepipe
;
423 NYD_X
; /* Signal handler */
426 if (_pop3_lock
++ == 0) {
427 if ((saveint
= safe_signal(SIGINT
, SIG_IGN
)) != SIG_IGN
)
428 safe_signal(SIGINT
, &_pop3_maincatch
);
429 savepipe
= safe_signal(SIGPIPE
, SIG_IGN
);
430 if (sigsetjmp(_pop3_jmp
, 1)) {
431 safe_signal(SIGINT
, saveint
);
432 safe_signal(SIGPIPE
, savepipe
);
435 if (savepipe
!= SIG_IGN
)
436 safe_signal(SIGPIPE
, pop3catch
);
437 if (pop3_noop1(&mb
) != OKAY
) {
438 safe_signal(SIGINT
, saveint
);
439 safe_signal(SIGPIPE
, savepipe
);
442 safe_signal(SIGINT
, saveint
);
443 safe_signal(SIGPIPE
, savepipe
);
446 alarm(_pop3_keepalive
);
452 pop3_stat(struct mailbox
*mp
, off_t
*size
, int *cnt
)
458 POP3_OUT(rv
, "STAT" NL
, MB_COMD
, goto jleave
);
459 POP3_ANSWER(rv
, goto jleave
);
461 for (cp
= _pop3_buf
; *cp
!= '\0' && !spacechar(*cp
); ++cp
)
463 while (*cp
!= '\0' && spacechar(*cp
))
467 *cnt
= (int)strtol(cp
, NULL
, 10);
468 while (*cp
!= '\0' && !spacechar(*cp
))
470 while (*cp
!= '\0' && spacechar(*cp
))
473 *size
= (int)strtol(cp
, NULL
, 10);
480 fprintf(stderr
, _("invalid POP3 STAT response: %s\n"), _pop3_buf
);
487 pop3_list(struct mailbox
*mp
, int n
, size_t *size
)
489 char o
[LINESIZE
], *cp
;
493 snprintf(o
, sizeof o
, "LIST %u" NL
, n
);
494 POP3_OUT(rv
, o
, MB_COMD
, goto jleave
);
495 POP3_ANSWER(rv
, goto jleave
);
497 for (cp
= _pop3_buf
; *cp
!= '\0' && !spacechar(*cp
); ++cp
)
499 while (*cp
!= '\0' && spacechar(*cp
))
501 while (*cp
!= '\0' && !spacechar(*cp
))
503 while (*cp
!= '\0' && spacechar(*cp
))
506 *size
= (size_t)strtol(cp
, NULL
, 10);
515 pop3_init(struct mailbox
*mp
, int n
)
522 m
->m_flag
= MUSED
| MNEW
| MNOFROM
| MNEWEST
;
525 pop3_list(mp
, PTR2SIZE(m
- message
+ 1), &m
->m_xsize
);
527 if ((cp
= hfield1("status", m
)) != NULL
) {
528 while (*cp
!= '\0') {
540 pop3_dates(struct mailbox
*mp
)
546 for (i
= 0; UICMP(z
, i
, <, msgCount
); ++i
)
547 substdate(message
+ i
);
552 pop3_setptr(struct mailbox
*mp
)
557 message
= scalloc(msgCount
+ 1, sizeof *message
);
558 for (i
= 0; UICMP(z
, i
, <, msgCount
); ++i
)
562 message
[msgCount
].m_size
= 0;
563 message
[msgCount
].m_lines
= 0;
569 pop3_get(struct mailbox
*mp
, struct message
*m
, enum needspec
volatile need
)
571 char o
[LINESIZE
], *line
, *lp
;
572 sighandler_type
volatile saveint
, savepipe
;
573 size_t linesize
, linelen
, size
;
575 int volatile emptyline
;
577 enum okay
volatile rv
;
580 line
= NULL
; /* TODO line pool */
581 saveint
= savepipe
= SIG_IGN
;
583 number
= (int)PTR2SIZE(m
- message
+ 1);
587 if (mp
->mb_sock
.s_fd
< 0) {
588 fprintf(stderr
, _("POP3 connection already closed.\n"));
593 if (_pop3_lock
++ == 0) {
594 if ((saveint
= safe_signal(SIGINT
, SIG_IGN
)) != SIG_IGN
)
595 safe_signal(SIGINT
, &_pop3_maincatch
);
596 savepipe
= safe_signal(SIGPIPE
, SIG_IGN
);
597 if (sigsetjmp(_pop3_jmp
, 1)) {
598 safe_signal(SIGINT
, saveint
);
599 safe_signal(SIGPIPE
, savepipe
);
603 if (savepipe
!= SIG_IGN
)
604 safe_signal(SIGPIPE
, pop3catch
);
607 fseek(mp
->mb_otf
, 0L, SEEK_END
);
608 offset
= ftell(mp
->mb_otf
);
612 snprintf(o
, sizeof o
, "TOP %u 0" NL
, number
);
615 snprintf(o
, sizeof o
, "RETR %u" NL
, number
);
620 POP3_OUT(rv
, o
, MB_COMD
| MB_MULT
, goto jleave
);
622 if (pop3_answer(mp
) == STOP
) {
623 if (need
== NEED_HEADER
) {
624 /* The TOP POP3 command is optional, so retry with entire message */
633 while (sgetline(&line
, &linesize
, &linelen
, &mp
->mb_sock
) > 0) {
634 if (line
[0] == '.' && line
[1] == NL
[0] && line
[2] == NL
[1] &&
636 mp
->mb_active
&= ~MB_MULT
;
639 if (line
[0] == '.') {
645 * Need to mask 'From ' lines. This cannot be done properly
646 * since some servers pass them as 'From ' and others as
647 * '>From '. Although one could identify the first kind of
648 * server in principle, it is not possible to identify the
649 * second as '>From ' may also come from a server of the
650 * first type as actual data. So do what is absolutely
651 * necessary only - mask 'From '.
653 * If the line is the first line of the message header, it
654 * is likely a real 'From ' line. In this case, it is just
655 * ignored since it violates all standards.
656 * TODO i have *never* seen the latter?!?!?
659 /* Since we simply copy over data without doing any transfer
660 * encoding reclassification/adjustment we *have* to perform
661 * RFC 4155 compliant From_ quoting here */
662 if (is_head(lp
, linelen
)) {
663 DBG( fprintf(stderr
, "!! POP3 really needs to quote From?\n"); )
666 fputc('>', mp
->mb_otf
);
670 if (lp
[linelen
-1] == NL
[1] && (linelen
== 1 || lp
[linelen
-2] == NL
[0])) {
671 emptyline
= linelen
<= 2;
673 fwrite(lp
, 1, linelen
- 2, mp
->mb_otf
);
674 fputc('\n', mp
->mb_otf
);
678 fwrite(lp
, 1, linelen
, mp
->mb_otf
);
683 /* This is very ugly; but some POP3 daemons don't end a
684 * message with NL NL, and we need \n\n for mbox format */
685 fputc('\n', mp
->mb_otf
);
691 m
->m_block
= mailx_blockof(offset
);
692 m
->m_offset
= mailx_offsetof(offset
);
697 m
->m_have
|= HAVE_HEADER
;
700 m
->m_have
|= HAVE_HEADER
| HAVE_BODY
;
701 m
->m_xlines
= m
->m_lines
;
702 m
->m_xsize
= m
->m_size
;
712 if (saveint
!= SIG_IGN
)
713 safe_signal(SIGINT
, saveint
);
714 if (savepipe
!= SIG_IGN
)
715 safe_signal(SIGPIPE
, savepipe
);
724 pop3_exit(struct mailbox
*mp
)
729 POP3_OUT(rv
, "QUIT" NL
, MB_COMD
, goto jleave
);
730 POP3_ANSWER(rv
, goto jleave
);
737 pop3_delete(struct mailbox
*mp
, int n
)
743 snprintf(o
, sizeof o
, "DELE %u" NL
, n
);
744 POP3_OUT(rv
, o
, MB_COMD
, goto jleave
);
745 POP3_ANSWER(rv
, goto jleave
);
752 pop3_update(struct mailbox
*mp
)
755 int dodel
, c
, gotcha
, held
;
761 for (m
= message
; PTRCMP(m
, <, message
+ msgCount
); ++m
)
762 if (m
->m_flag
& MBOX
)
769 for (m
= message
; PTRCMP(m
, <, message
+ msgCount
); ++m
) {
771 dodel
= m
->m_flag
& MDELETED
;
773 dodel
= !((m
->m_flag
& MPRESERVE
) || !(m
->m_flag
& MTOUCH
));
775 pop3_delete(mp
, PTR2SIZE(m
- message
+ 1));
780 if (gotcha
&& edit
) {
781 printf(_("\"%s\" "), displayname
);
782 printf((ok_blook(bsdcompat
) || ok_blook(bsdmsgs
))
783 ? _("complete\n") : _("updated.\n"));
784 } else if (held
&& !edit
) {
786 printf(_("Held 1 message in %s\n"), displayname
);
788 printf(_("Held %d messages in %s\n"), held
, displayname
);
798 sighandler_type
volatile saveint
, savepipe
;
803 if ((saveint
= safe_signal(SIGINT
, SIG_IGN
)) != SIG_IGN
)
804 safe_signal(SIGINT
, &_pop3_maincatch
);
805 savepipe
= safe_signal(SIGPIPE
, SIG_IGN
);
806 if (sigsetjmp(_pop3_jmp
, 1) == 0) {
807 if (savepipe
!= SIG_IGN
)
808 safe_signal(SIGPIPE
, pop3catch
);
809 rv
= pop3_noop1(&mb
);
811 safe_signal(SIGINT
, saveint
);
812 safe_signal(SIGPIPE
, savepipe
);
819 pop3_setfile(char const *server
, enum fedit_mode fm
)
822 sighandler_type saveint
, savepipe
;
828 if (fm
& FEDIT_NEWMAIL
)
832 if (!url_parse(&sc
.sc_url
, CPROTO_POP3
, server
))
834 if (!ok_blook(v15_compat
) &&
835 (!sc
.sc_url
.url_had_user
|| sc
.sc_url
.url_pass
.s
!= NULL
)) {
836 fprintf(stderr
, "New-style URL used without *v15-compat* being set\n");
840 if (!(ok_blook(v15_compat
) ? ccred_lookup(&sc
.sc_cred
, &sc
.sc_url
)
841 : ccred_lookup_old(&sc
.sc_cred
, CPROTO_POP3
, sc
.sc_url
.url_u_h_p
.s
)))
844 if (!sopen(&sc
.sc_sock
, &sc
.sc_url
))
850 edit
= !(fm
& FEDIT_SYSBOX
);
851 if (mb
.mb_sock
.s_fd
>= 0)
862 initbox(sc
.sc_url
.url_p_u_h_p
);
863 mb
.mb_type
= MB_VOID
;
865 mb
.mb_sock
= sc
.sc_sock
;
867 saveint
= safe_signal(SIGINT
, SIG_IGN
);
868 savepipe
= safe_signal(SIGPIPE
, SIG_IGN
);
869 if (sigsetjmp(_pop3_jmp
, 1)) {
871 safe_signal(SIGINT
, saveint
);
872 safe_signal(SIGPIPE
, savepipe
);
876 if (saveint
!= SIG_IGN
)
877 safe_signal(SIGINT
, pop3catch
);
878 if (savepipe
!= SIG_IGN
)
879 safe_signal(SIGPIPE
, pop3catch
);
881 if ((cp
= ok_vlook(pop3_keepalive
)) != NULL
) {
882 if ((_pop3_keepalive
= (int)strtol(cp
, NULL
, 10)) > 0) {
883 _pop3_savealrm
= safe_signal(SIGALRM
, pop3alarm
);
884 alarm(_pop3_keepalive
);
888 mb
.mb_sock
.s_desc
= sc
.sc_url
.url_proto
;
889 mb
.mb_sock
.s_onclose
= pop3_timer_off
;
890 if (_pop3_login(&mb
, &sc
) != OKAY
||
891 pop3_stat(&mb
, &mailsize
, &msgCount
) != OKAY
) {
894 safe_signal(SIGINT
, saveint
);
895 safe_signal(SIGPIPE
, savepipe
);
899 mb
.mb_type
= MB_POP3
;
900 mb
.mb_perm
= ((options
& OPT_R_FLAG
) || (fm
& FEDIT_RDONLY
)) ? 0 : MB_DELE
;
905 safe_signal(SIGINT
, saveint
);
906 safe_signal(SIGPIPE
, savepipe
);
908 if (!edit
&& msgCount
== 0) {
909 if (mb
.mb_type
== MB_POP3
&& !ok_blook(emptystart
))
910 fprintf(stderr
, _("No mail at %s\n"), server
);
921 pop3_header(struct message
*m
)
926 rv
= pop3_get(&mb
, m
, (ok_blook(pop3_bulk_load
) ? NEED_BODY
: NEED_HEADER
));
932 pop3_body(struct message
*m
)
937 rv
= pop3_get(&mb
, m
, NEED_BODY
);
945 sighandler_type
volatile saveint
, savepipe
;
948 if (mb
.mb_sock
.s_fd
< 0) {
949 fprintf(stderr
, _("POP3 connection already closed.\n"));
954 saveint
= safe_signal(SIGINT
, SIG_IGN
);
955 savepipe
= safe_signal(SIGPIPE
, SIG_IGN
);
956 if (sigsetjmp(_pop3_jmp
, 1)) {
957 safe_signal(SIGINT
, saveint
);
958 safe_signal(SIGPIPE
, saveint
);
962 if (saveint
!= SIG_IGN
)
963 safe_signal(SIGINT
, pop3catch
);
964 if (savepipe
!= SIG_IGN
)
965 safe_signal(SIGPIPE
, pop3catch
);
969 safe_signal(SIGINT
, saveint
);
970 safe_signal(SIGPIPE
, savepipe
);
978 #endif /* HAVE_POP3 */