From a91064722447e25862a26d0e61f250646f922762 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Thu, 12 Aug 1999 11:37:55 +0000 Subject: [PATCH] implement XDELE to delete a range of messages git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6795 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/popper/pop_dele.c | 54 +++++++++++++++++++++++++++++++++++ appl/popper/pop_get_command.c | 3 ++ appl/popper/popper.h | 4 +++ 3 files changed, 61 insertions(+) diff --git a/appl/popper/pop_dele.c b/appl/popper/pop_dele.c index 2aa4da827..46077a2a6 100644 --- a/appl/popper/pop_dele.c +++ b/appl/popper/pop_dele.c @@ -51,3 +51,57 @@ pop_dele (POP *p) return (pop_msg (p,POP_SUCCESS,"Message %d has been deleted.",msg_num)); } + +#ifdef XDELE +/* delete a range of messages */ +int +pop_xdele(POP *p) +{ + MsgInfoList * mp; /* Pointer to message info list */ + + int msg_min, msg_max; + int i; + + + msg_min = atoi(p->pop_parm[1]); + if(p->parm_count == 1) + msg_max = msg_min; + else + msg_max = atoi(p->pop_parm[2]); + + if (msg_min < 1) + return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_min)); + if(msg_max > p->msg_count) + return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_max)); + for(i = msg_min; i <= msg_max; i++) { + + /* Get a pointer to the message in the message list */ + mp = &(p->mlp[i - 1]); + + /* Is the message already flagged for deletion? */ + if (mp->flags & DEL_FLAG) + continue; /* no point in returning error */ + /* Flag the message for deletion */ + mp->flags |= DEL_FLAG; + +#ifdef DEBUG + if(p->debug) + pop_log(p, POP_DEBUG, + "Deleting message %u at offset %ld of length %ld\n", + mp->number, mp->offset, mp->length); +#endif /* DEBUG */ + + /* Update the messages_deleted and bytes_deleted counters */ + p->msgs_deleted++; + p->bytes_deleted += mp->length; + } + + /* Update the last-message-accessed number if it is lower than + the deleted message */ + if (p->last_msg < msg_max) p->last_msg = msg_max; + + return (pop_msg (p,POP_SUCCESS,"Messages %d-%d has been deleted.", + msg_min, msg_max)); + +} +#endif /* XDELE */ diff --git a/appl/popper/pop_get_command.c b/appl/popper/pop_get_command.c index 9c8918cb9..b7a857aa4 100644 --- a/appl/popper/pop_get_command.c +++ b/appl/popper/pop_get_command.c @@ -34,6 +34,9 @@ static state_table states[] = { #endif #ifdef XOVER {trans, "xover", 0, 0, pop_xover, {trans, trans}}, +#endif +#ifdef XDELE + {trans, "xdele", 1, 2, pop_xdele, {trans, trans}}, #endif {(state) 0, NULL, 0, 0, NULL, {halt, halt}}, }; diff --git a/appl/popper/popper.h b/appl/popper/popper.h index 348077150..372a280a4 100644 --- a/appl/popper/popper.h +++ b/appl/popper/popper.h @@ -18,6 +18,7 @@ #include #define UIDL #define XOVER +#define XDELE #define DEBUG #define RETURN_PATH_HANDLING #endif @@ -318,6 +319,9 @@ int pop_uidl(POP *p); #ifdef XOVER int pop_xover(POP *p); #endif +#ifdef XDELE +int pop_xdele(POP *p); +#endif int pop_help(POP *p); state_table *pop_get_command(POP *p, char *mp); void pop_lower(char *buf);