Commit Graph

37 Commits

Author SHA1 Message Date
Sami Kerola da27df2553 setterm: tell user when options does not effect
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola 16279cc2b4 setterm: improve perform_sequence() coding style
Delete pointless braces, new lines, and add spacing between operators.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola 253e5e7161 setterm: correct usage() bright color argument
This has been wrong since commit 2dc8716.  The bright is a prefix
attribute to other colors.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:17 +01:00
Sami Kerola 917465831f setterm: make -msglevel 0 to work as is did earlier
Commit 3393c136 caused regression.  The klogctl() logging range is 1-8,
but the value 0 is special according to setterm.1 manual page.  It turns
on loging, same way as '-msg on' option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:39 +01:00
Sami Kerola 609d48534a setterm: remove devfs and /dev/vcsa0 support
The devfs files /dev/vcc/a* does not need to be supported, and vcsa0 has
not existed in years if ever.

Reference: http://lwn.net/Articles/65197/
Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devices.txt?id=14186fea0cb06bc43181ce239efe0df6f1af260a#n260
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola 341566ff45 setterm: clean up screendump()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola dcc2fe2903 setterm: add init_terminal() to make main() shorter
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola d87d20b0fa setterm: add option control structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola 43f68f8fea setterm: remove usage comment segment
It is enough trouble to keep usage output aligned with getopt() parsing,
manual page, and bash-completion, so get rid of the unnecessary effort
duplication.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola c591be873b setterm: move show_tabs() and screendump() functions
Earlier the function was in the middle of option parsing code segment,
and screendump() required function prototype.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:37 +01:00
Sami Kerola 35b578a02a setterm: use string utils to numeric parsing
Check the input numbers are numbers, which makes also the code shorter,
and user experience better as half invalid imputs will error.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:36 +01:00
Sami Kerola fb27f91cac setterm: recommend long options with double hyphen
While the -version style options will work for next unknown number of
years start moving towards user interface that has way of invoking long
options as most of the other commands.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:21:14 +01:00
Sami Kerola 45c90b77e6 setterm: use getopt_long_only() for option parsing
The getopt_long_only() has advantage of allowing one and two hyphen
versions of options, for example -help and --help.  Secondly the getopt
function family from libc can ensure some options requiring arguments,
while other are optional, and some should not accept argument at all.
That makes option parsing more robust.

Unfortunately retiring the old option parsing makes this change greater
than preferred.  Assuming not mistakes happen the new code works
functionally exactly as the old did.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 21:58:01 +01:00
Sami Kerola 104ecc7e70 setterm: clean up includes
Use klogctl(2) from sys/klog.h just like dmesg(1).  The rest is just
reordering, and indenting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 21:56:24 +01:00
Sami Kerola 3393c136a2 setterm: convert remaining magic values to symbolic references
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-12 13:59:59 +02:00
Sami Kerola 010f219d5f setterm: convert various constant number definitions to enums
The enum strings are visible when using debugger.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-12 13:54:38 +02:00
Karel Zak 6ed37604fe setterm: cleanup printf() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-12 13:53:10 +02:00
Sami Kerola 45656c9fe1 setterm: remove unused code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-12 13:38:53 +02:00
Michael Forney 23e0d15ba4 build-sys: Fix check for __GNU_LIBRARY__
If we are not on glibc, __GNU_LIBRARY__ will not exist causing the check
to always fail and try to use syscalls directly.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-04 11:51:45 +02:00
Mike Frysinger bfc4331b14 setterm: fix term.h/ncurses.h include ordering
The ncurses term.h header has logic in it to detect if nucrses.h has
already been included and void defining things when it has.  But since
setterm includes term.h and the ncurses.h, it doesn't work and we can
get fun build-time warnings like:

  CC       term-utils/setterm-setterm.o
In file included from term-utils/setterm.c:109:0:
/usr/include/ncursesw/ncurses.h:827:12: warning: redundant redeclaration of 'tigetflag' [-Wredundant-decls]
 extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);  /* implemented */
            ^
In file included from term-utils/setterm.c:106:0:
/usr/include/ncursesw/term.h:775:12: note: previous declaration of 'tigetflag' was here
 extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
            ^

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-09-30 13:41:03 +02:00
Sami Kerola 2dc87166a7 setterm: fix various color option argument lists
The lists did not have correct colors in usage().  Because the usage()
had to be fixed, it is best to make the output easy for translators to
work with.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:56:12 +02:00
Karel Zak a77e7ac77c setterm: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:22:56 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Karel Zak 747c1d9d57 setterm: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:55:20 +01:00
Petr Uzel 2754ffc5f5 setterm: make error message more informative
If `setterm -dump` fails because of lack of permission to read
/dev/vcsa, it should not report that it couldn't read /dev/vcsa0.
This could be misleading if there is only /dev/vcsa, but not /dev/vcsa0.

Before:
$ ./setterm -dump
setterm: Couldn't read /dev/vcsa0

After:
$ ./setterm -dump
setterm: Couldn't read neither /dev/vcsa0 nor /dev/vcsa

(Note: /dev/vcsa0 does not exist and the user does not have read
permission on /dev/vcsa in this case).

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=780615
Reported-by: Christopher Yeleighton <giecrilj@stegny.2a.pl>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-09-21 12:14:14 +02:00
Sami Kerola 4d9e37bfed setterm: fix shadow declaration
term-utils/setterm.c:221:55: warning: declaration of 'opt_term' shadows a global declaration [-Wshadow]
term-utils/setterm.c:181:5: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 13:44:58 +02:00
Bernhard Voelker 871ffd0960 Fix typos in comments and wall's man page
Culprits identified again by (newer) misspellings:

  $ git ls-files | misspellings -f - | grep -v '^po/'

* wall: Fix typo in man page.
* Fix typos in source code comments.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-06-05 14:37:26 +02:00
Sami Kerola cdd2a8c360 term-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:46:25 +02:00
Sami Kerola 6a801e1a38 setterm: correct manual page reference
An error from commit faa0548de4

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:12 +02:00
Karel Zak a1e04e8fe3 setterm: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:50:29 +02:00
Karel Zak 9497ebb074 setterm: use xmalloc()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-04-06 11:24:23 +02:00
Sami Kerola 172ba4f2a8 setterm: fix variable types, and unused argument warnings
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-06 11:21:48 +02:00
Sami Kerola a973947c88 setterm: function screendump coding style fixed
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-06 11:19:15 +02:00
Sami Kerola 261f1423fb setterm: use libc error printing facilities
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-04-06 11:13:40 +02:00
Sami Kerola faa0548de4 setterm: support -help and -version options
[kzak@redhat.com: - merge all options to the one string]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-04-06 11:10:34 +02:00
Sami Kerola 2971543625 setterm: segfault with long dump file name
The patch will make too long path to be truncated to MAX_PATH
lenght. If user supplies too long file name that is caught at
fopen. Some users might find this unintuitive, so the altered
behavior will be mantioned in manual page.

Bug in earlier version was visible with a command bellow.

setterm -dump -file $(for i in $(seq 254); do printf x ; done)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-06 10:59:17 +02:00
Karel Zak 8c59914ee2 build-sys: move setterm to term-utils/
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-02 14:02:01 +01:00