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("$Heimdal: pop_dele.c 6795 1999-08-12 11:37:55Z joda $"
12 * dele: Delete a message from the POP maildrop
17 MsgInfoList
* mp
; /* Pointer to message info list */
20 /* Convert the message number parameter to an integer */
21 msg_num
= atoi(p
->pop_parm
[1]);
23 /* Is requested message out of range? */
24 if ((msg_num
< 1) || (msg_num
> p
->msg_count
))
25 return (pop_msg (p
,POP_FAILURE
,"Message %d does not exist.",msg_num
));
27 /* Get a pointer to the message in the message list */
28 mp
= &(p
->mlp
[msg_num
-1]);
30 /* Is the message already flagged for deletion? */
31 if (mp
->flags
& DEL_FLAG
)
32 return (pop_msg (p
,POP_FAILURE
,"Message %d has already been deleted.",
35 /* Flag the message for deletion */
36 mp
->flags
|= DEL_FLAG
;
41 "Deleting message %u at offset %ld of length %ld\n",
42 mp
->number
, mp
->offset
, mp
->length
);
45 /* Update the messages_deleted and bytes_deleted counters */
47 p
->bytes_deleted
+= mp
->length
;
49 /* Update the last-message-accessed number if it is lower than
50 the deleted message */
51 if (p
->last_msg
< msg_num
) p
->last_msg
= msg_num
;
53 return (pop_msg (p
,POP_SUCCESS
,"Message %d has been deleted.",msg_num
));
57 /* delete a range of messages */
61 MsgInfoList
* mp
; /* Pointer to message info list */
67 msg_min
= atoi(p
->pop_parm
[1]);
68 if(p
->parm_count
== 1)
71 msg_max
= atoi(p
->pop_parm
[2]);
74 return (pop_msg (p
,POP_FAILURE
,"Message %d does not exist.",msg_min
));
75 if(msg_max
> p
->msg_count
)
76 return (pop_msg (p
,POP_FAILURE
,"Message %d does not exist.",msg_max
));
77 for(i
= msg_min
; i
<= msg_max
; i
++) {
79 /* Get a pointer to the message in the message list */
80 mp
= &(p
->mlp
[i
- 1]);
82 /* Is the message already flagged for deletion? */
83 if (mp
->flags
& DEL_FLAG
)
84 continue; /* no point in returning error */
85 /* Flag the message for deletion */
86 mp
->flags
|= DEL_FLAG
;
91 "Deleting message %u at offset %ld of length %ld\n",
92 mp
->number
, mp
->offset
, mp
->length
);
95 /* Update the messages_deleted and bytes_deleted counters */
97 p
->bytes_deleted
+= mp
->length
;
100 /* Update the last-message-accessed number if it is lower than
101 the deleted message */
102 if (p
->last_msg
< msg_max
) p
->last_msg
= msg_max
;
104 return (pop_msg (p
,POP_SUCCESS
,"Messages %d-%d has been deleted.",