commands: Rename the command functions Command functions are traditionally named like the command shortened to four characters. When this name collides with a keyword or library function, we abbreviate more: brea(), rea(). A few are unabbreviated, e.g. execute(). A few have different names, e.g. explain(), not list(). Commit 23726b379 (v4.3.0) suppressed a GCC warning about carg() colliding with its built-in function. Ron Koenderink reported Microsoft Visual Studio 2019 fails to link: "_carg already defined in ucrtd.lib(ucrtbased.dll)". Time to clean this up: rename the functions to c_FOO(), where FOO is the unabbreviated name of the command. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
configure: Move terminfo check next to readline check Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
configure: Test GCC-specific compiler flags only when using GCC Commit 23373d01d "configure: Test compiler flags" (v4.4.0) made configure test whether compiler flags work, to let us use flags that work only for some compilers. Unfortunately, the Sun C compiler accepts invalid options with a warning, breaking the test. Observed on Solaris 10. Fix by testing the compiler flags only when AC_PROG_CC detected GCC. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Clarify build requirements Document the need for the XSI Extension. Don't list curses as required, it's actually optional. Correct advice for Solaris. Add advice for AIX. Drop references to C89; we actually require C99, and POSIX.1-2001 provides it. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Fix build for systems that don't provide POSIX.1-2001 by default We require POSIX.1-2001. Some systems provide it only with feature test macro _POSIX_C_SOURCE defined to 200112L. Since we don't define it, the build fails there. Observed on Solaris 10. We actually require the XSI extension. The GNU C Library provides it by default. With _POSIX_C_SOURCE 200112L, however, you have to define feature test macro _XOPEN_SOURCE to get it. But then _POSIX_C_SOURCE is redundant. Make configure put #define _XOPEN_SOURCE 600 into config.h. Drop the two existing #define _XOPEN_SOURCE 500 in .c files. Now Solaris cc refuses to play ball unless switched to C99. Replace AC_PROG_CC by AC_PROG_CC_STDC to mollify it. Unfortunately, use of _XOPEN_SOURCE exposes bugs in AIX libc and old versions of GNU libc: * AIX defines struct in6_addr's member s6_addr as a macro expanding into the actual member. Without _ALL_SOURCE (the default), the expansion is wrong and doesn't compile. Observed with AIX V7.2. * GNU lib's IN6_IS_ADDR_V4MAPPED() is unusable without _DEFAULT_SOURCE (default) or _GNU_SOURCE. Observed with Debian 8. Tracked at <https://sourceware.org/bugzilla/show_bug.cgi?id=16421>, fixed in version 2.25. Affects just sockaddr_ntop()'s special case from commit 372cdb136 "Use IPv4 format for IPv4-mapped addresses", v4.3.31. Disable the special case and use IPv6 format on such systems. This is a very minor usability regression. Could be avoided, I guess, but it's not worth the trouble. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
client: Drop use of getpass() getpass() is traditional Unix, but has been withdrawn from POSIX. We still use it when it's available, and fall back to portable code only when it's not. The portable code behaves differently: it reads stdin instead of /dev/tty, and in noncanonical mode. Simplify things: always use the replacement. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@redhat.com>
configure: Fix botched fix of .tarball-version access Commit ece998e fixed .tarball-version access from separate build tree by adding $srcdir/ to it. That's wrong in m4_esyscmd(), because there it runs at autoconf time, where $srcdir isn't necessary and doesn't exist. Revert that part. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
configure: Fix .tarball-version access from separate build tree configure reads .tarball-version when the source tree isn't git-controlled. Fails when the build tree is separate. Fix it to read $srcdir/.tarball-version. The occurence in Make.mk isn't wrong, because VPATH applies there. Change it anyway, for consistency and a bit of extra robustness. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Merge branch 'readline'
configure Make: More detailed version information Version information is in output of commands version, xdump version, and in program output for option -v. Looks like this: Wolfpack Empire 4.3.33 The version number is defined in configure.ac, and incremented manually. It identifies only the base release (here: 4.3.33). Fine when this is an unmodified released version. Pretty much useless during development. Add a suffix to the version number that describes it further: V Unmodified release V (same as before) V.N-H Modified release built from a clean git tree N is the number of additional commits, and H is the abbreviated commit hash V.N-H-dirty Same, but the working tree is dirty V-dirty Modified release built from a tarball A git tree is clean when the contents of its files are unchanged. Changing only the their timestamps doesn't count. It does count when building from a tarball, because tracking contents isn't implemented there. Also use this suffixed version for tarball names. The version reported by configure is fixed at configure generation time, i.e. it is usually out of date during development. Ensuring a release tarball contains one with a current version is manual for now. Running autoconf -f should do the trick. Elsewhere, the version is determined at build time, so it is always current. Dirty tracking isn't implemented in the standalone client build. If you start with a clean tarball, the version will not change from V to V-dirty when you build with modifications. Steal build-aux/git-version-gen from autoconf 2.69 to help with computing the version string. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
configure: Bump required autoconf version to 2.69 2.69 is more than four years old now. Nobody has tested with 2.64 in quite some time. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
client: New configure --with-readline Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
client: Rewrite readline configuration AX_LIB_READLINE tries to cope with systems where readline lacks history support, or lacks headers, or needs headers included in unorthodox ways. It puts six HAVE_ macros into config.h, and its usage example takes 24 lines of code just to include two headers. Way too complicated for my taste. Replace with new MY_LIB_READLINE, which succeeds only when you have a sane readline, and then defines *one* macro: HAVE_LIBREADLINE. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
client: Add readline support to empire client Readline provides fancy command line editing such as <Arrow Up> for previous commands and CTRL+A to jump to the beginning of the line. This patch does not add any completion on <tab> key, a TODO, if you will. A new command line flag, -H, turns on saving the history to disk. This may have security implications on shared computers, as all commands are saved as-is. Thus "change re 1234" would be logged directly to the file. Signed-off-by: Martin Haukeli <martin.haukeli@gmail.com> Rebase on top of preparatory work, fix a few bugs, and tidy up: * Update the standalone client build, too. * Fix the Windows build. * Keep command line options sorted case-insensitively. * Error out when $HOME is unset and getpwuid() fails, just like we do for $LOGNAME. * Give @input_from_rl, @has_rl_input static linkage. * @has_rl_input is a flag, not a counter, set and test it accordingly. * Save all input in history, not just commands. Martin's attempt to recognize commands works only as long as the server sends prompts faster than the user sends input. Drop that part, and update commit message accordingly. * Fix recv_input() not to truncate value of strlen() to int, and to use memmove() for updating @input_from_rl in place. * Clean up whitespace in a few places. * Tweak commit message. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Update copyright notice Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
configure: Use -fstack-protector-strong when available Testing whether the compiler supports it is a bit tricky. The obvious AX_APPEND_COMPILE_FLAGS([-fstack-protector-strong]) doesn't suffice, since some ports of the GNU toolchain reportedly pass this test, then fail to link. That's because the compiler accepts the flag, duly emits references to helper code in libc, but libc doesn't provide, and linking fails. Instead, use AX_APPEND_LINK_FLAGS with an input source that makes the compiler emit the extra stack checking code. This requires the latest version from the autoconf-archive, so update m4/ax* to commit e3d948b. Also update m4/my_append_compile_flags.m4 to keep it in sync with upstream's ax_append_compile_flags.m4. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>