bugs: Advantages for incremental library separation by analogy with incremental
[Ale.git] / ui / util.h
blob5aa35c5b5540d4d2cef548fec3b53add4ddbbe42
1 // Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@ugcs.caltech.edu>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __util_h__
22 #define __util_h__
24 #ifdef USE_IOCTL
25 #include <sys/ioctl.h>
26 #endif
29 * Returns the terminal width if possible. Else, returns
30 * -1. Based on the function 'determine_screen_width'
31 * in wget 1.9.1.
33 static inline int get_terminal_width (FILE *tty_file) {
34 int error_code = -1;
36 #if defined USE_IOCTL && defined TIOCGWINSZ
37 struct winsize wsz;
39 if(ioctl(fileno(tty_file), TIOCGWINSZ, &wsz) < 0)
40 return error_code;
42 return wsz.ws_col;
43 #else
44 return error_code;
45 #endif
47 #endif