add rsakey2048 and rsakey4096
[heimdal.git] / appl / popper / pop_dele.c
blob2328d5a2289447811be4ec8b54fe6e9e0a669c24
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 * dele: Delete a message from the POP maildrop
13 int
14 pop_dele (POP *p)
16 MsgInfoList * mp; /* Pointer to message info list */
17 int msg_num;
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.",
32 msg_num));
34 /* Flag the message for deletion */
35 mp->flags |= DEL_FLAG;
37 #ifdef DEBUG
38 if(p->debug)
39 pop_log(p, POP_DEBUG,
40 "Deleting message %u at offset %ld of length %ld\n",
41 mp->number, mp->offset, mp->length);
42 #endif /* DEBUG */
44 /* Update the messages_deleted and bytes_deleted counters */
45 p->msgs_deleted++;
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));
55 #ifdef XDELE
56 /* delete a range of messages */
57 int
58 pop_xdele(POP *p)
60 MsgInfoList * mp; /* Pointer to message info list */
62 int msg_min, msg_max;
63 int i;
66 msg_min = atoi(p->pop_parm[1]);
67 if(p->parm_count == 1)
68 msg_max = msg_min;
69 else
70 msg_max = atoi(p->pop_parm[2]);
72 if (msg_min < 1)
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;
87 #ifdef DEBUG
88 if(p->debug)
89 pop_log(p, POP_DEBUG,
90 "Deleting message %u at offset %ld of length %ld\n",
91 mp->number, mp->offset, mp->length);
92 #endif /* DEBUG */
94 /* Update the messages_deleted and bytes_deleted counters */
95 p->msgs_deleted++;
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.",
104 msg_min, msg_max));
107 #endif /* XDELE */