~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to g10/plaintext.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-11-03 09:18:26 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20061103091826-89kwl8tk1xypbmtk
Tags: upstream-1.4.5
ImportĀ upstreamĀ versionĀ 1.4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* plaintext.c -  process plaintext packets
2
 
 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3
 
 *               2005, 2006 Free Software Foundation, Inc.
 
2
 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 
3
 *               2006 Free Software Foundation, Inc.
4
4
 *
5
5
 * This file is part of GnuPG.
6
6
 *
91
91
        log_info(_("data not saved; use option \"--output\" to save it\n"));
92
92
        nooutput = 1;
93
93
    }
94
 
    else if( !opt.use_embedded_filename ) {
 
94
    else if( !opt.flags.use_embedded_filename ) {
95
95
        fname = make_outfile_name( iobuf_get_real_fname(pt->buf) );
96
96
        if( !fname )
97
97
            fname = ask_outfile_name( pt->name, pt->namelen );
100
100
            goto leave;
101
101
        }
102
102
    }
103
 
    else {
104
 
        fname = make_printable_string( pt->name, pt->namelen, 0 );
105
 
    }
 
103
    else
 
104
      fname=utf8_to_native(pt->name,pt->namelen,0);
106
105
 
107
106
    if( nooutput )
108
107
        ;
547
546
 
548
547
    return 0;
549
548
}
 
549
 
 
550
 
 
551
/* Set up a plaintext packet with the appropriate filename.  If there
 
552
   is a --set-filename, use it (it's already UTF8).  If there is a
 
553
   regular filename, UTF8-ize it if necessary.  If there is no
 
554
   filenames at all, set the field empty. */
 
555
 
 
556
PKT_plaintext *
 
557
setup_plaintext_name(const char *filename,IOBUF iobuf)
 
558
{
 
559
  PKT_plaintext *pt;
 
560
 
 
561
  if(filename || opt.set_filename)
 
562
    {
 
563
      char *s;
 
564
 
 
565
      if(opt.set_filename)
 
566
        s=make_basename(opt.set_filename,iobuf_get_real_fname(iobuf));
 
567
      else if(filename && !opt.flags.utf8_filename)
 
568
        {
 
569
          char *tmp=native_to_utf8(filename);
 
570
          s=make_basename(tmp,iobuf_get_real_fname(iobuf));
 
571
          xfree(tmp);
 
572
        }
 
573
      else
 
574
        s=make_basename(filename,iobuf_get_real_fname(iobuf));
 
575
 
 
576
      pt = xmalloc (sizeof *pt + strlen(s) - 1);
 
577
      pt->namelen = strlen (s);
 
578
      memcpy (pt->name, s, pt->namelen);
 
579
      xfree (s);
 
580
    }
 
581
  else
 
582
    {
 
583
      /* no filename */
 
584
      pt = xmalloc (sizeof *pt - 1);
 
585
      pt->namelen = 0;
 
586
    }
 
587
 
 
588
  return pt;
 
589
}