The legacy ioctl 'KDGETLED' (which also exists on BSD) is used to get the
state of keyboard LEDs, which, however, can be used to display arbitrary
information! So the new ioctl 'KDGKBLED' should be used to get the keyboard
flags (CapsLock, NumLock, ScrollLock), and this ioctl has a separate set of
macros ('K_NUMLOCK', 'K_CAPSLOCK') to check the flags.
See the ioctl_console(2) man page for more details.
* Include the correct headers on DragonFly BSD and FreeBSD.
* Use UTF-8 characters to draw border on Linux.
* Use ioctl 'KDGETLED' to get the keyboard LED states, which is supported
on both Linux and BSD.
* Use macros 'LED_NUM' and 'LED_CAP' instead of hard-coded magic numbers.
NOTE:
This patch only allows 'ly' to build fine on DragonFly BSD and FreeBSD
(other *BSD not tested), and more works are needed to make 'ly' working
fine on BSD.
* util: Fix gethostname() and freeaddrinfo() calls
I was passing the wrong size to the 'gethostname()' call because the
'hostname' is now dynamically allocated and cannot use 'sizeof' to get
its size. This mistake causes that the obtained hostname is empty.
The 'freeaddrinfo()' was placed at the wrong place. Fix it.
Fallback to '_POSIX_HOST_NAME_MAX' if 'sysconf()' fails.
Always null-terminate the 'hostname'.
* util: Simplify hostname() as no need to call getaddrinfo()
There is no need to call 'getaddrinfo()' to determine the hostname of
the machine, gethostname() is enough. This simplify the 'hostname()'
a lot.
Trim a trailing whitespace by the way.
The pam_misc header and library, as well as the pam_{modules,modutil}.h,
are not needed. Meanwhile add the necessary headers.
Builds fine on both Linux and DragonFly BSD.
This software requires GNU make to build, which is installed as "gmake"
on *BSD. Therefore, use $(MAKE) to make sure that the same GNU make is
invoked to build the sub-project.