Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=f5df03ed70b770e1cbd3c1cdc621d7698f08146d
commit f5df03ed70b770e1cbd3c1cdc621d7698f08146d Author: James Buren <[email protected]> Date: Mon Apr 28 05:12:08 2014 -0500 move checkTTY() to UI from UINewt. It does not rely on libnewt, so why keep it there? diff --git a/src-new/newt.cpp b/src-new/newt.cpp index 2342f26..7dffd20 100644 --- a/src-new/newt.cpp +++ b/src-new/newt.cpp @@ -1,36 +1,8 @@ -#include <unistd.h> #include <iostream> #include <cstdlib> +#include <unistd.h> #include "newt.hpp" -bool UINewt::checkTTY(int fd) -{ - std::string fd_name; - - switch(fd) - { - case STDIN_FILENO: - fd_name = "stdin"; - break; - - case STDOUT_FILENO: - fd_name = "stdout"; - break; - - case STDERR_FILENO: - fd_name = "stderr"; - break; - } - - if(!isatty(fd)) - { - printError(fd_name + " is not a tty."); - return false; - } - - return true; -} - int UINewt::main(int argc, char **argv) { int code = EXIT_FAILURE; diff --git a/src-new/newt.hpp b/src-new/newt.hpp index dde10d2..76277d2 100644 --- a/src-new/newt.hpp +++ b/src-new/newt.hpp @@ -4,9 +4,6 @@ class UINewt : UI { - private: - bool checkTTY(int fd); - public: int main(int argc, char **argv); }; \ No newline at end of file diff --git a/src-new/ui.cpp b/src-new/ui.cpp index bf3aa1b..6a0699f 100644 --- a/src-new/ui.cpp +++ b/src-new/ui.cpp @@ -2,6 +2,7 @@ #include <csignal> #include <cstring> #include <cstdlib> +#include <unistd.h> #include "ui.hpp" // UI Class Start @@ -10,6 +11,34 @@ void UI::printError(const std::string &line) std::cerr << line << std::endl; } +bool UI::checkTTY(int fd) +{ + std::string fd_name; + + switch(fd) + { + case STDIN_FILENO: + fd_name = "stdin"; + break; + + case STDOUT_FILENO: + fd_name = "stdout"; + break; + + case STDERR_FILENO: + fd_name = "stderr"; + break; + } + + if(!isatty(fd)) + { + printError(fd_name + " is not a tty."); + return false; + } + + return true; +} + bool UI::setSignalInterrupt(int sig, bool interrupt) { struct sigaction sig_handler; diff --git a/src-new/ui.hpp b/src-new/ui.hpp index b0fcc16..8704cc4 100644 --- a/src-new/ui.hpp +++ b/src-new/ui.hpp @@ -6,6 +6,7 @@ class UI { public: void printError(const std::string &line); + bool checkTTY(int fd); bool setSignalInterrupt(int sig, bool interrupt); virtual int main(int argc, char **argv); }; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
