++pIMAP->seq_num,i, CRLF); } else {  sprintf(command, "%d STORE %d +FLAGS (\\SEEN)%s",
imapRetrRecentMessages(ptcx_t ptcx,		       IMAP *pIMAP,		       SOCKET sock,		       mail_command_t *cmd,		       cmd_stats_t *ptimer,		       int numExists, 		       int numRecent){    int i = 0;    char command[MAX_COMMAND_LEN];    int numBytes = 0;    long msgSize = 0;    char *msgBuffer = NULL;    int msgBufferSize = 0;    int	rc;    pish_stats_t	*stats = (pish_stats_t *)ptimer->data;    pish_command_t	*pish = (pish_command_t *)cmd->data;    if ( numRecent == 0 )	return 0;    /* retr the msgs */    for (i = numExists - numRecent + 1; i <= numExists; i++) {	/* bail if time is up */	if (gf_timeexpired >= EXIT_SOON) {	    D_PRINTF(debugfile,"Time expired while reading messages\n");	    break;	}	/* fetch the size of the recent msg */	sprintf(command, "%d FETCH %d (RFC822.SIZE)%s", 		++pIMAP->seq_num, i, CRLF);	event_start(ptcx, &stats->cmd);	rc = doImapCommandResponse(ptcx, sock, pIMAP->seq_num,				   command, pIMAP->resp_buffer, sizeof(pIMAP->resp_buffer));	event_stop (ptcx, &stats->cmd);	if (rc == -1) {	    if (gf_timeexpired >= EXIT_FAST) break; /* dont fall into error */	    return -1;	}	/* parse the SIZE out of buffer */	if (!sscanf(pIMAP->resp_buffer, "* %*d FETCH (RFC822.SIZE %ld)", &msgSize)) {	    returnerr(debugfile, "IMAP4 Error parsing size of msg from response, %s: %s\n",		      pIMAP->resp_buffer, neterrstr());	    return -1;	}	/* malloc buffer for msg, with room for control (flags) info */	msgBufferSize = msgSize+1024;	msgBuffer = (char *) mycalloc(msgBufferSize);	/* FETCH the msg */	sprintf(command, "%d FETCH %d (RFC822)%s", ++pIMAP->seq_num, i, CRLF);	event_start(ptcx, &stats->msgread);	numBytes = sendCommand(ptcx, sock, command);	if (numBytes == -1) {	    event_stop(ptcx, &stats->msgread);	    myfree(msgBuffer);	    if (gf_timeexpired >= EXIT_FAST) break; /* dont fall into error */	    stats->msgread.errs++;	    returnerr(debugfile, "IMAP4 Error sending [%s] command: %s\n",		      command, neterrstr());	    return -1;	}	/* read msg */	numBytes = retrImapMsg(ptcx, sock, pIMAP->seq_num,			       msgBuffer, msgSize, msgBufferSize);	event_stop(ptcx, &stats->msgread);	if (numBytes <= 0) {	    myfree(msgBuffer);	    if (gf_timeexpired >= EXIT_FAST) break; /* dont fall into error */	    stats->msgread.errs++;	    returnerr(debugfile, "IMAP4 Error retrieving msg %d: %s\n",		      i, neterrstr());	    return -1;	}	myfree(msgBuffer);	/* send a NOOP */	sprintf(command, "%d NOOP%s",++pIMAP->seq_num, CRLF);	event_start(ptcx, &stats->cmd);	rc = doImapCommandResponse(ptcx, sock, pIMAP->seq_num,				   command, pIMAP->resp_buffer, sizeof(pIMAP->resp_buffer));	event_stop (ptcx, &stats->cmd);	if (rc == -1) {	    if (gf_timeexpired >= EXIT_FAST) break; /* dont fall into error */	    stats->cmd.errs++;	    return -1;	}	/* if we're told to leave mail on server, do not delete the message */        if (pish->leaveMailOnServer < IMAP_LEAVE_UNSEEN) {	    if (0 == pish->leaveMailOnServer) {					/* mark the msg \deleted and \seen */		sprintf(command, "%d STORE %d +FLAGS (\\DELETED \\SEEN)%s",			++pIMAP->seq_num,i, CRLF);	    } else {					/* mark the msg \seen needed??? */		sprintf(command, "%d STORE %d +FLAGS (\\SEEN)%s",			++pIMAP->seq_num,i, CRLF);	    }	    event_start(ptcx, &stats->cmd);	    rc = doImapCommandResponse(ptcx, sock, pIMAP->seq_num,				       command, pIMAP->resp_buffer, sizeof(pIMAP->resp_buffer));	    event_stop (ptcx, &stats->cmd);	    if (rc == -1) {		if (gf_timeexpired >= EXIT_FAST) break; /* dont fall into error */		stats->cmd.errs++;		return -1;	    }	} else {	    /* We dont mark it seen, but it still isnt new anymore... */	    D_PRINTF (stderr, "retrRecentMsgs() Leaving messaged %d unseen\n", i);	}    }    if (0 == pish->leaveMailOnServer) {	/* expunge if we are deleting */	/* EXPUNGE \deleted messages */	sprintf(command, "%d EXPUNGE%s", ++pIMAP->seq_num, CRLF);	event_start(ptcx, &stats->cmd);	rc = doImapCommandResponse(ptcx, sock, pIMAP->seq_num,				   command, pIMAP->resp_buffer, sizeof(pIMAP->resp_buffer));	event_stop (ptcx, &stats->cmd);	if (rc == -1) {	    if (gf_timeexpired < EXIT_FAST)	/* dont fall into error */		return -1;	    stats->cmd.errs++;	}    }    return 0;}