~ubuntu-dev/ubuntu/lucid/mutt/lucid-201002101906

« back to all changes in this revision

Viewing changes to copy.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-06-07 17:30:03 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090607173003-pj8koe54dv9cupwa
Tags: 1.5.19-4ubuntu1
* Merge from debian unstable, remaining changes: LP: #384499
  - Build-depend on elinks (elinks doesn't provide links anymore).

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
      | (h->env->refs_changed ? CH_UPDATE_REFS : 0);
349
349
  
350
350
  if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
351
 
    return (-1);
 
351
    return -1;
352
352
 
353
353
  if (flags & CH_TXTPLAIN)
354
354
  {
360
360
    rfc822_cat(buffer, sizeof(buffer), chsbuf, MimeSpecials);
361
361
    fputs(buffer, out);
362
362
    fputc('\n', out);
363
 
    
364
 
    if (ferror (out) != 0 || feof (out) != 0)
365
 
      return -1;
366
 
    
367
 
  }
368
 
 
369
 
  if (flags & CH_UPDATE)
370
 
  {
371
 
    if ((flags & CH_NOSTATUS) == 0)
372
 
    {
373
 
      if (h->env->irt_changed && h->env->in_reply_to)
374
 
      {
375
 
        LIST *listp = h->env->in_reply_to;
376
 
 
377
 
        if (fputs ("In-Reply-To: ", out) == EOF)
378
 
          return (-1);
379
 
 
380
 
        for (; listp; listp = listp->next)
381
 
          if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
382
 
            return (-1);
383
 
 
384
 
        if (fputc ('\n', out) == EOF)
385
 
          return (-1);
386
 
      }
387
 
 
388
 
      if (h->env->refs_changed && h->env->references)
389
 
      {
390
 
        LIST *listp = h->env->references, *refs = NULL, *t;
391
 
 
392
 
        if (fputs ("References: ", out) == EOF)
393
 
          return (-1);
394
 
 
395
 
        /* Mutt stores references in reverse order, thus we create
396
 
         * a reordered refs list that we can put in the headers */
397
 
        for (; listp; listp = listp->next, refs = t)
398
 
        {
399
 
          t = (LIST *)safe_malloc (sizeof (LIST));
400
 
          t->data = listp->data;
401
 
          t->next = refs;
402
 
        }
403
 
 
404
 
        for (; refs; refs = refs->next)
405
 
          if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
406
 
            return (-1);
407
 
 
408
 
        /* clearing refs from memory */
409
 
        for (t = refs; refs; refs = t->next, t = refs)
410
 
          FREE (&refs);
411
 
 
412
 
        if (fputc ('\n', out) == EOF)
413
 
          return (-1);
414
 
      }
415
 
 
416
 
      if (h->old || h->read)
417
 
      {
418
 
        if (fputs ("Status: ", out) == EOF)
419
 
          return (-1);
420
 
 
421
 
        if (h->read)
422
 
        {
423
 
          if (fputs ("RO", out) == EOF)
424
 
            return (-1);
425
 
        }
426
 
        else if (h->old)
427
 
        {
428
 
          if (fputc ('O', out) == EOF)
429
 
            return (-1);
430
 
        }
431
 
 
432
 
        if (fputc ('\n', out) == EOF)
433
 
          return (-1);
434
 
      }
435
 
 
436
 
      if (h->flagged || h->replied)
437
 
      {
438
 
        if (fputs ("X-Status: ", out) == EOF)
439
 
          return (-1);
440
 
 
441
 
        if (h->replied)
442
 
        {
443
 
          if (fputc ('A', out) == EOF)
444
 
            return (-1);
445
 
        }
446
 
 
447
 
        if (h->flagged)
448
 
        {
449
 
          if (fputc ('F', out) == EOF)
450
 
            return (-1);
451
 
        }
452
 
        
453
 
        if (fputc ('\n', out) == EOF)
454
 
          return (-1);
455
 
      }
 
363
  }
 
364
 
 
365
  if ((flags & CH_UPDATE_IRT) && h->env->in_reply_to)
 
366
  {
 
367
    LIST *listp = h->env->in_reply_to;
 
368
    fputs ("In-Reply-To:", out);
 
369
    for (; listp; listp = listp->next)
 
370
    {
 
371
      fputc (' ', out);
 
372
      fputs (listp->data, out);
 
373
    }
 
374
    fputc ('\n', out);
 
375
  }
 
376
 
 
377
  if ((flags & CH_UPDATE_REFS) && h->env->references)
 
378
  {
 
379
    fputs ("References:", out);
 
380
    mutt_write_references (h->env->references, out, 0);
 
381
    fputc ('\n', out);
 
382
  }
 
383
 
 
384
  if ((flags & CH_UPDATE) && (flags & CH_NOSTATUS) == 0)
 
385
  {
 
386
    if (h->old || h->read)
 
387
    {
 
388
      fputs ("Status: ", out);
 
389
      if (h->read)
 
390
        fputs ("RO", out);
 
391
      else if (h->old)
 
392
        fputc ('O', out);
 
393
      fputc ('\n', out);
 
394
    }
 
395
 
 
396
    if (h->flagged || h->replied)
 
397
    {
 
398
      fputs ("X-Status: ", out);
 
399
      if (h->replied)
 
400
        fputc ('A', out);
 
401
      if (h->flagged)
 
402
        fputc ('F', out);
 
403
      fputc ('\n', out);
456
404
    }
457
405
  }
458
406
 
468
416
  {
469
417
    if (flags & CH_PREFIX)
470
418
      fputs(prefix, out);
471
 
    if (fputc ('\n', out) == EOF) /* add header terminator */
472
 
      return (-1);
 
419
    fputc ('\n', out); /* add header terminator */
473
420
  }
474
421
 
475
422
  if (ferror (out) || feof (out))
476
423
    return -1;
477
424
  
478
 
  return (0);
 
425
  return 0;
479
426
}
480
427
 
481
428
/* Count the number of lines and bytes to be deleted in this body*/
572
519
      if (new_lines <= 0)
573
520
        new_lines = 0;
574
521
      else
575
 
        fprintf (fpout, "Lines: %d\n\n", new_lines);
 
522
        fprintf (fpout, "Lines: %d\n", new_lines);
 
523
 
 
524
      putc ('\n', fpout);
576
525
      if (ferror (fpout) || feof (fpout))
577
526
        return -1;
578
527
      new_offset = ftello (fpout);
652
601
  else if (WithCrypto
653
602
           && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT))
654
603
  {
655
 
    BODY *cur;
 
604
    BODY *cur = NULL;
656
605
    FILE *fp;
657
606
 
658
607
    if ((WithCrypto & APPLICATION_PGP)
672
621
        return (-1);
673
622
    }
674
623
 
 
624
    if (!cur)
 
625
    {
 
626
      mutt_error (_("No decryption engine available for message"));
 
627
      return -1;
 
628
    }
 
629
 
675
630
    mutt_write_mime_header (cur, fpout);
676
631
    fputc ('\n', fpout);
677
632
 
718
673
  return rc;
719
674
}
720
675
 
 
676
/* should be made to return -1 on fatal errors, and 1 on non-fatal errors
 
677
 * like partial decode, where it is worth displaying as much as possible */
721
678
int
722
679
mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags,
723
680
                   int chflags)