00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "ux.hpp"
00019
00020 using namespace Ux;
00021
00022
00023
00024
00025 speed_t Termios::cfgetispeed(void)
00026 {
00027 return ::cfgetispeed(this);
00028 }
00029
00030
00031
00032
00033 speed_t Termios::cfgetospeed(void)
00034 {
00035 return ::cfgetospeed(this);
00036 }
00037
00038
00039
00040
00041 void Termios::cfsetispeed(speed_t speed)
00042 {
00043 if (::cfsetispeed(this, speed) == -1)
00044 throw Error(errno);
00045 }
00046
00047
00048
00049
00050 void Termios::cfsetospeed(speed_t speed)
00051 {
00052 if (::cfsetospeed(this, speed) == -1)
00053 throw Error(errno);
00054 }
00055
00056
00057
00058
00059 bool Terminal::isatty(void)
00060 {
00061 return ::isatty(fd) == 1;
00062 }
00063
00064
00065
00066
00067 char *Terminal::ctermid(char *buf)
00068 {
00069 char *s;
00070
00071 errno = 0;
00072 s = ::ctermid(buf);
00073 if (s[0] == '\0') {
00074 if (errno == 0)
00075 throw Error(EINVAL);
00076 else
00077 throw Error(errno);
00078 }
00079 return s;
00080 }
00081
00082
00083
00084
00085 void Terminal::tcdrain(void)
00086 {
00087 if (::tcdrain(fd) == -1)
00088 throw Error(errno);
00089 }
00090
00091
00092
00093
00094 void Terminal::tcflow(int action)
00095 {
00096 if (::tcflow(fd, action) == -1)
00097 throw Error(errno);
00098 }
00099
00100
00101
00102
00103 void Terminal::tcflush(int queue)
00104 {
00105 if (::tcflush(fd, queue) == -1)
00106 throw Error(errno);
00107 }
00108
00109
00110
00111
00112 void Terminal::tcgetattr(Termios& t)
00113 {
00114 if (::tcgetattr(fd, &t) == -1)
00115 throw Error(errno);
00116 }
00117
00118
00119
00120
00121 pid_t Terminal::tcgetpgrp(void)
00122 {
00123 pid_t pid;
00124
00125 if ((pid = ::tcgetpgrp(fd)) == -1)
00126 throw Error(errno);
00127 return pid;
00128 }
00129
00130
00131
00132
00133 pid_t Terminal::tcgetsid(void)
00134 {
00135 pid_t pid;
00136
00137 if ((pid = ::tcgetsid(fd)) == -1)
00138 throw Error(errno);
00139 return pid;
00140 }
00141
00142
00143
00144
00145 void Terminal::tcsendbreak(int duration)
00146 {
00147 if (::tcsendbreak(fd, duration) == -1)
00148 throw Error(errno);
00149 }
00150
00151
00152
00153
00154 void Terminal::tcsetattr(int actions, const Termios& t)
00155 {
00156 if (::tcsetattr(fd, actions, &t) == -1)
00157 throw Error(errno);
00158 }
00159
00160
00161
00162
00163 void Terminal::tcsetpgrp(pid_t pgid)
00164 {
00165 if (::tcsetpgrp(fd, pgid) == -1)
00166 throw Error(errno);
00167 }
00168
00169
00170
00171
00172
00173 void Terminal::ttyname(char *buf, size_t bufsize)
00174 {
00175 int r;
00176
00177 if ((r = ::ttyname_r(fd, buf, bufsize)) > 0)
00178 throw Error(r);
00179 }