No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / appl / popper / pop_list.c
blobed38363d3be51ba81e041e105ff687ad929c5518
1 /*
2 * Copyright (c) 1989 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
7 #include <popper.h>
8 __RCSID("$Heimdal: pop_list.c 4794 1998-04-23 17:41:49Z joda $"
9 "$NetBSD$");
11 /*
12 * list: List the contents of a POP maildrop
15 int
16 pop_list (POP *p)
18 MsgInfoList * mp; /* Pointer to message info list */
19 int i;
20 int msg_num;
22 /* Was a message number provided? */
23 if (p->parm_count > 0) {
24 msg_num = atoi(p->pop_parm[1]);
26 /* Is requested message out of range? */
27 if ((msg_num < 1) || (msg_num > p->msg_count))
28 return (pop_msg (p,POP_FAILURE,
29 "Message %d does not exist.",msg_num));
31 /* Get a pointer to the message in the message list */
32 mp = &p->mlp[msg_num-1];
34 /* Is the message already flagged for deletion? */
35 if (mp->flags & DEL_FLAG)
36 return (pop_msg (p,POP_FAILURE,
37 "Message %d has been deleted.",msg_num));
39 /* Display message information */
40 return (pop_msg(p,POP_SUCCESS,"%d %ld",msg_num,mp->length));
43 /* Display the entire list of messages */
44 pop_msg(p,POP_SUCCESS,
45 "%d messages (%ld octets)",
46 p->msg_count-p->msgs_deleted,
47 p->drop_size-p->bytes_deleted);
49 /* Loop through the message information list. Skip deleted messages */
50 for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
51 if (!(mp->flags & DEL_FLAG))
52 fprintf(p->output,"%u %lu\r\n",mp->number,mp->length);
55 /* "." signals the end of a multi-line transmission */
56 fprintf(p->output,".\r\n");
57 fflush(p->output);
59 return(POP_SUCCESS);