Added POSIX functions posix_openpt(), grantpt(), ptsname(), and
unlockpt(), which provide a portable way of opening a pty. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25134 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
06b7c7ffe2
commit
fb913b19be
@ -166,6 +166,13 @@ extern size_t wcstombs(char *string, const wchar_t *pwcs, size_t maxSize);
|
||||
/* crypt */
|
||||
extern void setkey(const char *key);
|
||||
|
||||
|
||||
/* pty functions */
|
||||
extern int posix_openpt(int openFlags);
|
||||
extern int grantpt(int masterFD);
|
||||
extern char* ptsname(int masterFD);
|
||||
extern int unlockpt(int masterFD);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
SubDir HAIKU_TOP src system libroot posix stdlib ;
|
||||
|
||||
UsePrivateHeaders libroot ;
|
||||
UsePrivateHeaders drivers libroot ;
|
||||
UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ;
|
||||
|
||||
MergeObject posix_stdlib.o :
|
||||
@ -15,6 +15,7 @@ MergeObject posix_stdlib.o :
|
||||
heapsort.c
|
||||
merge.c
|
||||
mktemp.c
|
||||
pty.cpp
|
||||
qsort.c
|
||||
radixsort.c
|
||||
rand.c
|
||||
|
52
src/system/libroot/posix/stdlib/pty.cpp
Normal file
52
src/system/libroot/posix/stdlib/pty.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <tty.h>
|
||||
|
||||
|
||||
int
|
||||
posix_openpt(int openFlags)
|
||||
{
|
||||
return open("/dev/ptmx", openFlags);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
grantpt(int masterFD)
|
||||
{
|
||||
return ioctl(masterFD, B_IOCTL_GRANT_TTY);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
ptsname(int masterFD)
|
||||
{
|
||||
int32 index;
|
||||
if (ioctl(masterFD, B_IOCTL_GET_TTY_INDEX, &index, sizeof(index)) < 0)
|
||||
return NULL;
|
||||
|
||||
static char buffer[32];
|
||||
|
||||
char letter = 'p';
|
||||
snprintf(buffer, sizeof(buffer), "/dev/tt/%c%lx", char(letter + index / 16),
|
||||
index % 16);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
unlockpt(int masterFD)
|
||||
{
|
||||
// Noting to do ATM.
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user