1 /* 2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include <stdlib.h> 7 8 #include <fcntl.h> 9 #include <stdio.h> 10 11 #include <SupportDefs.h> 12 13 #include <tty.h> 14 15 16 int 17 posix_openpt(int openFlags) 18 { 19 return open("/dev/ptmx", openFlags); 20 } 21 22 23 int 24 grantpt(int masterFD) 25 { 26 return ioctl(masterFD, B_IOCTL_GRANT_TTY); 27 } 28 29 30 char* 31 ptsname(int masterFD) 32 { 33 int32 index; 34 if (ioctl(masterFD, B_IOCTL_GET_TTY_INDEX, &index, sizeof(index)) < 0) 35 return NULL; 36 37 static char buffer[32]; 38 39 char letter = 'p'; 40 snprintf(buffer, sizeof(buffer), "/dev/tt/%c%" B_PRIx32, 41 char(letter + index / 16), index % 16); 42 43 return buffer; 44 } 45 46 47 int 48 unlockpt(int masterFD) 49 { 50 // Noting to do ATM. 51 return 0; 52 } 53