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 */ 6 7#include <popper.h> 8RCSID("$Id$"); 9 10/* 11 * list: List the contents of a POP maildrop 12 */ 13 14int 15pop_list (POP *p) 16{ 17 MsgInfoList * mp; /* Pointer to message info list */ 18 int i; 19 int msg_num; 20 21 /* Was a message number provided? */ 22 if (p->parm_count > 0) { 23 msg_num = atoi(p->pop_parm[1]); 24 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)); 29 30 /* Get a pointer to the message in the message list */ 31 mp = &p->mlp[msg_num-1]; 32 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)); 37 38 /* Display message information */ 39 return (pop_msg(p,POP_SUCCESS,"%d %ld",msg_num,mp->length)); 40 } 41 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); 47 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); 52 } 53 54 /* "." signals the end of a multi-line transmission */ 55 fprintf(p->output,".\r\n"); 56 fflush(p->output); 57 58 return(POP_SUCCESS); 59} 60