Back to index

glibc  2.9
Defines | Functions | Variables
getpt.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stub-tag.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define _PATH_PTY   "/dev/pty"
#define PTYNAME1   "pqrsPQRS"
#define PTYNAME2   "0123456789abcdefghijklmnopqrstuv";

Functions

int __getpt (void)
 weak_alias (__getpt, getpt)

Variables

const char __libc_ptyname1[] attribute_hidden = PTYNAME1

Define Documentation

#define _PATH_PTY   "/dev/pty"

Definition at line 27 of file getpt.c.

#define PTYNAME1   "pqrsPQRS"

Definition at line 32 of file getpt.c.

#define PTYNAME2   "0123456789abcdefghijklmnopqrstuv";

Definition at line 38 of file getpt.c.


Function Documentation

int __getpt ( void  )

Definition at line 45 of file getpt.c.

{
  char buf[sizeof (_PATH_PTY) + 2];
  const char *p, *q;
  char *s;

  s = __mempcpy (buf, _PATH_PTY, sizeof (_PATH_PTY) - 1);
  /* s[0] and s[1] will be filled in the loop.  */
  s[2] = '\0';

  for (p = __libc_ptyname1; *p != '\0'; ++p)
    {
      s[0] = *p;

      for (q = __libc_ptyname2; *q != '\0'; ++q)
       {
         int fd;

         s[1] = *q;

         fd = __open (buf, O_RDWR);
         if (fd != -1)
           return fd;

         if (errno == ENOENT)
           return -1;
       }
    }

  __set_errno (ENOENT);
  return -1;
}

Here is the call graph for this function:

weak_alias ( __getpt  ,
getpt   
)

Definition at line 79 of file getpt.c.

{
  __set_errno (ENOSYS);
  return -1;
}

Variable Documentation

const char __libc_ptyname2 [] attribute_hidden = PTYNAME1

Definition at line 34 of file getpt.c.