~ubuntu-branches/ubuntu/lucid/gpgme1.0/lucid-security

« back to all changes in this revision

Viewing changes to gpgme/ttyname_r.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-07-30 10:49:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070730104921-g11b6qvc81o611zh
Tags: 1.1.5-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/rules: enable tests.
  - debian/control: adjust Maintainers field

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
int
33
33
ttyname_r (int fd, char *buf, size_t buflen)
34
34
{
 
35
  char *tty;
 
36
 
35
37
#if HAVE_W32_SYSTEM
36
 
  errno = ENOTTY; /* The best error code I have under mingw. */
 
38
  /* We use this default one for now.  AFAICS we only need it to be
 
39
     passed to gpg and in turn to pinentry.  Providing a replacement
 
40
     is needed because elsewhere we bail out on error.  If we
 
41
     eventually implement a pinentry for Windows it is uinlikely that
 
42
     we need a real tty at all.  */
 
43
  tty = "/dev/tty"; 
37
44
#else
38
 
  char *tty;
39
 
 
40
45
  tty = ttyname (fd);
41
46
  if (!tty)
42
47
    return errno;
 
48
#endif
43
49
  
44
50
  strncpy (buf, tty, buflen);
45
51
  buf[buflen - 1] = '\0';
46
52
  return (strlen (tty) >= buflen) ? ERANGE : 0;
47
 
#endif
48
53
}