imap/src/mailutil/mailutil.c
/* Append callback
 * Accepts: mail stream
 *	    append package
 *	    pointer to return flags
 *	    pointer to return date
 *	    pointer to return message stringstruct
 * Returns: T on success
 */
Append callback
Accepts: mail stream
append package
pointer to return flags
pointer to return date
pointer to return message stringstruct
Returns: T on success
Append callback Accepts : mail stream append package pointer to return flags pointer to return date pointer to return message stringstruct Returns : T on success
long mm_append (MAILSTREAM *stream,void *data,char **flags,char **date,
		STRING **message)
{
  char *t,*t1,tmp[MAILTMPLEN];
  unsigned long u;
  MESSAGECACHE *elt;
  APPENDPACKAGE *ap = (APPENDPACKAGE *) data;
  *flags = *date = NIL;		
  if (ap->flags) fs_give ((void **) &ap->flags);
  if (ap->date) fs_give ((void **) &ap->date);
  mail_gc (ap->stream,GC_TEXTS);
  if (++ap->msgno <= ap->msgmax) {
    memset (t = tmp,0,MAILTMPLEN);
    if ((elt = mail_elt (ap->stream,ap->msgno))->seen) strcat (t," \\Seen");
    if (elt->deleted) strcat (t," \\Deleted");
    if (elt->flagged) strcat (t," \\Flagged");
    if (elt->answered) strcat (t," \\Answered");
    if (elt->draft) strcat (t," \\Draft");
    if (!ignorep && (u = elt->user_flags)) do
      if ((t1 = ap->stream->user_flags[find_rightmost_bit (&u)]) &&
	  (MAILTMPLEN - ((t += strlen (t)) - tmp)) > (long) (2 + strlen (t1))){
	*t++ = ' ';		
	strcpy (t,t1);		
      }
    while (u);			
    *flags = ap->flags = cpystr (tmp + 1);
    *date = ap->date = cpystr (mail_date (tmp,elt));
    *message = ap->message;	
    INIT (ap->message,mstring,(void *) ap,elt->rfc822_size);
  }
  else *message = NIL;		
  return LONGT;
}
long mm_append ( MAILSTREAM * stream , void * data , char * * flags , char * * date , STRING * * message ) { char * t , * t1 , tmp [ MAILTMPLEN ] ; unsigned long u ; MESSAGECACHE * elt ; APPENDPACKAGE * ap = ( APPENDPACKAGE * ) data ; * flags = * date = NIL ; if ( ap -> flags ) fs_give ( ( void * * ) & ap -> flags ) ; if ( ap -> date ) fs_give ( ( void * * ) & ap -> date ) ; mail_gc ( ap -> stream , GC_TEXTS ) ; if ( ++ ap -> msgno <= ap -> msgmax ) { memset ( t = tmp , 0 , MAILTMPLEN ) ; if ( ( elt = mail_elt ( ap -> stream , ap -> msgno ) ) -> seen ) strcat ( t , " \\ " ) ; if ( elt -> deleted ) strcat ( t , " \\ " ) ; if ( elt -> flagged ) strcat ( t , " \\ " ) ; if ( elt -> answered ) strcat ( t , " \\ " ) ; if ( elt -> draft ) strcat ( t , " \\ " ) ; if ( ! ignorep && ( u = elt -> user_flags ) ) do if ( ( t1 = ap -> stream -> user_flags [ find_rightmost_bit ( & u ) ] ) && ( MAILTMPLEN - ( ( t += strlen ( t ) ) - tmp ) ) > ( long ) ( 2 + strlen ( t1 ) ) ) { * t ++ = ' ' ; strcpy ( t , t1 ) ; } while ( u ) ; * flags = ap -> flags = cpystr ( tmp + 1 ) ; * date = ap -> date = cpystr ( mail_date ( tmp , elt ) ) ; * message = ap -> message ; INIT ( ap -> message , mstring , ( void * ) ap , elt -> rfc822_size ) ; } else * message = NIL ; return LONGT ; }
Append callback
 Accepts: mail stream
          append package
          pointer to return flags
          pointer to return date
          pointer to return message stringstruct
 Returns: T on success
Append callback Accepts : mail stream append package pointer to return flags pointer to return date pointer to return message stringstruct Returns : T on success
/* assume no flags or date */ /* initialize flag string */ /* output system flags */ /* any user flags? */ /* space delimiter */ /* copy the user flag */ /* until no more user flags */ /* message stringstruct */ /* all done */