00001 /* 00002 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00003 May be copied only for purposes and under conditions described 00004 on the Web page www.basepath.com/aup/copyright.htm. 00005 00006 The Example Files are provided "as is," without any warranty; 00007 without even the implied warranty of merchantability or fitness 00008 for a particular purpose. The author and his publisher are not 00009 responsible for any damages, direct or incidental, resulting 00010 from the use or non-use of these Example Files. 00011 00012 The Example Files may contain defects, and some contain deliberate 00013 coding mistakes that were included for educational reasons. 00014 You are responsible for determining if and how the Example Files 00015 are to be used. 00016 00017 */ 00018 #include "ux.hpp" 00019 00020 using namespace Ux; 00021 00022 void Pty::posix_openpt(int oflag) 00023 { 00024 if ((fd = ::posix_openpt(oflag)) == -1) 00025 throw Error(errno); 00026 } 00027 00028 void Pty::grantpt(void) 00029 { 00030 if (::grantpt(fd) == -1) 00031 throw Error(errno); 00032 } 00033 00034 void Pty::unlockpt(void) 00035 { 00036 if (::unlockpt(fd) == -1) 00037 throw Error(errno); 00038 } 00039 00040 char *Pty::ptsname(void) 00041 { 00042 char *s; 00043 00044 errno = 0; 00045 if ((s = ::ptsname(fd)) == NULL) { 00046 if (errno == 0) 00047 throw Error(EINVAL); 00048 else 00049 throw Error(errno); 00050 } 00051 return s; 00052 }