deprecated warning
[heimdal.git] / appl / popper / pop_list.c
blobb7f0d1f9940136f23c57de9b3bb6be7ecbb006e0
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("$Id$");
11 * list: List the contents of a POP maildrop
14 int
15 pop_list (POP *p)
17 MsgInfoList * mp; /* Pointer to message info list */
18 int i;
19 int msg_num;
21 /* Was a message number provided? */
22 if (p->parm_count > 0) {
23 msg_num = atoi(p->pop_parm[1]);
25 /* Is requested message out of range? */
26 if ((msg_num < 1) || (msg_num > p->msg_count))
27 return (pop_msg (p,POP_FAILURE,
28 "Message %d does not exist.",msg_num));
30 /* Get a pointer to the message in the message list */
31 mp = &p->mlp[msg_num-1];
33 /* Is the message already flagged for deletion? */
34 if (mp->flags & DEL_FLAG)
35 return (pop_msg (p,POP_FAILURE,
36 "Message %d has been deleted.",msg_num));
38 /* Display message information */
39 return (pop_msg(p,POP_SUCCESS,"%d %ld",msg_num,mp->length));
42 /* Display the entire list of messages */
43 pop_msg(p,POP_SUCCESS,
44 "%d messages (%ld octets)",
45 p->msg_count-p->msgs_deleted,
46 p->drop_size-p->bytes_deleted);
48 /* Loop through the message information list. Skip deleted messages */
49 for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
50 if (!(mp->flags & DEL_FLAG))
51 fprintf(p->output,"%u %lu\r\n",mp->number,mp->length);
54 /* "." signals the end of a multi-line transmission */
55 fprintf(p->output,".\r\n");
56 fflush(p->output);
58 return(POP_SUCCESS);