iProper rewrite of function termsize (renamed getTerminalHeight): - add documentation - use constant instead of litteral integer value for the fd - handle ioctl failure - use better return type - clic - Clic is an command line interactive client for gopher written in Common LISP Err bitreich.org 70 hgit clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/ URL:git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/ bitreich.org 70 1Log /scm/clic/log.gph bitreich.org 70 1Files /scm/clic/files.gph bitreich.org 70 1Refs /scm/clic/refs.gph bitreich.org 70 1Tags /scm/clic/tag bitreich.org 70 1README /scm/clic/file/README.md.gph bitreich.org 70 1LICENSE /scm/clic/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 40244f6eac457069e60611709cda1851aae1eb08 /scm/clic/commit/40244f6eac457069e60611709cda1851aae1eb08.gph bitreich.org 70 1parent 27321d7d6a66be5fd4f18a8acc515387e5bb1564 /scm/clic/commit/27321d7d6a66be5fd4f18a8acc515387e5bb1564.gph bitreich.org 70 hAuthor: killruana URL:mailto:killruana@gmail.com bitreich.org 70 iDate: Sat, 11 Nov 2017 13:29:36 +0100 Err bitreich.org 70 i Err bitreich.org 70 iProper rewrite of function termsize (renamed getTerminalHeight): Err bitreich.org 70 i - add documentation Err bitreich.org 70 i - use constant instead of litteral integer value for the fd Err bitreich.org 70 i - handle ioctl failure Err bitreich.org 70 i - use better return type Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M extension.c | 17 +++++++++++++---- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 13 insertions(+), 4 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/extension.c b/extension.c /scm/clic/file/extension.c.gph bitreich.org 70 i@@ -1,8 +1,17 @@ Err bitreich.org 70 i+#include Err bitreich.org 70 i #include Err bitreich.org 70 i+#include Err bitreich.org 70 i Err bitreich.org 70 i-int termsize() Err bitreich.org 70 i+/** Err bitreich.org 70 i+ * @brief Get the height of the terminal in term of visible lines Err bitreich.org 70 i+ * @return the height of the terminal or UINT_MAX in case of error Err bitreich.org 70 i+ */ Err bitreich.org 70 i+unsigned int getTerminalHeight() Err bitreich.org 70 i { Err bitreich.org 70 i- struct winsize w; Err bitreich.org 70 i- ioctl(0,TIOCGWINSZ, &w); Err bitreich.org 70 i- return(w.ws_row); Err bitreich.org 70 i+ struct winsize w; Err bitreich.org 70 i+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) < 0) { Err bitreich.org 70 i+ return UINT_MAX; Err bitreich.org 70 i+ } Err bitreich.org 70 i+ Err bitreich.org 70 i+ return w.ws_row; Err bitreich.org 70 i } Err bitreich.org 70 .