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.
8 RCSID("$Id: pop_dele.c,v 1.10 1999/08/12 11:35:26 joda Exp $");
11 * dele: Delete a message from the POP maildrop
16 MsgInfoList * mp; /* Pointer to message info list */
19 /* Convert the message number parameter to an integer */
20 msg_num = atoi(p->pop_parm[1]);
22 /* Is requested message out of range? */
23 if ((msg_num < 1) || (msg_num > p->msg_count))
24 return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_num));
26 /* Get a pointer to the message in the message list */
27 mp = &(p->mlp[msg_num-1]);
29 /* Is the message already flagged for deletion? */
30 if (mp->flags & DEL_FLAG)
31 return (pop_msg (p,POP_FAILURE,"Message %d has already been deleted.",
34 /* Flag the message for deletion */
35 mp->flags |= DEL_FLAG;
40 "Deleting message %u at offset %ld of length %ld\n",
41 mp->number, mp->offset, mp->length);
44 /* Update the messages_deleted and bytes_deleted counters */
46 p->bytes_deleted += mp->length;
48 /* Update the last-message-accessed number if it is lower than
49 the deleted message */
50 if (p->last_msg < msg_num) p->last_msg = msg_num;
52 return (pop_msg (p,POP_SUCCESS,"Message %d has been deleted.",msg_num));
56 /* delete a range of messages */
60 MsgInfoList * mp; /* Pointer to message info list */
66 msg_min = atoi(p->pop_parm[1]);
67 if(p->parm_count == 1)
70 msg_max = atoi(p->pop_parm[2]);
73 return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_min));
74 if(msg_max > p->msg_count)
75 return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_max));
76 for(i = msg_min; i <= msg_max; i++) {
78 /* Get a pointer to the message in the message list */
79 mp = &(p->mlp[i - 1]);
81 /* Is the message already flagged for deletion? */
82 if (mp->flags & DEL_FLAG)
83 continue; /* no point in returning error */
84 /* Flag the message for deletion */
85 mp->flags |= DEL_FLAG;
90 "Deleting message %u at offset %ld of length %ld\n",
91 mp->number, mp->offset, mp->length);
94 /* Update the messages_deleted and bytes_deleted counters */
96 p->bytes_deleted += mp->length;
99 /* Update the last-message-accessed number if it is lower than
100 the deleted message */
101 if (p->last_msg < msg_max) p->last_msg = msg_max;
103 return (pop_msg (p,POP_SUCCESS,"Messages %d-%d has been deleted.",