~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-proposed

« back to all changes in this revision

Viewing changes to common/iobuf.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-05-25 14:27:35 UTC
  • mfrom: (1.1.15 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110525142735-jccyw0fopnyv728q
Tags: 2.0.17-2ubuntu1
* Merge from debian unstable. Remaining changes:
  - Add udev rules to give gpg access to some smartcard readers;
    Debian #543217.
    . debian/gnupg2.dev: udev rules to set ACLs on SCM smartcard readers.
    . debian/rules: Call dh_installudev.
  - debian/control: Rename Vcs-* to XS-Debian-Vcs-*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1260
1260
  return check_special_filename (fname) != -1;
1261
1261
}
1262
1262
 
 
1263
 
 
1264
/* Either open the file specified by the file descriptor FD or - if FD
 
1265
   is -1, the file with name FNAME.  As of now MODE is assumed to be
 
1266
   "rb" if FNAME is used.  In contrast to iobuf_fdopen the file
 
1267
   descriptor FD will not be closed during an iobuf_close.  */
 
1268
iobuf_t
 
1269
iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, const char *mode)
 
1270
{
 
1271
  iobuf_t a;
 
1272
 
 
1273
  if (fd == -1)
 
1274
    a = iobuf_open (fname);
 
1275
  else
 
1276
    {
 
1277
      int fd2;
 
1278
 
 
1279
      fd2 = dup (fd);
 
1280
      if (fd2 == -1)
 
1281
        a = NULL;
 
1282
      else
 
1283
        a = iobuf_fdopen (fd2, mode);
 
1284
    }
 
1285
  return a;
 
1286
}
 
1287
 
 
1288
 
1263
1289
/****************
1264
1290
 * Create a head iobuf for reading from a file
1265
1291
 * returns: NULL if an error occures and sets errno